Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions roborock/device_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Priority 1 — Capability Gating (AGENTS.md §3 Compound Capability & Feature Gating)

is_supported_drying (new_feature_info upper-32-bit flag 15) is a robot firmware capability bit rather than dynamic hardware detection of an installed dryer module—for example, tests/__snapshots__/test_supported_features.ambr shows is_supported_drying: True on S7 MaxV (roborock.vacuum.a27) and newer models regardless of which dock is attached.

With self.is_collect_wash_dry or self.supports_drying is True, a standalone robot with no dock (o0_dock / unknown) or a dust-only Auto-Empty Dock (o1_dock / oc_dock, such as S7 MaxV Plus) will report is_dryable == True and instantiate MopDryerTrait even though has_dock or is_washable is False.

In the Roborock app (RR_API), FM.isSupportedDrying() is only consulted on wash-capable dock screens (o2_dock via isPureWash, and o3_dock / isCollectWashDry via !isOldBelowO3()), never for o0_dock or pure-collect docks. Gating on self.is_washable fixes o3_dock (and o2_dock) without falsely enabling drying on dockless or collect-only setups:

Suggested change
return self.is_collect_wash_dry or self.supports_drying is True
return self.is_collect_wash_dry or (self.is_washable and self.supports_drying is True)


@property
def is_only_x_series(self) -> bool:
Expand Down
6 changes: 5 additions & 1 deletion roborock/devices/traits/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tests/devices/traits/v1/test_mop_dryer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
17 changes: 17 additions & 0 deletions tests/test_supported_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Gap: Please also assert that non-washable docks (o0_dock, unknown, o1_dock, oc_dock) remain is_dryable is False even when supports_drying=True, and that o2_dock behaves consistently with o3_dock.



def test_all_rr_api_dock_types_are_mapped() -> None:
"""Keep the enum synchronized with the RR_API DockConfigs snapshot."""
mapped_docks = {
Expand Down
Loading