Skip to content

Commit

Permalink
Add Support for Mop Auto-Wash Frequency (T30/X5 Omni)
Browse files Browse the repository at this point in the history
Contributes DeebotUniverse#555
- Add support for Mop Auto-Wash Frequency `setWashInterval`
  • Loading branch information
XxInvictus committed Dec 10, 2024
1 parent 3a373c0 commit 8e185be
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deebot_client/commands/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
GetMapTrace,
GetMinorMap,
)
from .mop_wash_frequency import GetMopWashFrequency, SetMopWashFrequency
from .moveup_warning import GetMoveUpWarning, SetMoveUpWarning
from .multimap_state import GetMultimapState, SetMultimapState
from .network import GetNetInfo
Expand Down Expand Up @@ -84,6 +85,7 @@
"GetMapSubSet",
"GetMapTrace",
"GetMinorMap",
"GetMopWashFrequency",
"GetMoveUpWarning",
"GetMultimapState",
"GetNetInfo",
Expand Down Expand Up @@ -111,6 +113,7 @@
"SetCutDirection",
"SetEfficiencyMode",
"SetFanSpeed",
"SetMopWashFrequency",
"SetMoveUpWarning",
"SetMultimapState",
"SetOta",
Expand Down Expand Up @@ -187,6 +190,9 @@
GetMapTrace,
GetMinorMap,

GetMopWashFrequency,
SetMopWashFrequency,

GetMoveUpWarning,
SetMoveUpWarning,

Expand Down
46 changes: 46 additions & 0 deletions deebot_client/commands/json/mop_wash_frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Mop Auto-Wash Frequency command module."""

from __future__ import annotations

from types import MappingProxyType
from typing import TYPE_CHECKING, Any

from deebot_client.command import InitParam
from deebot_client.events import MopWashFrequency, MopWashFrequencyEvent
from deebot_client.message import HandlingResult
from deebot_client.util import get_enum

from .common import JsonGetCommand, JsonSetCommand

if TYPE_CHECKING:
from deebot_client.event_bus import EventBus


class GetMopWashFrequency(JsonGetCommand):
"""Get Mop Auto-Wash Frequency command."""

name = "getMopWashFrequency"

@classmethod
def _handle_body_data_dict(
cls, event_bus: EventBus, data: dict[str, Any]
) -> HandlingResult:
"""Handle message->body->data and notify the correct event subscribers.
:return: A message response
"""
event_bus.notify(MopWashFrequencyEvent(MopWashFrequency(int(data["interval"]))))
return HandlingResult.success()


class SetMopWashFrequency(JsonSetCommand):
"""Set Mop Auto-Wash Frequency command."""

name = "setMopWashFrequency"
get_command = GetMopWashFrequency
_mqtt_params = MappingProxyType({"interval": InitParam(MopWashFrequency)})

def __init__(self, interval: MopWashFrequency | str) -> None:
if isinstance(interval, str):
interval = get_enum(MopWashFrequency, interval)
super().__init__({"interval": interval.value})
3 changes: 3 additions & 0 deletions deebot_client/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
PositionsEvent,
PositionType,
)
from .mop_wash_frequency import MopWashFrequency, MopWashFrequencyEvent
from .network import NetworkInfoEvent
from .water_info import SweepType, WaterAmount, WaterInfoEvent
from .work_mode import WorkMode, WorkModeEvent
Expand All @@ -47,6 +48,8 @@
"MapSubsetEvent",
"MapTraceEvent",
"MinorMapEvent",
"MopWashFrequency",
"MopWashFrequencyEvent",
"NetworkInfoEvent",
"Position",
"PositionType",
Expand Down
24 changes: 24 additions & 0 deletions deebot_client/events/mop_wash_frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Mop Auto-Wash Frequency event module."""

from __future__ import annotations

from dataclasses import dataclass
from enum import IntEnum, unique

from .base import Event


@unique
class MopWashFrequency(IntEnum):
"""Enum class for all possible mop auto-wash frequencies."""

TEN_MINUTES = 10
FIFTEEN_MINUTES = 15
TWENTY_FIVE_MINUTES = 25


@dataclass(frozen=True)
class MopWashFrequencyEvent(Event):
"""Mop Auto-Wash Frequency event representation."""

interval: MopWashFrequency

0 comments on commit 8e185be

Please sign in to comment.