Explicitly pass in the config_entry in ista_ecotrend coordinator (#138130)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 20:29:30 +01:00 committed by GitHub
parent db5605223f
commit fd57803b15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 9 deletions

View File

@ -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

View File

@ -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),
)

View File

@ -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__)