-
Notifications
You must be signed in to change notification settings - Fork 61
Add VacuumTrait to q10 devices #754
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
faf6226
fb69579
0fce06a
6e6df0b
7d12163
7b4b966
fee3873
68dbf43
deef3ba
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,56 @@ | ||
| """Traits for Q10 B01 devices.""" | ||
|
|
||
| from roborock.data.b01_q10.b01_q10_code_mappings import B01_Q10_DP | ||
|
|
||
| from .command import CommandTrait | ||
|
|
||
|
|
||
| class VacuumTrait: | ||
| """Trait for sending vacuum commands. | ||
|
|
||
| This is a wrapper around the CommandTrait for sending vacuum related | ||
| commands to Q10 devices. | ||
| """ | ||
|
|
||
| def __init__(self, command: CommandTrait) -> None: | ||
| """Initialize the VacuumTrait.""" | ||
| self._command = command | ||
|
|
||
| async def start_clean(self) -> None: | ||
| """Start cleaning.""" | ||
| await self._command.send( | ||
| command=B01_Q10_DP.START_CLEAN, | ||
| # TODO: figure out other commands | ||
| # 1 = start cleaning | ||
| # 2 = "electoral" clean, also has "clean_parameters" | ||
allenporter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 4 = fast create map | ||
| params={"cmd": 1}, | ||
| ) | ||
|
|
||
| async def pause_clean(self) -> None: | ||
| """Pause cleaning.""" | ||
| await self._command.send( | ||
| command=B01_Q10_DP.PAUSE, | ||
| params={}, | ||
| ) | ||
|
|
||
| async def resume_clean(self) -> None: | ||
| """Resume cleaning.""" | ||
| await self._command.send( | ||
| command=B01_Q10_DP.RESUME, | ||
| params={}, | ||
| ) | ||
|
|
||
| async def stop_clean(self) -> None: | ||
| """Stop cleaning.""" | ||
| await self._command.send( | ||
| command=B01_Q10_DP.STOP, | ||
| params={}, | ||
| ) | ||
|
|
||
| async def return_to_dock(self) -> None: | ||
| """Return to dock.""" | ||
| await self._command.send( | ||
| command=B01_Q10_DP.START_DOCK_TASK, | ||
| params={}, | ||
| ) | ||
| 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.vacuum import VacuumTrait | ||||||
| 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="vacuumm") | ||||||
|
||||||
| def vacuumm_fixture(q10_api: Q10PropertiesApi) -> VacuumTrait: | ||||||
| return q10_api.vacuum | ||||||
|
|
||||||
|
|
||||||
| @pytest.mark.parametrize( | ||||||
| ("command_fn", "expected_payload"), | ||||||
| [ | ||||||
| (lambda x: x.start_clean(), {"201": {"cmd": 1}}), | ||||||
| (lambda x: x.pause_clean(), {"204": {}}), | ||||||
| (lambda x: x.resume_clean(), {"205": {}}), | ||||||
| (lambda x: x.stop_clean(), {"206": {}}), | ||||||
| (lambda x: x.return_to_dock(), {"203": {}}), | ||||||
| ], | ||||||
| ) | ||||||
| async def test_vacuum_commands( | ||||||
|
||||||
| async def test_vacuum_commands( | |
| async def test_q10_vacuum_commands( |
Uh oh!
There was an error while loading. Please reload this page.