1 """The MyPermobil integration."""
3 from __future__
import annotations
7 from mypermobil
import MyPermobil, MyPermobilClientException
22 from .const
import APPLICATION, DOMAIN
23 from .coordinator
import MyPermobilCoordinator
25 PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
27 _LOGGER = logging.getLogger(__name__)
31 """Set up MyPermobil from a config entry."""
36 application=APPLICATION,
38 email=entry.data[CONF_EMAIL],
39 region=entry.data[CONF_REGION],
40 code=entry.data[CONF_CODE],
41 token=entry.data[CONF_TOKEN],
42 expiration_date=entry.data[CONF_TTL],
45 p_api.self_authenticate()
46 except MyPermobilClientException
as err:
47 _LOGGER.error(
"Error authenticating %s", err)
52 await coordinator.async_config_entry_first_refresh()
54 hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
55 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
61 """Unload a config entry."""
62 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
63 hass.data[DOMAIN].pop(entry.entry_id)
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)