* Adding initial Epion Air integration logic * Skipping sensors with missing data * Patching Epion integration * Adding additional Epion measurement types * Cleaning up logging * Cleaning up code * Fixing error handling for invalid Epion keys * Adding tests and improving error handling * Patching Epion tests * Cleaning up Epion integration code * Bumping Epion package and including missing files * Moving data updates to coordinator and addressing feedback * Improve exception handling * Exposing model name and firmware version * Cleaning up code according to review * Cleaning up code according to review * Adding check to prevent duplicate account setup * Refactoring tests and checking for duplicates * Cleaning up test code according to review * Cleaning up test code * Removing entity name overrides * Fix code format for tests * Adding missing newlines in JSON files * Fixing formatting * Updating device method to always return a device * Updating coordinator
32 lines
1 KiB
Python
32 lines
1 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
|