22
33from __future__ import annotations
44
5+ from types import MappingProxyType
56from typing import TYPE_CHECKING , Any
67
8+ from deebot_client .command import InitParam
79from deebot_client .events import (
810 WaterAmount ,
911 WaterInfoEvent ,
1012)
1113from deebot_client .message import HandlingResult
14+ from deebot_client .util import get_enum
1215
13- from .common import XmlGetCommand
16+ from .common import XmlGetCommand , XmlSetCommand
1417
1518if TYPE_CHECKING :
1619 from xml .etree .ElementTree import Element
@@ -47,6 +50,23 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
4750 return HandlingResult .success ()
4851
4952
53+ class SetWaterPermeability (XmlSetCommand ):
54+ """SetWaterPermeability command."""
55+
56+ NAME = "SetWaterPermeability"
57+ get_command = GetWaterPermeability
58+ _mqtt_params = MappingProxyType (
59+ {
60+ "amount" : InitParam (WaterAmount ),
61+ }
62+ )
63+
64+ def __init__ (self , amount : WaterAmount | str ) -> None :
65+ if isinstance (amount , str ):
66+ amount = get_enum (WaterAmount , amount )
67+ super ().__init__ ({"v" : str (amount .value )})
68+
69+
5070class GetWaterBoxInfo (XmlGetCommand ):
5171 """GetWaterBoxInfo command."""
5272
@@ -60,11 +80,7 @@ def handle_set_args(
6080
6181 :return: A message response
6282 """
63- event_bus .notify (
64- WaterInfoEvent (
65- amount = WaterAmount .HIGH , mop_attached = (str (args ["on" ]) != "0" )
66- )
67- )
83+ event_bus .notify (WaterInfoEvent (mop_attached = (str (args ["on" ]) != "0" )))
6884 return HandlingResult .success ()
6985
7086 @classmethod
@@ -76,7 +92,5 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
7692 if xml .attrib .get ("ret" ) != "ok" or not (on := xml .attrib .get ("on" )):
7793 return HandlingResult .analyse ()
7894
79- event_bus .notify (
80- WaterInfoEvent (amount = WaterAmount .HIGH , mop_attached = on != "0" )
81- )
95+ event_bus .notify (WaterInfoEvent (mop_attached = on != "0" ))
8296 return HandlingResult .success ()
0 commit comments