1 """The Electra Air Conditioner integration."""
3 from __future__
import annotations
5 from typing
import cast
7 from electrasmart.api
import ElectraAPI, ElectraApiError
15 from .const
import CONF_IMEI, DOMAIN
17 PLATFORMS: list[Platform] = [Platform.CLIMATE]
21 """Set up Electra Smart Air Conditioner from a config entry."""
22 hass.data.setdefault(DOMAIN, {})
23 entry.async_on_unload(entry.add_update_listener(update_listener))
24 hass.data[DOMAIN][entry.entry_id] = ElectraAPI(
29 await cast(ElectraAPI, hass.data[DOMAIN][entry.entry_id]).fetch_devices()
30 except ElectraApiError
as exp:
33 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
38 """Unload a config entry."""
39 if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
40 hass.data[DOMAIN].pop(entry.entry_id)
45 async
def update_listener(hass: HomeAssistant, config_entry: ConfigEntry) ->
None:
46 """Update listener."""
47 await hass.config_entries.async_reload(config_entry.entry_id)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
None update_listener(HomeAssistant hass, ConfigEntry config_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)