Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The AirTouch4 integration."""
2 
3 from airtouch4pyapi import AirTouch
4 
5 from homeassistant.config_entries import ConfigEntry
6 from homeassistant.const import CONF_HOST, Platform
7 from homeassistant.core import HomeAssistant
8 from homeassistant.exceptions import ConfigEntryNotReady
9 
10 from .coordinator import AirtouchDataUpdateCoordinator
11 
12 PLATFORMS = [Platform.CLIMATE]
13 
14 type AirTouch4ConfigEntry = ConfigEntry[AirtouchDataUpdateCoordinator]
15 
16 
17 async def async_setup_entry(hass: HomeAssistant, entry: AirTouch4ConfigEntry) -> bool:
18  """Set up AirTouch4 from a config entry."""
19  host = entry.data[CONF_HOST]
20  airtouch = AirTouch(host)
21  await airtouch.UpdateInfo()
22  info = airtouch.GetAcs()
23  if not info:
24  raise ConfigEntryNotReady
25  coordinator = AirtouchDataUpdateCoordinator(hass, airtouch)
26  await coordinator.async_config_entry_first_refresh()
27  entry.runtime_data = coordinator
28 
29  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
30 
31  return True
32 
33 
34 async def async_unload_entry(hass: HomeAssistant, entry: AirTouch4ConfigEntry) -> bool:
35  """Unload a config entry."""
36  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, AirTouch4ConfigEntry entry)
Definition: __init__.py:34
bool async_setup_entry(HomeAssistant hass, AirTouch4ConfigEntry entry)
Definition: __init__.py:17