Per-Panel SPAN HOP Dashboards in Home Assistant #18
dcj
started this conversation in
Show and tell
Replies: 1 comment
-
|
Note that the link/URL to HOP Dashboard auto-login docs is not currently reachable, but will be "soon" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is a small recipe that uses the HOP Dashboard auto-login query parameter to embed each SPAN panel's local dashboard, already authenticated, as its own panel-mode dashboard in Home Assistant. The result: one sidebar entry per panel, click it, the panel's UI fills the screen — no manual login.
What you get
For each SPAN panel you have, a Home Assistant dashboard whose only view is
panel: true(full-screen) containing a single iframe pointed athttp://<panel-ip>/login?passphrase=<hopPassphrase>. Per the auto-login docs, the panel consumes thepassphrasequery parameter, redirects to/homealready authenticated, and strips the passphrase from the URL bar before any history is recorded.Above: one of the resulting dashboards. The HA sidebar shows three SPAN entries (renamed here from the script's defaults to "SPAN LC1 / LC2 / LC3"), and the selected one fills the viewport with the panel's own HOP UI — Home page, 2.6 kW total, source breakdown — all live and already authenticated. The top-left page header shows the panel's serial (redacted as
<panel-serial>here); HA's standard sidebar with your other dashboards stays available on the left.Prerequisites — and a constraint worth noting up front
This recipe assumes you've set up SPAN in Home Assistant via the electrification-bus/span-hass custom integration (the eBus variant). That integration's stored config-entry data includes an
ebus_broker_passwordfield whose value is the same string as the panel'shopPassphrase. I verified this by POSTing the broker password ashopPassphraseto/api/v1/auth/registeron the panel and seeing it returned verbatim in the response along with a fresh access token — the broker password and the dashboard passphrase are the same secret on this generation of firmware.The other SPAN integration most people use — SpanPanel/span — does not store the hopPassphrase anywhere accessible. Its config-entry has only an
access_token(a JWT issued by the panel at setup time), which the dashboard's/loginpage does not accept as a passphrase. If that's the integration you have, you'll need to either: provide the passphrase out-of-band (an!secretreference in YAML, environment variable, hardcoded in the script), or skip the script and just paste the URLs into dashboards by hand.You also need: SSH access to the HA host as root with key auth (used to read the config-entries storage file), a long-lived HA access token (used for the WebSocket API), and the
websocketsPython module locally.The script
It discovers every
span_ebusconfig entry, builds an auto-login URL from each, and creates or refreshes a panel-mode dashboard per panel. No secrets in the source — passphrases are read from the HAY at runtime.Running it
Edit the
HAY_SSHandWS_URLconstants for your environment, then:You should see one
create+save(or justsaveon re-runs) per panel. After that, open Home Assistant and you'll find one new sidebar entry per panel, each opening directly into the panel's HOP UI in panel mode.Things worth knowing
Iframe-ability. The SPAN HOP dashboard nginx sends no
X-Frame-Optionsheader and noContent-Security-Policywithframe-ancestors, so it embeds cleanly. If your HA instance is served over HTTPS but the panel only over plain HTTP, expect a mixed-content block in the browser; on a LAN-internal HA accessed over HTTP this isn't an issue. You can also adapt the script to use HTTPS to the panel (the cert is self-signed, so browsers may need a one-time accept).Where the secret ends up. The script writes a URL containing the panel's hopPassphrase into HA's
.storage/lovelace.dashboard_span_<id>file. The same secret already lives in HA's.storage/core.config_entries(the integration'sebus_broker_password), so this is the same trust boundary, not a fresh exposure. But if you commit your HA config to git, you'll want the dashboard storage files in.gitignore(or commit only the script and have the dashboard files regenerated on each machine).Re-run safety. The script is idempotent: it creates dashboards that don't exist yet and overwrites the config on ones that do. Re-run any time a panel's IP or passphrase changes — it'll pull the new values from the integration's config-entry and refresh.
Sidebar ordering. Three new entries will show up at the bottom of the sidebar. To reorder, long-press the "Home Assistant" text at the top of the sidebar to drop into edit mode, drag, and click DONE.
Why this works
Per the HOP Dashboard auto-login docs, the dashboard's
/loginpage accepts apassphrasequery parameter. When present, it auto-submits the standardPOST /api/v1/auth/registerflow withhopPassphraseset to the query value, then strips the parameter from the URL viahistory.replaceState. An invalid passphrase falls back to the manual form with an error displayed; an empty value is ignored. So the embed Just Works as long as the passphrase we send matches what the panel was provisioned with — which on thespan_ebusintegration is the value already stored inebus_broker_password.Beta Was this translation helpful? Give feedback.
All reactions