Skip to content

Fix missing zone history and landscape data on multi-device accounts#397

Merged
sebr merged 1 commit intomainfrom
fix/per-device-history-landscape-cache
Apr 19, 2026
Merged

Fix missing zone history and landscape data on multi-device accounts#397
sebr merged 1 commit intomainfrom
fix/per-device-history-landscape-cache

Conversation

@sebr
Copy link
Copy Markdown
Owner

@sebr sebr commented Apr 19, 2026

Summary

Fixes #393. On accounts with more than one sprinkler_timer, zone history for every device after the first showed unknown starting in 4.0.0.

Root cause: _last_poll_device_histories and _last_poll_landscapes in pybhyve/client.py were 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 returns None → coordinator converts to [] → zone history sensor renders unknown.

Landscapes had the same shared-timestamp bug plus self._landscapes was 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

  • New tests/test_client.py covers:
    • Back-to-back history fetches for different devices each hit the API (regression for No longer getting zone history on HT25G2-0001 device since 4.0.0 update #393)
    • Same-device history fetch is rate-limited within the poll period
    • force_update=True bypasses the rate limit
    • Landscape fetches for different devices are both served
    • A zone lookup for one device does not fall through to another device's landscape list
    • Same-device landscape fetch is rate-limited
  • Full suite: 148 passed, 5 skipped
  • ruff check / ruff format --check clean

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.
@sebr sebr merged commit 25b845c into main Apr 19, 2026
4 checks passed
@sebr sebr deleted the fix/per-device-history-landscape-cache branch April 19, 2026 04:27
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.

No longer getting zone history on HT25G2-0001 device since 4.0.0 update

1 participant