-
-
Notifications
You must be signed in to change notification settings - Fork 138
Add wash interval commands #376
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
Open
NEVdataDyne
wants to merge
21
commits into
DeebotUniverse:dev
Choose a base branch
from
NEVdataDyne:dev
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.
+108
−0
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3534d34
Update capabilities.py - WashInterval
NEVdataDyne 23fe3b8
Update __init__.py - Wash interval
NEVdataDyne de0f4d4
Create wash_interval.py - Wash interval
NEVdataDyne 0c1b727
Update wash_interval.py - Wash interval
NEVdataDyne 45bd31b
Update __init__.py - Wash interval
NEVdataDyne c377052
Create wash_interval.py - Wash interval
NEVdataDyne cf4ff86
Update wash_interval.py - Wash interval
NEVdataDyne 78ce0c2
Update p1jij8.py - Wash interval
NEVdataDyne aa3d91e
Create test_wash_interval.py - Wash interval
NEVdataDyne 4ed8e2b
Update test_wash_interval.py - Wash interval
NEVdataDyne c82254c
Update wash_interval.py - Wash interval correction
NEVdataDyne e855c24
Update wash_interval.py - Was interval correction
NEVdataDyne 1785238
Update tests/commands/json/test_wash_interval.py
NEVdataDyne 8550419
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne 70938eb
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne e21b21e
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne 8b948e9
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne c94193c
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne 98392b1
Update deebot_client/commands/json/wash_interval.py
NEVdataDyne 64d553e
Update deebot_client/events/wash_interval.py
NEVdataDyne a2fab23
Merge branch 'dev' into dev
NEVdataDyne 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
"""Pads cleaning interval commands.""" | ||
from types import MappingProxyType | ||
from typing import Any | ||
|
||
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 | ||
|
||
from .common import JsonGetCommand, JsonSetCommand | ||
|
||
|
||
class GetWashInterval(JsonGetCommand): | ||
"""Get wash 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 SetWashInterval(JsonSetCommand): | ||
"""Set wash interval command.""" | ||
|
||
name = "setWashInterval" | ||
get_command = GetWashInterval | ||
_mqtt_params = MappingProxyType({"interval": InitParam(int)}) | ||
|
||
def __init__(self, interval: int) -> None: | ||
if interval <= 0: | ||
raise ValueError("'interval' must be positive") | ||
super().__init__({"interval": interval}) |
This file contains hidden or 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 hidden or 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,11 @@ | ||
"""Cleaning pads interval event module.""" | ||
from dataclasses import dataclass | ||
|
||
from .base import Event | ||
|
||
|
||
@dataclass(frozen=True) | ||
class WashIntervalEvent(Event): | ||
"""Wash interval event representation.""" | ||
|
||
interval: int |
This file contains hidden or 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 hidden or 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,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}, WashIntervalEvent(6)), | ||
({"interval": 10}, WashIntervalEvent(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) |
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.
Uh oh!
There was an error while loading. Please reload this page.