Skip to content

Raise the cooling setpoint first when moving a heat/cool range up - #1045

Draft
zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/raise-cooling-setpoint-first-in-heat-cool
Draft

zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/raise-cooling-setpoint-first-in-heat-cool

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Summary

Severity: medium (the audit's estimate)

In heat/cool mode, Thermostat.async_set_temperature always 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 by MinSetpointDeadBand. write_attributes_safe then 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_temperature in 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 with Failed to write attribute occupied_heating_setpoint=2600: <Status.INVALID_VALUE: 135> and passes with the fix. The existing test_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

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.
@zigpy-review-bot zigpy-review-bot added bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bugfix This PR fixes a bug bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) labels Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (2da1a5b) to head (1a36219).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moving a heat/cool range up fails with INVALID_VALUE because the heating setpoint is written first

1 participant