Skip to content

Commit 35f7910

Browse files
authored
feat: add clean route and repeat for q7 (#756)
* feat: add clean route and repeat for q7 * chore: lint
1 parent 3dceac1 commit 35f7910

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
@@ -7,6 +7,8 @@
77
from ..containers import RoborockBase
88
from .b01_q7_code_mappings import (
99
B01Fault,
10+
CleanPathPreferenceMapping,
11+
CleanRepeatMapping,
1012
CleanTypeMapping,
1113
SCWindMapping,
1214
WaterLevelMapping,
@@ -94,10 +96,10 @@ class B01Props(RoborockBase):
9496
mop_life: int | None = None
9597
main_sensor: int | None = None
9698
net_status: NetStatus | None = None
97-
repeat_state: int | None = None
99+
repeat_state: CleanRepeatMapping | None = None
98100
tank_state: int | None = None
99101
sweep_type: int | None = None
100-
clean_path_preference: int | None = None
102+
clean_path_preference: CleanPathPreferenceMapping | None = None
101103
cloth_state: int | None = None
102104
time_zone: int | None = None
103105
time_zone_info: str | None = None
@@ -210,6 +212,16 @@ def work_mode_name(self) -> str | None:
210212
"""Returns the name of the current work mode."""
211213
return self.work_mode.value if self.work_mode is not None else None
212214

215+
@property
216+
def repeat_state_name(self) -> str | None:
217+
"""Returns the name of the current repeat state."""
218+
return self.repeat_state.value if self.repeat_state is not None else None
219+
220+
@property
221+
def clean_path_preference_name(self) -> str | None:
222+
"""Returns the name of the current clean path preference."""
223+
return self.clean_path_preference.value if self.clean_path_preference is not None else None
224+
213225

214226
@dataclass
215227
class CleanRecordDetail(RoborockBase):

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,
@@ -66,6 +68,14 @@ async def set_mode(self, mode: CleanTypeMapping) -> None:
6668
"""Set the cleaning mode (vacuum, mop, or vacuum and mop)."""
6769
await self.set_prop(RoborockB01Props.MODE, mode.code)
6870

71+
async def set_clean_path_preference(self, preference: CleanPathPreferenceMapping) -> None:
72+
"""Set the cleaning path preference (route)."""
73+
await self.set_prop(RoborockB01Props.CLEAN_PATH_PREFERENCE, preference.code)
74+
75+
async def set_repeat_state(self, repeat: CleanRepeatMapping) -> None:
76+
"""Set the cleaning repeat state (cycles)."""
77+
await self.set_prop(RoborockB01Props.REPEAT_STATE, repeat.code)
78+
6979
async def start_clean(self) -> None:
7080
"""Start cleaning."""
7181
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
@@ -5,8 +5,10 @@
55
from roborock.data.b01_q7 import (
66
B01Fault,
77
B01Props,
8+
CleanPathPreferenceMapping,
89
CleanRecordDetail,
910
CleanRecordList,
11+
CleanRepeatMapping,
1012
SCWindMapping,
1113
WorkStatusMapping,
1214
)
@@ -106,6 +108,10 @@ def test_b01props_deserialization():
106108
assert deserialized.wind == SCWindMapping.STRONG
107109
assert deserialized.net_status is not None
108110
assert deserialized.net_status.ip == "192.168.1.102"
111+
assert deserialized.repeat_state == CleanRepeatMapping.TWO
112+
assert deserialized.clean_path_preference == CleanPathPreferenceMapping.DEEP
113+
assert deserialized.repeat_state_name == "two"
114+
assert deserialized.clean_path_preference_name == "deep"
109115

110116

111117
def test_b01_q7_clean_record_list_parses_detail_fields():

0 commit comments

Comments
 (0)