"""Die ninstrip-Integration.""" from __future__ import annotations from homeassistant.const import CONF_HOST, CONF_TOKEN, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from .api import NinstripClient from .const import DEFAULT_PORT from .coordinator import NinstripConfigEntry, NinstripCoordinator PLATFORMS: list[Platform] = [ Platform.LIGHT, Platform.SELECT, Platform.SENSOR, Platform.BUTTON, ] async def async_setup_entry(hass: HomeAssistant, entry: NinstripConfigEntry) -> bool: """Einen Strip einrichten.""" client = NinstripClient( async_get_clientsession(hass), entry.data[CONF_HOST], entry.data[CONF_TOKEN], port=entry.data.get("port", DEFAULT_PORT), ) coordinator = NinstripCoordinator(hass, entry, client) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) entry.async_on_unload(entry.add_update_listener(_async_options_updated)) return True async def async_unload_entry(hass: HomeAssistant, entry: NinstripConfigEntry) -> bool: return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) async def _async_options_updated(hass: HomeAssistant, entry: NinstripConfigEntry) -> None: """Eine geaenderte Abfragehaeufigkeit wirkt ohne Neustart.""" await hass.config_entries.async_reload(entry.entry_id)