Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """The Epion integration."""
2 
3 from __future__ import annotations
4 
5 from epion import Epion
6 
7 from homeassistant.config_entries import ConfigEntry
8 from homeassistant.const import CONF_API_KEY, Platform
9 from homeassistant.core import HomeAssistant
10 
11 from .const import DOMAIN
12 from .coordinator import EpionCoordinator
13 
14 PLATFORMS = [Platform.SENSOR]
15 
16 
17 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
18  """Set up the Epion coordinator from a config entry."""
19  api = Epion(entry.data[CONF_API_KEY])
20  coordinator = EpionCoordinator(hass, api)
21  await coordinator.async_config_entry_first_refresh()
22 
23  hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
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 Epion config entry."""
30  unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
31  if unload_ok:
32  del hass.data[DOMAIN][entry.entry_id]
33  return unload_ok
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:28
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:17