1 """The Whirlpool Appliances integration."""
3 from dataclasses
import dataclass
6 from aiohttp
import ClientError
7 from whirlpool.appliancesmanager
import AppliancesManager
8 from whirlpool.auth
import Auth
9 from whirlpool.backendselector
import BackendSelector
17 from .const
import CONF_BRAND, CONF_BRANDS_MAP, CONF_REGIONS_MAP, DOMAIN
19 _LOGGER = logging.getLogger(__name__)
21 PLATFORMS = [Platform.CLIMATE, Platform.SENSOR]
25 """Set up Whirlpool Sixth Sense from a config entry."""
26 hass.data.setdefault(DOMAIN, {})
29 region = CONF_REGIONS_MAP[entry.data.get(CONF_REGION,
"EU")]
30 brand = CONF_BRANDS_MAP[entry.data.get(CONF_BRAND,
"Whirlpool")]
31 backend_selector = BackendSelector(brand, region)
34 backend_selector, entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], session
37 await auth.do_auth(store=
False)
38 except (ClientError, TimeoutError)
as ex:
41 if not auth.is_access_token_valid():
42 _LOGGER.error(
"Authentication failed")
45 appliances_manager = AppliancesManager(backend_selector, auth, session)
46 if not await appliances_manager.fetch_appliances():
47 _LOGGER.error(
"Cannot fetch appliances")
51 appliances_manager, auth, backend_selector
54 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
59 """Unload a config entry."""
60 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
62 hass.data[DOMAIN].pop(entry.entry_id)
69 """Whirlpool integaration shared data."""
71 appliances_manager: AppliancesManager
73 backend_selector: BackendSelector
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
bool async_setup_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)