Fix hotwater_lock key-collision hazard, address Opus review of triage fixes
An Opus review of the previous commit found that giving the switchHotwater fallback and LOCK.hotwater_lock the same key introduced a real bug: adapter.flatten() (the source of coordinator.data, which every switch's is_on reads) only ever honours exists_fn, never entity.py's implicit own-field-presence default that gates plain registration. With only one side of the pair gated, both descriptors still wrote the same key into the flattened state dict, and whichever was processed last -- decided by device-reported href order, not correctness -- silently won. Reproduced with the existing coffee fixture: reversing resource order flipped hotwater_lock from correct (False) to a stuck True. Fixed by gating both sides symmetrically via a shared tri-state helper that also treats an unfetched /status/lock/vs/0 stub as "outcome pending" rather than "confirmed absent" -- otherwise the stub window let both descriptors pass exists_fn at once, which would have registered two switch entities with the same unique_id. The fallback also re-asserts its own field's presence, a check it used to get for free before it shared LOCK's key. Also addresses two smaller findings from the same review, both in the range-hood after-run capability (#147): runningProgress's unit='%' was a guess from a single "0" sample with no supported-values/range field to confirm the domain -- inconsistent with treating activationState as read-only for the same "don't guess" reason -- so it's now a bare passthrough sensor; and entity_category='diagnostic' was dropped from the two read entities since after-run is a feature the user actively watches and cancels via the (correctly uncategorized) button, not passive diagnostics.
This commit is contained in:
4 files changed
+120
-21
No files matched your search
@@ -62,7 +62,7 @@ def test_range_hood_fixture_values():
|
||||
assert state['air_sensing_state'] == 'NonProcessing'
|
||||
assert state['last_air_sensing_level'] == 'Kr2'
|
||||
assert state['after_run_active'] is False
|
||||
assert state['after_run_progress'] == 0
|
||||
assert state['after_run_progress'] == '0'
|
||||
|
||||
|
||||
def test_one_composite_fan_is_bound():
|
||||
|
||||
Reference in new issue
Block a user