2021-02-17 05:37:56 +00:00
|
|
|
"""SmartTub integration."""
|
2022-01-02 15:29:52 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
2021-12-04 12:43:48 +00:00
|
|
|
from homeassistant.const import Platform
|
2022-01-02 15:29:52 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2021-12-04 12:43:48 +00:00
|
|
|
|
2021-02-17 05:37:56 +00:00
|
|
|
from .const import DOMAIN, SMARTTUB_CONTROLLER
|
|
|
|
from .controller import SmartTubController
|
|
|
|
|
2021-12-04 12:43:48 +00:00
|
|
|
PLATFORMS = [
|
|
|
|
Platform.BINARY_SENSOR,
|
|
|
|
Platform.CLIMATE,
|
|
|
|
Platform.LIGHT,
|
|
|
|
Platform.SENSOR,
|
|
|
|
Platform.SWITCH,
|
|
|
|
]
|
2021-02-17 05:37:56 +00:00
|
|
|
|
|
|
|
|
2022-01-02 15:29:52 +00:00
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-02-17 05:37:56 +00:00
|
|
|
"""Set up a smarttub config entry."""
|
|
|
|
|
|
|
|
controller = SmartTubController(hass)
|
2021-04-16 16:23:27 +00:00
|
|
|
hass.data.setdefault(DOMAIN, {})
|
2021-02-17 05:37:56 +00:00
|
|
|
hass.data[DOMAIN][entry.entry_id] = {
|
|
|
|
SMARTTUB_CONTROLLER: controller,
|
|
|
|
}
|
|
|
|
|
|
|
|
if not await controller.async_setup_entry(entry):
|
|
|
|
return False
|
|
|
|
|
2021-04-27 20:10:04 +00:00
|
|
|
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
|
2021-02-17 05:37:56 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2022-01-02 15:29:52 +00:00
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
2021-02-17 05:37:56 +00:00
|
|
|
"""Remove a smarttub config entry."""
|
2021-04-27 20:10:04 +00:00
|
|
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
|
|
|
if unload_ok:
|
|
|
|
hass.data[DOMAIN].pop(entry.entry_id)
|
|
|
|
return unload_ok
|