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 is_wash_n_fill_dock 8from roborock.devices.traits.v1 import common 9from roborock.devices.traits.v1.device_features import DeviceFeaturesTrait 10from roborock.roborock_typing import RoborockCommand 11 12 13class WashTowelModeTrait(WashTowelMode, common.V1TraitMixin): 14 """Trait for wash towel mode.""" 15 16 command = RoborockCommand.GET_WASH_TOWEL_MODE 17 converter = common.DefaultConverter(WashTowelMode) 18 requires_dock_type = is_wash_n_fill_dock 19 20 def __init__( 21 self, 22 device_feature_trait: DeviceFeaturesTrait, 23 ) -> None: 24 super().__init__() 25 self.device_feature_trait = device_feature_trait 26 27 def _parse_response(self, response: common.V1ResponseData) -> Self: 28 """Parse the response from the device into a WashTowelMode object.""" 29 if isinstance(response, list): 30 response = response[0] 31 if isinstance(response, dict): 32 return WashTowelMode.from_dict(response) 33 raise ValueError(f"Unexpected wash towel mode format: {response!r}") 34 35 @cached_property 36 def wash_towel_mode_options(self) -> list[WashTowelModes]: 37 return get_wash_towel_modes(self.device_feature_trait) 38 39 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 40 """Set the wash towel mode.""" 41 await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code}) 42 43 async def start_wash(self) -> None: 44 """Start washing the mop.""" 45 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH) 46 47 async def stop_wash(self) -> None: 48 """Stop washing the mop.""" 49 await self.rpc_channel.send_command(RoborockCommand.APP_STOP_WASH)
class
WashTowelModeTrait(roborock.data.v1.v1_containers.WashTowelMode, roborock.devices.traits.v1.common.V1TraitMixin):
14class WashTowelModeTrait(WashTowelMode, common.V1TraitMixin): 15 """Trait for wash towel mode.""" 16 17 command = RoborockCommand.GET_WASH_TOWEL_MODE 18 converter = common.DefaultConverter(WashTowelMode) 19 requires_dock_type = is_wash_n_fill_dock 20 21 def __init__( 22 self, 23 device_feature_trait: DeviceFeaturesTrait, 24 ) -> None: 25 super().__init__() 26 self.device_feature_trait = device_feature_trait 27 28 def _parse_response(self, response: common.V1ResponseData) -> Self: 29 """Parse the response from the device into a WashTowelMode object.""" 30 if isinstance(response, list): 31 response = response[0] 32 if isinstance(response, dict): 33 return WashTowelMode.from_dict(response) 34 raise ValueError(f"Unexpected wash towel mode format: {response!r}") 35 36 @cached_property 37 def wash_towel_mode_options(self) -> list[WashTowelModes]: 38 return get_wash_towel_modes(self.device_feature_trait) 39 40 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 41 """Set the wash towel mode.""" 42 await self.rpc_channel.send_command(RoborockCommand.SET_WASH_TOWEL_MODE, params={"wash_mode": mode.code}) 43 44 async def start_wash(self) -> None: 45 """Start washing the mop.""" 46 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH) 47 48 async def stop_wash(self) -> None: 49 """Stop washing the mop.""" 50 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)
21 def __init__( 22 self, 23 device_feature_trait: DeviceFeaturesTrait, 24 ) -> None: 25 super().__init__() 26 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).
660def is_wash_n_fill_dock(dock_type: RoborockDockTypeCode) -> bool: 661 """Check if the dock type is a wash and fill dock.""" 662 return dock_type in WASH_N_FILL_DOCK_TYPES
Check if the dock type is a wash and fill dock.
wash_towel_mode_options: list[roborock.data.v1.v1_clean_modes.WashTowelModes]
40 async def set_wash_towel_mode(self, mode: WashTowelModes) -> None: 41 """Set the wash towel mode.""" 42 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:
44 async def start_wash(self) -> None: 45 """Start washing the mop.""" 46 await self.rpc_channel.send_command(RoborockCommand.APP_START_WASH)
Start washing the mop.