-
Notifications
You must be signed in to change notification settings - Fork 81
Add Q10 remote trait #813
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
base: main
Are you sure you want to change the base?
Add Q10 remote trait #813
Changes from all commits
6f71fae
dc86444
43d8e7c
2dd3cec
5030516
a6c1008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| from enum import Enum | ||
|
|
||
| from ..code_mappings import RoborockModeEnum | ||
|
|
||
|
|
||
|
|
@@ -217,3 +219,11 @@ class YXDeviceDustCollectionFrequency(RoborockModeEnum): | |
| INTERVAL_30 = "interval_30", 30 | ||
| INTERVAL_45 = "interval_45", 45 | ||
| INTERVAL_60 = "interval_60", 60 | ||
|
|
||
|
|
||
| class RemoteCommand(Enum): | ||
| FORWARD = 0 | ||
| LEFT = 2 | ||
| RIGHT = 3 | ||
| STOP = 4 | ||
| EXIT = 5 | ||
|
Comment on lines
+225
to
+229
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is 1? Does that exist? |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||
| """Traits for Q10 B01 devices.""" | ||||||
|
|
||||||
| from roborock.data.b01_q10.b01_q10_code_mappings import ( | ||||||
| B01_Q10_DP, | ||||||
| RemoteCommand, | ||||||
| ) | ||||||
|
|
||||||
| from .command import CommandTrait | ||||||
|
|
||||||
|
|
||||||
| class RemoteTrait: | ||||||
| """Trait for sending vacuum commands. | ||||||
|
||||||
| """Trait for sending vacuum commands. | |
| """Trait for sending remote-control commands. |
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.
Stop both starts and stops the control?
If it uses the same REmoteCommand thats okay, but can we split it up into two different functions? one start() and one stop()?
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.
Let's name this exit_remote
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||
| import json | ||||||
| from collections.abc import Awaitable, Callable | ||||||
| from typing import Any | ||||||
|
|
||||||
| import pytest | ||||||
|
|
||||||
| from roborock.devices.traits.b01.q10 import Q10PropertiesApi | ||||||
| from roborock.devices.traits.b01.q10.remote import RemoteTrait | ||||||
| from tests.fixtures.channel_fixtures import FakeChannel | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(name="fake_channel") | ||||||
| def fake_channel_fixture() -> FakeChannel: | ||||||
| return FakeChannel() | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(name="q10_api") | ||||||
| def q10_api_fixture(fake_channel: FakeChannel) -> Q10PropertiesApi: | ||||||
| return Q10PropertiesApi(fake_channel) # type: ignore[arg-type] | ||||||
|
|
||||||
|
|
||||||
| @pytest.fixture(name="remote") | ||||||
| def remote_fixture(q10_api: Q10PropertiesApi) -> RemoteTrait: | ||||||
| return q10_api.remote | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize( | ||||||
| ("command_fn", "expected_payload"), | ||||||
| [ | ||||||
| (lambda x: x.forward(), {"101": {"dpRemote": 0}}), | ||||||
| (lambda x: x.left(), {"101": {"dpRemote": 2}}), | ||||||
| (lambda x: x.right(), {"101": {"dpRemote": 3}}), | ||||||
| (lambda x: x.stop(), {"101": {"dpRemote": 4}}), | ||||||
| (lambda x: x.exit(), {"101": {"dpRemote": 5}}), | ||||||
| ], | ||||||
| ) | ||||||
| async def test_remote_commands( | ||||||
| remote: RemoteTrait, | ||||||
| fake_channel: FakeChannel, | ||||||
| command_fn: Callable[[RemoteTrait], Awaitable[None]], | ||||||
| expected_payload: dict[str, Any], | ||||||
| ) -> None: | ||||||
| """Test sending a remote start command.""" | ||||||
|
||||||
| """Test sending a remote start command.""" | |
| """Test sending remote commands with the expected payloads.""" |
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.
Please use RoborockEnum or IntEnum