mirror of https://github.com/home-assistant/core
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
"""The Epion integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from epion import Epion
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import CONF_API_KEY, Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import EpionCoordinator
|
|
|
|
PLATFORMS = [Platform.SENSOR]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up the Epion coordinator from a config entry."""
|
|
api = Epion(entry.data[CONF_API_KEY])
|
|
coordinator = EpionCoordinator(hass, api)
|
|
await coordinator.async_config_entry_first_refresh()
|
|
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload Epion config entry."""
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
if unload_ok:
|
|
del hass.data[DOMAIN][entry.entry_id]
|
|
return unload_ok
|