feat: add some basic setters for q7#690
Conversation
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds basic setter methods for the Roborock Q7 vacuum device, enabling control operations needed for the vacuum entity. The changes include comprehensive test coverage and necessary protocol adjustments to handle different response types from B01 devices.
Key Changes
- Added vacuum control methods: set fan speed, set water level, start/pause/stop cleaning, return to dock, and find device
- Updated B01 protocol handling to correctly distinguish between dictionary responses (for GET commands) and scalar responses (for SET commands)
- Enhanced parameter encoding to properly handle falsy values like
0and empty dictionaries{}
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
roborock/devices/traits/b01/q7/__init__.py |
Added setter methods for fan speed, water level, and cleaning controls; added type checking for GET_PROP responses |
roborock/devices/b01_channel.py |
Updated return type to Any and modified response validation to only require dict responses for .get commands |
roborock/protocols/b01_protocol.py |
Fixed parameter encoding to preserve falsy values (0, {}) and only default to [] when params is None |
roborock/roborock_typing.py |
Added comprehensive B01 Q7 service method constants; removed unused EVENT_ORDER_LIST_POST |
roborock/data/b01_q7/b01_q7_code_mappings.py |
Added SCDeviceCleanParam enum for cleaning control; removed unsupported MAX wind mapping for Q7 |
tests/devices/traits/b01/test_init.py |
Added comprehensive tests for all new setter methods with proper message validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # All get commands should be dicts | ||
| if command.endswith(".get") and not isinstance(data, dict): | ||
| if not future.done(): | ||
| future.set_exception(RoborockException("Unexpected data type for response")) | ||
| return |
There was a problem hiding this comment.
The validation logic only checks if the command ends with ".get" to determine if the response should be a dict. However, this string-based check may not cover all query commands. Consider also checking for commands that end with ".post" or other query-like patterns if they are expected to return dictionaries. Alternatively, consider using a more explicit enumeration of command types (e.g., GET vs SET) to avoid potential false positives or negatives with string matching.
| async def query_values(self, props: list[RoborockB01Props]) -> B01Props | None: | ||
| """Query the device for the values of the given Q7 properties.""" | ||
| result = await send_decoded_command( | ||
| async def send(self, command: RoborockB01Q7Methods, params: dict) -> Any: |
There was a problem hiding this comment.
Add typing
| async def send(self, command: RoborockB01Q7Methods, params: dict) -> Any: | |
| async def send(self, command: RoborockB01Q7Methods, params: dict[str, Any]) -> Any: |
This should be all we need for the vacuum entity.