2019-02-13 20:21:14 +00:00
|
|
|
"""Support for Ecovacs Deebot vacuums."""
|
2024-03-08 18:15:59 +00:00
|
|
|
|
2024-07-29 09:24:14 +00:00
|
|
|
from sucks import VacBot
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2024-08-12 07:09:51 +00:00
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
|
|
from homeassistant.const import Platform
|
2021-12-31 10:05:44 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
2018-08-20 15:42:53 +00:00
|
|
|
|
2024-01-19 15:52:30 +00:00
|
|
|
from .controller import EcovacsController
|
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
|
|
|
|
|
|
|
|
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-07-29 09:24:14 +00:00
|
|
|
|
|
|
|
async def _async_wait_connect(device: VacBot) -> None:
|
|
|
|
await hass.async_add_executor_job(device.connect_and_wait_until_ready)
|
|
|
|
|
|
|
|
for device in controller.legacy_devices:
|
|
|
|
entry.async_create_background_task(
|
|
|
|
hass=hass,
|
|
|
|
target=_async_wait_connect(device),
|
|
|
|
name=f"{entry.title}_wait_connect_{device.vacuum['did']}",
|
|
|
|
)
|
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)
|