|
| 1 | +# Adding New Devices to python-roborock |
| 2 | + |
| 3 | +This document outlines the workflow and necessary steps for adding a new Roborock device (specifically, the Qrevo Curv 2 Flow) to the `python-roborock` library, based on the project's documentation (`CONTRIBUTING.md`, `README.md`, and CLI structure). |
| 4 | + |
| 5 | +## 1. Device Discovery & Feature Extraction |
| 6 | + |
| 7 | +The primary method for adding a new device is to extract its hardware capabilities directly from the Roborock cloud using the built-in CLI tools. |
| 8 | + |
| 9 | +### Relevant CLI Commands (`roborock/cli.py`) |
| 10 | +- **Authentication:** `uv run roborock login --email <your-email>` |
| 11 | + - Uses an interactive Email + OTP flow. Stores credentials locally in `~/.roborock`. |
| 12 | +- **Information Gathering:** `uv run roborock get-device-info` |
| 13 | + - Connects to the API, queries the devices, and outputs their specific feature sets, protocol versions, and internal model IDs in YAML format. |
| 14 | + |
| 15 | +### Required Data |
| 16 | +From the `get-device-info` output, we need: |
| 17 | +- `model`: The internal identifier (e.g., `roborock.vacuum.a15X`). |
| 18 | +- `protocol_version`: Typically `v1` for standard vacuums or `a01`/`b01` for others. |
| 19 | +- `new_feature_info` & `feature_info`: Hex strings and integer lists that map to the physical capabilities of the vacuum (e.g., SpiraFlow roller, specific camera types, mop modules). |
| 20 | + |
| 21 | +## 2. Codebase Updates |
| 22 | + |
| 23 | +Once the device data is acquired, the following files must be updated to fully integrate the new model: |
| 24 | + |
| 25 | +### `device_info.yaml` |
| 26 | +- **Action:** Paste the YAML output from `get-device-info` directly into this file. |
| 27 | +- **Purpose:** Acts as the source of truth for generating the supported features documentation. |
| 28 | + |
| 29 | +### `roborock/data/code_mappings.py` |
| 30 | +- **Action:** Add the new internal model ID to the appropriate product family enum (e.g., the `VIVIAN` series `ProductInfo` tuple). |
| 31 | +- **Purpose:** Maps the raw model string to a readable nickname and groups it with similar devices. |
| 32 | + |
| 33 | +### `roborock/device_features.py` |
| 34 | +- **Action:** Define the specific capabilities of the new model by mapping its `RoborockProductNickname` to a list of `ProductFeatures` (e.g., `CLEANMODE_MAXPLUS`, `MOP_SPIN_MODULE`). |
| 35 | +- **Purpose:** Tells the library which API commands (fan speeds, mop intensities, dock controls) the vacuum supports. |
| 36 | + |
| 37 | +### `roborock/const.py` (Optional) |
| 38 | +- **Action:** If the device requires specific constant mappings or overrides, add them here. |
| 39 | + |
| 40 | +## 3. Testing & Documentation |
| 41 | + |
| 42 | +As per `CONTRIBUTING.md`: |
| 43 | + |
| 44 | +### Test Data |
| 45 | +- **Action:** Capture the Home API data for the new device and save it as `tests/testdata/home_data_device_<device_name>.json`. |
| 46 | +- **Purpose:** Ensures device discovery and initialization tests pass during CI. |
| 47 | + |
| 48 | +### Documentation |
| 49 | +- **Action:** Run `uv run roborock update-docs` after modifying `device_info.yaml`. |
| 50 | +- **Purpose:** Automatically regenerates `SUPPORTED_FEATURES.md` based on the new device capabilities. |
| 51 | + |
| 52 | +## Summary Workflow for Curv 2 Flow |
| 53 | + |
| 54 | +1. User runs `uv run roborock login --email <email>` and completes OTP. |
| 55 | +2. User runs `uv run roborock get-device-info` and provides the YAML output. |
| 56 | +3. Agent updates `device_info.yaml`, `code_mappings.py`, and `device_features.py`. |
| 57 | +4. Agent runs `uv run roborock update-docs`. |
| 58 | +5. Agent requests/creates test JSON fixtures. |
| 59 | +6. Agent runs `uv run pytest` and `uv run pre-commit run --all-files` to validate. |
0 commit comments