2021-05-05 23:41:32 +00:00
|
|
|
"""Support for Elgato Lights."""
|
2019-12-08 08:26:31 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2023-02-05 20:54:30 +00:00
|
|
|
from homeassistant.const import Platform
|
2019-12-08 08:26:31 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
2023-02-05 20:54:30 +00:00
|
|
|
from .const import DOMAIN
|
|
|
|
from .coordinator import ElgatoDataUpdateCoordinator
|
2019-12-08 08:26:31 +00:00
|
|
|
|
2023-02-08 10:42:53 +00:00
|
|
|
PLATFORMS = [Platform.BUTTON, Platform.LIGHT, Platform.SENSOR, Platform.SWITCH]
|
2021-04-27 06:46:49 +00:00
|
|
|
|
2019-12-08 08:26:31 +00:00
|
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-05-05 23:41:32 +00:00
|
|
|
"""Set up Elgato Light from a config entry."""
|
2023-02-05 20:54:30 +00:00
|
|
|
coordinator = ElgatoDataUpdateCoordinator(hass, entry)
|
2022-01-21 18:38:02 +00:00
|
|
|
await coordinator.async_config_entry_first_refresh()
|
2019-12-08 08:26:31 +00:00
|
|
|
|
2023-02-05 20:54:30 +00:00
|
|
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
2022-07-09 15:27:42 +00:00
|
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
2019-12-08 08:26:31 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-05-05 23:41:32 +00:00
|
|
|
"""Unload Elgato Light config entry."""
|
2022-01-13 12:09:08 +00:00
|
|
|
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
2021-04-27 06:46:49 +00:00
|
|
|
del hass.data[DOMAIN][entry.entry_id]
|
|
|
|
return unload_ok
|