Repository navigation
Raise the cooling setpoint first when moving a heat/cool range up - #1045
Draft
zigpy-review-bot wants to merge 1 commit into
Draft
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
In heat/cool mode, async_set_temperature always wrote the heating setpoint before the cooling setpoint. When the new heating setpoint is within the deadband of the current cooling setpoint (moving 20-25 °C to 26-29 °C), the thermostat rejects that first write with INVALID_VALUE (ZCL R8 6.3.2.2.2.2), write_attributes_safe raises, and the cooling setpoint is never sent: the range can't be moved up in one step. Write the cooling setpoint first when the heating setpoint goes up, and keep heating first otherwise, so every intermediate pair of setpoints stays valid.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1045 +/- ##
=======================================
Coverage 97.48% 97.48%
=======================================
Files 61 61
Lines 10870 10874 +4
=======================================
+ Hits 10597 10601 +4
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: medium (the audit's estimate)
In heat/cool mode,
Thermostat.async_set_temperaturealways wrote the heating setpoint before the cooling setpoint. Moving the range up, for example from 20–25 °C to 26–29 °C, first writes a heating setpoint above the current cooling setpoint. ZCL R8 §6.3.2.2.2.2 requires the thermostat to answer such a write with INVALID_VALUE, because the cooling setpoint must stay above the heating setpoint byMinSetpointDeadBand.write_attributes_safethen raises and the cooling setpoint is never written, so the range can't be moved up in one step.This writes the cooling setpoint first when the heating setpoint goes up. As before when lowering the range, a write rejected for another reason (a setpoint outside its limits) still leaves the first write applied.
Changes
async_set_temperaturein heat/cool mode compares the new heating setpoint with the current one (occupied, or unoccupied in away). When it goes up, the cooling setpoint is written first and the heating setpoint second; otherwise the order stays heating first. When the current setpoints are valid and both ends are given, every intermediate pair is then valid whenever the requested range is. When the current heating setpoint isn't in the cache (it is read at startup and reported), the order stays heating first, as before.Testing
test_set_temperature_heat_cool_keeps_deadband(occupied and away) gives the thermostat cluster a write handler that rejects a write breaking the 2.5 °C deadband, moves the range from 20–25 °C to 26–29 °C and back to 18–22 °C, and checks the written values and their order. It fails at dev 2da1a5b withFailed to write attribute occupied_heating_setpoint=2600: <Status.INVALID_VALUE: 135>and passes with the fix. The existingtest_set_temperature_heat_cool(which lowers the heating setpoint) is unchanged and passes.tests/test_climate.py: 90 passed. Full suite: 1783 passed. pre-commit (codespell, ruff, ruff format, mypy) passed.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1044