Skip to content

Commit a2cfdcf

Browse files
authored
feat(dyad): add F25 Ultra drying mode, schedule and reset support (#1019)
* fix(dyad): decode F25 Ultra drying mode DP 272 was documented and decoded as a drying time in minutes, but on the F25 Ultra it carries a mode code that follows DP 225: 5 for fast drying and 22 for silent drying. Decode it with a new DyadDryingMode enum. Keep DP 225 as an integer, because it is the silent drying duration in minutes on older models, and document the F25 Ultra codes. Also document that DP 204 reports the mode of the current or last drying run: it does not change when the mode setting changes. * feat(dyad): decode schedule and add drying commands Decode SCHEDULE_TASK (10002) into DyadScheduleTask. The device sends a JSON list of tasks or an empty string. The cron field uses local time. On an F25 Ultra every task had the same dpAction, while the device ran nothing, drying, or self-clean and drying, so dpAction does not identify the action. Add DyadApi.start_drying and DyadApi.stop_drying, which send the same data points as the Roborock app and were verified on an F25 Ultra. * feat(dyad): add filter and brush reset commands Add DyadApi.reset_filter and DyadApi.reset_brush, which write 1 to MESH_RESET (218) and BRUSH_RESET (219). On an F25 Ultra the device answers with the matching usage counter (214 or 215) reset to 0, the same response as when resetting from the Roborock app.
1 parent 4924dca commit a2cfdcf

5 files changed

Lines changed: 119 additions & 8 deletions

File tree

‎roborock/data/dyad/dyad_code_mappings.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ class DyadPowerwheelDirection(RoborockEnum):
134134
exit = 9 # sent when remote control ends
135135

136136

137+
class DyadDryingMode(RoborockEnum):
138+
"""Drying mode of the F25 Ultra, reported on DP 272 and set through DP 225."""
139+
140+
unknown = -1
141+
fast = 5
142+
silent = 22
143+
144+
137145
class DyadError(RoborockEnum):
138146
none = 0
139147
dirty_tank_full = 20000 # Dirty tank full. Empty it

‎roborock/data/dyad/dyad_containers.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ class DyadSndState(RoborockBase):
2323
language: str
2424

2525

26+
@dataclass
27+
class DyadScheduleTask(RoborockBase):
28+
"""A task from the device schedule (DP 10002).
29+
30+
`cron` uses the device's local time. On the F25 Ultra every task had the same
31+
`dp_action`, while the device ran nothing, drying, or self-clean and drying,
32+
so the action that will run cannot be inferred from `dp_action`.
33+
"""
34+
35+
id: int
36+
on: bool
37+
cron: str
38+
dp_action: dict[int, int]
39+
40+
2641
@dataclass
2742
class DyadOtaNfo(RoborockBase):
2843
mqttOtaData: dict

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
from datetime import UTC, datetime, time
3232
from typing import Any, Generic, TypeVar
3333

34-
from roborock.data import DyadProductInfo, DyadSndState, HomeDataProduct, RoborockCategory
34+
from roborock.data import DyadProductInfo, DyadScheduleTask, DyadSndState, HomeDataProduct, RoborockCategory
3535
from roborock.data.dyad.dyad_code_mappings import (
3636
DyadBrushSpeed,
3737
DyadCleanAssistPower,
3838
DyadCleanMode,
3939
DyadCleanserAmount,
40+
DyadDryingMode,
4041
DyadError,
4142
DyadPowerwheelDirection,
4243
DyadSelfCleanIntensity,
@@ -88,6 +89,13 @@
8889
]
8990

9091

92+
def _decode_dyad_schedule(value: str) -> list[DyadScheduleTask]:
93+
"""Decode the schedule data point, which is a JSON list or an empty string."""
94+
if not value:
95+
return []
96+
return [DyadScheduleTask.from_dict(task) for task in json.loads(value)]
97+
98+
9199
DYAD_PROTOCOL_ENTRIES: dict[RoborockDyadDataProtocol, Callable] = {
92100
RoborockDyadDataProtocol.STATUS: lambda val: RoborockDyadStateCode(val).name,
93101
RoborockDyadDataProtocol.SELF_CLEAN_MODE: lambda val: DyadSelfCleanMode(val).name,
@@ -107,7 +115,7 @@
107115
RoborockDyadDataProtocol.STAND_LOCK_AUTO_RUN: lambda val: bool(val),
108116
RoborockDyadDataProtocol.AUTO_SELF_CLEAN_SET_MODE: lambda val: DyadSelfCleanLevel(val).name,
109117
RoborockDyadDataProtocol.AUTO_DRY_MODE: lambda val: bool(val),
110-
RoborockDyadDataProtocol.SILENT_DRY_DURATION: lambda val: int(val), # in minutes
118+
RoborockDyadDataProtocol.SILENT_DRY_DURATION: lambda val: int(val), # minutes, or DyadDryingMode on F25
111119
RoborockDyadDataProtocol.SILENT_MODE: lambda val: bool(val),
112120
RoborockDyadDataProtocol.SILENT_MODE_START_TIME: lambda val: time(
113121
hour=int(val / 60), minute=val % 60
@@ -134,7 +142,8 @@
134142
RoborockDyadDataProtocol.POWERWHEEL_SPEED: lambda val: int(val),
135143
RoborockDyadDataProtocol.SELF_CLEAN_CUR_MODE: lambda val: DyadSelfCleanIntensity(val).name,
136144
RoborockDyadDataProtocol.SELF_CLEAN_CUR_TEMP: lambda val: DyadSelfCleanWaterTemp(val).name,
137-
RoborockDyadDataProtocol.DRY_CUR_MODE: lambda val: int(val), # in minutes
145+
RoborockDyadDataProtocol.DRY_CUR_MODE: lambda val: DyadDryingMode(val).name,
146+
RoborockDyadDataProtocol.SCHEDULE_TASK: _decode_dyad_schedule,
138147
RoborockDyadDataProtocol.SND_STATE: lambda val: DyadSndState.from_dict(val),
139148
RoborockDyadDataProtocol.PRODUCT_INFO: lambda val: DyadProductInfo.from_dict(val),
140149
}
@@ -315,6 +324,28 @@ async def set_value(self, protocol: RoborockDyadDataProtocol, value: Any) -> dic
315324
params = {protocol: value}
316325
return await send_decoded_command(self._channel, params)
317326

327+
async def start_drying(self) -> None:
328+
"""Start drying with the drying mode currently set on the device.
329+
330+
The app sends the same command for fast and silent drying on the F25 Ultra.
331+
"""
332+
await send_decoded_command(
333+
self._channel,
334+
{RoborockDyadDataProtocol.START: 1, RoborockDyadDataProtocol.WARM_LEVEL: 1},
335+
)
336+
337+
async def stop_drying(self) -> None:
338+
"""Stop a running drying cycle."""
339+
await send_decoded_command(self._channel, {RoborockDyadDataProtocol.START: 0})
340+
341+
async def reset_filter(self) -> None:
342+
"""Reset the filter usage counter."""
343+
await send_decoded_command(self._channel, {RoborockDyadDataProtocol.MESH_RESET: 1})
344+
345+
async def reset_brush(self) -> None:
346+
"""Reset the brush roller usage counter."""
347+
await send_decoded_command(self._channel, {RoborockDyadDataProtocol.BRUSH_RESET: 1})
348+
318349
async def add_listener(self, callback: Callable[[dict[RoborockDyadDataProtocol, Any]], None]) -> Callable[[], None]:
319350
"""Listen for state the device pushes on its own.
320351

‎roborock/roborock_message.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RoborockDyadDataProtocol(RoborockEnum):
8686
STATUS = 201
8787
SELF_CLEAN_MODE = 202
8888
SELF_CLEAN_LEVEL = 203
89-
WARM_LEVEL = 204
89+
WARM_LEVEL = 204 # F25 Ultra: mode of the current or last drying run, 2 fast and 1 silent
9090
CLEAN_MODE = 205
9191
SUCTION = 206
9292
WATER_LEVEL = 207
@@ -104,7 +104,7 @@ class RoborockDyadDataProtocol(RoborockEnum):
104104
STAND_LOCK_AUTO_RUN = 222
105105
AUTO_SELF_CLEAN_SET_MODE = 223
106106
AUTO_DRY_MODE = 224
107-
SILENT_DRY_DURATION = 225
107+
SILENT_DRY_DURATION = 225 # minutes on older models; F25 Ultra uses DyadDryingMode codes
108108
SILENT_MODE = 226
109109
SILENT_MODE_START_TIME = 227
110110
SILENT_MODE_END_TIME = 228
@@ -128,7 +128,7 @@ class RoborockDyadDataProtocol(RoborockEnum):
128128
POWERWHEEL_SPEED = 250 # remote control drive speed
129129
SELF_CLEAN_CUR_MODE = 270 # intensity of the current or last self-clean run
130130
SELF_CLEAN_CUR_TEMP = 271 # water temperature of the current or last self-clean run
131-
DRY_CUR_MODE = 272 # drying time in minutes of the current or next run, follows SILENT_DRY_DURATION
131+
DRY_CUR_MODE = 272 # DyadDryingMode on the F25 Ultra, follows SILENT_DRY_DURATION
132132
ID_QUERY = 10000
133133
F_C = 10001
134134
SCHEDULE_TASK = 10002

‎tests/devices/traits/a01/test_init.py‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from Crypto.Util.Padding import unpad
88
from freezegun import freeze_time
99

10+
from roborock.data import DyadScheduleTask
1011
from roborock.devices.traits.a01 import DyadApi, ZeoApi, create
1112
from roborock.devices.traits.a01.device_feature import build_force_load_dp_list
1213
from roborock.roborock_message import RoborockDyadDataProtocol, RoborockMessageProtocol, RoborockZeoProtocol
@@ -180,7 +181,7 @@ async def test_dyad_f25_ultra_status_snapshot(dyad_api: DyadApi, fake_channel: F
180181
RoborockDyadDataProtocol.FLAT_STATUS: False,
181182
RoborockDyadDataProtocol.SELF_CLEAN_CUR_MODE: "smart",
182183
RoborockDyadDataProtocol.SELF_CLEAN_CUR_TEMP: "high",
183-
RoborockDyadDataProtocol.DRY_CUR_MODE: 5,
184+
RoborockDyadDataProtocol.DRY_CUR_MODE: "fast",
184185
}
185186

186187

@@ -217,7 +218,10 @@ async def test_dyad_f25_ultra_status_snapshot(dyad_api: DyadApi, fake_channel: F
217218
(RoborockDyadDataProtocol.POWERWHEEL_DIRECTION, 9, "exit"),
218219
(RoborockDyadDataProtocol.POWERWHEEL_DIRECTION, 3, "unknown"),
219220
(RoborockDyadDataProtocol.POWERWHEEL_SPEED, 15, 15),
220-
(RoborockDyadDataProtocol.DRY_CUR_MODE, 22, 22),
221+
(RoborockDyadDataProtocol.DRY_CUR_MODE, 5, "fast"),
222+
(RoborockDyadDataProtocol.DRY_CUR_MODE, 22, "silent"),
223+
(RoborockDyadDataProtocol.DRY_CUR_MODE, 7, "unknown"),
224+
(RoborockDyadDataProtocol.SILENT_DRY_DURATION, 22, 22),
221225
],
222226
)
223227
async def test_dyad_f25_ultra_value_conversion(
@@ -481,6 +485,59 @@ async def test_dyad_api_set_value(dyad_api: DyadApi, fake_channel: FakeChannel):
481485
assert "t" in payload_data
482486

483487

488+
@pytest.mark.parametrize(
489+
("raw", "expected"),
490+
[
491+
("", []),
492+
(
493+
'[{"id":1794139256726,"on":true,"cron":"0 15 * * 1,2,3,4,5","dpAction":{"200":1,"204":1}}]',
494+
[DyadScheduleTask(id=1794139256726, on=True, cron="0 15 * * 1,2,3,4,5", dp_action={200: 1, 204: 1})],
495+
),
496+
],
497+
ids=["empty", "weekdays"],
498+
)
499+
async def test_dyad_schedule_task(
500+
raw: str,
501+
expected: list[DyadScheduleTask],
502+
dyad_api: DyadApi,
503+
fake_channel: FakeChannel,
504+
):
505+
"""The schedule payload seen on an F25 Ultra is decoded into typed tasks."""
506+
await dyad_api.start()
507+
fake_channel.notify_subscribers(build_a01_message({10002: raw}))
508+
assert dyad_api.values == {RoborockDyadDataProtocol.SCHEDULE_TASK: expected}
509+
510+
511+
async def test_dyad_schedule_task_invalid(dyad_api: DyadApi, fake_channel: FakeChannel):
512+
"""A malformed schedule payload does not produce a value."""
513+
await dyad_api.start()
514+
fake_channel.notify_subscribers(build_a01_message({10002: "not json"}))
515+
assert dyad_api.values == {}
516+
517+
518+
@pytest.mark.parametrize(
519+
("method", "expected_dps"),
520+
[
521+
("start_drying", {"200": 1, "204": 1}),
522+
("stop_drying", {"200": 0}),
523+
("reset_filter", {"218": 1}),
524+
("reset_brush", {"219": 1}),
525+
],
526+
)
527+
async def test_dyad_action_commands(
528+
method: str,
529+
expected_dps: dict[str, int],
530+
dyad_api: DyadApi,
531+
fake_channel: FakeChannel,
532+
):
533+
"""Action commands send the data points used by the app."""
534+
await getattr(dyad_api, method)()
535+
536+
assert len(fake_channel.published_messages) == 1
537+
payload_data = json.loads(unpad(fake_channel.published_messages[0].payload, AES.block_size))
538+
assert payload_data["dps"] == expected_dps
539+
540+
484541
async def test_zeo_api_set_value(zeo_api: ZeoApi, fake_channel: FakeChannel):
485542
"""Test ZeoApi set_value sends correct command."""
486543
await zeo_api.set_value(RoborockZeoProtocol.MODE, "standard")

0 commit comments

Comments
 (0)