1 """The laundrify integration."""
3 from __future__
import annotations
7 from laundrify_aio
import LaundrifyAPI
8 from laundrify_aio.exceptions
import ApiConnectionException, UnauthorizedException
16 from .const
import DEFAULT_POLL_INTERVAL, DOMAIN
17 from .coordinator
import LaundrifyUpdateCoordinator
19 _LOGGER = logging.getLogger(__name__)
21 PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
25 """Set up laundrify from a config entry."""
28 api_client = LaundrifyAPI(entry.data[CONF_ACCESS_TOKEN], session)
31 await api_client.validate_token()
32 except UnauthorizedException
as err:
34 except ApiConnectionException
as err:
39 await coordinator.async_config_entry_first_refresh()
41 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = {
43 "coordinator": coordinator,
46 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
52 """Unload a config entry."""
54 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
55 hass.data[DOMAIN].pop(entry.entry_id)
63 _LOGGER.debug(
"Migrating from version %s", entry.version)
65 if entry.version == 1:
67 if entry.minor_version == 1:
69 hass.config_entries.async_update_entry(
70 entry, unique_id=
str(entry.unique_id), minor_version=minor_version
73 _LOGGER.debug(
"Migration successful")
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_migrate_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)