From 003f953568db9f8910b14121e801cb72c24af785 Mon Sep 17 00:00:00 2001 From: ryanmac8 <7333067+ryanmac8@users.noreply.github.com> Date: Tue, 17 Nov 2026 19:48:43 -0500 Subject: [PATCH] fix: treat o3 docks as dryable when the device supports drying --- roborock/device_features.py | 18 ++++++++++++++--- roborock/devices/traits/v1/__init__.py | 6 +++++- tests/devices/traits/v1/test_mop_dryer.py | 24 +++++++++++++++++++++++ tests/test_supported_features.py | 17 ++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/roborock/device_features.py b/roborock/device_features.py index 160d14cc5..fcf3f13c6 100644 --- a/roborock/device_features.py +++ b/roborock/device_features.py @@ -876,12 +876,24 @@ class RoborockDockFeatures: dock_type: RoborockDockTypeCode has_am: bool | None = None + supports_drying: bool | None = None + """Whether the device advertises the drying device feature. + + Used for docks that can dry only when an optional dryer module is + installed (e.g. the HADM02RR module on the o3 Empty Wash Fill dock), where + the dock type alone cannot answer the question. + """ @classmethod @cache - def from_dock_type(cls, dock_type: RoborockDockTypeCode | None, has_am: bool | None = None) -> Self: + def from_dock_type( + cls, + dock_type: RoborockDockTypeCode | None, + has_am: bool | None = None, + supports_drying: bool | None = None, + ) -> Self: """Return cached capabilities for a V1 dock type.""" - return cls(dock_type or RoborockDockTypeCode.o0_dock, has_am=has_am) + return cls(dock_type or RoborockDockTypeCode.o0_dock, has_am=has_am, supports_drying=supports_drying) def _matches_am_variant(self, dock_types: set[RoborockDockTypeCode]) -> bool: return self.has_am is True and self.dock_type in dock_types @@ -919,7 +931,7 @@ def is_washable(self) -> bool: @property def is_dryable(self) -> bool: - return self.is_collect_wash_dry + return self.is_collect_wash_dry or self.supports_drying is True @property def is_only_x_series(self) -> bool: diff --git a/roborock/devices/traits/v1/__init__.py b/roborock/devices/traits/v1/__init__.py index 28c404d65..b4562c1a4 100644 --- a/roborock/devices/traits/v1/__init__.py +++ b/roborock/devices/traits/v1/__init__.py @@ -283,7 +283,11 @@ async def discover_features(self) -> None: await self.device_features.refresh() # Dock type also acts like a device feature for some traits. dock_type = await self._dock_type() - dock_features = RoborockDockFeatures.from_dock_type(dock_type, has_am=self.status.has_am) + dock_features = RoborockDockFeatures.from_dock_type( + dock_type, + has_am=self.status.has_am, + supports_drying=self.device_features.is_supported_drying, + ) self.device_features.dock_features = dock_features # Initialize traits with special arguments before the generic loop diff --git a/tests/devices/traits/v1/test_mop_dryer.py b/tests/devices/traits/v1/test_mop_dryer.py index a4b33f4f7..cd48c6125 100644 --- a/tests/devices/traits/v1/test_mop_dryer.py +++ b/tests/devices/traits/v1/test_mop_dryer.py @@ -5,6 +5,7 @@ import pytest from roborock.data import RoborockDockTypeCode +from roborock.device_features import RoborockDockFeatures from roborock.devices.device import RoborockDevice from roborock.devices.traits.v1.mop_dryer import MopDryerTrait from roborock.roborock_typing import RoborockCommand @@ -164,3 +165,26 @@ async def test_dry_cycle( mock_rpc_channel.send_command.assert_called_with( RoborockCommand.APP_SET_DRYER_STATUS, params={"status": expected_status} ) + + +@pytest.mark.parametrize( + ("supports_drying", "expected"), + [ + pytest.param(None, False, id="feature_not_reported"), + pytest.param(False, False, id="feature_absent"), + pytest.param(True, True, id="optional_dryer_module"), + ], +) +def test_trait_gate_with_optional_dryer_module(supports_drying: bool | None, expected: bool) -> None: + """The o3 dock is dryable when the device advertises drying support. + + The o3 Empty Wash Fill dock is collect+wash only, so drying requires the + optional dryer module (e.g. HADM02RR). The device reports that through the + ``is_supported_drying`` device feature instead of the dock type. + """ + dock_features = RoborockDockFeatures.from_dock_type( + RoborockDockTypeCode.o3_dock, + supports_drying=supports_drying, + ) + + assert MopDryerTrait.requires_dock_features(dock_features) is expected diff --git a/tests/test_supported_features.py b/tests/test_supported_features.py index b427ccc5d..a278ceb20 100644 --- a/tests/test_supported_features.py +++ b/tests/test_supported_features.py @@ -311,6 +311,23 @@ def test_dock_features(dock_type: RoborockDockTypeCode, is_collectable: bool, is assert is_wash_n_fill_dock(dock_type) is dock_features.is_washable +def test_dock_drying_depends_on_device_feature() -> None: + """Drying can come from an optional module rather than the dock family. + + The o3 Empty Wash Fill dock does not dry by itself, but it supports the + separately sold dryer module (e.g. HADM02RR). The device advertises that + capability through the ``is_supported_drying`` device feature, so the dock + type alone must not decide. + """ + assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock).is_dryable is False + assert ( + RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock, supports_drying=False).is_dryable is False + ) + assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o3_dock, supports_drying=True).is_dryable is True + # Dock families that dry on their own are unaffected by the flag. + assert RoborockDockFeatures.from_dock_type(RoborockDockTypeCode.o4_dock, supports_drying=False).is_dryable is True + + def test_all_rr_api_dock_types_are_mapped() -> None: """Keep the enum synchronized with the RR_API DockConfigs snapshot.""" mapped_docks = {