Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Aquacell integration."""
2 
3 from __future__ import annotations
4 
5 from aioaquacell import AquacellApi
6 from aioaquacell.const import Brand
7 
8 from homeassistant.config_entries import ConfigEntry
9 from homeassistant.const import Platform
10 from homeassistant.core import HomeAssistant
11 from homeassistant.helpers.aiohttp_client import async_get_clientsession
12 
13 from .const import CONF_BRAND
14 from .coordinator import AquacellCoordinator
15 
16 PLATFORMS = [Platform.SENSOR]
17 
18 type AquacellConfigEntry = ConfigEntry[AquacellCoordinator]
19 
20 
21 async def async_setup_entry(hass: HomeAssistant, entry: AquacellConfigEntry) -> bool:
22  """Set up Aquacell from a config entry."""
23  session = async_get_clientsession(hass)
24 
25  brand = entry.data.get(CONF_BRAND, Brand.AQUACELL)
26 
27  aquacell_api = AquacellApi(session, brand)
28 
29  coordinator = AquacellCoordinator(hass, aquacell_api)
30 
31  await coordinator.async_config_entry_first_refresh()
32  entry.runtime_data = coordinator
33 
34  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
35 
36  return True
37 
38 
39 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
40  """Unload a config entry."""
41  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:39
bool async_setup_entry(HomeAssistant hass, AquacellConfigEntry entry)
Definition: __init__.py:21
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)