Skip to content

Update heat setpoint limit number ranges when the other limit changes - #1059

Open
zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/update-heat-setpoint-limit-number-ranges
Open

zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/update-heat-setpoint-limit-number-ranges

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

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

  • NumberConfigurationEntity gets _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 of MinHeatSetpointLimit and MaxHeatSetpointLimit) sets it to abs_min_heat_setpoint_limit, abs_max_heat_setpoint_limit, min_heat_setpoint_limit and max_heat_setpoint_limit.

Testing

  • New test_heat_setpoint_limit_ranges_follow_each_other joins 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.py and tests/test_climate.py pass, 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

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.
@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 22, 2026
@codecov

codecov Bot commented Nov 22, 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 (178c22e).

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.
📢 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.

Thermostat min/max heat setpoint limit numbers keep a stale range after the other limit changes

1 participant