Butterfly EDFA Rack: Home Assistant config and dashboard

Fresh repo holding only the Butterfly-rack HA side (the firmware and BOM
live in koheron-esp32-bridge). Contents, pulled from the live HA host:

- configuration.butterfly.yaml: dBm->mW template sensors + the YAML
  dashboard registration, to merge into /config/configuration.yaml
- scripts.butterfly.yaml: the butterfly_edfa_shutdown emergency-off script
- ui-lovelace-butterfly.yaml: the dashboard
- deploy.sh: scp the dashboard, check_config, restart HA
- .gitignore guards against committing the HA DB, logs and secrets

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
James Bateman (hp-laptop)
2026-10-02 13:35:40 +01:00
co-authored by Claude Opus 4.8
commit abcb6b7553
6 changed files with 297 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
# Butterfly EDFA Rack: snippet to merge into Home Assistant's configuration.yaml.
#
# The rack's sensors, switches and numbers arrive automatically over MQTT
# discovery (the ESP32 firmware publishes homeassistant/.../config topics), so
# this file only adds what discovery cannot: mW optical-power sensors derived
# from the dBm telemetry, and the YAML-mode dashboard registration.
#
# These are top-level keys. Merge them into the existing configuration.yaml on
# the HA host (do not drop its default_config:, frontend:, etc.). If an `mqtt:`
# key already exists there, merge the sensors into it rather than adding a
# second `mqtt:` block.
#
# The internal PDs read ~0.5 dB optimistic, so treat the mW figures as
# indicative, not calibrated.
mqtt:
sensor:
- name: "Output Power mW"
unique_id: butterfly_edfa_rack_out_mw
state_topic: "lab/laser/butterfly_edfa_rack/amp/output1_power_dbm"
value_template: "{{ (10 ** (value | float / 10)) | round(1) }}"
unit_of_measurement: "mW"
device_class: power
state_class: measurement
availability_topic: "lab/laser/butterfly_edfa_rack/availability"
payload_available: "online"
payload_not_available: "offline"
device: { identifiers: ["butterfly_edfa_rack"] }
# EDFA input PD = seed AFTER the external attenuators (not seed output power).
- name: "Amp Input Power mW"
unique_id: butterfly_edfa_rack_ampin_mw
state_topic: "lab/laser/butterfly_edfa_rack/amp/input_power_dbm"
value_template: "{{ (10 ** (value | float / 10)) | round(3) }}"
unit_of_measurement: "mW"
device_class: power
state_class: measurement
availability_topic: "lab/laser/butterfly_edfa_rack/availability"
payload_available: "online"
payload_not_available: "offline"
device: { identifiers: ["butterfly_edfa_rack"] }
- name: "Pre-amp Power mW"
unique_id: butterfly_edfa_rack_preamp_mw
state_topic: "lab/laser/butterfly_edfa_rack/amp/preamp_power_dbm"
value_template: "{{ (10 ** (value | float / 10)) | round(1) }}"
unit_of_measurement: "mW"
device_class: power
state_class: measurement
availability_topic: "lab/laser/butterfly_edfa_rack/availability"
payload_available: "online"
payload_not_available: "offline"
device: { identifiers: ["butterfly_edfa_rack"] }
# YAML-mode dashboard registration. Points at ui-lovelace-butterfly.yaml, which
# must sit next to configuration.yaml in HA's /config directory.
lovelace:
mode: storage
dashboards:
butterfly-rack:
mode: yaml
title: Butterfly Rack
icon: mdi:laser-pointer
show_in_sidebar: true
filename: ui-lovelace-butterfly.yaml