Add Home Assistant dashboard and config for the rack

Minimal HA content to reproduce the Butterfly Rack GUI: a YAML-mode
dashboard (power graphs in mW, temperature graph, dual dBm/mW output
readout, staged seed/booster controls, emergency-off), MQTT template
sensors deriving mW from the dBm telemetry, and an emergency-shutdown
script. Snippets merge into configuration.yaml / scripts.yaml; the
dashboard file is copied whole. See homeassistant/README.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
James Bateman (hp-laptop)
2026-08-11 16:55:04 +01:00
co-authored by Claude Opus 4.8
parent b31065acd7
commit da466efdb3
4 changed files with 247 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
# Home Assistant integration
Config for presenting the Butterfly EDFA Rack in Home Assistant. The rack's sensors, switches and numbers are auto-discovered over MQTT (the firmware publishes `homeassistant/.../config` topics), so these files only add what discovery cannot: derived mW power sensors and a dedicated dashboard.
Target: the HA instance on the lab broker host (`192.168.0.102`), running in Docker with its config bind-mounted at `~/HA/homeassistant/` (that is HA's `/config`).
## Files
| File | Goes to | Purpose |
|------|---------|---------|
| `configuration.snippet.yaml` | merge into `/config/configuration.yaml` | MQTT template sensors (dBm→mW for the EDFA input, pre-amp and output PDs) + the `butterfly-rack` YAML dashboard registration |
| `scripts.snippet.yaml` | merge into `/config/scripts.yaml` | `butterfly_edfa_shutdown` emergency-off script |
| `ui-lovelace-butterfly.yaml` | copy to `/config/ui-lovelace-butterfly.yaml` | the dashboard itself (graphs of power in mW + temperatures, dual dBm/mW output readout, staged seed/booster controls, emergency-off) |
The `*.snippet.yaml` files hold top-level keys (`mqtt:`, `lovelace:`, and the script) to merge into the matching HA files — they are not standalone configs. `ui-lovelace-butterfly.yaml` is copied whole.
## Deploy
From this directory, with the HA container named `homeassistant`:
```bash
host=lab@192.168.0.102
scp ui-lovelace-butterfly.yaml $host:/tmp/
ssh $host 'docker cp /tmp/ui-lovelace-butterfly.yaml homeassistant:/config/ui-lovelace-butterfly.yaml'
# then hand-merge the two snippets into /config/configuration.yaml and
# /config/scripts.yaml, and validate + restart:
ssh $host 'docker exec homeassistant python -m homeassistant --script check_config -c /config'
ssh $host 'docker restart homeassistant'
```
The dashboard reloads on browser refresh; changes to `configuration.yaml`/`scripts.yaml` need the restart. The dashboard appears in the sidebar as **Butterfly Rack** (`/butterfly-rack`).
## Notes
- The `*_mw` sensors are grouped onto the same `butterfly_edfa_rack` device via the shared `identifiers`.
- mW figures are derived from the internal-PD dBm telemetry, which reads ~0.5 dB optimistic — indicative, not calibrated.
- The seed temperature setpoint is the CTL200 thermistor resistance (`rtset`, ohms); the °C readout is a firmware-side NTC β-model. See the repo root README.