Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """Kuler Sky lights integration."""
2 
3 from homeassistant.config_entries import ConfigEntry
4 from homeassistant.const import Platform
5 from homeassistant.core import HomeAssistant
6 
7 from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN
8 
9 PLATFORMS = [Platform.LIGHT]
10 
11 
12 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
13  """Set up Kuler Sky from a config entry."""
14  if DOMAIN not in hass.data:
15  hass.data[DOMAIN] = {}
16  if DATA_ADDRESSES not in hass.data[DOMAIN]:
17  hass.data[DOMAIN][DATA_ADDRESSES] = set()
18 
19  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
20 
21  return True
22 
23 
24 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
25  """Unload a config entry."""
26  # Stop discovery
27  unregister_discovery = hass.data[DOMAIN].pop(DATA_DISCOVERY_SUBSCRIPTION, None)
28  if unregister_discovery:
29  unregister_discovery()
30 
31  hass.data.pop(DOMAIN, None)
32 
33  return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:12
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:24