diff --git a/deebot_client/commands/xml/__init__.py b/deebot_client/commands/xml/__init__.py
index 4541cba5..ba5c85e4 100644
--- a/deebot_client/commands/xml/__init__.py
+++ b/deebot_client/commands/xml/__init__.py
@@ -8,7 +8,7 @@
from .charge_state import GetChargeState
from .error import GetError
-from .fan_speed import GetFanSpeed, SetFanSpeed
+from .fan_speed import GetCleanSpeed, SetCleanSpeed
from .pos import GetPos
from .stats import GetCleanSum
@@ -16,17 +16,19 @@
from .common import XmlCommand
__all__ = [
+ "GetCleanSpeed",
+ "SetCleanSpeed",
"GetChargeState",
"GetCleanSum",
"GetError",
- "GetFanSpeed",
- "SetFanSpeed",
"GetPos",
]
# fmt: off
# ordered by file asc
_COMMANDS: list[type[XmlCommand]] = [
+ GetCleanSpeed,
+ SetCleanSpeed,
GetError,
]
# fmt: on
diff --git a/deebot_client/commands/xml/fan_speed.py b/deebot_client/commands/xml/fan_speed.py
index 649d20d0..1a0751bc 100644
--- a/deebot_client/commands/xml/fan_speed.py
+++ b/deebot_client/commands/xml/fan_speed.py
@@ -17,8 +17,8 @@
from deebot_client.event_bus import EventBus
-class GetFanSpeed(XmlCommandWithMessageHandling):
- """GetFanSpeed command."""
+class GetCleanSpeed(XmlCommandWithMessageHandling):
+ """GetCleanSpeed command."""
name = "GetCleanSpeed"
@@ -35,9 +35,9 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
match speed.lower():
case "standard":
- event = FanSpeedEvent(FanSpeedLevel.NORMAL)
+ event = FanSpeedEvent(FanSpeedLevel.STANDARD)
case "strong":
- event = FanSpeedEvent(FanSpeedLevel.MAX)
+ event = FanSpeedEvent(FanSpeedLevel.STRONG)
if event:
event_bus.notify(event)
@@ -46,15 +46,15 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
return HandlingResult.analyse()
-class SetFanSpeed(XmlSetCommand):
- """Set fan speed command."""
+class SetCleanSpeed(XmlSetCommand):
+ """Set clean speed command."""
name = "SetCleanSpeed"
- get_command = GetFanSpeed
+ get_command = GetCleanSpeed
_mqtt_params = MappingProxyType({"speed": InitParam(FanSpeedLevel)})
def __init__(self, speed: FanSpeedLevel | str) -> None:
- if isinstance(speed, int):
- speed = "strong" if speed in [1, 2] else "normal"
+ if isinstance(speed, FanSpeedLevel):
+ speed = speed.name.lower()
super().__init__({"speed": speed})
diff --git a/deebot_client/events/fan_speed.py b/deebot_client/events/fan_speed.py
index 4a8f599e..00fcc3bb 100644
--- a/deebot_client/events/fan_speed.py
+++ b/deebot_client/events/fan_speed.py
@@ -14,8 +14,10 @@ class FanSpeedLevel(IntEnum):
# Values should be sort from low to high on their meanings
QUIET = 1000
+ STANDARD = -1
NORMAL = 0
MAX = 1
+ STRONG = -2
MAX_PLUS = 2
diff --git a/tests/commands/xml/test_fan_speed.py b/tests/commands/xml/test_fan_speed.py
index 740091fc..140fbdb1 100644
--- a/tests/commands/xml/test_fan_speed.py
+++ b/tests/commands/xml/test_fan_speed.py
@@ -5,14 +5,12 @@
import pytest
from deebot_client.command import CommandResult
-from deebot_client.commands.xml import GetFanSpeed
-from deebot_client.commands.xml.fan_speed import SetFanSpeed
+from deebot_client.commands.xml import GetCleanSpeed, SetCleanSpeed
from deebot_client.events import FanSpeedEvent, FanSpeedLevel
from deebot_client.message import HandlingState
from tests.commands import assert_command
from . import get_request_xml
-from ..json import assert_set_command
if TYPE_CHECKING:
from deebot_client.events.base import Event
@@ -21,14 +19,14 @@
@pytest.mark.parametrize(
("speed", "expected_event"),
[
- ("standard", FanSpeedEvent(FanSpeedLevel.NORMAL)),
- ("strong", FanSpeedEvent(FanSpeedLevel.MAX)),
+ ("standard", FanSpeedEvent(FanSpeedLevel.STANDARD)),
+ ("strong", FanSpeedEvent(FanSpeedLevel.STRONG)),
],
ids=["standard", "strong"],
)
async def test_get_fan_speed(speed: str, expected_event: Event) -> None:
json = get_request_xml(f"")
- await assert_command(GetFanSpeed(), json, expected_event)
+ await assert_command(GetCleanSpeed(), json, expected_event)
@pytest.mark.parametrize(
@@ -39,18 +37,20 @@ async def test_get_fan_speed(speed: str, expected_event: Event) -> None:
async def test_get_fan_speed_error(xml: str) -> None:
json = get_request_xml(xml)
await assert_command(
- GetFanSpeed(),
+ GetCleanSpeed(),
json,
None,
command_result=CommandResult(HandlingState.ANALYSE_LOGGED),
)
+
async def test_set_fan_speed() -> None:
- command = SetFanSpeed(FanSpeedLevel.MAX)
+ command = SetCleanSpeed(FanSpeedLevel.STRONG)
json = get_request_xml("")
await assert_command(command, json, None, command_result=CommandResult(HandlingState.SUCCESS))
+
async def test_set_fan_speed_error() -> None:
- command = SetFanSpeed("invalid")
+ command = SetCleanSpeed("invalid")
json = get_request_xml("")
await assert_command(command, json, None, command_result=CommandResult(HandlingState.FAILED))