From 3f50fa3b218638364874ea1f463e4b238c41911c Mon Sep 17 00:00:00 2001 From: Luke Date: Wed, 28 Jan 2026 10:32:35 -0500 Subject: [PATCH 1/2] feat: add clean route and repeat for q7 --- roborock/data/b01_q7/b01_q7_code_mappings.py | 11 +++++++++-- roborock/data/b01_q7/b01_q7_containers.py | 16 ++++++++++++++-- roborock/devices/traits/b01/q7/__init__.py | 10 ++++++++++ tests/data/b01_q7/test_b01_q7_containers.py | 6 ++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/roborock/data/b01_q7/b01_q7_code_mappings.py b/roborock/data/b01_q7/b01_q7_code_mappings.py index 857b0ca3..b1c910b8 100644 --- a/roborock/data/b01_q7/b01_q7_code_mappings.py +++ b/roborock/data/b01_q7/b01_q7_code_mappings.py @@ -46,8 +46,15 @@ class CleanTypeMapping(RoborockModeEnum): class CleanRepeatMapping(RoborockModeEnum): """Maps the cleaning repeat parameter.""" - ONCE = ("once", 0) - TWICE = ("twice", 1) + ONE = ("one", 0) + TWO = ("two", 1) + + +class CleanPathPreferenceMapping(RoborockModeEnum): + """Maps the cleaning path preference parameter.""" + + BALANCED = ("balanced", 0) + DEEP = ("deep", 1) class SCDeviceCleanParam(RoborockModeEnum): diff --git a/roborock/data/b01_q7/b01_q7_containers.py b/roborock/data/b01_q7/b01_q7_containers.py index c91e596e..174dba25 100644 --- a/roborock/data/b01_q7/b01_q7_containers.py +++ b/roborock/data/b01_q7/b01_q7_containers.py @@ -3,6 +3,8 @@ from ..containers import RoborockBase from .b01_q7_code_mappings import ( B01Fault, + CleanPathPreferenceMapping, + CleanRepeatMapping, CleanTypeMapping, SCWindMapping, WaterLevelMapping, @@ -90,10 +92,10 @@ class B01Props(RoborockBase): mop_life: int | None = None main_sensor: int | None = None net_status: NetStatus | None = None - repeat_state: int | None = None + repeat_state: CleanRepeatMapping | None = None tank_state: int | None = None sweep_type: int | None = None - clean_path_preference: int | None = None + clean_path_preference: CleanPathPreferenceMapping | None = None cloth_state: int | None = None time_zone: int | None = None time_zone_info: str | None = None @@ -205,3 +207,13 @@ def wind_name(self) -> str | None: def work_mode_name(self) -> str | None: """Returns the name of the current work mode.""" return self.work_mode.value if self.work_mode is not None else None + + @property + def repeat_state_name(self) -> str | None: + """Returns the name of the current repeat state.""" + return self.repeat_state.value if self.repeat_state is not None else None + + @property + def clean_path_preference_name(self) -> str | None: + """Returns the name of the current clean path preference.""" + return self.clean_path_preference.value if self.clean_path_preference is not None else None diff --git a/roborock/devices/traits/b01/q7/__init__.py b/roborock/devices/traits/b01/q7/__init__.py index 73d5b07e..e2b5f339 100644 --- a/roborock/devices/traits/b01/q7/__init__.py +++ b/roborock/devices/traits/b01/q7/__init__.py @@ -5,6 +5,8 @@ from roborock import B01Props from roborock.data.b01_q7.b01_q7_code_mappings import ( + CleanPathPreferenceMapping, + CleanRepeatMapping, CleanTaskTypeMapping, CleanTypeMapping, SCDeviceCleanParam, @@ -59,6 +61,14 @@ async def set_mode(self, mode: CleanTypeMapping) -> None: """Set the cleaning mode (vacuum, mop, or vacuum and mop).""" await self.set_prop(RoborockB01Props.MODE, mode.code) + async def set_clean_path_preference(self, preference: CleanPathPreferenceMapping) -> None: + """Set the cleaning path preference (route).""" + await self.set_prop(RoborockB01Props.CLEAN_PATH_PREFERENCE, preference.code) + + async def set_repeat_state(self, repeat: CleanRepeatMapping) -> None: + """Set the cleaning repeat state (cycles).""" + await self.set_prop(RoborockB01Props.REPEAT_STATE, repeat.code) + async def start_clean(self) -> None: """Start cleaning.""" await self.send( diff --git a/tests/data/b01_q7/test_b01_q7_containers.py b/tests/data/b01_q7/test_b01_q7_containers.py index de5b108f..4fa187f3 100644 --- a/tests/data/b01_q7/test_b01_q7_containers.py +++ b/tests/data/b01_q7/test_b01_q7_containers.py @@ -3,6 +3,8 @@ from roborock.data.b01_q7 import ( B01Fault, B01Props, + CleanPathPreferenceMapping, + CleanRepeatMapping, SCWindMapping, WorkStatusMapping, ) @@ -102,3 +104,7 @@ def test_b01props_deserialization(): assert deserialized.wind == SCWindMapping.STRONG assert deserialized.net_status is not None assert deserialized.net_status.ip == "192.168.1.102" + assert deserialized.repeat_state == CleanRepeatMapping.TWO + assert deserialized.clean_path_preference == CleanPathPreferenceMapping.DEEP + assert deserialized.repeat_state_name == "two" + assert deserialized.clean_path_preference_name == "deep" From c3c28fbd048a809bab5a450a10364ad5e2ee8d1d Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 1 Feb 2026 20:58:39 -0500 Subject: [PATCH 2/2] chore: lint --- roborock/data/b01_q7/b01_q7_containers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/roborock/data/b01_q7/b01_q7_containers.py b/roborock/data/b01_q7/b01_q7_containers.py index c492353f..58b6dd35 100644 --- a/roborock/data/b01_q7/b01_q7_containers.py +++ b/roborock/data/b01_q7/b01_q7_containers.py @@ -222,6 +222,7 @@ def clean_path_preference_name(self) -> str | None: """Returns the name of the current clean path preference.""" return self.clean_path_preference.value if self.clean_path_preference is not None else None + @dataclass class CleanRecordDetail(RoborockBase): """Represents a single clean record detail (from `record_list[].detail`)."""