Skip to content

Commit 1f35820

Browse files
authored
Merge branch 'main' into submit/fix/clean-summary-detail-dataclass
2 parents a865d54 + 62c0c3b commit 1f35820

12 files changed

Lines changed: 1137 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
<!-- version list -->
44

5+
## v7.25.0 (2026-11-21)
6+
7+
### Features
8+
9+
- Add Q7 zone cleaning ([#1038](https://github.com/Python-roborock/python-roborock/pull/1038),
10+
[`e9d8b34`](https://github.com/Python-roborock/python-roborock/commit/e9d8b34f9d754420695c0432f1c5bb444319d0d3))
11+
12+
13+
## v7.24.0 (2026-11-21)
14+
15+
### Features
16+
17+
- **map**: Plan V1 dynamic element page updates
18+
([#1010](https://github.com/Python-roborock/python-roborock/pull/1010),
19+
[`769f35f`](https://github.com/Python-roborock/python-roborock/commit/769f35f60bb6bc2b4746cf46efd29994acfdcb29))
20+
21+
522
## v7.23.2 (2026-11-16)
623

724
### Bug Fixes

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python-roborock"
3-
version = "7.23.2"
3+
version = "7.25.0"
44
description = "A package to control Roborock vacuums."
55
authors = [{ name = "humbertogontijo", email = "humbertogontijo@users.noreply.github.com" }, {name="Lash-L"}, {name="allenporter"}]
66
requires-python = ">=3.11, <4"

‎roborock/data/b01_q7/b01_q7_containers.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
from dataclasses import dataclass, field
44
from functools import cached_property
5+
from typing import Self
56

67
from ...exceptions import RoborockException
78
from ..containers import RoborockBase
@@ -77,6 +78,39 @@ class Recommend(RoborockBase):
7778
room_id: list[int] = field(default_factory=list)
7879

7980

81+
_ROBOROCK_COORDINATE_OFFSET_MM = 25_500
82+
_MM_PER_METER = 1000
83+
84+
85+
@dataclass
86+
class Q7RoborockPoint(RoborockBase):
87+
"""A point in the common Roborock millimetre coordinate space.
88+
89+
Q7 firmware uses world coordinates in meters (floats) whose origin is the
90+
map origin next to the dock, with the y axis pointing up. Public Q7 APIs use
91+
this common coordinate system instead, matching other Roborock devices and
92+
placing the map origin at ``(25500, 25500)``.
93+
"""
94+
95+
x: int
96+
y: int
97+
98+
@classmethod
99+
def from_world(cls, x: float, y: float) -> Self:
100+
"""Convert Q7 world coordinates (meters) to common Roborock coordinates."""
101+
return cls(
102+
x=_ROBOROCK_COORDINATE_OFFSET_MM + round(x * _MM_PER_METER),
103+
y=_ROBOROCK_COORDINATE_OFFSET_MM + round(y * _MM_PER_METER),
104+
)
105+
106+
def to_world(self) -> tuple[float, float]:
107+
"""Convert common Roborock coordinates to Q7 world coordinates (meters)."""
108+
return (
109+
(self.x - _ROBOROCK_COORDINATE_OFFSET_MM) / _MM_PER_METER,
110+
(self.y - _ROBOROCK_COORDINATE_OFFSET_MM) / _MM_PER_METER,
111+
)
112+
113+
80114
@dataclass
81115
class Q7MapListEntry(RoborockBase):
82116
"""Single map list entry returned by `service.get_map_list`."""

‎roborock/data/v1/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
from .dynamic_map import *
12
from .v1_clean_modes import *
23
from .v1_code_mappings import *
34
from .v1_containers import *
4-
from .v1_dynamic_map import *
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
"""Wire models for the V1 dynamic map diff commands.
1+
"""Wire models for incremental updates to V1 vacuum maps.
2+
3+
A full map is a snapshot of the floor plan, cleaning path, and robot position.
4+
Dynamic map commands report changes since that snapshot so a client can fetch
5+
the changed parts and keep the displayed path and position current during a
6+
clean, without downloading the whole map each time. The client falls back to
7+
a full map when incremental updates cannot be applied.
28
39
These dataclasses describe the JSON results of ``get_dynamic_map_diff`` and
410
``get_dynamic_data`` after ordinary command-response decoding, plus the

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import Any
88

99
from roborock import B01Props
10-
from roborock.data import HomeDataDevice, HomeDataProduct, Q7MapList, Q7MapListEntry
10+
from roborock.data import HomeDataDevice, HomeDataProduct, Q7MapList, Q7MapListEntry, Q7RoborockPoint
1111
from roborock.data.b01_q7.b01_q7_code_mappings import (
1212
CleanPathPreferenceMapping,
1313
CleanRepeatMapping,
@@ -35,6 +35,7 @@
3535
"MapContentTrait",
3636
"Q7MapList",
3737
"Q7MapListEntry",
38+
"Q7RoborockPoint",
3839
]
3940

4041

@@ -190,6 +191,33 @@ async def clean_segments(self, segment_ids: list[int]) -> None:
190191
},
191192
)
192193

194+
async def clean_zone(self, first_corner: Q7RoborockPoint, second_corner: Q7RoborockPoint) -> None:
195+
"""Clean one rectangular zone given two opposite corners in common Roborock coordinates."""
196+
await self.clean_zones([(first_corner, second_corner)])
197+
198+
async def clean_zones(self, zones: list[tuple[Q7RoborockPoint, Q7RoborockPoint]]) -> None:
199+
"""Clean one or more rectangular zones in a single task.
200+
201+
Each zone is given by two opposite corners in common Roborock coordinates.
202+
The device takes the zones as a flat list of rectangle corners in world
203+
meters (``[x1, y1, x2, y1, x2, y2, x1, y2, ...]``) and needs the zone
204+
preference type selected first; ``set_zone_clean`` then starts the task.
205+
"""
206+
if not zones:
207+
raise ValueError("at least one zone is required")
208+
zone_points: list[float] = []
209+
for first_corner, second_corner in zones:
210+
x1, y1 = first_corner.to_world()
211+
x2, y2 = second_corner.to_world()
212+
if x1 == x2 or y1 == y2:
213+
raise ValueError(f"zone corners must span an area: {first_corner}, {second_corner}")
214+
min_x, max_x = sorted((x1, x2))
215+
min_y, max_y = sorted((y1, y2))
216+
zone_points += [min_x, min_y, max_x, min_y, max_x, max_y, min_x, max_y]
217+
await self.send(RoborockB01Q7Methods.SET_PREFERENCE_TYPE, {"prefer_type": CleanTaskTypeMapping.AREA.code})
218+
await self.send(RoborockB01Q7Methods.SET_ZONE_POINTS, {"zone_points": zone_points})
219+
await self.send(RoborockB01Q7Methods.SET_ZONE_CLEAN, {"ctrl_value": SCDeviceCleanParam.START.code})
220+
193221
async def pause_clean(self) -> None:
194222
"""Pause cleaning."""
195223
await self.send(

0 commit comments

Comments
 (0)