roborock.devices.traits.v1.wash_towel_mode
Trait for wash towel mode.
1"""Trait for wash towel mode.""" 2 3from functools import cached_property 4from typing import Self 5 6from roborock.data import WashTowelMode, WashTowelModes, get_wash_towel_modes 7from roborock.device_features import RoborockDockFeatures 8from roborock.devices.traits.v1 import common 9from roborock.devices.traits.v1.device_features import DeviceFeaturesTrait 10from roborock.roborock_typing import RoborockCommand 11 12 13def _supports_wash_towel_mode(dock_features: RoborockDockFeatures) -> bool: 14 return dock_features.is_washable 15 16 17class WashTowelModeTrait(WashTowelMode, common.V1TraitMixin): 18 """Trait for wash towel mode.""" 19 20 command = RoborockCommand.GET_WASH_TOWEL_MODE 21 converter = common.DefaultConverter(WashTowelMode) 22 requires_dock_features = _supports_wash_towel_mode 23 24 def __init__( 25 self, 26 device_feature_trait: DeviceFeaturesTrait, 27 ) -> None: 28 super().__init__() 29 self.device_feature_trait = device_feature_trait 30 31 def _parse_response(self, response: common.V1ResponseData) -> Self: 32 """Parse the response from the device into a WashTowelMode object.""" 33 if isinstance(response, list): 34 response = response[0] 35 if isinstance(response, dict): 36 return WashTowelMode.from_dict(response) 37 raise ValueError(f"Unexpected wash towel mode format: {response!r}") 38 39 @cached_property 40 def wash_towel_mode_options(self) -> list[WashTowelModes]: 41 return get_wash_towel_modes(self.device_feature_trait) 42 43 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 44 """Set the wash towel mode.""" 45 await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code}) 46 47 async def start_wash(self) -> None: 48 """Start washing the mop.""" 49 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH) 50 51 async def stop_wash(self) -> None: 52 """Stop washing the mop.""" 53 await self.rpc_channel.send_command(RoborockCommand.APP_STOP_WASH)
class
WashTowelModeTrait(roborock.data.v1.v1_containers.WashTowelMode, roborock.devices.traits.v1.common.V1TraitMixin):
18class WashTowelModeTrait(WashTowelMode, common.V1TraitMixin): 19 """Trait for wash towel mode.""" 20 21 command = RoborockCommand.GET_WASH_TOWEL_MODE 22 converter = common.DefaultConverter(WashTowelMode) 23 requires_dock_features = _supports_wash_towel_mode 24 25 def __init__( 26 self, 27 device_feature_trait: DeviceFeaturesTrait, 28 ) -> None: 29 super().__init__() 30 self.device_feature_trait = device_feature_trait 31 32 def _parse_response(self, response: common.V1ResponseData) -> Self: 33 """Parse the response from the device into a WashTowelMode object.""" 34 if isinstance(response, list): 35 response = response[0] 36 if isinstance(response, dict): 37 return WashTowelMode.from_dict(response) 38 raise ValueError(f"Unexpected wash towel mode format: {response!r}") 39 40 @cached_property 41 def wash_towel_mode_options(self) -> list[WashTowelModes]: 42 return get_wash_towel_modes(self.device_feature_trait) 43 44 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 45 """Set the wash towel mode.""" 46 await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code}) 47 48 async def start_wash(self) -> None: 49 """Start washing the mop.""" 50 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH) 51 52 async def stop_wash(self) -> None: 53 """Stop washing the mop.""" 54 await self.rpc_channel.send_command(RoborockCommand.APP_STOP_WASH)
Trait for wash towel mode.
WashTowelModeTrait( device_feature_trait: roborock.devices.traits.v1.device_features.DeviceFeaturesTrait)
25 def __init__( 26 self, 27 device_feature_trait: DeviceFeaturesTrait, 28 ) -> None: 29 super().__init__() 30 self.device_feature_trait = device_feature_trait
Initialize the V1TraitMixin.
command =
<RoborockCommand.GET_WASH_TOWEL_MODE: 'get_wash_towel_mode'>
The RoborockCommand used to fetch the trait data from the device (internal only).
converter =
DefaultConverter
The converter used to parse the response from the device (internal only).
wash_towel_mode_options: list[roborock.data.v1.v1_clean_modes.WashTowelModes]
44 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 45 """Set the wash towel mode.""" 46 await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code})
Set the wash towel mode.
async def
start_wash(self) -> None:
48 async def start_wash(self) -> None: 49 """Start washing the mop.""" 50 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH)
Start washing the mop.