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