Skip to content

Commit 5c16930

Browse files
committed
feat: add some more actions
1 parent dccbe6b commit 5c16930

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

roborock/data/b01_q7/b01_q7_code_mappings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ class CleanRepeatMapping(RoborockModeEnum):
5050
TWICE = ("twice", 1)
5151

5252

53+
class SCDeviceCleanParam(RoborockModeEnum):
54+
"""Maps the control values for cleaning tasks."""
55+
56+
STOP = ("stop", 0)
57+
START = ("start", 1)
58+
PAUSE = ("pause", 2)
59+
60+
5361
class WorkModeMapping(RoborockModeEnum):
5462
"""Maps the detailed work modes of the robot."""
5563

roborock/devices/traits/b01/q7/__init__.py

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
from typing import Any
55

66
from roborock import B01Props
7-
from roborock.data.b01_q7.b01_q7_code_mappings import SCWindMapping, WaterLevelMapping
7+
from roborock.data.b01_q7.b01_q7_code_mappings import (
8+
CleanTaskTypeMapping,
9+
SCDeviceCleanParam,
10+
SCWindMapping,
11+
WaterLevelMapping,
12+
)
813
from roborock.devices.b01_channel import send_decoded_command
914
from roborock.devices.mqtt_channel import MqttChannel
1015
from roborock.devices.traits import Trait
@@ -50,6 +55,63 @@ async def set_water_level(self, water_level: WaterLevelMapping) -> dict[str, Any
5055
"""Set the water level (water)."""
5156
return await self.set_prop(RoborockB01Props.WATER, water_level.code)
5257

58+
async def start_clean(self) -> dict[str, Any]:
59+
"""Start cleaning."""
60+
return await send_decoded_command(
61+
self._channel,
62+
dps=10000,
63+
command=RoborockB01Q7Methods.SET_ROOM_CLEAN,
64+
params={
65+
"clean_type": CleanTaskTypeMapping.ALL.code,
66+
"ctrl_value": SCDeviceCleanParam.START.code,
67+
"room_ids": [],
68+
},
69+
)
70+
71+
async def pause_clean(self) -> dict[str, Any]:
72+
"""Pause cleaning."""
73+
return await send_decoded_command(
74+
self._channel,
75+
dps=10000,
76+
command=RoborockB01Q7Methods.SET_ROOM_CLEAN,
77+
params={
78+
"clean_type": CleanTaskTypeMapping.ALL.code,
79+
"ctrl_value": SCDeviceCleanParam.PAUSE.code,
80+
"room_ids": [],
81+
},
82+
)
83+
84+
async def stop_clean(self) -> dict[str, Any]:
85+
"""Stop cleaning."""
86+
return await send_decoded_command(
87+
self._channel,
88+
dps=10000,
89+
command=RoborockB01Q7Methods.SET_ROOM_CLEAN,
90+
params={
91+
"clean_type": CleanTaskTypeMapping.ALL.code,
92+
"ctrl_value": SCDeviceCleanParam.STOP.code,
93+
"room_ids": [],
94+
},
95+
)
96+
97+
async def return_to_dock(self) -> dict[str, Any]:
98+
"""Return to dock."""
99+
return await send_decoded_command(
100+
self._channel,
101+
dps=10000,
102+
command=RoborockB01Q7Methods.START_RECHARGE,
103+
params={},
104+
)
105+
106+
async def find_me(self) -> dict[str, Any]:
107+
"""Locate the robot."""
108+
return await send_decoded_command(
109+
self._channel,
110+
dps=10000,
111+
command=RoborockB01Q7Methods.FIND_DEVICE,
112+
params={},
113+
)
114+
53115

54116
def create(channel: MqttChannel) -> Q7PropertiesApi:
55117
"""Create traits for B01 devices."""

0 commit comments

Comments
 (0)