diff --git a/homeassistant/components/history_stats/__init__.py b/homeassistant/components/history_stats/__init__.py index dcca10d73e9..63f32138dba 100644 --- a/homeassistant/components/history_stats/__init__.py +++ b/homeassistant/components/history_stats/__init__.py @@ -41,7 +41,7 @@ async def async_setup_entry( Template(end, hass) if end else None, duration, ) - coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry.title) + coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, entry, entry.title) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator diff --git a/homeassistant/components/history_stats/coordinator.py b/homeassistant/components/history_stats/coordinator.py index 0d613d2bbc0..fafbb5d3ce0 100644 --- a/homeassistant/components/history_stats/coordinator.py +++ b/homeassistant/components/history_stats/coordinator.py @@ -6,6 +6,7 @@ from datetime import timedelta import logging from typing import Any +from homeassistant.config_entries import ConfigEntry from homeassistant.core import ( CALLBACK_TYPE, Event, @@ -33,6 +34,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]): self, hass: HomeAssistant, history_stats: HistoryStats, + config_entry: ConfigEntry | None, name: str, ) -> None: """Initialize DataUpdateCoordinator.""" @@ -43,6 +45,7 @@ class HistoryStatsUpdateCoordinator(DataUpdateCoordinator[HistoryStatsState]): super().__init__( hass, _LOGGER, + config_entry=config_entry, name=name, update_interval=UPDATE_INTERVAL, ) diff --git a/homeassistant/components/history_stats/sensor.py b/homeassistant/components/history_stats/sensor.py index 4558da8722c..e1241034aeb 100644 --- a/homeassistant/components/history_stats/sensor.py +++ b/homeassistant/components/history_stats/sensor.py @@ -104,7 +104,7 @@ async def async_setup_platform( unique_id: str | None = config.get(CONF_UNIQUE_ID) history_stats = HistoryStats(hass, entity_id, entity_states, start, end, duration) - coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, name) + coordinator = HistoryStatsUpdateCoordinator(hass, history_stats, None, name) await coordinator.async_refresh() if not coordinator.last_update_success: raise PlatformNotReady from coordinator.last_exception