dashPi: a self-hosted home dashboard, its sync server and phone app

The dashboard (Raspberry Pi 3.5" screen + web pages), the end-to-end
encrypted sync mailbox (PHP + SQLite) and the Android companion app
(Flutter), with docs, clean-install checks and screenshots made from
demo data.

Built mostly with an AI coding assistant; not yet reviewed line by line
by a human (see README and SECURITY.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-10-24 09:35:12 +02:00
commit fb3c01cdd7
333 changed files with 45151 additions and 0 deletions

139
docs/dashboard.md Normal file
View file

@ -0,0 +1,139 @@
# The dashboard
## What you need
- **With the screen:** a Raspberry Pi (a Pi 3 is enough) on Raspberry Pi OS Bookworm or newer, and a 3.5"
480×320 SPI TFT on the GPIO header. The common ILI9486 + XPT2046 "piscreen" boards work.
- **Without a screen:** any Linux machine (Debian/Ubuntu for the install script). With no small screen found it runs
the web pages and background workers only; `--headless` forces that.
## The screen (skip for headless)
In `/boot/firmware/config.txt`:
```
dtparam=spi=on
dtoverlay=piscreen,speed=16000000,rotate=270
```
Reboot. The panel should appear as `/dev/fb0` (RGB565, 480×320) and touch as an `ads7846` input device.
To keep the console from blanking the panel, add ` consoleblank=0` to the single line in
`/boot/firmware/cmdline.txt`. The first start runs a 5-point touch calibration; `dash.py --calibrate`
redoes it.
## Install
```bash
git clone https://git.hackman.club/HackmanClub/dashboard.git dashpi
cd dashpi
sudo ./dashboard/install.sh # with the screen, runs as you
sudo ./dashboard/install.sh --headless # without
```
The script installs the apt packages, copies `dashboard/` to `/opt/dashboard` and writes
`/opt/dashboard/dash_config.json` from the example if there isn't one. It then installs and starts the
`dashboard` systemd service. Options: `--dir`, `--user <name>` (creates a system user if missing),
`--no-apt`, `--no-service`.
**Update:** `git pull`, then run the same command again. Your `dash_config.json`, `dash_data/` and the
other state files in `/opt/dashboard` are never touched.
Without the script (another distro, a virtualenv): install the packages from
[`dashboard/requirements.txt`](../dashboard/requirements.txt) plus the DejaVu fonts (and Symbola for emoji
on the screen). Copy `dash_config.example.json` to `dash_config.json` and run `python3 dash.py [--headless]`.
## First start (everything else is in the browser)
1. Open `http://<the machine>:8080/settings`.
2. **Settings ▸ Users:** create the admin account. It asks for the **setup code** printed in the log:
`journalctl -u dashboard | grep 'setup code'`. From the machine itself (`localhost`) no code is needed.
3. **Settings ▸ Users ▸ Household view:** choose what people see without a login (the 3.5" screen too).
By default that's weather and sensors, with no calendars.
4. **Weather:** search your town; add more places for the weather page. The phone app gets the same places.
**Calendar:** any ICS feeds (Google's "secret address in iCal format", Outlook, holidays), and if you have
one, Nextcloud / CalDAV (URL, user name, an app password: Nextcloud ▸ Settings ▸ Security). The dashboard's
own Local calendar works with neither.
5. **Sensors:** **+ Add sensor source**, pick the kind, **Test** it, then **+ Add** the readings you want (below).
6. **Plugins:** switch on the ones you want. Each has its own settings tab.
## Configuration
Everything is in the Settings page and stored in `dash_config.json` (chmod 600, it holds the passwords). The only
key without a page is `web.enabled` (`false` by default, `true` in the example the installer copies).
**Settings ▸ General** (besides units, the plugins and Sync):
- **Web pages:** who can open them (everyone on the network / only this computer), the port, and extra host
names it answers to. IP addresses, `localhost` and this machine's name (+ `.local` / `.lan` / `.home`) always work.
- **Screen:** where to draw. "Find it" uses a small SPI panel and never a desktop's own display; or pick one, or none.
It also recalibrates the touch screen.
- **Backup:** download one, or restore one (also to move to a new machine).
For the command-line tools only: `FOOD_COUNTRIES` (`plugins/food/off.py`: whose shop products go into the
food database, e.g. `romania,slovakia`) and `DASH_TZ` (the Health time zone for `plugins/health/mi.py`; on
the dashboard it's Settings ▸ Health; left empty, the phone app's time zone, sent with the band's data, else the
machine's).
## Plugins
| Plugin | On by default | Needs |
|---|---|---|
| Weather | yes | Nothing (Open-Meteo, no key) |
| Calendar | yes | A CalDAV server and/or ICS links |
| Measurement stations | yes | A sensor source (below); hidden until configured |
| Workload tracker | no | |
| Health | no | Optional: a Gadgetbridge database export folder (e.g. synced with Syncthing) |
| Food diary | no | Optional: an Ollama-style model URL for the "describe what you ate" box |
| Cycle tracker | no | |
| Notes | no | |
| Activity | no | [ActivityWatch](https://activitywatch.net) on each computer, listening on the LAN (`aw-server.toml`: `host = "0.0.0.0"`) |
Each plugin is a folder in `dashboard/plugins/<name>/` with a `META` and a `register(ctx)`. See the docstring
of `dashboard/pluginhost.py` for writing your own.
### Sensors (Measurement stations)
**Settings ▸ Sensors**: **+ Add sensor source** and pick the kind (the table below), press **Test** to see what it
has, and **+ Add** the readings to show.
Name them, put each indoor / outdoor / hidden, order them, and tick **Main** on the one shown as the big temperature
on Home (any indoor or outdoor one; by default the first indoor one). Up to 3 outdoor ones sit next to the weather.
Saving applies at once.
| Source | What to give it | What a sensor reads |
|---|---|---|
| **Home Assistant** | Its URL + a long-lived access token (your profile ▸ Security) | An entity (`sensor.kitchen_temperature`); humidity from a second entity |
| **MQTT** | Broker, port, optional login / TLS (needs `python3-paho-mqtt`) | A topic (`tasmota/attic/temp`) or a JSON field of one (`zigbee2mqtt/garage\|temperature`) |
| **JSON URL** | Any URL that answers JSON (ESPHome's web server, Tasmota, your own script), an optional header | A path in the answer (`sensors.0.temp`) |
| **DS18B20 (1-wire)** | Nothing: wire it to GPIO 4 and add `dtoverlay=w1-gpio` to `/boot/firmware/config.txt` | The sensor's id (`28-…`) |
| **termix** | The `stm32.php` URL, API key and device ids | A device id (temperature + humidity) |
Temperatures can be in °F (a tick per source); they're kept in °C. Readings are kept as 5-minute rows forever, for
the graphs on `/stations` and in the app.
## Sync, the phone app, more dashboards
Set up the server first ([server.md](server.md)); it prints this dashboard's token. Then **Settings ▸ General ▸ Sync**:
1. Server address + token → **Next**. The account's first device chooses the **sync passphrase** and is shown
the **recovery key** once. Write it down: without the passphrase or the recovery key, the synced data
can't be read.
2. **Devices ▸ Add a device** ("phone") shows a QR code. In the app: **Scan the code from the dashboard**,
then type the passphrase. Another dashboard: add a device for it, paste its token into that dashboard's
Settings ▸ General ▸ Sync, and join with the passphrase. Untick **Primary dashboard** there.
3. The same tab: sync now, revoke a lost device, change the passphrase, disconnect.
The command line does the same: `python3 sync.py setup|join|now|status|passphrase`.
## Files
| Path (in `/opt/dashboard`) | What |
|---|---|
| `dash_config.json` | Settings + secrets (600) |
| `dash_data/<plugin>/` | Each plugin's SQLite data (600); `dash_data/auth/users.db` the users, `dash_data/sync/state.json` the sync key |
| `dash_calib.json`, `dash_history.json`, `dash_weather.json` | Touch calibration, 24 h sensor history, last weather |
**Back up** with Settings ▸ General ▸ Backup (or copy `dash_data/` + `dash_config.json`). Everything
else comes from git. **Move to a new machine:** install there, create an admin, Settings ▸ General ▸ Restore,
then switch the old one off.
Logs: `journalctl -u dashboard -f`. Don't run `dash.py` by hand while the service runs: both would write
the screen.