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. |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| test_avg_none_fallback.py | ||
| test_cache_age.py | ||
| test_cache_validity.py | ||
| test_cache_validity_after_midnight.py | ||
| test_chart_data_push_updates.py | ||
| test_config_validators.py | ||
| test_midnight_handler.py | ||
| test_midnight_periods.py | ||
| test_midnight_turnover.py | ||
| test_minmax_none_fallback.py | ||
| test_percentage_calculations.py | ||
| test_price_calculations.py | ||
| test_rating_threshold_validation.py | ||