mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
Introduced TibberPricesMidnightHandler to prevent duplicate midnight turnover when multiple timers fire simultaneously. Problem: Timer #1 (API poll) and Timer #2 (quarter-hour refresh) both wake at midnight, each detecting day change and triggering cache clear. Race condition caused duplicate turnover operations. Solution: - Atomic flag coordination: First timer sets flag, subsequent timers skip - Persistent state survives HA restart (cache stores last_turnover_time) - Day-boundary detection: Compares current.date() vs last_check.date() - 13 comprehensive tests covering race conditions and HA restart scenarios Architecture: - coordinator/midnight_handler.py: 165 lines, atomic coordination logic - coordinator/core.py: Integrated handler in coordinator initialization - coordinator/listeners.py: Delegate midnight check to handler Impact: Eliminates duplicate cache clears at midnight. Single atomic turnover operation regardless of how many timers fire simultaneously. |
||
|---|---|---|
| .. | ||
| development | ||
| user | ||