Skip to content

Commit 003f953

Browse files
committed
fix: treat o3 docks as dryable when the device supports drying
1 parent 109f433 commit 003f953

4 files changed

Lines changed: 61 additions & 4 deletions

File tree

‎roborock/device_features.py‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -876,12 +876,24 @@ class RoborockDockFeatures:
876876

877877
dock_type: RoborockDockTypeCode
878878
has_am: bool | None = None
879+
supports_drying: bool | None = None
880+
"""Whether the device advertises the drying device feature.
881+
882+
Used for docks that can dry only when an optional dryer module is
883+
installed (e.g. the HADM02RR module on the o3 Empty Wash Fill dock), where
884+
the dock type alone cannot answer the question.
885+
"""
879886

880887
@classmethod
881888
@cache
882-
def from_dock_type(cls, dock_type: RoborockDockTypeCode | None, has_am: bool | None = None) -> Self:
889+
def from_dock_type(
890+
cls,
891+
dock_type: RoborockDockTypeCode | None,
892+
has_am: bool | None = None,
893+
supports_drying: bool | None = None,
894+
) -> Self:
883895
"""Return cached capabilities for a V1 dock type."""
884-
return cls(dock_type or RoborockDockTypeCode.o0_dock, has_am=has_am)
896+
return cls(dock_type or RoborockDockTypeCode.o0_dock, has_am=has_am, supports_drying=supports_drying)
885897

886898
def _matches_am_variant(self, dock_types: set[RoborockDockTypeCode]) -> bool:
887899
return self.has_am is True and self.dock_type in dock_types
@@ -919,7 +931,7 @@ def is_washable(self) -> bool:
919931

920932
@property
921933
def is_dryable(self) -> bool:
922-
return self.is_collect_wash_dry
934+
return self.is_collect_wash_dry or self.supports_drying is True
923935

924936
@property
925937
def is_only_x_series(self) -> bool:

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ async def discover_features(self) -> None:
283283
await self.device_features.refresh()
284284
# Dock type also acts like a device feature for some traits.
285285
dock_type = await self._dock_type()
286-
dock_features = RoborockDockFeatures.from_dock_type(dock_type, has_am=self.status.has_am)
286+
dock_features = RoborockDockFeatures.from_dock_type(
287+
dock_type,
288+
has_am=self.status.has_am,
289+
supports_drying=self.device_features.is_supported_drying,
290+
)
287291
self.device_features.dock_features = dock_features
288292

289293
# Initialize traits with special arguments before the generic loop

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from roborock.data import RoborockDockTypeCode
8+
from roborock.device_features import RoborockDockFeatures
89
from roborock.devices.device import RoborockDevice
910
from roborock.devices.traits.v1.mop_dryer import MopDryerTrait
1011
from roborock.roborock_typing import RoborockCommand
@@ -164,3 +165,26 @@ async def test_dry_cycle(
164165
mock_rpc_channel.send_command.assert_called_with(
165166
RoborockCommand.APP_SET_DRYER_STATUS, params={"status": expected_status}
166167
)
168+
169+
170+
@pytest.mark.parametrize(
171+
("supports_drying", "expected"),
172+
[
173+
pytest.param(None, False, id="feature_not_reported"),
174+
pytest.param(False, False, id="feature_absent"),
175+
pytest.param(True, True, id="optional_dryer_module"),
176+
],
177+
)
178+
def test_trait_gate_with_optional_dryer_module(supports_drying: bool | None, expected: bool) -> None:
179+
"""The o3 dock is dryable when the device advertises drying support.
180+
181+
The o3 Empty Wash Fill dock is collect+wash only, so drying requires the
182+
optional dryer module (e.g. HADM02RR). The device reports that through the
183+
``is_supported_drying`` device feature instead of the dock type.
184+
"""
185+
dock_features = RoborockDockFeatures.from_dock_type(
186+
RoborockDockTypeCode.o3_dock,
187+
supports_drying=supports_drying,
188+
)
189+
190+
assert MopDryerTrait.requires_dock_features(dock_features) is expected

‎tests/test_supported_features.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,23 @@ def test_dock_features(dock_type: RoborockDockTypeCode, is_collectable: bool, is
311311
assert is_wash_n_fill_dock(dock_type) is dock_features.is_washable
312312

313313

314+
def test_dock_drying_depends_on_device_feature() -> None:
315+
"""Drying can come from an optional module rather than the dock family.
316+
317+
The o3 Empty Wash Fill dock does not dry by itself, but it supports the
318+
separately sold dryer module (e.g. HADM02RR). The device advertises that
319+
capability through the ``is_supported_drying`` device feature, so the dock
320+
type alone must not decide.
321+
"""
322+
assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock).is_dryable is False
323+
assert (
324+
RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock, supports_drying=False).is_dryable is False
325+
)
326+
assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock, supports_drying=True).is_dryable is True
327+
# Dock families that dry on their own are unaffected by the flag.
328+
assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o4_dock, supports_drying=False).is_dryable is True
329+
330+
314331
def test_all_rr_api_dock_types_are_mapped() -> None:
315332
"""Keep the enum synchronized with the RR_API DockConfigs snapshot."""
316333
mapped_docks = {

0 commit comments

Comments
 (0)