Skip to content

fix: add late-arriving thermostats and automations on update#224

Draft
bluetoothbot wants to merge 2 commits into
hvaclibs:masterfrom
bluetoothbot:koan/append-late-thermostats-automations
Draft

fix: add late-arriving thermostats and automations on update#224
bluetoothbot wants to merge 2 commits into
hvaclibs:masterfrom
bluetoothbot:koan/append-late-thermostats-automations

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Make _update_devices and _update_automations add-only: a thermostat or automation that first appears on a later fetch is now appended instead of dropped.

Why

Both methods built the entity list once (when it was None) and afterwards only patched entities whose id was already known. Some systems under-report devices on the initial poll, so an entity can be absent at construction and only surface on a subsequent update — and it was being silently ignored forever. This is the same class of bug as #149 (UX360 zones reported after initial discovery), just one level up: whole thermostats and automations rather than zones within a thermostat.

How

  • Unified the first-fetch and later-fetch paths: compute the set of already-tracked ids, then append any id present in the new JSON but not yet tracked.
  • Preserved the existing zone-skip guard for thermostats with no zones (e.g. xl624).
  • Kept existing entity objects intact so consumers holding references (e.g. Home Assistant) keep working. The library never removes thermostats/automations, so add-only is the safe convention — matching the late-zone fix.

Testing

  • New regression test_late_thermostat_and_automation_are_added: under-reports one thermostat + one automation on the first update, confirms both are absent, then re-feeds the full payload and asserts both are added while the pre-existing objects are reused (identity check). Fails against the prior code, passes after.
  • Full suite: 58 passed, 1 skipped. ruff and mypy nexia/home.py clean.

Quality Report

Changes: 2 files changed, 96 insertions(+), 24 deletions(-)

Code scan: clean

Tests: passed (58 passed)

Branch hygiene: clean

Generated by Kōan

bluetoothbot and others added 2 commits June 23, 2026 06:08
_update_devices and _update_automations only patched entities already known
from the first fetch; a thermostat or automation that first appears on a later
poll was silently dropped. Some systems under-report devices on the initial
poll, so this is the same class of bug as hvaclibs#149 (late zones) one level up. Make
both methods add-only: append any id not yet tracked while preserving existing
objects that consumers hold references to.
@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