mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
fix(binary_sensor): restore push updates from coordinator
Binary sensor _handle_coordinator_update() was empty, blocking all push updates from coordinator. This prevented binary sensors from reflecting state changes immediately after API fetch or error conditions. Changes: - Implement _handle_coordinator_update() to call async_write_ha_state() - All binary sensors now receive push updates when coordinator has new data Binary sensors affected: - tomorrow_data_available: Now reflects data availability immediately after API fetch - connection: Now shows disconnected state immediately on auth/API errors - chart_data_export: Now updates chart data when price data changes - peak_price_period, best_price_period: Get push updates when periods change - data_lifecycle_status: Gets push updates on status changes Impact: Binary sensors update in real-time instead of waiting for next timer cycle or user interaction. Fixes stale state issue where tomorrow_data_available remained off despite data being available, and connection sensor not reflecting authentication failures immediately.
This commit is contained in:
parent
0ac2c4970f
commit
8893b31f21
1 changed files with 7 additions and 5 deletions
|
|
@ -217,11 +217,13 @@ class TibberPricesBinarySensor(TibberPricesEntity, BinarySensorEntity):
|
|||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
# Chart data export: No automatic refresh needed.
|
||||
# Data only refreshes on:
|
||||
# 1. Initial sensor activation (async_added_to_hass)
|
||||
# 2. Config changes via Options Flow (triggers re-add)
|
||||
# Hourly coordinator updates don't change the chart data content.
|
||||
# All binary sensors get push updates when coordinator has new data:
|
||||
# - tomorrow_data_available: Reflects new data availability immediately after API fetch
|
||||
# - connection: Reflects connection state changes immediately
|
||||
# - chart_data_export: Updates chart data when price data changes
|
||||
# - peak_price_period, best_price_period: Update when periods change (also get Timer #2 updates)
|
||||
# - data_lifecycle_status: Gets both push and Timer #2 updates
|
||||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue