Fix missing zone history and landscape data on multi-device accounts#397
Merged
Fix missing zone history and landscape data on multi-device accounts#397
Conversation
The history and landscape refresh paths each used a single scalar last-poll timestamp shared across all devices. On coordinator ticks that fetched multiple sprinkler_timers sequentially, the first device updated the stamp and every subsequent device bailed out at the rate-limit check within milliseconds, so its history/landscape data was never populated. Landscapes had an additional bug where self._landscapes was a single list overwritten on every per-device fetch, so only the last-fetched device's data survived. Key both state and timestamps by device_id. Fixes #393.
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.
Summary
Fixes #393. On accounts with more than one
sprinkler_timer, zone history for every device after the first showedunknownstarting in 4.0.0.Root cause:
_last_poll_device_historiesand_last_poll_landscapesinpybhyve/client.pywere single scalar timestamps shared across all devices. The 4.0.0 coordinator fetches history/landscapes for each sprinkler sequentially on every tick — the first device updates the stamp, subsequent devices bail out at the rate-limit check milliseconds later, and their entries are never populated in_device_histories.get_device_history()then returnsNone→ coordinator converts to[]→ zone history sensor rendersunknown.Landscapes had the same shared-timestamp bug plus
self._landscapeswas a single list overwritten on each per-device fetch, so only the last device's landscape data survived regardless.Fix: key both the state and the timestamps by
device_id.Test plan
tests/test_client.pycovers:force_update=Truebypasses the rate limitruff check/ruff format --checkclean