mirror of
https://github.com/home-assistant/core.git
synced 2026-06-06 15:36:51 +01:00
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""The WiLight integration."""
|
|
|
|
from homeassistant.const import Platform
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.exceptions import ConfigEntryNotReady
|
|
|
|
from .parent_device import WiLightConfigEntry, WiLightParent
|
|
|
|
# List the platforms that you want to support.
|
|
PLATFORMS = [Platform.COVER, Platform.FAN, Platform.LIGHT, Platform.SWITCH]
|
|
|
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: WiLightConfigEntry) -> bool:
|
|
"""Set up a wilight config entry."""
|
|
|
|
parent = WiLightParent(hass, entry)
|
|
|
|
if not await parent.async_setup():
|
|
raise ConfigEntryNotReady
|
|
|
|
entry.runtime_data = parent
|
|
|
|
# Set up all platforms for this device/entry.
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
|
|
return True
|
|
|
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: WiLightConfigEntry) -> bool:
|
|
"""Unload WiLight config entry."""
|
|
|
|
# Unload entities for this entry/device.
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
|
|
# Cleanup
|
|
await entry.runtime_data.async_reset()
|
|
|
|
return unload_ok
|