Home Assistant Unofficial Reference 2024.12.1
__init__.py
Go to the documentation of this file.
1 """SmartTub 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 DOMAIN, SMARTTUB_CONTROLLER
8 from .controller import SmartTubController
9 
10 PLATFORMS = [
11  Platform.BINARY_SENSOR,
12  Platform.CLIMATE,
13  Platform.LIGHT,
14  Platform.SENSOR,
15  Platform.SWITCH,
16 ]
17 
18 
19 async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
20  """Set up a smarttub config entry."""
21 
22  controller = SmartTubController(hass)
23  hass.data.setdefault(DOMAIN, {})
24  hass.data[DOMAIN][entry.entry_id] = {
25  SMARTTUB_CONTROLLER: controller,
26  }
27 
28  if not await controller.async_setup_entry(entry):
29  return False
30 
31  await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
32 
33  return True
34 
35 
36 async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
37  """Remove a smarttub config entry."""
38  unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
39  if unload_ok:
40  hass.data[DOMAIN].pop(entry.entry_id)
41  return unload_ok
bool async_unload_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:36
bool async_setup_entry(HomeAssistant hass, ConfigEntry entry)
Definition: __init__.py:19