Skip to content

fix: keep auto-mode setpoint band on the unit grid (Celsius) - #226

Draft
bluetoothbot wants to merge 2 commits into
hvaclibs:masterfrom
bluetoothbot:koan/auto-mode-celsius-deadband-grid
Draft

fix: keep auto-mode setpoint band on the unit grid (Celsius)#226
bluetoothbot wants to merge 2 commits into
hvaclibs:masterfrom
bluetoothbot:koan/auto-mode-celsius-deadband-grid

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What: Keep the auto-mode setpoint band aligned to the temperature unit's grid when expanding a single set_temperature into heat/cool setpoints.

Why: set_heat_cool_temp's auto/off-mode branch split the deadband with math.ceil(deadband / 2), forcing a whole-degree half-offset. On Celsius systems (0.5° grid) this over-widened the band: a 1.0° deadband produced a ±1.0° band (gap 2.0°) instead of the minimal ±0.5° (gap 1.0°). Since py.typed shipped (#203), Celsius fractional precision is a real downstream contract — the read/write setpoint paths were widened to float in #205/#206, and this is the matching rounding fix.

How: Round the half-deadband up to the unit's grid step (0.5° Celsius, 1° Fahrenheit) rather than to an integer. The band still satisfies the deadband, but is the minimal grid-aligned spread. Fahrenheit output is provably unchanged (ceil(d/2/1)*1 == ceil(d/2)).

Testing: Added two cases for the previously untested auto-mode branch — Fahrenheit (deadband 3 → ±2°, regression guard) and Celsius (deadband 1.0 → ±0.5° on the half-degree grid). Full suite 59 passed, ruff + mypy clean.


Quality Report

Changes: 2 files changed, 64 insertions(+), 5 deletions(-)

Code scan: clean

Tests: passed (59 passed)

Branch hygiene: clean

Generated by Kōan

bluetoothbot and others added 2 commits June 23, 2026 08:04
set_heat_cool_temp's auto/off-mode branch split the deadband with
math.ceil(deadband / 2), forcing an integer half-offset. On Celsius
systems this over-widened the band off the 0.5 grid: a 1.0 deadband
yielded +/-1.0 instead of the minimal +/-0.5. Round the half-deadband
up to the unit's grid step (0.5 C, 1 F) instead. Fahrenheit output is
unchanged. Adds coverage for the previously untested branch.
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant