Repository navigation
feat: add Q7 carpet settings and map names #1040
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
ramon-angosto
wants to merge
3
commits into
Python-roborock:main
Choose a base branch
from
ramon-angosto:q7/3-carpet-map-names
base: main
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 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
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,54 @@ | ||
| """Remote (manual) control trait for B01 Q7 devices.""" | ||
|
|
||
| from roborock.data.b01_q7.b01_q7_code_mappings import Q7RemoteDirection | ||
| from roborock.devices.rpc.b01_q7_channel import Q7RpcChannel | ||
| from roborock.roborock_message import RoborockB01Props | ||
| from roborock.roborock_typing import RoborockB01Q7Methods | ||
|
|
||
| # ``sweep_type`` values observed while the official app drives the remote control. | ||
| _MANUAL_SWEEP_TYPE = 5 | ||
| _NORMAL_SWEEP_TYPE = 0 | ||
|
|
||
|
|
||
| class RemoteTrait: | ||
| """Trait for driving a Q7 manually, mirroring the Q10 ``RemoteTrait`` API. | ||
|
|
||
| Manual mode is entered with ``prop.set sweep_type=5`` (the device then reports | ||
| ``work_mode`` manual). Each movement command only moves the robot for a short | ||
| burst, so callers repeat it (the official app sends several per second) while | ||
| a direction is held. | ||
| """ | ||
|
|
||
| def __init__(self, channel: Q7RpcChannel) -> None: | ||
| """Initialize the RemoteTrait.""" | ||
| self._channel = channel | ||
|
|
||
| async def _send_direction(self, direction: Q7RemoteDirection) -> None: | ||
| await self._channel.send_command(RoborockB01Q7Methods.SET_DIRECTION, {"direction": direction.code}) | ||
|
|
||
| async def stop(self) -> None: | ||
| """Stop moving, entering manual (remote control) mode if needed.""" | ||
| await self._channel.send_command( | ||
| RoborockB01Q7Methods.SET_PROP, | ||
| {RoborockB01Props.SWEEP_TYPE: _MANUAL_SWEEP_TYPE}, | ||
| ) | ||
|
|
||
| async def forward(self) -> None: | ||
| """Move forward.""" | ||
| await self._send_direction(Q7RemoteDirection.FORWARD) | ||
|
|
||
| async def left(self) -> None: | ||
| """Turn left.""" | ||
| await self._send_direction(Q7RemoteDirection.LEFT) | ||
|
|
||
| async def right(self) -> None: | ||
| """Turn right.""" | ||
| await self._send_direction(Q7RemoteDirection.RIGHT) | ||
|
|
||
| async def exit_remote(self) -> None: | ||
| """Exit remote control and return to the normal idle state.""" | ||
| await self._send_direction(Q7RemoteDirection.EXIT) | ||
| await self._channel.send_command( | ||
| RoborockB01Q7Methods.SET_PROP, | ||
| {RoborockB01Props.SWEEP_TYPE: _NORMAL_SWEEP_TYPE}, | ||
| ) |
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
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
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.
RoborockB01Propsis also the parameter enum forQ7PropertiesApi.query_values(props: list[RoborockB01Props]) -> B01Props | None. Whileprop.getnestscarpet_turboandcarpet_avoidunderprivacywhenRoborockB01Props.PRIVACYis queried, queryingcarpet_turboorcarpet_avoiddirectly inprop.getreturns top-levelcarpet_turbo/carpet_avoidinteger fields in the response payload.Consider also adding
carpet_turbo: int | None = Noneandcarpet_avoid: int | None = NonetoB01Propsinroborock/data/b01_q7/b01_q7_containers.py(matching all otherRoborockB01Propsmembers, such asquiet_is_open/quiet_begin_time/quiet_end_time) soquery_values([RoborockB01Props.CARPET_TURBO, RoborockB01Props.CARPET_AVOID])does not silently drop those fields duringB01Props.from_dict().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.
Good catch, done in 318dc35:
B01Propsnow hascarpet_turboandcarpet_avoid, with a test thatquery_values([CARPET_TURBO, CARPET_AVOID])keeps them.