1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00
ha-core/homeassistant/components/smarttub/__init__.py
epenet 00ec874389
Add init type hints [s] (#63193)
Co-authored-by: epenet <epenet@users.noreply.github.com>
2022-01-02 16:29:52 +01:00

41 lines
1.1 KiB
Python

"""SmartTub integration."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
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: HomeAssistant, entry: ConfigEntry) -> bool:
"""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: HomeAssistant, entry: ConfigEntry) -> bool:
"""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