Xiaomii miio vaccum clean segment service (#36801)
This commit is contained in:
1 parent
e1060f154e
commit
247df5874b
4 files changed
+80
-67
No files matched your search
@@ -48,6 +48,7 @@ SERVICE_MOVE_REMOTE_CONTROL = "vacuum_remote_control_move"
|
||||
SERVICE_MOVE_REMOTE_CONTROL_STEP = "vacuum_remote_control_move_step"
|
||||
SERVICE_START_REMOTE_CONTROL = "vacuum_remote_control_start"
|
||||
SERVICE_STOP_REMOTE_CONTROL = "vacuum_remote_control_stop"
|
||||
SERVICE_CLEAN_SEGMENT = "vacuum_clean_segment"
|
||||
SERVICE_CLEAN_ZONE = "vacuum_clean_zone"
|
||||
SERVICE_GOTO = "vacuum_goto"
|
||||
|
||||
|
||||
@@ -343,3 +343,13 @@ vacuum_goto:
|
||||
y_coord:
|
||||
description: y-coordinate.
|
||||
example: 32000
|
||||
|
||||
vacuum_clean_segment:
|
||||
description: Start cleaning of the specified segment(s).
|
||||
fields:
|
||||
entity_id:
|
||||
description: Name of the vacuum entity.
|
||||
example: "vacuum.xiaomi_vacuum_cleaner"
|
||||
segments:
|
||||
description: Segments.
|
||||
example: "[1,2]"
|
||||
@@ -31,6 +31,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.util.dt import as_utc
|
||||
|
||||
from .const import (
|
||||
SERVICE_CLEAN_SEGMENT,
|
||||
SERVICE_CLEAN_ZONE,
|
||||
SERVICE_GOTO,
|
||||
SERVICE_MOVE_REMOTE_CONTROL,
|
||||
@@ -198,6 +199,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
},
|
||||
MiroboVacuum.async_goto.__name__,
|
||||
)
|
||||
platform.async_register_entity_service(
|
||||
SERVICE_CLEAN_SEGMENT,
|
||||
{vol.Required("segments"): vol.Any(vol.Coerce(int), [vol.Coerce(int)])},
|
||||
MiroboVacuum.async_clean_segment.__name__,
|
||||
)
|
||||
|
||||
|
||||
class MiroboVacuum(StateVacuumEntity):
|
||||
@@ -447,6 +453,17 @@ class MiroboVacuum(StateVacuumEntity):
|
||||
y_coord=y_coord,
|
||||
)
|
||||
|
||||
async def async_clean_segment(self, segments):
|
||||
"""Clean the specified segments(s)."""
|
||||
if isinstance(segments, int):
|
||||
segments = [segments]
|
||||
|
||||
await self._try_command(
|
||||
"Unable to start cleaning of the specified segments: %s",
|
||||
self._vacuum.segment_clean,
|
||||
segments=segments,
|
||||
)
|
||||
|
||||
def update(self):
|
||||
"""Fetch state from the device."""
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user