1616from homeassistant .helpers .update_coordinator import DataUpdateCoordinator
1717
1818from ..api import EcoflowApiClient
19+ from .data_coordinator import EcoflowBroadcastDataHolder
1920
2021_LOGGER = logging .getLogger (__name__ )
2122
@@ -44,9 +45,7 @@ def unregister(self, entry_id: str) -> None:
4445
4546 def _actualize_interval (self ) -> None :
4647 interval = min (
47- (d .device_data .options .assume_offline_sec
48- for c in self ._clients .values ()
49- for d in c .devices .values ()),
48+ (d .device_data .options .assume_offline_sec for c in self ._clients .values () for d in c .devices .values ()),
5049 default = DEFAULT_STATUS_POLL_INTERVAL_SEC ,
5150 )
5251 self .update_interval = datetime .timedelta (seconds = interval )
@@ -80,9 +79,7 @@ async def _async_update_data(self) -> None:
8079
8180 # Only poll if at least one device needs status clarification
8281 needs_poll = any (
83- device .status_tracker .wants_status_poll
84- for devices in all_devices .values ()
85- for device in devices
82+ device .status_tracker .wants_status_poll for devices in all_devices .values () for device in devices
8683 )
8784 if not needs_poll :
8885 _LOGGER .debug ("No devices need status poll — skipping" )
@@ -98,4 +95,7 @@ async def _async_update_data(self) -> None:
9895
9996 for api_device in api_devices :
10097 for device in all_devices .get (api_device .sn , []):
101- device .status_tracker .on_explicit_status (api_device .status == 1 )
98+ online = api_device .status == 1
99+ device .status_tracker .on_explicit_status (online )
100+ device .data .mark_status_changed ()
101+ device .coordinator .async_set_updated_data (EcoflowBroadcastDataHolder (device .data , online ))
0 commit comments