Skip to content

feat: expose Q10 current cleaning room - #939

Open
hCoureau wants to merge 4 commits into
Python-roborock:mainfrom
hCoureau:feat/q10-current-room
Open

hCoureau wants to merge 4 commits into
Python-roborock:mainfrom
hCoureau:feat/q10-current-room

Conversation

@hCoureau

@hCoureau hCoureau commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Expose MapContentTrait.current_room from the latest live robot pose and segmented map. Header metadata enables room resolution from the first pose; incomplete or unusable headers fall back to dense-path calibration. Outside-map and ambiguous nearby poses return None, and docking clears the live trace.

Preserve custom room labels verbatim, redact rawName in diagnostics, and sample raw occupancy cells when validating header calibration. Remove the unused fixed-origin solver. Includes public resolver and trait regressions.

Validation: 2,234 passed and 53 xfailed on Python 3.11 and 3.14; 11 broker tests deselected by repository configuration. Focused suites: 294 passed on each version. All pre-commit checks and wheel/source builds passed.

Updated on upstream main (acd298ee, 7.19.0). GitHub CI passed, including MQTT-broker suites on Python 3.11 and 3.14. No physical-device validation was run for this revision. Related: #767.

@hCoureau hCoureau mentioned this pull request Aug 31, 2026
9 of 23 tasks
@lboue

lboue commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Tested against a real device: Roborock Q10 S5+ (ss07 firmware family), on commit cd2621d (this PR's isolated commit, rebased onto its stacked dependencies).

Watched device.b01_q10_properties.map.current_room live via add_update_listener while running a targeted clean:

{"time": "13:16:10", "state": null,            "room_id": null, "room_name": null,        "position": null}
{"time": "13:16:11", "state": "SWEEP_AND_MOP",  "room_id": null, "room_name": null,        "position": {"x": -976, "y": -888}}
{"time": "13:16:11", "state": "SWEEP_AND_MOP",  "room_id": 3,    "room_name": "Salle d’eau","position": {"x": -976, "y": -888}}
...
{"time": "13:18:26", "state": "RETURNING_HOME", "room_id": null, "room_name": null,        "position": {"x": -412, "y": -508}}
{"time": "13:20:03", "state": "EMPTYING_THE_BIN","room_id": null,"room_name": null,        "position": null}

Observations:

  • current_room correctly reflects a custom room label (Salle d’eau, French for "bathroom") rather than a raw firmware rr_... default - matches the "preserve custom room labels" goal.
  • It's briefly None right after the position/state first arrive (before the first segmented-grid match resolves), then locks onto the right room.
  • It correctly clears back to None as soon as the state moves to RETURNING_HOME / EMPTYING_THE_BIN, confirming stale session state doesn't leak into docking/post-clean states.

This was a single-room spot clean, so I didn't get to observe a room-to-room transition in this pass.

@allenporter allenporter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: Conducting this code review following our /review skill using Antigravity (AGY) and Gemini 4 Argon.

Preserving custom room labels verbatim in Q10Room.name, redacting rawName in diagnostics, and calibrating trace coordinates from the header metadata look good.

We can simplify the current_room trait state and tests considerably:

  1. Remove _CURRENT_ROOM_STATES and self._current_room_trace_fresh state tracking in MapContentTrait:

    • Right now MapContentTrait gates current_room on _CURRENT_ROOM_STATES and tracks self._current_room_trace_fresh across status and trace updates.
    • This makes current_room inconsistent with robot_position: when the robot is IDLE or RETURNING_HOME (or when map+trace packets arrive before the first status DPS), trait.robot_position returns the live position from self._trace_packet while trait.current_room is forced to None.
    • In V1 (RoborockMapDataParser._get_current_vacuum_room), the current room (map_data.vacuum_room) is simply the room at the robot's position whenever the map and robot position are present—without gating on cleaning status.
    • Since MapContentTrait already clears self._trace_packet = None when self._map_dps.robot_at_dock is true, current_room can be a stateless 3-line property derived directly from (self._map_packet, self._trace_packet). That also removes the need for the 7 mock-heavy status/arrival-order permutation tests in tests/devices/traits/b01/q10/test_map.py.
  2. Remove defensive math.isfinite checks on int coordinates and replace(room) cloning:

    • See inline comments in roborock/map/b01_q10_render.py.
  3. Test through public entrypoints rather than private helpers or patched functions:

    • See inline comments in tests/devices/traits/b01/q10/test_map.py and tests/map/test_b01_q10_render.py.

Comment thread roborock/devices/traits/b01/q10/map.py Resolved
Comment thread roborock/map/b01_q10_render.py Resolved
Comment thread roborock/map/b01_q10_render.py Resolved
Comment thread tests/map/test_b01_q10_render.py Resolved
@Lash-L

Lash-L commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Hi! Marking as a draft until Allen's comments are addressed!

@Lash-L
Lash-L marked this pull request as draft October 31, 2026 01:54
@hCoureau
hCoureau force-pushed the feat/q10-current-room branch from 33b5af5 to 3ee80aa Compare November 7, 2026 19:04
@hCoureau
hCoureau marked this pull request as ready for review November 7, 2026 19:07

@allenporter allenporter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: Conducting this code review following our /review skill using Antigravity (AGY) and Gemini 4 Argon.

Thanks for addressing all of the previous review comments—the stateless MapContentTrait.current_room property, simplified room lookup, and public-entrypoint tests look much cleaner!

A few items came up in re-review after the standalone rebuild onto main:

  1. Restore custom room label preservation and rawName diagnostic redaction (dropped from cd2621d during the rebuild onto main):

    • Q10Room.name (roborock/map/b01_q10_map_parser.py): Without the if not self.raw_name.startswith("rr_"): return self.raw_name guard, custom room labels exposed on current_room.name are modified by .replace("_", " ").strip().title() (e.g. turning "Salle d’eau" into "Salle D’Eau" or "Owner's bedroom" into "Owner'S Bedroom").
    • REDACT_KEYS (roborock/diagnostics.py): MapContentTrait.as_dict() exports "currentRoom" (and "rooms") with "rawName", which needs "rawName" in REDACT_KEYS (and test_redact_q10_raw_room_name in tests/test_diagnostics.py) so custom room names are redacted in diagnostics.
  2. Avoid full-grid packet.layers decomposition on every synchronous current_room access:

    • See inline comment in roborock/map/b01_q10_render.py.
  3. Remove unused solve_calibration_with_origin:

    • See inline comment in roborock/map/b01_q10_render.py.

Comment thread roborock/devices/traits/b01/q10/map.py Resolved
Comment thread roborock/map/b01_q10_render.py Resolved
Comment thread roborock/map/b01_q10_render.py Resolved
@hCoureau
hCoureau marked this pull request as draft November 8, 2026 18:57
@hCoureau
hCoureau marked this pull request as ready for review November 8, 2026 19:03

This branch has not been deployed

No deployments
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.

4 participants