* add Arve integration * Update homeassistant/components/arve/config_flow.py Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com> * Various fixes, changed scan interval to one minute * coordinator implementation * Code cleanup * Moved device info to the entity.py, ArveDeviceEntityDescription to sensor.py * delete refresh before adding entities Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com> * Update tests/components/arve/test_config_flow.py Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com> * Update tests/components/arve/conftest.py Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com> * Changed value_fn in sensors.py, added typing to description * Code cleanups, platfrom test implementation * New code cleanups, first two working tests * Created platform test, generated snapshots * Reworked integration to get all of the customer devices * new fixes * Added customer id, small cleanups * Logic of setting unique_id to the config flow * Added test of abortion on duplicate config_flow id * Added "available" and "device" properties fro ArveDeviceEntity * small _attr_unique_id fix * Added new test, improved mocking, various fixes * Various cleanups and fixes * microfix * Update homeassistant/components/arve/strings.json * ruff fix --------- Co-authored-by: Josef Zweck <24647999+zweckj@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
34 lines
972 B
Python
34 lines
972 B
Python
"""The Arve integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import ArveCoordinator
|
|
|
|
PLATFORMS: list[Platform] = [Platform.SENSOR]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|
"""Set up Arve from a config entry."""
|
|
|
|
coordinator = ArveCoordinator(hass)
|
|
|
|
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 a config entry."""
|
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
|
|
|
return unload_ok
|