Skip to content

Commit

Permalink
Explicitly pass in the config_entry in ista_ecotrend coordinator (#13…
Browse files Browse the repository at this point in the history
…8130)

explicitly pass in the config_entry in coordinator
  • Loading branch information
mib1185 authored Feb 9, 2025
1 parent db56052 commit fd57803
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
7 changes: 2 additions & 5 deletions homeassistant/components/ista_ecotrend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@

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."""
Expand All @@ -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
Expand Down
9 changes: 7 additions & 2 deletions homeassistant/components/ista_ecotrend/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@

_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),
)
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/components/ista_ecotrend/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
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__)
Expand Down

0 comments on commit fd57803

Please sign in to comment.