-
Notifications
You must be signed in to change notification settings - Fork 80
feat: 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
Changes from all commits
6f71fae
dc86444
43d8e7c
2dd3cec
5030516
a6c1008
133917b
a5ce338
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 | ||||
|---|---|---|---|---|---|---|
| @@ -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.
Every command that uses remote control on device starts the remote mode, except the exit command
Stop command only stops the moving command, cause the moving is forever until the device get command "stop" (idk if really moving is forever, but looks like)
| 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_remote(), {"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.
What is 1? Does that exist?
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.
I don't really know, but looks like it meaned to be "backward", but on the device level it was deleted, so there's a space between 0 and 2
I tried to use it, nothing