mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +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.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
|
||||||
from .const import DEFAULT_POLL_INTERVAL, DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import LaundrifyUpdateCoordinator
|
from .coordinator import LaundrifyUpdateCoordinator
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -34,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
except ApiConnectionException as err:
|
except ApiConnectionException as err:
|
||||||
raise ConfigEntryNotReady("Cannot reach laundrify API") from 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()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -7,11 +7,12 @@ import logging
|
|||||||
from laundrify_aio import LaundrifyAPI, LaundrifyDevice
|
from laundrify_aio import LaundrifyAPI, LaundrifyDevice
|
||||||
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
from laundrify_aio.exceptions import ApiConnectionException, UnauthorizedException
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -19,15 +20,21 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class LaundrifyUpdateCoordinator(DataUpdateCoordinator[dict[str, LaundrifyDevice]]):
|
class LaundrifyUpdateCoordinator(DataUpdateCoordinator[dict[str, LaundrifyDevice]]):
|
||||||
"""Class to manage fetching laundrify API data."""
|
"""Class to manage fetching laundrify API data."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, laundrify_api: LaundrifyAPI, poll_interval: int
|
self,
|
||||||
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
laundrify_api: LaundrifyAPI,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize laundrify coordinator."""
|
"""Initialize laundrify coordinator."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=poll_interval),
|
update_interval=timedelta(seconds=DEFAULT_POLL_INTERVAL),
|
||||||
)
|
)
|
||||||
self.laundrify_api = laundrify_api
|
self.laundrify_api = laundrify_api
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user