Skip to content

Pick latest zone history irrigation by start_time#398

Merged
sebr merged 2 commits intomainfrom
fix/zone-history-latest-by-start-time
Apr 19, 2026
Merged

Pick latest zone history irrigation by start_time#398
sebr merged 2 commits intomainfrom
fix/zone-history-latest-by-start-time

Conversation

@sebr
Copy link
Copy Markdown
Owner

@sebr sebr commented Apr 19, 2026

Summary

  • Zone history sensor previously picked zone_irrigation[-1] from the first history item containing any entry for the zone. That relied on the upstream irrigation array being ordered by time, which isn't always true — a later entry appearing earlier in the array caused the sensor to surface the wrong run (wrong start_time, run_time, status, consumption_gallons, consumption_litres).
  • Now selects the irrigation entry with the greatest start_time across all history items. All statuses are considered so skipped runs still report their flow consumption.

Test plan

  • pytest tests/test_sensor.py — all 11 tests pass, including a new case that asserts selection is by greatest start_time regardless of array position or history-item position.
  • ./scripts/lint — clean.

sebr added 2 commits April 19, 2026 09:04
The zone history sensor picked zone_irrigation[-1] from the first
history item that had any entry for the zone. That relied on the
upstream irrigation array being ordered by time, which isn't always
true: when a later entry appears earlier in the array, the sensor
surfaces the wrong run and its attributes (run_time, consumption,
status).

Select the entry with the greatest start_time across every history
item instead. All statuses are considered so skipped runs still report
consumption.
@sebr sebr merged commit 05c975a into main Apr 19, 2026
4 checks passed
@sebr sebr deleted the fix/zone-history-latest-by-start-time branch April 19, 2026 09:11
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