UX-01: translate the add-on config, and order it by task
checks / unit (pull_request) Successful in 5m1s

The add-on had NO translations/ directory, so Home Assistant fell back to
rendering the raw option KEYS. An operator opening Configuration read
`unit_sign_disagree_w`, `saturation_cycles`, `integrator_max_w` - seventy of
them, in file order, with no description and no way to tell a constant derived
from 1890 closed-loop test runs from their own inverter's rating.

⚠️ PRESENTATION ONLY. Not one default, not one schema range and not one line of
behaviour moved. The 175 non-comment lines of config.yaml are byte-identical to
release/1.0's, reordered; the only comment lines that changed are the group
banners and five sentences whose "above"/"below" the reorder made false.

* translations/en.yaml and translations/nl.yaml: a name and a description for
  all 70 options and all 7 per-entry keys of the `inverters:` repeatable
  section. The Dutch is written for a Flemish homeowner - afname/injectie,
  kwartierpiek, capaciteitstarief - not transliterated from the English.
* ⭐ Every derived constant says WHERE IT CAME FROM and whether to touch it.
  `unit_sign_disagree_s` cites its 1890 closed-loop runs (SAFETY-30);
  `circulation_w` its 924 runs and the measured 400 W knee (SAFETY-31);
  `meter_freeze_s` its 2399 s capture (SAFETY-18); `bms_soc_floor` register
  0x0560. The two numbers that are the operator's - max_w and peak_cap_w - say
  "THIS IS YOUR NUMBER". `cycle_cost_threshold_eur`, which is neither, says it
  is an open product question (OPT-08).
* config.yaml reordered into task order in BOTH halves, comments carried with
  their keys: hardware -> meter -> ratings and limits -> tariff -> maintenance
  -> safety -> advanced.
  ⚠️ test_inverter.py:1788's trap is PRESERVED: the nested per-entry `max_w:`
  still precedes the flat one under `schema:`, and `inverters: []` still ships
  in the `options:` half. Moving the nested block below the flat one is a 1-byte
  edit; it was run and goes red in test_inverter.py and test_translations.py.
* tools/supervisor_shape_probe.py section F MEASURES the result against
  ghcr.io/home-assistant/amd64-hassio-supervisor:2026.08.0 - Supervisor's own
  _read_app_translations(), its own UiOptions, and the frontend's label
  resolution transcribed from the shipped bundle - and prints every rendered row
  in both languages. `all cases passed`, exit 0.
* ⚠️ ONE MEASURED NEGATIVE RESULT, NOT GLOSSED: the per-entry keys inside the
  `inverters:` section still render RAW on frontend 20250925.1, because a
  list-of-objects goes to ha-selector-object and the converter sets no `label`
  and no `translation_key`. The `fields:` translations are shipped and validated
  - that is Supervisor's own shape for this - but this card does not claim they
  reach the screen. The `inverters` label and description do.
* test_translations.py: a translation naming a non-existent option, or an option
  with no translation, fails CI - both directions, both languages, top level and
  per entry. Mutation-tested BOTH WAYS: eleven in-process mutations each
  required to NAME the key they broke, plus a negative control; six more run on
  disk through the purge-and-re-read protocol. Two of the eleven are the ones
  that cost the WHOLE FILE rather than one label - an unrecognised top-level
  block, and a `network:` value that is not a string. Supervisor drops a file
  that fails SCHEMA_APP_TRANSLATIONS with only a log warning, so those silently
  return the entire tab to raw keys; neither is reachable through the
  `configuration:` coverage, which is why they were hunted for and closed.
* tools/translations_lint.py is the hand parser CI needs (no PyYAML in the
  add-on image) and the probe grades it, key by key and string by string,
  against Supervisor's own loader. It is strict and RAISES rather than skipping;
  nine malformed shapes prove it.

