Skip to content

Permanent controls gated by availability + write-tier sensors (2.5.0) - #31

Merged
basmeerman merged 1 commit into
mainfrom
feat/permanent-controls-tier-sensors
Sep 17, 2026
Merged

basmeerman merged 1 commit into
mainfrom
feat/permanent-controls-tier-sensors

Conversation

@basmeerman

Copy link
Copy Markdown
Owner

Why

2.4.0 gave settings stable ids, but the control entity was still created when a tier went on and deleted when it went off. Two problems followed:

What changes

Controls are published permanently. The tier gates their availability:

availability:
  - topic: jkbms2mqtt/availability     # bridge online
  - topic: jkbms2mqtt/safety_writes    # tier on
availability_mode: all

Home Assistant disables a control whose entity is unavailable — verified in hui-number-entity-row.ts, which sets .disabled=${stateObj.state === UNAVAILABLE} — so with the tier off it is visible, greyed and impossible to operate, while the read-only twin still shows the value. Nothing is ever re-registered, so #29 cannot recur after first install.

Note availability replaces availability_topic on controls: the MQTT docs state the two must not be used together.

New bridge device with two tier sensors (#30): binary_sensor.jkbms2mqtt_basic_writes and …_safety_writes, backed by the same retained topics that gate the controls — one source of truth. The device has no area, so these ids stay clean wherever the BMS devices live.

The generated dashboard is tier-agnostic. Each settings row is a conditional pair; hui-conditional-row hides a row entirely when its condition isn't met, so exactly one of the two is ever visible. Toggling a tier needs only an add-on restart. --basic-writes / --safety-writes and the # writes: header are gone, and the drift check no longer iterates tier combinations.

Trade-off

With both tiers off, the controls are visible but greyed on the device page under Configuration. That is the cost of entities that never vanish — and it's what makes the ids permanent.

Test plan

  • ruff, mypy, pytest — 581 passed, 100 % branch coverage
  • Drift check: 134 entities, now tier-free
  • Tests pin: both twins published for every tier combination, control availability is [bridge, tier] with mode all and no availability_topic, tier topics publish online/offline, bridge sensors published once with the right device
  • On HA: with tiers off, controls appear greyed and cannot be operated; the twin shows the value
  • On HA: enable a tier, restart, confirm the same control becomes operable and a write reaches the BMS — with no new entity and no id change
  • On HA: confirm the conditional rows swap without regenerating the dashboard

Closes #29
Closes #30

🤖 Generated with Claude Code

2.4.0 published a setting's control only while its write tier was on. Ids
stayed stable across a toggle, but the control itself was created and
deleted — and a newly created entity is what Home Assistant gives an area
prefix, so toggling a tier could produce
number.technische_ruimte_tuinhuis_bms_1_cell_count_control (#29).

Controls are now published always. The tier gates their availability
instead: an `availability` list of the bridge LWT plus the tier's retained
topic, with availability_mode "all". HA disables a control whose entity is
unavailable (hui-number-entity-row sets .disabled on UNAVAILABLE), so with
the tier off it is visible, greyed and inoperable, while the read-only twin
keeps showing the value. Nothing is registered twice, so the area-prefix
problem cannot recur after first install.

`availability` replaces `availability_topic` on controls — the two cannot
be used together.

New bridge device `jkbms2mqtt` carries two write-tier sensors (#30):

  binary_sensor.jkbms2mqtt_basic_writes
  binary_sensor.jkbms2mqtt_safety_writes

backed by the same retained topics that gate the controls, so "is this tier
on" has one source of truth. The device has no area, so those ids stay
clean regardless of where the BMS devices live.

The generated dashboard is now tier-agnostic: each settings row is a
conditional pair (hui-conditional-row hides a row entirely when its
condition is unmet), showing the twin while the tier is off and the control
while it is on. A tier change needs only an add-on restart. The
--basic-writes / --safety-writes flags and the `# writes:` header are gone,
and the entity-drift check no longer iterates tier combinations.

Add-on version 2.5.0.

Closes #29
Closes #30

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@basmeerman
basmeerman merged commit f82fcf5 into main Sep 17, 2026
4 checks passed
@basmeerman
basmeerman deleted the feat/permanent-controls-tier-sensors branch September 17, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant