Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions roborock/data/b01_q7/b01_q7_code_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 14 additions & 2 deletions roborock/data/b01_q7/b01_q7_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from ..containers import RoborockBase
from .b01_q7_code_mappings import (
B01Fault,
CleanPathPreferenceMapping,
CleanRepeatMapping,
CleanTypeMapping,
SCWindMapping,
WaterLevelMapping,
Expand Down Expand Up @@ -94,10 +96,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
Expand Down Expand Up @@ -210,6 +212,16 @@ 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


@dataclass
class CleanRecordDetail(RoborockBase):
Expand Down
10 changes: 10 additions & 0 deletions roborock/devices/traits/b01/q7/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from roborock import B01Props
from roborock.data.b01_q7.b01_q7_code_mappings import (
CleanPathPreferenceMapping,
CleanRepeatMapping,
CleanTaskTypeMapping,
CleanTypeMapping,
SCDeviceCleanParam,
Expand Down Expand Up @@ -66,6 +68,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)
Comment on lines +71 to +77
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new methods set_clean_path_preference and set_repeat_state lack test coverage. Similar setter methods in this file (e.g., set_fan_speed, set_water_level, set_mode) have corresponding tests in tests/devices/traits/b01/q7/test_init.py. Consider adding tests for these new methods to maintain consistent test coverage across the API.

Copilot uses AI. Check for mistakes.

async def start_clean(self) -> None:
"""Start cleaning."""
await self.send(
Expand Down
6 changes: 6 additions & 0 deletions tests/data/b01_q7/test_b01_q7_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from roborock.data.b01_q7 import (
B01Fault,
B01Props,
CleanPathPreferenceMapping,
CleanRecordDetail,
CleanRecordList,
CleanRepeatMapping,
SCWindMapping,
WorkStatusMapping,
)
Expand Down Expand Up @@ -106,6 +108,10 @@ 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"


def test_b01_q7_clean_record_list_parses_detail_fields():
Expand Down