Skip to content

Commit 82ed8d7

Browse files
authored
Merge branch 'main' into q7-set-button-light
2 parents 25876d8 + 6397ace commit 82ed8d7

12 files changed

Lines changed: 386 additions & 7 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Evaluate every change against the repository's three core layers in strict prior
5454
## Detailed Engineering Conventions
5555

5656
### 1. Typing & Data Models
57-
- **Subclass `RoborockBase`**: Define structured domain and wire data models as `@dataclass` subclassing `RoborockBase` (`from_dict`, `as_dict`). Avoid `TypedDict` or loose dicts. (Binary protocol packets, transport message envelopes, and map layers are exempt).
57+
- **Subclass `RoborockBase`**: Define structured domain and wire data models as `@dataclass` subclassing `RoborockBase` (`from_dict`, `as_dict`). Avoid `TypedDict` or loose dicts. (Binary protocol packets, transport message envelopes, and map layers are exempt). The existing frozen `Q10RoborockPoint` coordinate value is also exempt: it must retain immutability and hashability, and Python disallows frozen dataclass inheritance from the non-frozen `RoborockBase`. This exception does not extend to other domain models.
5858
- **Enum Fallback Resilience**: All enums representing device status, firmware modes, error codes, and wire protocol integer codes MUST inherit from `RoborockEnum` (defining a lowercase `unknown = -1` or `0` member) or `RoborockModeEnum` (using `from_code_optional()`). Internal enums not decoding unknown firmware codes remain standard `Enum`/`StrEnum`.
5959
- **Strongly Type What You Know; Contain `Any` to the Wire**: Public trait APIs, method signatures, properties, and domain models MUST declare concrete types. `Any` is accepted only where the underlying wire protocol is dynamic or polymorphic (Tuya DPS maps, low-level RPC dispatch, serialization helpers, evolving cloud schemas).
6060
- **Avoid Forward References & `TYPE_CHECKING`**: Avoid stringified forward references (`"ClassName"`) and `if typing.TYPE_CHECKING:` guards wherever possible. They typically indicate circular dependencies or coupling that should be refactored by extracting shared models.

‎CHANGELOG.md‎

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

33
<!-- version list -->
44

