1 """The Fujitsu HVAC (based on Ayla IOT) integration."""
3 from __future__
import annotations
5 from contextlib
import suppress
7 from ayla_iot_unofficial
import new_ayla_api
8 from ayla_iot_unofficial.fujitsu_consts
import FGLAIR_APP_CREDENTIALS
15 from .const
import API_TIMEOUT, CONF_EUROPE, CONF_REGION, REGION_DEFAULT, REGION_EU
16 from .coordinator
import FGLairCoordinator
18 PLATFORMS: list[Platform] = [Platform.CLIMATE]
20 type FGLairConfigEntry = ConfigEntry[FGLairCoordinator]
24 """Set up Fujitsu HVAC (based on Ayla IOT) from a config entry."""
25 app_id, app_secret = FGLAIR_APP_CREDENTIALS[entry.data[CONF_REGION]]
27 entry.data[CONF_USERNAME],
28 entry.data[CONF_PASSWORD],
31 europe=entry.data[CONF_REGION] == REGION_EU,
32 websession=aiohttp_client.async_get_clientsession(hass),
37 await coordinator.async_config_entry_first_refresh()
39 entry.runtime_data = coordinator
41 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
46 """Unload a config entry."""
47 unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
48 with suppress(TimeoutError):
49 await entry.runtime_data.api.async_sign_out()
55 """Migrate old entry."""
59 if entry.version == 1:
60 new_data = {**entry.data}
61 if entry.minor_version < 2:
62 is_europe = new_data.get(CONF_EUROPE,
False)
64 new_data[CONF_REGION] = REGION_EU
66 new_data[CONF_REGION] = REGION_DEFAULT
68 hass.config_entries.async_update_entry(
69 entry, data=new_data, minor_version=2, version=1
bool async_migrate_entry(HomeAssistant hass, FGLairConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, FGLairConfigEntry entry)
bool async_unload_entry(HomeAssistant hass, FGLairConfigEntry entry)