Repository navigation
feat: add Q7 zone cleaning - #1038
Conversation
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Argon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary by Layer
roborock/data/b01_q7/(Q7RoborockPoint):- Cleanly encapsulates the conversion between the common Roborock millimetre coordinate frame (origin at
(25500, 25500)) and Q7 world coordinates in meters ((x - 25500) / 1000,(y - 25500) / 1000, with y-up matching Q7 map coordinates). - Exported in
roborock/data/b01_q7/__init__.py,roborock/data/__init__.py, androborock/devices/traits/b01/q7/__init__.py.
- Cleanly encapsulates the conversion between the common Roborock millimetre coordinate frame (origin at
roborock/devices/traits/b01/q7/(Q7PropertiesApi.clean_zone/clean_zones):- Accurately implements the 3-step Q7 zone cleaning command sequence:
service.set_preference_type({"prefer_type": 4}),service.set_zone_points({"zone_points": [...]}with 8 world-meter floats per rectangular zone), andservice.set_zone_clean({"ctrl_value": 1}). - Validates non-empty zone lists and rejects degenerate zero-width/zero-height rectangles before issuing any RPC commands.
- Minor suggestion: Reuse the already-imported
CleanTaskTypeMapping.AREA.code(4) instead of defining a duplicate_ZONE_PREFERENCE_TYPE = 4constant.
- Accurately implements the 3-step Q7 zone cleaning command sequence:
tests/:- Good unit test coverage in
tests/data/b01_q7/test_b01_q7_containers.pyandtests/devices/traits/b01/q7/test_init.pycovering coordinate round-trips, single-zone and multi-zone command payloads, and pre-send validation errors.
- Good unit test coverage in
| ] | ||
|
|
||
| # ``service.set_preference_type`` value that selects zone cleaning (``custom_type`` 4). | ||
| _ZONE_PREFERENCE_TYPE = 4 |
There was a problem hiding this comment.
CleanTaskTypeMapping is already imported in this module (line 14) and defines CleanTaskTypeMapping.AREA = ("zones", 4) in b01_q7_code_mappings.py. Using CleanTaskTypeMapping.AREA.code in clean_zones (similar to CleanTaskTypeMapping.ALL.code and CleanTaskTypeMapping.ROOM.code in start_clean and clean_segments above) avoids duplicating the constant here.
There was a problem hiding this comment.
Done in ad3991f: clean_zones now uses CleanTaskTypeMapping.AREA.code and the duplicated _ZONE_PREFERENCE_TYPE constant is gone.
| min_x, max_x = sorted((x1, x2)) | ||
| min_y, max_y = sorted((y1, y2)) | ||
| zone_points += [min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y] | ||
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": _ZONE_PREFERENCE_TYPE}) |
There was a problem hiding this comment.
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": _ZONE_PREFERENCE_TYPE}) | |
| await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": CleanTaskTypeMapping.AREA.code}) |
|
Hi @ramon-angosto - please take a look at the automated feedback. Once you're done, mark the PR as ready for review and I will take a look myself! Going ahead and doing this for all your PRs |
Add `clean_zone` and `clean_zones` to the Q7 properties API. Zones are given as two opposite corners in the common Roborock millimetre coordinate space through a new `Q7RoborockPoint`, which converts to and from the Q7 world coordinates (meters, origin next to the dock). The device expects the zone preference type to be selected first (`service.set_preference_type`), then the zone corners as a flat list (`service.set_zone_points`), and finally `service.set_zone_clean` to start. Several zones are concatenated into a single task.
67ce5a1 to
ad3991f
Compare
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Follow-up review on commit ad3991f, including cross-verification against the Roborock Q7 app bundle and Q7 (roborock.vacuum.sc05) firmware. Prior Nov 15 feedback (reusing CleanTaskTypeMapping.AREA.code instead of a duplicate _ZONE_PREFERENCE_TYPE constant) has been addressed.
Summary by Architectural Layer
- Priority 1 — Public Trait APIs & Consumer Contracts (
roborock/data/b01_q7/b01_q7_containers.py,roborock/devices/traits/b01/q7/__init__.py):Q7RoborockPointcleanly subclassesRoborockBaseas a@dataclasswith concreteintcoordinates andfrom_world()/to_world()conversions, keeping the public API in the consumer-agnostic millimetre coordinate space ((25500, 25500)origin) consistent with V1 and Q10.Q7PropertiesApi.clean_zoneandclean_zonesare strongly typed with noAnyleakage and properly exportQ7RoborockPointvia__all__.
- Priority 2 — Lifecycle, State & Concurrency (
roborock/devices/traits/b01/q7/__init__.py):- Input validation (non-empty zones, non-degenerate rectangles) runs upfront before any RPC is sent, avoiding partial command side effects.
- Linear, direct 3-step
await self.send(...)flow with no hidden state mutation or lifecycle leaks.
- Priority 3 — Wire Protocol & Firmware Verification:
- Command sequence & payloads: Cross-verified against the Roborock Q7 app bundle (
_startZoneClean/_setAndStartZoneClean) and Q7 (roborock.vacuum.sc05) firmware (CAiotParseBuf):service.set_preference_type({"prefer_type": 4}viaCleanTaskTypeMapping.AREA.code) →service.set_zone_points({"zone_points": [...]}as a flat float array of 4(x, y)world-meter corners per zone, matching the firmware'sPart_%d :[%f,%f],[%f,%f],[%f,%f],[%f,%f]parser) →service.set_zone_clean({"ctrl_value": 1}viaSCDeviceCleanParam.START.code). - Coordinate space: Confirmed world meters with y-up matches
B01MapParser(_WorldToPixel), and canonical rectangle corner ordering[min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y]aligns with the rest of the codebase.
- Command sequence & payloads: Cross-verified against the Roborock Q7 app bundle (
- Tests (
tests/data/b01_q7/test_b01_q7_containers.py,tests/devices/traits/b01/q7/test_init.py):- Properly mirrored under
tests/, usingfake_channeland@pytest.mark.parametrizeto verify coordinate round-trips, single/multi-zone command sequences, and pre-send validation errors.
- Properly mirrored under
No defects found — this PR is clean and ready to approve.
Lash-L
left a comment
There was a problem hiding this comment.
TY @ramon-angosto - this looks good and seems to be working for me!
Summary
Adds zone cleaning to the Q7 (B01) properties API:
Q7PropertiesApi.clean_zone(first_corner, second_corner)cleans one rectangle.Q7PropertiesApi.clean_zones([(first, second), ...])cleans several rectangles in a single task.Q7RoborockPoint(common Roborock millimetre coordinates, map origin at(25500, 25500)) withfrom_world()/to_world()conversions to the Q7 world coordinates (meters, origin next to the dock, y pointing up). This keeps the public API in the same coordinate space as other Roborock devices.Device protocol
The device needs three commands, in this order:
service.set_preference_type {"prefer_type": 4}selects zone cleaning.service.set_zone_points {"zone_points": [x1, y1, x2, y1, x2, y2, x1, y2, ...]}sends the corners of each rectangle in world meters. Multiple rectangles are concatenated.service.set_zone_clean {"ctrl_value": 1}starts the task.ctrl_value: 0stops it.While the zone task runs, the device reports
work_mode30 (PLAN_AREA).Testing
roborock.vacuum.sc05, firmware 03.01.80) with one and two zones.Fixes #992