1 """Custom DataUpdateCoordinator for the laundrify integration."""
4 from datetime
import timedelta
7 from laundrify_aio
import LaundrifyAPI, LaundrifyDevice
8 from laundrify_aio.exceptions
import ApiConnectionException, UnauthorizedException
14 from .const
import DOMAIN, REQUEST_TIMEOUT
16 _LOGGER = logging.getLogger(__name__)
20 """Class to manage fetching laundrify API data."""
23 self, hass: HomeAssistant, laundrify_api: LaundrifyAPI, poll_interval: int
25 """Initialize laundrify coordinator."""
30 update_interval=
timedelta(seconds=poll_interval),
35 """Fetch data from laundrify API."""
39 async
with asyncio.timeout(REQUEST_TIMEOUT):
40 return {m.id: m
for m
in await self.
laundrify_apilaundrify_api.get_machines()}
41 except UnauthorizedException
as err:
44 raise ConfigEntryAuthFailed
from err
45 except ApiConnectionException
as err:
46 raise UpdateFailed(f
"Error communicating with API: {err}")
from err
None __init__(self, HomeAssistant hass, LaundrifyAPI laundrify_api, int poll_interval)
dict[str, LaundrifyDevice] _async_update_data(self)