Repository navigation
Update heat setpoint limit number ranges when the other limit changes - #1059
Open
zigpy-review-bot wants to merge 1 commit into
Open
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
The min and max heat setpoint limit numbers take one bound from the other limit (and the outer bounds from the absolute limits), but their range was only computed when the entity was added. After writing or receiving a new limit, the other entity kept the old bound until the next restart, so Home Assistant rejected valid values and offered values the thermostat refuses. Recompute the range when one of those attributes is read, reported, written or updated.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1059 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 61 61
Lines 10870 10875 +5
=======================================
+ Hits 10597 10602 +5
Misses 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Severity: low (the audit's estimate)
The min and max heat setpoint limit numbers take one bound from each other (and the outer bounds from the absolute limits), but their range was only computed when the entity was added (
Device.recompute_entities()also recomputes it, but only the tests call that). After one limit changed, written from Home Assistant or reported by the thermostat, the other number kept the old bound until the next restart: Home Assistant refused valid values and offered values below the new minimum or above the new maximum.Changes
NumberConfigurationEntitygets_capability_attribute_names, the attributes its range is computed from. When one of them is read, reported, written or updated,handle_attribute_updated()recomputes the capabilities and emits the state; events for the entity's own attribute emit the state as before, and other attributes are still ignored.ZCLHeatSetpointLimitEntity(the base ofMinHeatSetpointLimitandMaxHeatSetpointLimit) sets it toabs_min_heat_setpoint_limit,abs_max_heat_setpoint_limit,min_heat_setpoint_limitandmax_heat_setpoint_limit.Testing
test_heat_setpoint_limit_ranges_follow_each_otherjoins a thermostat with limits 7–30 °C (absolute 5–35 °C), writes 16 °C through the minimum limit number and checks the maximum limit's lower bound follows, then sends a report of 22 °C for the maximum limit and checks the minimum limit's upper bound follows. It fails at 2da1a5b (assert 7.0 == 16.0) and passes with the fix.tests/test_number.pyandtests/test_climate.pypass, and so does the full suite (1782 passed). pre-commit (codespell, ruff, mypy) passes on the changed files.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1058