diff --git a/homeassistant/components/starlink/coordinator.py b/homeassistant/components/starlink/coordinator.py index 89d03a4fadc..6fcfd8e0bfe 100644 --- a/homeassistant/components/starlink/coordinator.py +++ b/homeassistant/components/starlink/coordinator.py @@ -52,6 +52,7 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]): def __init__(self, hass: HomeAssistant, name: str, url: str) -> None: """Initialize an UpdateCoordinator for a group of sensors.""" self.channel_context = ChannelContext(target=url) + self.history_stats_start = None self.timezone = ZoneInfo(hass.config.time_zone) super().__init__( hass, @@ -67,7 +68,18 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]): location = location_data(context) sleep = get_sleep_config(context) status, obstruction, alert = status_data(context) - usage, consumption = history_stats(parse_samples=-1, context=context)[-2:] + index, _, _, _, _, usage, consumption, *_ = history_stats( + parse_samples=-1, start=self.history_stats_start, context=context + ) + self.history_stats_start = index["end_counter"] + if self.data: + if index["samples"] > 0: + usage["download_usage"] += self.data.usage["download_usage"] + usage["upload_usage"] += self.data.usage["upload_usage"] + consumption["total_energy"] += self.data.consumption["total_energy"] + else: + usage = self.data.usage + consumption = self.data.consumption return StarlinkData( location, sleep, status, obstruction, alert, usage, consumption )