Initial room configuration support for Q10 devices#837
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for reading and refreshing room configuration for Q10 (B01) devices, including parsing the CUSTOMER_CLEAN payload and exposing room helpers on the properties API.
Changes:
- Introduces
RoomsTraitand wires it intoQ10PropertiesApisubscribe loop and helper methods. - Adds room-config parsing/container models for the
CUSTOMER_CLEANbase64 payload. - Adds tests covering streaming updates, listener notifications, and refresh requests for room config.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| tests/devices/traits/b01/q10/test_rooms.py | Adds integration-style tests for rooms streaming, listener behavior, and refresh request payload. |
| roborock/devices/traits/b01/q10/rooms.py | Implements RoomsTrait to refresh and parse room configuration updates and notify listeners. |
| roborock/devices/traits/b01/q10/init.py | Wires RoomsTrait into Q10PropertiesApi and adds convenience room helper APIs. |
| roborock/data/b01_q10/b01_q10_containers.py | Adds dataclasses and parsing/normalization for the room configuration payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| assert parsed.declared_count == 1 | ||
| assert parsed.parsed_count == 1 | ||
| room = parsed.rooms[0] |
There was a problem hiding this comment.
Can you add a test for an instance with multiple rooms?
There was a problem hiding this comment.
Done — added test_parse_customer_clean_payload_with_multiple_rooms in tests/data/b01_q10/test_b01_q10_containers.py. It builds two rooms with different ids, names, and vertex counts and asserts both are parsed correctly.
|
Marking as draft, mark it as ready once you have addressed the reviews and we can take another look! |
- Remove room helper methods from Q10PropertiesApi (room_map, room_names, get_room, get_room_name, refresh_room_config) — callers use api.rooms.* - Change sentinel values from -1 to None (int | None) for clean_order, clean_type, fan_level, water_level, material, clean_line - Replace break-on-error parsing with upfront _validate_customer_clean_layout to avoid returning partial room data - Extract raw_room_name field + room_name property on Q10RoomConfig - Add _decode_q10_room_name and _u8/_u16_to_optional helpers - Add test for multiple rooms and update sentinel assertions to check None - Use iteration instead of exception in RoborockModeEnum.from_code_optional Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cf3d03d to
c37d4b8
Compare
Introduces parsing for the CUSTOMER_CLEAN DPS payload and a RoomsTrait that integrates into Q10PropertiesApi alongside the existing traits. - New dataclasses Q10RoomVertex, Q10RoomConfig, Q10RoomsConfig with upfront layout validation; sentinel values (0xFF/0xFFFF) map to None - normalize_q10_room_name() converts firmware rr_* slugs to title case - RoomsTrait exposes refresh(), room_map, room_names, get_room(), get_room_name() and plugs into the _updatable_traits dispatch loop - 13 tests: parsing edge cases, sentinel values, multiple rooms, streaming updates, listener notifications, refresh request payload Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
Adds initial room configuration support for Q10 (B01 protocol) devices.
Introduces parsing for the
CUSTOMER_CLEANDPS payload and a dedicatedRoomsTraitthat is wired intoQ10PropertiesApi. Room data is refreshed on demand and updated automatically via the subscribe loop.What Changed
b01_q10_containers.py— new dataclasses (Q10RoomVertex,Q10RoomConfig,Q10RoomsConfig) andparse_customer_clean_payload()with upfront layout validation; sentinel values (0xFF / 0xFFFF) map toNone;rr_*firmware names normalized vianormalize_q10_room_name()rooms.py— newRoomsTraitexposingrefresh(),room_map,room_names,get_room(),get_room_name(), and update listener support__init__.py— wiresRoomsTraitintoQ10PropertiesApisubscribe loop asapi.roomsBehaviour
await api.rooms.refresh()sends theCUSTOMER_CLEAN_REQUESTDPS; the robot replies with aCUSTOMER_CLEANupdate that is parsed automaticallyapi.rooms.room_namesreturns adict[int, str]of room id → human-readable namerr_living_roomare normalized toLiving RoomValidation