Repository navigation
Permanent controls gated by availability + write-tier sensors (2.5.0) - #31
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
number.technische_ruimte_tuinhuis_bms_1_cell_count_control— 204 of them — and the generated dashboard could not resolve any of them.What changes
Controls are published permanently. The tier gates their availability:
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
availabilityreplacesavailability_topicon controls: the MQTT docs state the two must not be used together.New bridge device with two tier sensors (#30):
binary_sensor.jkbms2mqtt_basic_writesand…_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-rowhides 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-writesand 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[bridge, tier]with modealland noavailability_topic, tier topics publishonline/offline, bridge sensors published once with the right deviceCloses #29
Closes #30
🤖 Generated with Claude Code