-
-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support mop autowash interval #677
Open
XxInvictus
wants to merge
3
commits into
DeebotUniverse:dev
Choose a base branch
from
XxInvictus:support_mop_autowash_interval
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""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 MopAutoWashFrequency, MopAutoWashFrequencyEvent | ||
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 GetMopAutoWashFrequency(JsonGetCommand): | ||
"""Get Mop Auto-Wash Frequency command.""" | ||
|
||
name = "getWashInfo" | ||
|
||
@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( | ||
MopAutoWashFrequencyEvent(MopAutoWashFrequency(int(data["interval"]))) | ||
) | ||
return HandlingResult.success() | ||
|
||
|
||
class SetMopAutoWashFrequency(JsonSetCommand): | ||
"""Set Mop Auto-Wash Frequency command.""" | ||
|
||
name = "setWashInfo" | ||
get_command = GetMopAutoWashFrequency | ||
_mqtt_params = MappingProxyType({"interval": InitParam(MopAutoWashFrequency)}) | ||
|
||
def __init__(self, interval: MopAutoWashFrequency | str) -> None: | ||
if isinstance(interval, str): | ||
interval = get_enum(MopAutoWashFrequency, interval) | ||
super().__init__({"interval": interval.value}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 MopAutoWashFrequency(IntEnum): | ||
"""Enum class for all possible mop auto-wash frequencies.""" | ||
|
||
TEN_MINUTES = 10 | ||
FIFTEEN_MINUTES = 15 | ||
TWENTY_FIVE_MINUTES = 25 | ||
|
||
|
||
@dataclass(frozen=True) | ||
class MopAutoWashFrequencyEvent(Event): | ||
"""Mop Auto-Wash Frequency event representation.""" | ||
|
||
interval: MopAutoWashFrequency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
import pytest | ||
|
||
from deebot_client.commands.json import GetMopAutoWashFrequency, SetMopAutoWashFrequency | ||
from deebot_client.events import MopAutoWashFrequency, MopAutoWashFrequencyEvent | ||
from tests.helpers import ( | ||
get_request_json, | ||
get_success_body, | ||
) | ||
|
||
from . import assert_command, assert_set_command | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("json", "expected"), | ||
[ | ||
({"interval": 10}, MopAutoWashFrequencyEvent(MopAutoWashFrequency.TEN_MINUTES)), | ||
( | ||
{"interval": 15}, | ||
MopAutoWashFrequencyEvent(MopAutoWashFrequency.FIFTEEN_MINUTES), | ||
), | ||
( | ||
{"interval": 25}, | ||
MopAutoWashFrequencyEvent(MopAutoWashFrequency.TWENTY_FIVE_MINUTES), | ||
), | ||
], | ||
) | ||
async def test_GetMopAutoWashFrequency( | ||
json: dict[str, Any], expected: MopAutoWashFrequencyEvent | ||
) -> None: | ||
json = get_request_json(get_success_body(json)) | ||
await assert_command(GetMopAutoWashFrequency(), json, expected) | ||
|
||
|
||
@pytest.mark.parametrize(("value"), [MopAutoWashFrequency.TEN_MINUTES, "ten_minutes"]) | ||
async def test_SetMopAutoWashFrequency(value: MopAutoWashFrequency | str) -> None: | ||
command = SetMopAutoWashFrequency(value) | ||
args = {"interval": 10} | ||
await assert_set_command( | ||
command, args, MopAutoWashFrequencyEvent(MopAutoWashFrequency.TEN_MINUTES) | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the values are numbers, can we also set the interval to 1 minute? And would the bot respect this set one minute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem like it, there may be some other magic values but these are the available presets for the X5 Pro Omni.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the App from T30 I can only chose between 10, 15 and 25 minutes for time based mop auto wash.
The other option is mop after room