38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""The Aquacell integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from aioaquacell import AquacellApi
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|
|
|
from .coordinator import AquacellCoordinator
|
|
|
|
PLATFORMS = [Platform.SENSOR]
|
|
|
|
type AquacellConfigEntry = ConfigEntry[AquacellCoordinator]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: AquacellConfigEntry) -> bool:
|
|
"""Set up Aquacell from a config entry."""
|
|
session = async_get_clientsession(hass)
|
|
|
|
aquacell_api = AquacellApi(session)
|
|
|
|
coordinator = AquacellCoordinator(hass, aquacell_api)
|
|
|
|
await coordinator.async_config_entry_first_refresh()
|
|
entry.runtime_data = coordinator
|
|
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Unload a config entry."""
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|