diff --git a/homeassistant/components/ista_ecotrend/__init__.py b/homeassistant/components/ista_ecotrend/__init__.py index 76ef8d13fd4..4262b354acb 100644 --- a/homeassistant/components/ista_ecotrend/__init__.py +++ b/homeassistant/components/ista_ecotrend/__init__.py @@ -6,20 +6,17 @@ import logging from pyecotrend_ista import KeycloakError, LoginError, PyEcotrendIsta, ServerError -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from .const import DOMAIN -from .coordinator import IstaCoordinator +from .coordinator import IstaConfigEntry, IstaCoordinator _LOGGER = logging.getLogger(__name__) PLATFORMS: list[Platform] = [Platform.SENSOR] -type IstaConfigEntry = ConfigEntry[IstaCoordinator] - async def async_setup_entry(hass: HomeAssistant, entry: IstaConfigEntry) -> bool: """Set up ista EcoTrend from a config entry.""" @@ -42,7 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: IstaConfigEntry) -> bool translation_placeholders={CONF_EMAIL: entry.data[CONF_EMAIL]}, ) from e - coordinator = IstaCoordinator(hass, ista) + coordinator = IstaCoordinator(hass, entry, ista) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator diff --git a/homeassistant/components/ista_ecotrend/coordinator.py b/homeassistant/components/ista_ecotrend/coordinator.py index 0f14cd06fe3..53ef4a46d20 100644 --- a/homeassistant/components/ista_ecotrend/coordinator.py +++ b/homeassistant/components/ista_ecotrend/coordinator.py @@ -18,17 +18,22 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) +type IstaConfigEntry = ConfigEntry[IstaCoordinator] + class IstaCoordinator(DataUpdateCoordinator[dict[str, Any]]): """Ista EcoTrend data update coordinator.""" - config_entry: ConfigEntry + config_entry: IstaConfigEntry - def __init__(self, hass: HomeAssistant, ista: PyEcotrendIsta) -> None: + def __init__( + self, hass: HomeAssistant, config_entry: IstaConfigEntry, ista: PyEcotrendIsta + ) -> None: """Initialize ista EcoTrend data update coordinator.""" super().__init__( hass, _LOGGER, + config_entry=config_entry, name=DOMAIN, update_interval=timedelta(days=1), ) diff --git a/homeassistant/components/ista_ecotrend/sensor.py b/homeassistant/components/ista_ecotrend/sensor.py index e96ac103741..59fd48a5fe9 100644 --- a/homeassistant/components/ista_ecotrend/sensor.py +++ b/homeassistant/components/ista_ecotrend/sensor.py @@ -34,9 +34,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import CoordinatorEntity -from . import IstaConfigEntry from .const import DOMAIN -from .coordinator import IstaCoordinator +from .coordinator import IstaConfigEntry, IstaCoordinator from .util import IstaConsumptionType, IstaValueType, get_native_value, get_statistics _LOGGER = logging.getLogger(__name__)