hass.tibber_prices/custom_components
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
..
tibber_prices fix(interval_pool): rebuild index after GC dead interval cleanup 2026-04-17 11:15:08 +00:00