hass.tibber_prices/custom_components/tibber_prices/interval_pool
Julian Pawlowski ec3bc9f84d fix(interval_pool): rebuild index after GC dead interval cleanup
_cleanup_dead_intervals() compacts group["intervals"] in-place after
removing dead (touched) intervals. Surviving intervals shift to new
positions, but the timestamp index was not updated to reflect this.

_remove_empty_groups() only rebuilds the index when groups become
completely empty. For partially-compacted groups (some dead intervals
removed but group still has living intervals), no rebuild happened.
This left stale interval_index values that point past the end of
the compacted list, causing IndexError in _get_cached_intervals.

Fix: after _remove_empty_groups, if dead intervals were cleaned but
no groups became empty, explicitly rebuild the index so positions
reflect the compacted group["intervals"] lists.

Adds regression test reproducing the exact partial-touch scenario
that triggers stale index entries after in-place compaction.

Fixes #118

Impact: Brand-new Tibber users can now set up the integration
without getting "Failed setup, will retry: list index out of range".
2026-04-17 11:15:08 +00:00
..
__init__.py feat(interval-pool): add intelligent interval caching and memory optimization 2025-11-25 20:44:39 +00:00
cache.py fix(interval_pool): prevent external mutation of cached intervals 2025-12-23 14:13:24 +00:00
fetcher.py fix(interval_pool): use tz-aware datetime comparison at resolution boundary 2026-04-06 14:08:27 +00:00
garbage_collector.py fix(interval_pool): rebuild index after GC dead interval cleanup 2026-04-17 11:15:08 +00:00
index.py refactor(interval_pool): improve reliability and test coverage 2025-12-23 10:10:35 +00:00
manager.py perf(interval_pool): hoist fetch_groups and precompute period criteria 2026-04-06 14:35:33 +00:00
routing.py feat(interval-pool): add intelligent interval caching and memory optimization 2025-11-25 20:44:39 +00:00
storage.py feat(interval-pool): add intelligent interval caching and memory optimization 2025-11-25 20:44:39 +00:00