2024-08-20 08:44:06 +00:00
|
|
|
"""SMLIGHT SLZB Zigbee device integration."""
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
|
|
from homeassistant.const import CONF_HOST, Platform
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
|
|
from .coordinator import SmDataUpdateCoordinator
|
|
|
|
|
|
|
|
PLATFORMS: list[Platform] = [
|
2024-09-06 06:11:50 +00:00
|
|
|
Platform.BINARY_SENSOR,
|
2024-09-04 17:10:59 +00:00
|
|
|
Platform.BUTTON,
|
2024-08-20 08:44:06 +00:00
|
|
|
Platform.SENSOR,
|
2024-09-06 12:25:55 +00:00
|
|
|
Platform.SWITCH,
|
2024-08-20 08:44:06 +00:00
|
|
|
]
|
|
|
|
type SmConfigEntry = ConfigEntry[SmDataUpdateCoordinator]
|
|
|
|
|
|
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: SmConfigEntry) -> bool:
|
|
|
|
"""Set up SMLIGHT Zigbee from a config entry."""
|
|
|
|
coordinator = SmDataUpdateCoordinator(hass, entry.data[CONF_HOST])
|
|
|
|
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: SmConfigEntry) -> bool:
|
|
|
|
"""Unload a config entry."""
|
|
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|