ADR-0075: The integration updates the Tab5 dashboard in one click — a marker in the dashboard, a repair, a backup¶
Page en anglais
Cette page n'existe qu'en anglais.
Status: Proposed (2026-11-09; implemented in the pull request that adds it, accepted when the author merges it) Date: 2026-11-09
Context¶
With the HACS integration (ADR-0035) a release costs two gestures: Install in Settings → Updates, then a restart. The Home Assistant files and the firmware follow by themselves. What the user still does by hand is the dashboard: custom_templates/tab5_dashboard.jinja is a macro whose output the user pasted once into the raw configuration editor of a dashboard, so a new release leaves the old copy in place until the user renders the macro again and pastes it again (docs/installation/dashboard.md, steps 2 and 3). The audit of 2026-11-09 counted it: since 3.6.0 the macro changed in 5 releases out of 6.
Options weighed in that audit:
- A repair with one click (chosen): the integration notices that a dashboard was written by older files, and rewrites it when the user says so.
- A managed YAML dashboard: the integration writes a
mode: yamldashboard file itself. No internal API, but the user can no longer edit the dashboard in the interface,configuration.yamlhas to declare it, and the macro output would have to be rendered and written by the integration anyway. Kept as the way out if the internal API below ever breaks. - Automatic rewriting (an option): later, if the repair proves itself. Not now — a dashboard silently replaced is the one thing this must never do.
Decision¶
- A marker in the dashboard. The macro writes, at the root of the configuration it produces, one key:
tab5_dashboard: {"macro": …, "version": …, "adresse": …, "langue": …, …}(tab5_marqueurintab5_dashboard.jinja). It says which macro wrote the dashboard, with which call arguments, and with which version of the files (the value of « Tab5 · HA files version » when it was rendered; empty when the sensor does not read a version number, e.g. « dépôt »).tab5_dashboard_ecrans(several screens) writes it once, before its views; the views of a screen inside a multi-screen dashboard carry none. The key is JSON, so any value (quotes, colons, accents) survives. - Why a key in the dashboard rather than a list kept by the integration: the marker travels with the dashboard (backup, restore, copy), and it is the only way to know a dashboard the user pasted by hand.
- Accepted by Home Assistant:
lovelace/config/savestores any dict, and the CI reads it back identical on three Home Assistant versions. Accepted by the frontend: its raw editor validates the root withtype({title, views})(superstruct, notobject), so an unknown key is kept; read in the frontend code only, not seen in a browser. - A repair per out-of-date dashboard. Once the new files are active (the version sensor reads the integration's version), the integration lists the dashboards in storage mode that carry the marker, and compares versions (
tableau.en_retard: a pre-release is older than its release; files with no version number, « dépôt », propose nothing; a marker with no readable version always does, since a render writes it up to date). Each out-of-date one gets a repairtableau_a_mettre_a_jour__<dashboard address>: at start and each time a dashboard is saved (lovelace_updated). A dashboard with no marker (pasted before this release) is never proposed and never touched; paste it once more and it will be. - One click, never silent. The repair's fix flow shows one confirmation that says the dashboard will be replaced (what the user added by hand is lost) and where the old one is kept. On Submit, in this order, and nothing is written before the last check passes:
- render the macro named in the marker through
Template— from a fixed list of macros (tableau.MACROS), the arguments handed over as a variable, never written into the template text; - check the result: a non-empty list of views, a marker of the same macro, and the version of the files;
- copy the old configuration to
config/tab5_sauvegardes/tableaux/<date>_<address>_<old version>.json(written atomically, never over an existing file, the 5 most recent of each dashboard kept) — JSON is YAML, so it pastes back as is into the raw editor; - save with the dashboard's own
async_save(the call behind thelovelace/config/savecommand), then read it back: it must be current. Any refusal raisesTableauRefusewith a key that is also a translated error of the form (api,introuvable,rendu,version). - Protected internal API. Reading the dashboards (
hass.data[LOVELACE_DATA].dashboards,LovelaceStorage.async_load/async_save) is not a public API of Home Assistant. Every access is behind one function (tableau_ha.py), the import is lazy, and any surprise — the entry missing, a method gone, an unexpected type — becomes a refusal, never an exception that escapes: one warning in the log, no repair, and the install notification keeps giving the manual steps (2 and 3 of the dashboard guide). The pieces used have the same code on 2026.8.3, 2026.10.4 and 2026.11.0 (read, and exercised by the CI on all three).manifest.jsongainsafter_dependencies: lovelace(hassfest refuses the import otherwise; after, not a dependency: the integration still starts when Lovelace is not there). - Not done. The integration does not create the dashboard (once by hand,
dashboard.mdstep 1). No automatic option. No detection of a dashboard edited by hand since it was written (the confirmation says so and the backup keeps it; a hash of the last written configuration would let the repair say it, at the price of one more thing to store). - The author's Home Assistant. Its files come from the repository by Samba and its sensor reads « dépôt » (ADR-0035, amended): nothing is ever proposed there.
Consequences¶
- A release is now: Install in Settings → Updates, restart, then Update the dashboard in Settings → Repairs (one confirmation per Tab5 dashboard). Updating by hand stays possible (
dashboard.md), and is the way for a dashboard in YAML mode. - The macro grows by one macro (
tab5_marqueur) and one call per dashboard;tests/test_tableau_de_bord.pystill compares the single-screen output with the marker line left out. - Tests:
tests/test_integration_tableau.pyrenders the real macro and reads its marker with the integration's own module (puretableau.py: marker, versions, rendering recipe, rendering check, backup), without Home Assistant.tools/installation_ha/verifier_integration.py(CIintegration-hacs.yml, steps 1 ter and 2 bis, on 2026.8.3, 2026.9.4, 2026.10.4 and 2026.11.0) does the whole chain in a fresh Home Assistant: three dashboards created through the websocket like the interface does, one with an older marker (its repair appears at once, without a restart), one without a marker (none), the update to a newer files version, each repair validated through the repairs API, the dashboard read back equal to what the macro renders, the old one equal in its backup, repairs gone. That Home Assistant has no tablet, so the CI zips carry a replacementtab5_dashboardmacro (appended to the template, still using the realtab5_marqueur); the real macro's full output is tested elsewhere (test_tableau_de_bord.py, the « fresh Home Assistant » job). - Not verified: the marker kept by the frontend's editor in a real browser; the internal API on a Home Assistant newer than 2026.11.0; the rendering time of the real macro in a big home (it runs inside the event loop's
async_render, like the developer tools' template page); the Marketplace that replaces HACS in 2026.11 for a first install of the integration.