Skip to content

Commit 3f50fa3

Browse files
committed
feat: add clean route and repeat for q7
1 parent 5f5a59b commit 3f50fa3

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

roborock/data/b01_q7/b01_q7_code_mappings.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ class CleanTypeMapping(RoborockModeEnum):
4646
class CleanRepeatMapping(RoborockModeEnum):
4747
"""Maps the cleaning repeat parameter."""
4848

49-
ONCE = ("once", 0)
50-
TWICE = ("twice", 1)
49+
ONE = ("one", 0)
50+
TWO = ("two", 1)
51+
52+
53+
class CleanPathPreferenceMapping(RoborockModeEnum):
54+
"""Maps the cleaning path preference parameter."""
55+
56+
BALANCED = ("balanced", 0)
57+
DEEP = ("deep", 1)
5158

5259

5360
class SCDeviceCleanParam(RoborockModeEnum):

roborock/data/b01_q7/b01_q7_containers.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from ..containers import RoborockBase
44
from .b01_q7_code_mappings import (
55
B01Fault,
6+
CleanPathPreferenceMapping,
7+
CleanRepeatMapping,
68
CleanTypeMapping,
79
SCWindMapping,
810
WaterLevelMapping,
@@ -90,10 +92,10 @@ class B01Props(RoborockBase):
9092
mop_life: int | None = None
9193
main_sensor: int | None = None
9294
net_status: NetStatus | None = None
93-
repeat_state: int | None = None
95+
repeat_state: CleanRepeatMapping | None = None
9496
tank_state: int | None = None
9597
sweep_type: int | None = None
96-
clean_path_preference: int | None = None
98+
clean_path_preference: CleanPathPreferenceMapping | None = None
9799
cloth_state: int | None = None
98100
time_zone: int | None = None
99101
time_zone_info: str | None = None
@@ -205,3 +207,13 @@ def wind_name(self) -> str | None:
205207
def work_mode_name(self) -> str | None:
206208
"""Returns the name of the current work mode."""
207209
return self.work_mode.value if self.work_mode is not None else None
210+
211+
@property
212+
def repeat_state_name(self) -> str | None:
213+
"""Returns the name of the current repeat state."""
214+
return self.repeat_state.value if self.repeat_state is not None else None
215+
216+
@property
217+
def clean_path_preference_name(self) -> str | None:
218+
"""Returns the name of the current clean path preference."""
219+
return self.clean_path_preference.value if self.clean_path_preference is not None else None

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
from roborock import B01Props
77
from roborock.data.b01_q7.b01_q7_code_mappings import (
8+
CleanPathPreferenceMapping,
9+
CleanRepeatMapping,
810
CleanTaskTypeMapping,
911
CleanTypeMapping,
1012
SCDeviceCleanParam,
@@ -59,6 +61,14 @@ async def set_mode(self, mode: CleanTypeMapping) -> None:
5961
"""Set the cleaning mode (vacuum, mop, or vacuum and mop)."""
6062
await self.set_prop(RoborockB01Props.MODE, mode.code)
6163

64+
async def set_clean_path_preference(self, preference: CleanPathPreferenceMapping) -> None:
65+
"""Set the cleaning path preference (route)."""
66+
await self.set_prop(RoborockB01Props.CLEAN_PATH_PREFERENCE, preference.code)
67+
68+
async def set_repeat_state(self, repeat: CleanRepeatMapping) -> None:
69+
"""Set the cleaning repeat state (cycles)."""
70+
await self.set_prop(RoborockB01Props.REPEAT_STATE, repeat.code)
71+
6272
async def start_clean(self) -> None:
6373
"""Start cleaning."""
6474
await self.send(

tests/data/b01_q7/test_b01_q7_containers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from roborock.data.b01_q7 import (
44
B01Fault,
55
B01Props,
6+
CleanPathPreferenceMapping,
7+
CleanRepeatMapping,
68
SCWindMapping,
79
WorkStatusMapping,
810
)
@@ -102,3 +104,7 @@ def test_b01props_deserialization():
102104
assert deserialized.wind == SCWindMapping.STRONG
103105
assert deserialized.net_status is not None
104106
assert deserialized.net_status.ip == "192.168.1.102"
107+
assert deserialized.repeat_state == CleanRepeatMapping.TWO
108+
assert deserialized.clean_path_preference == CleanPathPreferenceMapping.DEEP
109+
assert deserialized.repeat_state_name == "two"
110+
assert deserialized.clean_path_preference_name == "deep"

0 commit comments

Comments
 (0)