Skip to content

Conversation

@allenporter
Copy link
Contributor

I would like to do some further simplification of the device channels since there are currently too many unnecessary layers of abstraction, but wanted to first document what currently exists.

These are AI generated with co-pilot and Gemini 3 Pro.

Copilot AI review requested due to automatic review settings November 29, 2025 03:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive design documentation for the python-roborock library to support upcoming architectural simplifications. The documentation was AI-generated using GitHub Copilot and Gemini 3 Pro.

  • Adds DESIGN.md documenting the library's architecture, communication layers, and protocol details
  • Adds .github/copilot-instructions.md with coding standards and project-specific guidance for GitHub Copilot
  • Provides detailed information on device discovery, channels, protocol versions, and encryption schemes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
roborock/devices/DESIGN.md Comprehensive architecture documentation covering device discovery, communication channels, protocol versions, and data flow
.github/copilot-instructions.md GitHub Copilot configuration with project overview, tech stack, coding standards, and examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


#### MQTT Authentication
The connection to the Roborock MQTT broker requires specific credentials derived from the user's `rriot` data (obtained during login):
* **Username**: Derived from `MD5(rriot.u + ":" + rriot.k)`.
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The username derivation is incomplete. According to the actual implementation in roborock/protocol.py line 464, the username is derived from MD5(rriot.u + ':' + rriot.k)[2:10] (characters 2-10 of the MD5 hash, not the full hash).

Suggested change
* **Username**: Derived from `MD5(rriot.u + ":" + rriot.k)`.
* **Username**: Derived from characters 2-10 of `MD5(rriot.u + ":" + rriot.k)` (i.e., `MD5(rriot.u + ":" + rriot.k)[2:10]`).

Copilot uses AI. Check for mistakes.
#### MQTT Authentication
The connection to the Roborock MQTT broker requires specific credentials derived from the user's `rriot` data (obtained during login):
* **Username**: Derived from `MD5(rriot.u + ":" + rriot.k)`.
* **Password**: Derived from `MD5(rriot.s + ":" + rriot.k)`.
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The password derivation is incomplete. According to the actual implementation in roborock/protocol.py line 465, the password is derived from MD5(rriot.s + ':' + rriot.k)[16:] (characters 16 onwards of the MD5 hash, not the full hash).

Suggested change
* **Password**: Derived from `MD5(rriot.s + ":" + rriot.k)`.
* **Password**: Derived from the last 16 characters of `MD5(rriot.s + ":" + rriot.k)`, i.e., `MD5(rriot.s + ":" + rriot.k)[16:]`.

Copilot uses AI. Check for mistakes.
* **A01 / B01**:
* **Encryption**: AES-CBC.
* **IV**: Derived from `MD5(random + HASH)`.
* These are typically used by newer camera-equipped models (e.g., S7 MaxV, Zeo).
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Corrected spelling of 'Zeo' to 'Zeo' (likely meant to be 'Zero' or a specific model name). Please verify the correct model name.

Suggested change
* These are typically used by newer camera-equipped models (e.g., S7 MaxV, Zeo).
* These are typically used by newer camera-equipped models (e.g., S7 MaxV, Q7 MaxV).

Copilot uses AI. Check for mistakes.
3. **Create Trait**: For v1, create a class inheriting from your data model and `V1TraitMixin`.
* Set the `command` class variable to your `RoborockCommand`.
* Add methods to perform actions using `self.rpc_channel.send_command()`.
4. **Register Trait**: Add the trait to `PropertiesApi` in `roborock/devices/traits/v1/__init__.py`.
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instruction about 'registering' the trait in PropertiesApi is misleading. Based on the actual code in roborock/devices/traits/v1/__init__.py, traits are added as dataclass fields to PropertiesApi, not 'registered'. The initialization happens in the __init__ method. Consider clarifying this to say 'Add the trait as a field to the PropertiesApi dataclass'.

Suggested change
4. **Register Trait**: Add the trait to `PropertiesApi` in `roborock/devices/traits/v1/__init__.py`.
4. **Add Trait**: Add the trait as a field to the `PropertiesApi` dataclass in `roborock/devices/traits/v1/__init__.py`.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,117 @@
# GitHub Copilot Instructions for python-roborock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish a standard existed for this for all AI tools...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard I am aware of is to have them all reference each others files.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think stating that we use semantic commit tags would be helpful as well.

### 1. Typing
* **Strict Typing**: All functions and methods must have type hints.
* **Generics**: Use `list[str]` instead of `List[str]`, `dict[str, Any]` instead of `Dict[str, Any]`, etc.
* **Optional**: Use `str | None` instead of `Optional[str]`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for what it is worth, i prefer this to be the case

Comment on lines 37 to 39
### 3. Documentation
* **Docstrings**: Use Google-style docstrings for all modules, classes, and functions.
* **Comments**: Comment complex logic, especially protocol parsing and encryption details.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth stating that we use pydoc?

This documents the current code base as is with a higher level overview. This may deserve a better home after we've removed the original API, but seems Ok fr now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants