Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Devialet integration."""
2 
3 from __future__ import annotations
4 
5 from devialet import DevialetApi
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import CONF_HOST, Platform
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers.aiohttp_client import async_get_clientsession
11 
12 from .const import DOMAIN
13 
14 PLATFORMS = [Platform.MEDIA_PLAYER]
15 
16 
17 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
18  """Set up Devialet from a config entry."""
19  session = async_get_clientsession(hass)
20  hass.data.setdefault(DOMAIN, {})[entry.entry_id] = DevialetApi(
21  entry.data[CONF_HOST], session
22  )
23 
24  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
25  return True
26 
27 
28 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
29  """Unload Devialet config entry."""
30  if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
31  del hass.data[DOMAIN][entry.entry_id]
32  return unload_ok
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:17
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:28
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)