fix: wait for device confirmation on switch/select/number commands#25
Open
jlopez wants to merge 1 commit into
Open
fix: wait for device confirmation on switch/select/number commands#25jlopez wants to merge 1 commit into
jlopez wants to merge 1 commit into
Conversation
…ng state Replaces fire-and-forget MQTT commands plus an optimistic local state write with `wait=True` plus a merge of the device's echoed property dict. When the device does not confirm within the socketry timeout, log a warning and leave coordinator data untouched. Previously, if the device firmware refused a command (e.g. AC output turn-off while a load is attached), HA would record a phantom state change that was later silently corrected by an unrelated periodic DevicePropertyChange push, breaking automations that depend on the command actually taking effect. Fixes #24
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.
Summary
wait=Trueplus a merge of the device's echoed property dict.switch.py,select.py, andnumber.py— all three platforms shared the same defect.Why
Previously, if the device firmware refused a command (e.g. AC output turn-off while a load is attached), HA would record a phantom state change that was later silently corrected by an unrelated periodic
DevicePropertyChangepush — breaking automations that rely on the command actually taking effect (the original report involved a low-battery cutoff that drained the battery anyway because the inverter never disengaged).The fix:
wait=Trueblocks until the device echoes the change (or a 10s timeout).Noneresponse (timeout) leaves state alone and emits a warning so users can build watchdog automations.Fixes #24
Test plan
uv run ruff check . && uv run ruff format --check .uv run mypy custom_components/jackeryuv run pytest tests/test_switch.py tests/test_select.py tests/test_number.py— all 96 tests pass, 100% coverage on the three moduleswait=True🤖 Generated with Claude Code