1 """Ecovacs mower entity."""
3 from __future__
import annotations
7 from deebot_client.capabilities
import Capabilities, DeviceType
8 from deebot_client.device
import Device
9 from deebot_client.events
import StateEvent
10 from deebot_client.models
import CleanAction, State
15 LawnMowerEntityEntityDescription,
16 LawnMowerEntityFeature,
21 from .
import EcovacsConfigEntry
22 from .entity
import EcovacsEntity
24 _LOGGER = logging.getLogger(__name__)
27 _STATE_TO_MOWER_STATE = {
28 State.IDLE: LawnMowerActivity.PAUSED,
29 State.CLEANING: LawnMowerActivity.MOWING,
30 State.RETURNING: LawnMowerActivity.RETURNING,
31 State.DOCKED: LawnMowerActivity.DOCKED,
32 State.ERROR: LawnMowerActivity.ERROR,
33 State.PAUSED: LawnMowerActivity.PAUSED,
39 config_entry: EcovacsConfigEntry,
40 async_add_entities: AddEntitiesCallback,
42 """Set up the Ecovacs mowers."""
43 controller = config_entry.runtime_data
44 mowers: list[EcovacsMower] = [
46 for device
in controller.devices
47 if device.capabilities.device_type
is DeviceType.MOWER
49 _LOGGER.debug(
"Adding Ecovacs Mowers to Home Assistant: %s", mowers)
54 EcovacsEntity[Capabilities],
59 _attr_supported_features = (
60 LawnMowerEntityFeature.DOCK
61 | LawnMowerEntityFeature.PAUSE
62 | LawnMowerEntityFeature.START_MOWING
68 """Initialize the mower."""
69 super().
__init__(device, device.capabilities)
72 """Set up the event listeners now that hass is ready."""
75 async
def on_status(event: StateEvent) ->
None:
82 await self.
_device_device.execute_command(
83 self.
_capability_capability.clean.action.command(action)
87 """Resume schedule."""
91 """Pauses the mower."""
95 """Parks the mower until next schedule."""
96 await self.
_device_device.execute_command(self.
_capability_capability.charge.execute())
None _subscribe(self, type[EventT] event_type, Callable[[EventT], Coroutine[Any, Any, None]] callback)
None _clean_command(self, CleanAction action)
None async_added_to_hass(self)
None __init__(self, Device device)
None async_start_mowing(self)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, EcovacsConfigEntry config_entry, AddEntitiesCallback async_add_entities)