core/homeassistant/components/smarttub/__init__.py

39 lines
957 B
Python

"""SmartTub integration."""
from homeassistant.const import Platform
from .const import DOMAIN, SMARTTUB_CONTROLLER
from .controller import SmartTubController
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.LIGHT,
Platform.SENSOR,
Platform.SWITCH,
]
async def async_setup_entry(hass, entry):
"""Set up a smarttub config entry."""
controller = SmartTubController(hass)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = {
SMARTTUB_CONTROLLER: controller,
}
if not await controller.async_setup_entry(entry):
return False
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
async def async_unload_entry(hass, entry):
"""Remove a smarttub config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok