mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Explicitly pass in the config_entry in laundrify coordinator (#138116)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
9244e84326
commit
8234c9a183
@ -13,7 +13,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import DEFAULT_POLL_INTERVAL, DOMAIN
|
||||
from .const import DOMAIN
|
||||
from .coordinator import LaundrifyUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -34,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
except ApiConnectionException as err:
|
||||
raise ConfigEntryNotReady("Cannot reach laundrify API") from err
|
||||
|
||||
coordinator = LaundrifyUpdateCoordinator(hass, api_client, DEFAULT_POLL_INTERVAL)
|
||||
coordinator = LaundrifyUpdateCoordinator(hass, entry, api_client)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
@ -7,11 +7,12 @@ import logging
|
||||
from laundrify_aio import LaundrifyAPI, LaundrifyDevice
|
||||
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import DOMAIN, REQUEST_TIMEOUT
|
||||
from .const import DEFAULT_POLL_INTERVAL, DOMAIN, REQUEST_TIMEOUT
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -19,15 +20,21 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class LaundrifyUpdateCoordinator(DataUpdateCoordinator[dict[str, LaundrifyDevice]]):
|
||||
"""Class to manage fetching laundrify API data."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistant, laundrify_api: LaundrifyAPI, poll_interval: int
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
laundrify_api: LaundrifyAPI,
|
||||
) -> None:
|
||||
"""Initialize laundrify coordinator."""
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=poll_interval),
|
||||
update_interval=timedelta(seconds=DEFAULT_POLL_INTERVAL),
|
||||
)
|
||||
self.laundrify_api = laundrify_api
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user