mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-04-07 08:03:40 +00:00
On DST fall-back nights the clocks repeat an hour (e.g. 02:00 CET/CEST). Tibber delivers quarter-hourly intervals for both the CEST (+02:00) and CET (+01:00) copies of that hour. Both share the same 19-char naive local key 'YYYY-MM-DDTHH:MM:SS', so _add_intervals treated the CET arrivals as unwanted duplicates and sent them to _touch_intervals, which kept the CEST data and silently discarded the CET price data. The fall-back hour's prices were permanently lost from the pool. Fix: - Add module constant _DST_COLLISION_MAX_SAME_UTC_S (60 s) to distinguish true duplicate arrivals (same UTC, ≤60 s apart) from DST collision pairs (~3600 s apart). - Add _handle_index_collision() helper that compares the UTC datetimes of the existing and incoming interval. If they differ by more than the threshold it stores the new interval in self._dst_extras keyed by the normalised local timestamp and returns True. - _add_intervals delegates every collision to _handle_index_collision and only routes to touch when it returns False (true duplicate). - _get_cached_intervals yields the saved extras after the main interval. - After each GC run, stale entries are pruned from _dst_extras. - to_dict / from_dict persist and restore _dst_extras across HA restarts. Impact: The full fall-back hour (e.g. 02:00-02:45 CET) now appears in the interval pool alongside the CEST copies, so sensors that query that hour return correct prices instead of stale or missing data. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| cache.py | ||
| fetcher.py | ||
| garbage_collector.py | ||
| index.py | ||
| manager.py | ||
| routing.py | ||
| storage.py | ||