Skip to content

Commit 30ae010

Browse files
committed
fix: address dock feature review comments
1 parent f430a07 commit 30ae010

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

roborock/data/v1/v1_containers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def current_map(self) -> int | None:
241241

242242
@property
243243
def has_am(self) -> bool | None:
244-
if not self.dss:
244+
if self.dss is None:
245245
return None
246246
return (self.dss & 3) == 2
247247

@@ -384,7 +384,7 @@ def current_map(self) -> int | None:
384384

385385
@property
386386
def has_am(self) -> bool | None:
387-
if not self.dss:
387+
if self.dss is None:
388388
return None
389389
return (self.dss & 3) == 2
390390

roborock/device_features.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,18 @@ def is_hatch_door_dock_cool_fan_supported(self) -> bool:
846846
@property
847847
def is_special_support_wash_temp(self) -> bool:
848848
return self.dock_type in _SPECIAL_WASH_TEMP_DOCK_TYPES
849+
850+
851+
WASH_N_FILL_DOCK_TYPES = [
852+
dock_type for dock_type in RoborockDockTypeCode if RoborockDockFeatures.from_dock_type(dock_type).is_washable
853+
]
854+
855+
856+
def is_wash_n_fill_dock(dock_type: RoborockDockTypeCode) -> bool:
857+
"""Check if the dock type is a wash and fill dock."""
858+
return RoborockDockFeatures.from_dock_type(dock_type).is_washable
859+
860+
861+
def is_valid_dock(dock_type: RoborockDockTypeCode) -> bool:
862+
"""Check if device supports a dock."""
863+
return RoborockDockFeatures.from_dock_type(dock_type).has_dock

roborock/testing/v1_simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _serialize_dataclass(obj: Any) -> dict[str, Any]:
8181
home_sec_enable_password=0,
8282
adbumper_status=[0, 0, 0],
8383
water_shortage_status=0,
84-
dock_type=RoborockDockTypeCode.s8_dock,
84+
dock_type=RoborockDockTypeCode.o4_dock,
8585
dust_collection_status=0,
8686
auto_dust_collection=1,
8787
avoid_count=19,

tests/data/v1/test_v1_containers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ def test_qrevo_s5v_dock_type():
272272
assert s.dock_type.value == 22
273273

274274

275+
def test_has_am_dss_zero_is_not_missing():
276+
modified_status = STATUS.copy()
277+
modified_status["dss"] = 0
278+
279+
assert S7MaxVStatus.from_dict(modified_status).has_am is False
280+
assert StatusV2.from_dict(modified_status).has_am is False
281+
282+
275283
def test_multi_maps_list_info(snapshot: SnapshotAssertion) -> None:
276284
"""Test that MultiMapsListInfo can be deserialized correctly."""
277285
data = {

tests/test_supported_features.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from roborock import SHORT_MODEL_TO_ENUM
77
from roborock.data.code_mappings import RoborockProductNickname
88
from roborock.data.v1 import RoborockDockTypeCode
9-
from roborock.device_features import DeviceFeatures, RoborockDockFeatures
9+
from roborock.device_features import DeviceFeatures, RoborockDockFeatures, is_valid_dock, is_wash_n_fill_dock
1010
from tests import mock_data
1111

1212

@@ -117,6 +117,8 @@ def test_dock_features(dock_type: RoborockDockTypeCode, is_collectable: bool, is
117117
assert dock_features.has_dock is (dock_type not in {RoborockDockTypeCode.unknown, RoborockDockTypeCode.o0_dock})
118118
assert dock_features.is_collectable is is_collectable
119119
assert dock_features.is_washable is is_washable
120+
assert is_valid_dock(dock_type) is dock_features.has_dock
121+
assert is_wash_n_fill_dock(dock_type) is dock_features.is_washable
120122

121123

122124
def test_dock_feature_flags_from_rr_api() -> None:

0 commit comments

Comments
 (0)