Conversation
_execute_state_change is documented to return False on failure, but a
Hive API timeout propagated as asyncio.TimeoutError, and a failed
request (for which _call_endpoint returns {}) raised KeyError on
resp["original"]. In Home Assistant this aborts the whole multi-entity
service call (e.g. climate.set_hvac_mode on several TRVs) and bypasses
continue_on_error, since neither is a HomeAssistantError.
Catch the timeout and read the status with .get() so both cases log
and return False as documented. Polling's own timeout handling is
unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #159 +/- ##
=======================================
Coverage 99.96% 99.96%
=======================================
Files 30 30
Lines 2571 2576 +5
Branches 297 297
=======================================
+ Hits 2570 2575 +5
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This branch has not been deployed
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
BaseDeviceHandler._execute_state_changeis documented to returnFalseon failure, but two failure paths raise instead:asyncio.TimeoutErrorpropagate out ofsession.api.set_state._call_endpointreturns{}, soresp["original"]raisesKeyError.Neither exception is a
HomeAssistantError. So in Home Assistant, one slow device aborts a whole multi-entity service call, e.g.climate.set_hvac_modeacross several TRVs, and the exception bypassescontinue_on_error. The remaining devices never get the command.Changes
src/helper/device_handler_base.py:asyncio.TimeoutErroraroundset_state, log a warning and returnFalse.resp.get("original")so a failed/empty response takes the existing "set_state failed" error path and returnsFalse.The timeout handling for polling is unchanged.
Behaviour change
tests/unit/test_base_handler.pypreviously asserted that a malformed response raisesKeyError. That test is nowtest_malformed_set_state_response_returns_false, since raising contradicted the method's documented contract. I also addedtest_set_state_timeout_returns_false.Testing
climate.set_hvac_modeon 11 TRVs in one service call, and the Hive API timed out on 5 of them:WARNING ... device_handler_base: _execute_state_change - set_state timed out for <TRV name>asyncio.TimeoutErrorout of the service call. The TRVs after it would have been skipped and the automation run marked as errored.🤖 Generated with Claude Code