From 3534d34e8e79fa00529cb8de6a0645bbd34ed259 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:42:30 +0100 Subject: [PATCH 01/20] Update capabilities.py - WashInterval --- deebot_client/capabilities.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deebot_client/capabilities.py b/deebot_client/capabilities.py index 01231821..f819b5e5 100644 --- a/deebot_client/capabilities.py +++ b/deebot_client/capabilities.py @@ -36,6 +36,7 @@ TrueDetectEvent, VoiceAssistantStateEvent, VolumeEvent, + WashIntervalEvent, WaterAmount, WaterInfoEvent, WorkMode, @@ -124,6 +125,7 @@ class CapabilityClean: count: CapabilitySet[CleanCountEvent, int] | None = None log: CapabilityEvent[CleanLogEvent] | None = None preference: CapabilitySetEnable[CleanPreferenceEvent] | None = None + wash_interval: CapabilitySet[WashIntervalEvent, int] | None = None work_mode: CapabilitySetTypes[WorkModeEvent, WorkMode] | None = None From 23fe3b8a54d7a500c558cde41792b65b35b88c87 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:47:31 +0100 Subject: [PATCH 02/20] Update __init__.py - Wash interval --- deebot_client/commands/json/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/deebot_client/commands/json/__init__.py b/deebot_client/commands/json/__init__.py index cb9f8e2f..b5a870a6 100644 --- a/deebot_client/commands/json/__init__.py +++ b/deebot_client/commands/json/__init__.py @@ -33,6 +33,7 @@ from .true_detect import GetTrueDetect, SetTrueDetect from .voice_assistant_state import GetVoiceAssistantState, SetVoiceAssistantState from .volume import GetVolume, SetVolume +from .wash_interval import GetWashInterval, SetWashInterval from .water_info import GetWaterInfo, SetWaterInfo from .work_mode import GetWorkMode, SetWorkMode @@ -81,6 +82,8 @@ "SetVoiceAssistantState", "GetVolume", "SetVolume", + "GetWashInterval", + "SetWashInterval", "GetWaterInfo", "SetWaterInfo", "GetWorkMode", @@ -158,6 +161,9 @@ GetVolume, SetVolume, + GetWashInterval, + SetWashInterval, + GetWaterInfo, SetWaterInfo, From de0f4d4daadea6f8cc6db19a7a15e82f507025c9 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:48:52 +0100 Subject: [PATCH 03/20] Create wash_interval.py - Wash interval --- deebot_client/commands/json/wash_interval.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 deebot_client/commands/json/wash_interval.py diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/deebot_client/commands/json/wash_interval.py @@ -0,0 +1 @@ + From 0c1b727ab66e118aedf04e8768fbc15fae411773 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:52:42 +0100 Subject: [PATCH 04/20] Update wash_interval.py - Wash interval --- deebot_client/commands/json/wash_interval.py | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 8b137891..6628aea5 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -1 +1,39 @@ +"""Pads cleaning interval commands.""" +from typing import Any +from deebot_client.command import InitParam +from deebot_client.event_bus import EventBus +from deebot_client.events.pads_cleaning_interval import PadsCleaningIntervalEvent +from deebot_client.message import HandlingResult, MessageBodyDataDict + +from .common import CommandWithMessageHandling, SetCommand + + +class GetWashInterval(CommandWithMessageHandling, MessageBodyDataDict): + """Get pads cleaning interval command.""" + + name = "getWashInterval" + + @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(WashIntervalEvent(int(data["interval"]))) + return HandlingResult.success() + + +class SeWashInterval(SetCommand): + """Set pads cleaning interval command.""" + + name = "setWashInterval" + get_command = GetWashInterval + _mqtt_params = {"interval": InitParam(int)} + + def __init__(self, interval: int) -> None: + if interval <= 0: + raise ValueError("'interval' must be positive") + super().__init__({"interval": interval}) From 45bd31b3383eafa993027b950d608d591280f229 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:19:00 +0100 Subject: [PATCH 05/20] Update __init__.py - Wash interval --- deebot_client/events/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deebot_client/events/__init__.py b/deebot_client/events/__init__.py index 607beefb..e8d88fd1 100644 --- a/deebot_client/events/__init__.py +++ b/deebot_client/events/__init__.py @@ -24,6 +24,7 @@ PositionType, ) from .network import NetworkInfoEvent +from .wash_interval import WashIntervalEvent from .water_info import WaterAmount, WaterInfoEvent from .work_mode import WorkMode, WorkModeEvent @@ -48,6 +49,7 @@ "Position", "PositionType", "PositionsEvent", + "WashIntervalEvent", "WaterAmount", "WaterInfoEvent", "WorkMode", From c3770527591be361b4de2d5f3273fef93ac032a1 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:19:31 +0100 Subject: [PATCH 06/20] Create wash_interval.py - Wash interval --- deebot_client/events/wash_interval.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 deebot_client/events/wash_interval.py diff --git a/deebot_client/events/wash_interval.py b/deebot_client/events/wash_interval.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/deebot_client/events/wash_interval.py @@ -0,0 +1 @@ + From cf4ff86535eaed109e3186b7391a8c860e5db5c3 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:20:12 +0100 Subject: [PATCH 07/20] Update wash_interval.py - Wash interval --- deebot_client/events/wash_interval.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deebot_client/events/wash_interval.py b/deebot_client/events/wash_interval.py index 8b137891..96bbe75e 100644 --- a/deebot_client/events/wash_interval.py +++ b/deebot_client/events/wash_interval.py @@ -1 +1,11 @@ +"""Cleaning pads interval event module.""" +from dataclasses import dataclass +from .base import Event + + +@dataclass(frozen=True) +class WashIntervalEvent(Event): + """Cleaning pads interval event representation.""" + + interval: int From 78ce0c233658c48de3dd5bd38990ebcd2e14d1f3 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:24:08 +0100 Subject: [PATCH 08/20] Update p1jij8.py - Wash interval --- deebot_client/hardware/deebot/p1jij8.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deebot_client/hardware/deebot/p1jij8.py b/deebot_client/hardware/deebot/p1jij8.py index 297153c5..a5c9f43e 100644 --- a/deebot_client/hardware/deebot/p1jij8.py +++ b/deebot_client/hardware/deebot/p1jij8.py @@ -49,6 +49,10 @@ from deebot_client.commands.json.stats import GetStats, GetTotalStats from deebot_client.commands.json.true_detect import GetTrueDetect, SetTrueDetect from deebot_client.commands.json.volume import GetVolume, SetVolume +from deebot_client.commands.json.wash_interval import ( + GetWashInterval, + SetWashInterval, +) from deebot_client.commands.json.water_info import GetWaterInfo, SetWaterInfo from deebot_client.commands.json.work_mode import GetWorkMode, SetWorkMode from deebot_client.const import DataType @@ -81,6 +85,7 @@ TotalStatsEvent, TrueDetectEvent, VolumeEvent, + WashIntervalEvent, WaterAmount, WaterInfoEvent, WorkMode, @@ -111,6 +116,11 @@ preference=CapabilitySetEnable( CleanPreferenceEvent, [GetCleanPreference()], SetCleanPreference ), + wash_interval=CapabilitySet( + event=WashIntervalEvent, + get=[GetWashInterval()], + set=SetWashInterval, + ), work_mode=CapabilitySetTypes( event=WorkModeEvent, get=[GetWorkMode()], From aa3d91ec2ac138b877545408534413e6f22ddeab Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:42:54 +0100 Subject: [PATCH 09/20] Create test_wash_interval.py - Wash interval --- tests/commands/json/test_wash_interval.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/commands/json/test_wash_interval.py diff --git a/tests/commands/json/test_wash_interval.py b/tests/commands/json/test_wash_interval.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/tests/commands/json/test_wash_interval.py @@ -0,0 +1 @@ + From 4ed8e2b0b4eb616f8b76700dc7586e8f43a6dcc2 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 16:48:55 +0100 Subject: [PATCH 10/20] Update test_wash_interval.py - Wash interval --- tests/commands/json/test_wash_interval.py | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/commands/json/test_wash_interval.py b/tests/commands/json/test_wash_interval.py index 8b137891..6b497162 100644 --- a/tests/commands/json/test_wash_interval.py +++ b/tests/commands/json/test_wash_interval.py @@ -1 +1,37 @@ +from typing import Any +import pytest + +from deebot_client.commands.json import GetWashInterval, SetWashInterval +from deebot_client.events import WashIntervalEvent +from tests.helpers import ( + get_request_json, + get_success_body, +) + +from . import assert_command, assert_set_command + + +@pytest.mark.parametrize( + ("json", "expected"), + [ + ({"interval": 6}, PadsCleaningIntervalEvent(6)), + ({"interval": 10}, PadsCleaningIntervalEvent(10)), + ], +) +async def test_GetPadsCleaningInterval( + json: dict[str, Any], expected: WashIntervalEvent +) -> None: + json = get_request_json(get_success_body(json)) + await assert_command(GetWashInterval(), json, expected) + + +async def test_SetWashInterval() -> None: + command = SetWashInterval(60) + args = {"interval": 60} + await assert_set_command(command, args, WashIntervalEvent(60)) + + +def test_SetWashInterval_invalid_value() -> None: + with pytest.raises(ValueError, match="'interval' must be positive"): + SetWashInterval(0) From c82254cad10e74b07a8e06153c1c9ca2eba44b28 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:16:50 +0100 Subject: [PATCH 11/20] Update wash_interval.py - Wash interval correction --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 6628aea5..6d6fa189 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -3,7 +3,7 @@ from deebot_client.command import InitParam from deebot_client.event_bus import EventBus -from deebot_client.events.pads_cleaning_interval import PadsCleaningIntervalEvent +from deebot_client.events.wash_interval import WashIntervalEvent from deebot_client.message import HandlingResult, MessageBodyDataDict from .common import CommandWithMessageHandling, SetCommand From e855c241096716b1491e10f1c54b3a749a35277d Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:20:59 +0100 Subject: [PATCH 12/20] Update wash_interval.py - Was interval correction --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 6d6fa189..df4d31a9 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -26,7 +26,7 @@ def _handle_body_data_dict( return HandlingResult.success() -class SeWashInterval(SetCommand): +class SetWashInterval(SetCommand): """Set pads cleaning interval command.""" name = "setWashInterval" From 17852386062541685e974168c8c9e4f6c43a8019 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:52:11 +0100 Subject: [PATCH 13/20] Update tests/commands/json/test_wash_interval.py Co-authored-by: Robert Resch --- tests/commands/json/test_wash_interval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/commands/json/test_wash_interval.py b/tests/commands/json/test_wash_interval.py index 6b497162..fea8e120 100644 --- a/tests/commands/json/test_wash_interval.py +++ b/tests/commands/json/test_wash_interval.py @@ -15,8 +15,8 @@ @pytest.mark.parametrize( ("json", "expected"), [ - ({"interval": 6}, PadsCleaningIntervalEvent(6)), - ({"interval": 10}, PadsCleaningIntervalEvent(10)), + ({"interval": 6}, WashIntervalEvent(6)), + ({"interval": 10}, WashIntervalEvent(10)), ], ) async def test_GetPadsCleaningInterval( From 85504195fde8c82df7449d552656eb434f6e802f Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:52:22 +0100 Subject: [PATCH 14/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 1 + 1 file changed, 1 insertion(+) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index df4d31a9..368fba87 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -1,4 +1,5 @@ """Pads cleaning interval commands.""" +from types import MappingProxyType from typing import Any from deebot_client.command import InitParam From 70938ebf7adf9d92be633a41e95fbf724cef1b17 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:52:32 +0100 Subject: [PATCH 15/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 368fba87..3656d07c 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -5,12 +5,12 @@ from deebot_client.command import InitParam from deebot_client.event_bus import EventBus from deebot_client.events.wash_interval import WashIntervalEvent -from deebot_client.message import HandlingResult, MessageBodyDataDict +from deebot_client.message import HandlingResult -from .common import CommandWithMessageHandling, SetCommand +from .common import JsonGetCommand, JsonSetCommand -class GetWashInterval(CommandWithMessageHandling, MessageBodyDataDict): +class GetWashInterval(JsonGetCommand): """Get pads cleaning interval command.""" name = "getWashInterval" From e21b21e930b5206e41f28e99d6770c386961e380 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:52:41 +0100 Subject: [PATCH 16/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 3656d07c..5ec24b89 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -27,7 +27,7 @@ def _handle_body_data_dict( return HandlingResult.success() -class SetWashInterval(SetCommand): +class SetWashInterval(JsonSetCommand): """Set pads cleaning interval command.""" name = "setWashInterval" From 8b948e91c18fff68a2fec71ab20aa0ed5764bcdb Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:52:55 +0100 Subject: [PATCH 17/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 5ec24b89..ce8ae03c 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -32,7 +32,7 @@ class SetWashInterval(JsonSetCommand): name = "setWashInterval" get_command = GetWashInterval - _mqtt_params = {"interval": InitParam(int)} + _mqtt_params = MappingProxyType({"interval": InitParam(int)}) def __init__(self, interval: int) -> None: if interval <= 0: From c94193cf1db14a31f69dce4bf405bbc4329bdd5f Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Fri, 29 Dec 2023 08:44:46 +0100 Subject: [PATCH 18/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index ce8ae03c..2a6db738 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -11,7 +11,7 @@ class GetWashInterval(JsonGetCommand): - """Get pads cleaning interval command.""" + """Get wash interval command.""" name = "getWashInterval" From 98392b163f390b6604c39ee658387e72837e5c08 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Fri, 29 Dec 2023 08:44:54 +0100 Subject: [PATCH 19/20] Update deebot_client/commands/json/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/commands/json/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/commands/json/wash_interval.py b/deebot_client/commands/json/wash_interval.py index 2a6db738..7a16bec3 100644 --- a/deebot_client/commands/json/wash_interval.py +++ b/deebot_client/commands/json/wash_interval.py @@ -28,7 +28,7 @@ def _handle_body_data_dict( class SetWashInterval(JsonSetCommand): - """Set pads cleaning interval command.""" + """Set wash interval command.""" name = "setWashInterval" get_command = GetWashInterval From 64d553e15c30818d72bf2806cdd0d5ef61604b52 Mon Sep 17 00:00:00 2001 From: NEVdataDyne <82730421+NEVdataDyne@users.noreply.github.com> Date: Fri, 29 Dec 2023 08:45:01 +0100 Subject: [PATCH 20/20] Update deebot_client/events/wash_interval.py Co-authored-by: Robert Resch --- deebot_client/events/wash_interval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deebot_client/events/wash_interval.py b/deebot_client/events/wash_interval.py index 96bbe75e..6e5e39c9 100644 --- a/deebot_client/events/wash_interval.py +++ b/deebot_client/events/wash_interval.py @@ -6,6 +6,6 @@ @dataclass(frozen=True) class WashIntervalEvent(Event): - """Cleaning pads interval event representation.""" + """Wash interval event representation.""" interval: int