2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Ecovacs Deebot vacuums."""
|
2024-03-08 18:15:59 +00:00
|
|
|
|
2018-08-20 15:42:53 +00:00
|
|
|
import voluptuous as vol
|
|
|
|
|
2024-01-16 12:31:42 +00:00
|
|
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
2024-01-19 15:52:30 +00:00
|
|
|
from homeassistant.const import CONF_COUNTRY, CONF_PASSWORD, CONF_USERNAME, Platform
|
2021-12-31 10:05:44 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2019-02-13 20:21:14 +00:00
|
|
|
import homeassistant.helpers.config_validation as cv
|
2021-12-31 10:05:44 +00:00
|
|
|
from homeassistant.helpers.typing import ConfigType
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2024-01-16 12:31:42 +00:00
|
|
|
from .const import CONF_CONTINENT, DOMAIN
|
2024-01-19 15:52:30 +00:00
|
|
|
from .controller import EcovacsController
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2019-07-31 19:25:30 +00:00
|
|
|
CONFIG_SCHEMA = vol.Schema(
|
|
|
|
{
|
|
|
|
DOMAIN: vol.Schema(
|
|
|
|
{
|
|
|
|
vol.Required(CONF_USERNAME): cv.string,
|
|
|
|
vol.Required(CONF_PASSWORD): cv.string,
|
|
|
|
vol.Required(CONF_COUNTRY): vol.All(vol.Lower, cv.string),
|
|
|
|
vol.Required(CONF_CONTINENT): vol.All(vol.Lower, cv.string),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
extra=vol.ALLOW_EXTRA,
|
|
|
|
)
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2024-01-16 12:31:42 +00:00
|
|
|
PLATFORMS = [
|
2024-01-22 12:36:26 +00:00
|
|
|
Platform.BINARY_SENSOR,
|
2024-01-31 08:00:43 +00:00
|
|
|
Platform.BUTTON,
|
2024-03-25 17:31:04 +00:00
|
|
|
Platform.EVENT,
|
2024-01-26 19:33:21 +00:00
|
|
|
Platform.IMAGE,
|
2024-02-28 15:35:29 +00:00
|
|
|
Platform.LAWN_MOWER,
|
2024-01-31 13:43:35 +00:00
|
|
|
Platform.NUMBER,
|
2024-01-24 16:17:43 +00:00
|
|
|
Platform.SELECT,
|
2024-01-23 20:17:18 +00:00
|
|
|
Platform.SENSOR,
|
2024-01-31 15:05:41 +00:00
|
|
|
Platform.SWITCH,
|
2024-01-16 12:31:42 +00:00
|
|
|
Platform.VACUUM,
|
|
|
|
]
|
2024-05-17 13:42:58 +00:00
|
|
|
type EcovacsConfigEntry = ConfigEntry[EcovacsController]
|
2018-08-20 15:42:53 +00:00
|
|
|
|
|
|
|
|
2023-07-24 22:07:43 +00:00
|
|
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
2018-08-20 15:42:53 +00:00
|
|
|
"""Set up the Ecovacs component."""
|
2024-01-16 12:31:42 +00:00
|
|
|
if DOMAIN in config:
|
|
|
|
hass.async_create_task(
|
|
|
|
hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2024-04-30 20:44:56 +00:00
|
|
|
async def async_setup_entry(hass: HomeAssistant, entry: EcovacsConfigEntry) -> bool:
|
2024-01-16 12:31:42 +00:00
|
|
|
"""Set up this integration using UI."""
|
2024-01-19 15:52:30 +00:00
|
|
|
controller = EcovacsController(hass, entry.data)
|
|
|
|
await controller.initialize()
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2024-04-30 20:44:56 +00:00
|
|
|
async def on_unload() -> None:
|
|
|
|
await controller.teardown()
|
|
|
|
|
|
|
|
entry.async_on_unload(on_unload)
|
|
|
|
entry.runtime_data = controller
|
2024-01-19 15:52:30 +00:00
|
|
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
|
|
|
return True
|
2018-08-20 15:42:53 +00:00
|
|
|
|
|
|
|
|
2024-04-30 20:44:56 +00:00
|
|
|
async def async_unload_entry(hass: HomeAssistant, entry: EcovacsConfigEntry) -> bool:
|
2024-01-19 15:52:30 +00:00
|
|
|
"""Unload config entry."""
|
2024-04-30 20:44:56 +00:00
|
|
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|