fix: add late-arriving thermostats and automations on update#224
Draft
bluetoothbot wants to merge 2 commits into
Draft
fix: add late-arriving thermostats and automations on update#224bluetoothbot wants to merge 2 commits into
bluetoothbot wants to merge 2 commits into
Conversation
_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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
What
Make
_update_devicesand_update_automationsadd-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
Testing
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.ruffandmypy nexia/home.pyclean.Quality Report
Changes: 2 files changed, 96 insertions(+), 24 deletions(-)
Code scan: clean
Tests: passed (58 passed)
Branch hygiene: clean
Generated by Kōan