Skip to content

Commit b8b4a17

Browse files
committed
feat: add V1 wash tray self-clean and wash mode validation
1 parent d244532 commit b8b4a17

3 files changed

Lines changed: 100 additions & 13 deletions

File tree

‎docs/V1_API_COMMANDS.md‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Commands do not immediately make it to this page. You can find more commands [he
66

77
Commands can have multiple parameters that can change from one model to another.
88

9+
* [app_amethyst_self_check](#app_amethyst_self_check)
910
* [app_charge](#app_charge)
1011
* [app_get_dryer_setting](#app_get_dryer_setting)
1112
* [app_get_init_status](#app_get_init_status)
@@ -254,13 +255,15 @@ Parameters: None
254255

255256
### app_stop_wash
256257

257-
Description: This stops washing the mop whiloe docked
258+
Description: This stops washing the mop whiloe docked. It also stops a running wash tray self-clean
259+
([app_amethyst_self_check](#app_amethyst_self_check)).
258260

259261
Parameters: None
260262

261263
**Supported devices:**
262264

263265
* Roborock S8 Pro Ultra: ✅
266+
* Roborock Saros 10R: ✅
264267

265268
### app_goto_target
266269

@@ -1291,24 +1294,15 @@ Parameters: None
12911294

12921295
Returns:
12931296

1294-
wash_mode:
1297+
wash_mode: 0 light, 1 balanced, 2 deep, 8 super deep, 10 smart
12951298

12961299
Return example:
12971300

12981301
```json
12991302
{'wash_mode': 1}
13001303
```
13011304

1302-
Source: Roborock S7 MaxV Ultra
1303-
1304-
1305-
unknown = -9999
1306-
1307-
light = 0
1308-
1309-
balanced = 1
1310-
1311-
deep = 2
1305+
Source: Roborock S7 MaxV Ultra; smart (10) seen on the Roborock Saros 10R
13121306

13131307

13141308
**Supported devices:**
@@ -1323,6 +1317,9 @@ Description: Sets the wash wash_towel_mode
13231317

13241318
Parameters: {'wash_mode': 2}
13251319

1320+
wash_mode: 0 light, 1 balanced, 2 deep, 8 super deep, 10 smart. Super deep and smart are offered only on
1321+
devices that support them.
1322+
13261323
Returns: ok or error
13271324

13281325
Source: S8 Pro Ultra
@@ -1332,6 +1329,25 @@ Source: S8 Pro Ultra
13321329
* Roborock S7 MaxV Ultra: ✅
13331330
* Roborock S8 Pro Ultra: ✅
13341331

1332+
### app_amethyst_self_check
1333+
1334+
Description: Start the self-clean of the dock's mop wash tray (app: tray self-cleaning). Offered on docks with a
1335+
self-cleaning wash carousel, such as the Saros 10R dock (dock type 16).
1336+
1337+
Parameters: None
1338+
1339+
Returns: ok or error
1340+
1341+
While it runs, `get_status` reports `state` 23 (washing the mop) and `wash_phase` 11, the same as when the
1342+
self-clean is started from the app. The dock needs clean water (`dock_error_status` 38, water empty, otherwise).
1343+
It ends by itself after about a minute; `app_stop_wash` stops it early, like the stop button in the app.
1344+
1345+
Source: Roborock Saros 10R, Roborock app plugin
1346+
1347+
**Supported devices:**
1348+
1349+
* Roborock Saros 10R: ✅
1350+
13351351
### get_wash_water_temperature
13361352

13371353
Description: Get the water temperature the dock uses to wash the mop (app: water temperature). Available on

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from roborock.device_features import RoborockDockFeatures
88
from roborock.devices.traits.v1 import common
99
from roborock.devices.traits.v1.device_features import DeviceFeaturesTrait
10+
from roborock.exceptions import RoborockUnsupportedFeature
1011
from roborock.roborock_typing import RoborockCommand
1112

1213

@@ -42,12 +43,23 @@ def wash_towel_mode_options(self) -> list[WashTowelModes]:
4243

4344
async def set_wash_towel_mode(self, mode: WashTowelModes) -> None:
4445
"""Set the wash towel mode."""
46+
if mode not in self.wash_towel_mode_options:
47+
raise RoborockUnsupportedFeature(f"Wash towel mode {mode.value} is not supported")
4548
await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code})
4649

4750
async def start_wash(self) -> None:
4851
"""Start washing the mop."""
4952
await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH)
5053

5154
async def stop_wash(self) -> None:
52-
"""Stop washing the mop."""
55+
"""Stop washing the mop. Also stops a running wash tray self-clean."""
5356
await self.rpc_channel.send_command(RoborockCommand.APP_STOP_WASH)
57+
58+
async def self_clean_tray(self) -> None:
59+
"""Start the self-clean of the dock's mop wash tray (app: tray self-cleaning).
60+
61+
It runs for about a minute; `stop_wash()` stops it early, as the app's stop button does.
62+
"""
63+
if not self.device_feature_trait.dock_features.is_clean_carousel_self_clean_supported:
64+
raise RoborockUnsupportedFeature("Wash tray self-clean is not supported by this dock")
65+
await self.rpc_channel.send_command(RoborockCommand.APP_AMETHYST_SELF_CHECK)

‎tests/devices/traits/v1/test_wash_towel_mode.py‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from roborock.devices.device import RoborockDevice
1212
from roborock.devices.traits.v1.wash_towel_mode import WashTowelModeTrait
13+
from roborock.exceptions import RoborockUnsupportedFeature
1314
from roborock.roborock_typing import RoborockCommand
1415
from tests.devices.traits.v1.helpers import dock_types_with_capability
1516

@@ -83,6 +84,8 @@ async def test_set_wash_towel_mode(
8384
) -> None:
8485
"""Test setting the wash towel mode."""
8586
assert wash_towel_mode is not None
87+
# Offer the smart mode, as on the Saros 10R
88+
wash_towel_mode.device_feature_trait.is_dirty_replenish_clean_supported = True
8689

8790
await wash_towel_mode.set_wash_towel_mode(wash_mode)
8891

@@ -189,3 +192,59 @@ async def test_wash_towel_mode_options(
189192
wash_towel_mode.device_feature_trait.is_dirty_replenish_clean_supported = is_dirty_replenish_clean_supported
190193

191194
assert wash_towel_mode.wash_towel_mode_options == expected_modes
195+
196+
197+
@pytest.mark.parametrize(
198+
("dock_type_code"),
199+
[(RoborockDockTypeCode.o4_dock)],
200+
)
201+
async def test_set_wash_towel_mode_rejects_unoffered(
202+
wash_towel_mode: WashTowelModeTrait,
203+
mock_rpc_channel: AsyncMock,
204+
dock_type_code: RoborockDockTypeCode,
205+
) -> None:
206+
"""Test that a wash mode the device does not offer is rejected without sending."""
207+
assert wash_towel_mode is not None
208+
wash_towel_mode.device_feature_trait.is_super_deep_wash_supported = True
209+
wash_towel_mode.device_feature_trait.is_dirty_replenish_clean_supported = True
210+
assert WashTowelModes.SUPER_DEEP not in wash_towel_mode.wash_towel_mode_options
211+
212+
with pytest.raises(RoborockUnsupportedFeature):
213+
await wash_towel_mode.set_wash_towel_mode(WashTowelModes.SUPER_DEEP)
214+
215+
mock_rpc_channel.send_command.assert_not_called()
216+
217+
218+
@pytest.mark.parametrize(
219+
("dock_type_code"),
220+
[(RoborockDockTypeCode.shell_3s_dock)],
221+
)
222+
async def test_self_clean_tray(
223+
wash_towel_mode: WashTowelModeTrait,
224+
mock_rpc_channel: AsyncMock,
225+
dock_type_code: RoborockDockTypeCode,
226+
) -> None:
227+
"""Test starting the wash tray self-clean on a dock with the carousel."""
228+
assert wash_towel_mode is not None
229+
230+
await wash_towel_mode.self_clean_tray()
231+
232+
mock_rpc_channel.send_command.assert_called_once_with(RoborockCommand.APP_AMETHYST_SELF_CHECK)
233+
234+
235+
@pytest.mark.parametrize(
236+
("dock_type_code"),
237+
[(RoborockDockTypeCode.o4_dock)],
238+
)
239+
async def test_self_clean_tray_unsupported(
240+
wash_towel_mode: WashTowelModeTrait,
241+
mock_rpc_channel: AsyncMock,
242+
dock_type_code: RoborockDockTypeCode,
243+
) -> None:
244+
"""Test that the tray self-clean is rejected without sending on a dock without the carousel."""
245+
assert wash_towel_mode is not None
246+
247+
with pytest.raises(RoborockUnsupportedFeature):
248+
await wash_towel_mode.self_clean_tray()
249+
250+
mock_rpc_channel.send_command.assert_not_called()

0 commit comments

Comments
 (0)