diff --git a/miio/integrations/vacuum/roborock/tests/test_vacuum.py b/miio/integrations/vacuum/roborock/tests/test_vacuum.py index 80e5f18a2..8b381994f 100644 --- a/miio/integrations/vacuum/roborock/tests/test_vacuum.py +++ b/miio/integrations/vacuum/roborock/tests/test_vacuum.py @@ -457,7 +457,7 @@ def test_set_mop_dryer_enabled_model_check(self): def test_set_mop_dryer_dry_time_model_check(self): """Test Roborock S7 check when setting mop dryer dry time.""" with pytest.raises(UnsupportedFeatureException): - self.device.set_mop_dryer_dry_time(dry_time=2) + self.device.set_mop_dryer_dry_time(dry_time_seconds=10800) def test_start_mop_drying_model_check(self): """Test Roborock S7 check when starting mop drying.""" @@ -528,15 +528,23 @@ def test_mop_dryer_is_drying(self): def test_mop_dryer_remaining_seconds(self): """Test getting mop dryer remaining seconds.""" - assert self.device.status().mop_dryer_remaining_seconds == 3600 + assert self.device.status().mop_dryer_remaining_seconds == datetime.timedelta( + seconds=3600 + ) def test_set_mop_dryer_enabled_model_check(self): """Test setting mop dryer enabled.""" - assert self.device.set_mop_dryer_enabled(enabled=True) + with patch.object(self.device, "send", return_value=["ok"]) as mock_method: + assert self.device.set_mop_dryer_enabled(enabled=False) + mock_method.assert_called_once_with("app_set_dryer_setting", {"status": 0}) def test_set_mop_dryer_dry_time_model_check(self): """Test setting mop dryer dry time.""" - assert self.device.set_mop_dryer_dry_time(dry_time=2) + with patch.object(self.device, "send", return_value=["ok"]) as mock_method: + assert self.device.set_mop_dryer_dry_time(dry_time_seconds=14400) + mock_method.assert_called_once_with( + "app_set_dryer_setting", {"on": {"dry_time": 14400}} + ) def test_start_mop_drying_model_check(self): """Test starting mop drying.""" diff --git a/miio/integrations/vacuum/roborock/vacuum.py b/miio/integrations/vacuum/roborock/vacuum.py index a7891c122..d0867c803 100644 --- a/miio/integrations/vacuum/roborock/vacuum.py +++ b/miio/integrations/vacuum/roborock/vacuum.py @@ -965,11 +965,6 @@ def _verify_mop_dryer_supported(self) -> None: if self.model not in [ROCKROBO_S7, ROCKROBO_S7_MAXV]: raise UnsupportedFeatureException("Dryer not supported by %s", self.model) - # check if `dry_status` attribute is in status response - # this a good indication if the add-on has been installed - if self.status().is_mop_drying is None: - raise UnsupportedFeatureException("Mop dryer add-on not installed") - @command() def mop_dryer_settings(self) -> MopDryerSettings: """Get mop dryer settings.""" @@ -983,11 +978,13 @@ def set_mop_dryer_enabled(self, enabled: bool) -> bool: return self.send("app_set_dryer_setting", {"status": int(enabled)})[0] == "ok" @command(click.argument("dry_time", type=int)) - def set_mop_dryer_dry_time(self, dry_time: int) -> bool: + def set_mop_dryer_dry_time(self, dry_time_seconds: int) -> bool: """Set mop dryer add-on dry time.""" self._verify_mop_dryer_supported() return ( - self.send("app_set_dryer_setting", {"on": {"dry_time": dry_time * 3600}})[0] + self.send("app_set_dryer_setting", {"on": {"dry_time": dry_time_seconds}})[ + 0 + ] == "ok" ) diff --git a/miio/integrations/vacuum/roborock/vacuumcontainers.py b/miio/integrations/vacuum/roborock/vacuumcontainers.py index 660830f93..6b7e712f9 100644 --- a/miio/integrations/vacuum/roborock/vacuumcontainers.py +++ b/miio/integrations/vacuum/roborock/vacuumcontainers.py @@ -430,10 +430,10 @@ def is_mop_drying(self) -> Optional[bool]: entity_category="diagnostic", enabled_default=False, ) - def mop_dryer_remaining_seconds(self) -> Optional[int]: + def mop_dryer_remaining_seconds(self) -> Optional[timedelta]: """Return remaining mop drying seconds.""" if "rdt" in self.data: - return self.data["rdt"] + return pretty_seconds(self.data["rdt"]) return None @@ -1006,13 +1006,13 @@ def enabled(self) -> bool: "Mop dry time", setter_name="set_mop_dryer_dry_time", icon="mdi:fan", - unit="hour", - min_value=2, - max_value=4, - step=1, + unit="s", + min_value=7200, + max_value=14400, + step=3600, entity_category="config", enabled_default=False, ) - def dry_time(self) -> bool: + def dry_time(self) -> timedelta: """Return mop dry time.""" - return self.data["on"]["dry_time"] * 3600 + return pretty_seconds(self.data["on"]["dry_time"])