From 9d53c88cc65bd137046718fc59b623cc1abf41be Mon Sep 17 00:00:00 2001 From: Harry Coureau Date: Sun, 15 Nov 2026 15:19:48 +0000 Subject: [PATCH] fix(v1): update wash towel mode after setting it WashTowelModeTrait.set_wash_towel_mode sent the command but left wash_mode unchanged, so the trait kept reporting the previous mode until the next refresh. Update wash_mode optimistically after the command, like the other V1 trait setters. --- roborock/devices/traits/v1/wash_towel_mode.py | 2 ++ tests/devices/traits/v1/test_wash_towel_mode.py | 1 + 2 files changed, 3 insertions(+) diff --git a/roborock/devices/traits/v1/wash_towel_mode.py b/roborock/devices/traits/v1/wash_towel_mode.py index 909e96b68..a97ae6cb0 100644 --- a/roborock/devices/traits/v1/wash_towel_mode.py +++ b/roborock/devices/traits/v1/wash_towel_mode.py @@ -43,6 +43,8 @@ def wash_towel_mode_options(self) -> list[WashTowelModes]: async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: """Set the wash towel mode.""" await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code}) + # Optimistic update to avoid an extra refresh + self.wash_mode = mode async def start_wash(self) -> None: """Start washing the mop.""" diff --git a/tests/devices/traits/v1/test_wash_towel_mode.py b/tests/devices/traits/v1/test_wash_towel_mode.py index 8395c70ce..637992c66 100644 --- a/tests/devices/traits/v1/test_wash_towel_mode.py +++ b/tests/devices/traits/v1/test_wash_towel_mode.py @@ -89,6 +89,7 @@ async def test_set_wash_towel_mode( mock_rpc_channel.send_command.assert_called_with( RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": wash_mode.code} ) + assert wash_towel_mode.wash_mode == wash_mode @pytest.mark.parametrize(