5+
## v7.9.0 (2026-09-21)
6+
7+
### Features
8+
9+
- Add MopDryerTrait for controlling the dock mop dryer
10+
([#952](https://github.com/Python-roborock/python-roborock/pull/952),
11+
[`48f793f`](https://github.com/Python-roborock/python-roborock/commit/48f793fcb1ae13a4b2d21b939150fa464bae7879))
12+
13+
### Refactoring
14+
15+
- Back MopDryerTrait with the dryer setting instead of device status
16+
([#952](https://github.com/Python-roborock/python-roborock/pull/952),
17+
[`48f793f`](https://github.com/Python-roborock/python-roborock/commit/48f793fcb1ae13a4b2d21b939150fa464bae7879))
18+
19+
20+
## v7.8.2 (2026-09-20)
21+
22+
### Bug Fixes
23+
24+
- Fetch the latest user agreement version instead of hardcoding it
25+
([#960](https://github.com/Python-roborock/python-roborock/pull/960),
26+
[`f6a40f8`](https://github.com/Python-roborock/python-roborock/commit/f6a40f8795d7991b85a2e5e99c5dee7bba97aaa5))
27+
28+
29+
## v7.8.1 (2026-09-17)
30+
31+
### Bug Fixes
32+
33+
- Preserve immutable Q10 points in model conformance checks
34+
([#965](https://github.com/Python-roborock/python-roborock/pull/965),
35+
[`386e4c5`](https://github.com/Python-roborock/python-roborock/commit/386e4c50fe9ca29d7a4caa85a3662c3c104b26f2))
36+
37+
538
## v7.8.0 (2026-09-13)
639

740
### Features

‎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.8.0"
3+
version = "7.9.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/v1/v1_containers.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,28 @@ class SmartWashParams(RoborockBase):
459459
wash_interval: int | None = None
460460

461461

462+
@dataclass
463+
class MopDryerProfile(RoborockBase):
464+
"""Dryer parameters for one state of the auto mop-drying setting."""
465+
466+
cliff_on: int | None = None
467+
cliff_off: int | None = None
468+
count: int | None = None
469+
dry_time: int | None = None
470+
"""Drying duration in seconds. Only present in the ``on`` profile."""
471+
dry_heating_film_time: int | None = None
472+
"""Heating element run time in seconds. Only present in the ``on`` profile."""
473+
474+
475+
@dataclass
476+
class MopDryerSetting(RoborockBase):
477+
"""Auto mop-drying setting, as returned by APP_GET_DRYER_SETTING."""
478+
479+
status: int | None = None
480+
on: MopDryerProfile | None = None
481+
off: MopDryerProfile | None = None
482+
483+
462484
@dataclass
463485
class DustCollectionMode(RoborockBase):
464486
mode: RoborockDockDustCollectionModeCode | None = None

‎roborock/devices/traits/v1/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
led_status,
8383
map_content,
8484
maps,
85+
mop_dryer,
8586
network_info,
8687
obstacle_photos,
8788
rooms,
@@ -105,6 +106,7 @@
105106
from .led_status import LedStatusTrait
106107
from .map_content import MapContentTrait
107108
from .maps import MapsTrait
109+
from .mop_dryer import MopDryerTrait
108110
from .network_info import NetworkInfoTrait
109111
from .obstacle_photos import ObstaclePhotoTrait
110112
from .rooms import RoomsTrait
@@ -132,6 +134,7 @@
132134
"led_status",
133135
"map_content",
134136
"maps",
137+
"mop_dryer",
135138
"network_info",
136139
"obstacle_photos",
137140
"rooms",
@@ -175,6 +178,7 @@ class PropertiesApi(Trait):
175178
wash_towel_mode: WashTowelModeTrait | None = None
176179
smart_wash_params: SmartWashParamsTrait | None = None
177180
obstacle_photos: ObstaclePhotoTrait | None = None
181+
mop_dryer: MopDryerTrait | None = None
178182

179183
def __init__(
180184
self,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""Trait for the dock mop dryer."""
2+
3+
from roborock.data import MopDryerSetting
4+
from roborock.device_features import RoborockDockFeatures
5+
from roborock.devices.traits.v1 import common
6+
from roborock.roborock_typing import RoborockCommand
7+
8+
_STATUS_PARAM = "status"
9+
10+
11+
def _supports_mop_dryer(dock_features: RoborockDockFeatures) -> bool:
12+
return dock_features.is_dryable
13+
14+
15+
class MopDryerTrait(MopDryerSetting, common.V1TraitMixin, common.RoborockSwitchBase):
16+
"""Trait for the dock mop dryer.
17+
18+
The switch controls the auto mop-drying setting, i.e. whether the dock
19+
dries the mop after washing. ``start_dry`` and ``stop_dry`` control a
20+
drying cycle directly. Whether a cycle is currently running is reported
21+
as ``dry_status`` on the device status.
22+
"""
23+
24+
command = RoborockCommand.APP_GET_DRYER_SETTING
25+
converter = common.DefaultConverter(MopDryerSetting)
26+
requires_dock_features = _supports_mop_dryer
27+
28+
@property
29+
def is_on(self) -> bool:
30+
"""Return whether auto mop drying is enabled."""
31+
return self.status == 1
32+
33+
async def enable(self) -> None:
34+
"""Enable auto mop drying."""
35+
await self.rpc_channel.send_command(RoborockCommand.APP_SET_DRYER_SETTING, params={_STATUS_PARAM: 1})
36+
# Optimistic update to avoid an extra refresh
37+
self.status = 1
38+
39+
async def disable(self) -> None:
40+
"""Disable auto mop drying."""
41+
await self.rpc_channel.send_command(RoborockCommand.APP_SET_DRYER_SETTING, params={_STATUS_PARAM: 0})
42+
# Optimistic update to avoid an extra refresh
43+
self.status = 0
44+
45+
async def start_dry(self) -> None:
46+
"""Start a mop drying cycle."""
47+
await self.rpc_channel.send_command(RoborockCommand.APP_SET_DRYER_STATUS, params={_STATUS_PARAM: 1})
48+
49+
async def stop_dry(self) -> None:
50+
"""Stop the running mop drying cycle."""
51+
await self.rpc_channel.send_command(RoborockCommand.APP_SET_DRYER_STATUS, params={_STATUS_PARAM: 0})

‎roborock/web_api.py‎

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"https://ruiot.roborock.com",
3939
]
4040

41+
# Fallback user agreement version, used only if the latest version cannot be fetched.
42+
DEFAULT_AGREEMENT_MAJOR_VERSION = 14
43+
DEFAULT_AGREEMENT_MINOR_VERSION = 0
44+
4145

4246
@dataclass
4347
class IotLoginInfo:
@@ -292,6 +296,34 @@ async def _sign_key_v3(self, s: str) -> str:
292296

293297
return code_response["data"]["k"]
294298

299+
async def _get_agreement_version(self, country: str) -> dict[str, int]:
300+
"""Get the latest user agreement version for the given country.
301+
302+
The login endpoint rejects a stale agreement version with code 3006. The
303+
current version differs per server and per country, so it must be looked
304+
up rather than hardcoded. Falls back to the previously hardcoded values
305+
if the lookup fails so that login is never blocked by this request.
306+
"""
307+
try:
308+
base_url = await self.base_url
309+
agreement_request = PreparedRequest(base_url, self.session, {"header_clientlang": "en"})
310+
response = await agreement_request.request(
311+
"get",
312+
"/api/v3/app/agreement/latest",
313+
params={"country": country},
314+
)
315+
if response is not None and response.get("code") == 200:
316+
data = response.get("data") or {}
317+
major = data.get("majorVersion")
318+
minor = data.get("minorVersion")
319+
if isinstance(major, int) and isinstance(minor, int):
320+
_LOGGER.debug("Using user agreement version %s.%s for %s", major, minor, country)
321+
return {"majorVersion": major, "minorVersion": minor}
322+
_LOGGER.debug("Unexpected agreement version response: %s", response)
323+
except RoborockException as err:
324+
_LOGGER.debug("Could not fetch latest user agreement version: %s", err)
325+
return {"majorVersion": DEFAULT_AGREEMENT_MAJOR_VERSION, "minorVersion": DEFAULT_AGREEMENT_MINOR_VERSION}
326+
295327
async def code_login_v4(
296328
self, code: int | str, country: str | None = None, country_code: int | None = None
297329
) -> UserData:
@@ -334,10 +366,7 @@ async def code_login_v4(
334366
"countryCode": country_code,
335367
"email": self._username,
336368
"code": code,
337-
# Major and minor version are the user agreement version, we will need to see if this needs to be
338-
# dynamic https://usiot.roborock.com/api/v3/app/agreement/latest?country=US
339-
"majorVersion": 14,
340-
"minorVersion": 0,
369+
**await self._get_agreement_version(country),
341370
},
342371
)
343372
if login_response is None:

‎tests/conformance/test_model_conformance.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111

1212
import roborock.data
13+
from roborock.data.b01_q10.b01_q10_containers import Q10RoborockPoint
1314
from roborock.data.containers import RoborockBase
1415
from tests.conformance.discovery import discover_dataclasses, to_pytest_params
1516

@@ -20,6 +21,12 @@
2021
)
2122
def test_data_model_subclasses_roborock_base(model_cls: type) -> None:
2223
"""All domain dataclasses in roborock.data must inherit from RoborockBase."""
24+
# This immutable coordinate value predates the conformance suite. Frozen
25+
# dataclasses cannot inherit from the non-frozen RoborockBase dataclass.
26+
# Keep this exception explicit; other models must satisfy the normal rule.
27+
if model_cls is Q10RoborockPoint:
28+
assert model_cls.__dataclass_params__.frozen # type: ignore[attr-defined]
29+
return
2330
assert issubclass(model_cls, RoborockBase), (
2431
f"{model_cls.__module__}.{model_cls.__name__} is a dataclass but does not inherit from RoborockBase. "
2532
"Per AGENTS.md, domain containers must subclass RoborockBase for serialization."

‎tests/data/b01_q10/test_b01_q10_containers.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Tests for Q10 data containers."""
22

3+
from dataclasses import FrozenInstanceError
4+
35
import pytest
46

57
from roborock.data.b01_q10.b01_q10_containers import Q10RoborockPoint
@@ -47,3 +49,15 @@ def test_q10_roborock_point_rejects_invalid_vector_coordinates(
4749
"""Outbound vector coordinates must fit the signed wire grid exactly."""
4850
with pytest.raises(ValueError):
4951
point.to_vector()
52+
53+
54+
@pytest.mark.parametrize("field", ["x", "y"])
55+
def test_roborock_point_preserves_immutable_value_contract(field: str) -> None:
56+
point = Q10RoborockPoint(25500, 25500)
57+
original_hash = hash(point)
58+
with pytest.raises(FrozenInstanceError):
59+
setattr(point, field, 0)
60+
with pytest.raises(FrozenInstanceError):
61+
delattr(point, field)
62+
assert point == Q10RoborockPoint(25500, 25500)
63+
assert hash(point) == original_hash

0 commit comments

Comments
 (0)