Full 20-file suite green (19 existing + test_translations.py).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BwRLw7eKYj2byVdwB6kbjU
This commit is contained in:
Claude Opus 5
2026-09-05 12:02:56 +02:00
parent 3993f9f32b
commit fef6ef20a4
8 changed files with 1772 additions and 315 deletions
+84
View File
@@ -2,6 +2,90 @@
## Unreleased
**The add-on configuration screen now speaks English and Dutch instead of raw
option keys (UX-01).** There was no `translations/` directory at all, so Home
Assistant fell back to rendering the option KEYS — an operator opening
*Configuration* read `unit_sign_disagree_w`, `saturation_cycles`,
`integrator_max_w`, seventy of them, in file order, with no description and no
way to tell a constant derived from 1890 closed-loop test runs from their own
inverter's rating. **This card changes presentation only: not one default, not
one range and not one line of behaviour moved.**
* **`translations/en.yaml` and `translations/nl.yaml`**, with a `name` and a
`description` for **all 70 options** and for **all 7 per-entry keys** of the
`inverters:` repeatable section. The Dutch is written for a Flemish
homeowner rather than transliterated: *afname* and *injectie*, *kwartierpiek*
and *capaciteitstarief*, *laadniveau*, *uitschakelgrens* — the words that are
on the bill and on the meter.
* **⭐ EVERY DERIVED CONSTANT SAYS WHERE IT CAME FROM AND WHETHER TO TOUCH IT.**
`unit_sign_disagree_s` now reads *"derived from 1890 closed-loop test runs
(SAFETY-30): 85 s is 8.5 times the worst legitimate opposition those runs
produce… do not change it without re-deriving"*; `circulation_w` cites its 924
runs and the measured 400 W knee; `meter_freeze_s` cites the 2399 s capture;
`bms_soc_floor` says it is register `0x0560` read off the pack. The two
numbers that are genuinely the operator's — `max_w` and `peak_cap_w` — say
**"THIS IS YOUR NUMBER"** instead, and `cycle_cost_threshold_eur`, which is
neither measured nor the operator's, admits it is an open product question
(OPT-08) rather than borrowing the others' authority.
* **`config.yaml` reordered into task order** — hardware/entities → meter →
ratings and limits → tariff → maintenance → safety → advanced — in **both**
halves, with every comment carried with its key. ⚠️ The rendered order is the
**`schema:`** half's (`App.schema_ui` is `UiOptions(...)(data["schema"])`);
the `options:` half is reordered to match so the file reads the way the tab
renders. ⚠️ **`test_inverter.py` part 12's first-match trap is preserved**:
the nested per-entry `max_w:` still appears BEFORE the flat one under
`schema:`, and `inverters: []` still ships in the `options:` half. Moving the
nested block below the flat one is a **1-byte** edit and it was run: red in
`test_inverter.py` and in `test_translations.py`.
* **MEASURED, NOT ASSERTED.** `tools/supervisor_shape_probe.py` gains a section
F that loads both files with Supervisor 2026.08.0's *own*
`_read_app_translations()` out of the release image (a file that fails
`SCHEMA_APP_TRANSLATIONS` is **dropped with a log warning and nothing else**),
runs its own `UiOptions`, replays the frontend's label resolution transcribed
from the shipped bundle, and prints every rendered row in both languages.
* **⚠️ ONE MEASURED NEGATIVE RESULT, RECORDED RATHER THAN GLOSSED.** The
per-entry keys inside the `inverters:` repeatable section still render RAW.
`_convertSchemaElement` sends `type: "schema"` **with** `multiple` to
`ha-selector-object`, which labels its fields `fields[name].label || name`,
and the converter sets neither `label` nor `translation_key`. The `fields:`
translations are shipped and validated because that is the shape Supervisor's
own schema defines for exactly this, and a frontend that wires `label` through
would consume them — but on 20250925.1 they do not reach the screen, and this
card does not claim they do. The `inverters` label and description themselves
do.
* **A new check, `test_translations.py`, so this cannot rot.** A translation key
naming an option that does not exist, or an option with no translation, fails
CI — in both directions, for both languages, top-level and per-entry. It is
**mutation-tested both ways**: eleven mutations applied in-process, each
required to NAME the key it broke rather than merely to go red, plus a
negative control that the unmutated input is clean. Two of the eleven are the
ones that cost the WHOLE FILE rather than one label — an unrecognised
top-level block, and a `network:` value that is not a string. Supervisor
validates each translation file through `SCHEMA_APP_TRANSLATIONS` and, on
refusal, **logs a warning and drops all of it**, so those silently return the
entire tab to raw keys; neither is reachable through the `configuration:`
coverage, which is why they were hunted for and closed. Six more were run **on disk**, through the
purge-and-re-read protocol: deleting a translation (−65 B), renaming an option
in `config.yaml` (+4 B), adding an orphan key (+47 B), emptying a Dutch
description (−711 B), breaking one label's group prefix (−4 B) and deleting a
provenance citation (−19 B) each go red.
* **The parser has a licence.** There is no PyYAML in the add-on's CI image, so
`tools/translations_lint.py` reads these files by hand — and a hand parser
that quietly disagrees with the real loader is the defect this repository
keeps finding. The probe imports **that same module** and asserts, key by key
and string by string, that it returns what `_read_app_translations()` returns.
The parser is deliberately strict and **raises** on anything outside the
subset; nine malformed shapes are fed to it to prove it does.
* **⚠️ WHAT THIS CHECK CANNOT SEE, stated with its size.** It grades coverage
and provenance *citations*, not truth. Falsifying a figure inside a
description that is not one of the cited tokens survives (run: *"8.5 times"* →
*"3 times"*, −2 B, green), and swapping two options' descriptions survives
(0 B, green). Separately and out of this card's scope: changing a shipped
default that no suite pins survives — `step_w: 10` → `20` (0 B) leaves
`test_control.py`, `test_clamp.py`, `test_validate.py` and
`test_peakguard.py` green. That is the same family as CFG-04's DEFECT 2 and
the UX-01 rescope moved it to its own card on purpose.
**Inverter B's rating is 4600 W, FROM ITS DATASHEET, and every documented copy
of it now says so (SPIKE-04a).** Three places stated B's rating — `config.yaml`'s
commented roster example, `DOCS.md`'s, and `tools/supervisor_shape_probe.py`'s