Files
home-assistant-core/homeassistant/components/indevolt/__init__.py
T
2026-04-30 21:14:48 +02:00

47 lines
1.4 KiB
Python

"""Home Assistant integration for indevolt device."""
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN
from .coordinator import IndevoltConfigEntry, IndevoltCoordinator
from .services import async_setup_services
PLATFORMS: list[Platform] = [
Platform.BINARY_SENSOR,
Platform.BUTTON,
Platform.NUMBER,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
]
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def async_setup_entry(hass: HomeAssistant, entry: IndevoltConfigEntry) -> bool:
"""Set up indevolt integration entry using given configuration."""
coordinator = IndevoltCoordinator(hass, entry)
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_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up indevolt services (actions)."""
await async_setup_services(hass)
return True
async def async_unload_entry(hass: HomeAssistant, entry: IndevoltConfigEntry) -> bool:
"""Unload a config entry / clean up resources (when integration is removed / reloaded)."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)