Skip to content

fix: show docked Q10 robot on map - #904

Merged
allenporter merged 1 commit into
Python-roborock:mainfrom
tubededentifrice:vc/q10-docked-state
Aug 2, 2026
Merged

fix: show docked Q10 robot on map#904
allenporter merged 1 commit into
Python-roborock:mainfrom
tubededentifrice:vc/q10-docked-state

Conversation

@tubededentifrice

@tubededentifrice tubededentifrice commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

The Q10 map trait now uses map-specific DPS data when it renders a map. The map shows the robot at the dock when the robot has no visible live trace.

Changes

  • keep dock status and map overlays in one private map DPS model
  • use named dock-state values for charging and bin emptying
  • keep all received trace packets unchanged
  • omit the trace from the rendered image when the robot is at the dock
  • render the robot at the saved dock position
  • report a DPS update only when a model value changes
  • keep Q10PropertiesApi independent of map rendering details

Before and after

These images are from the Home Assistant map card in #900.

Before After
Before: Q10 map without the docked robot state After: docked Q10 robot rendered at the saved dock position

Validation

  • pytest -q — 895 passed, 86 snapshots passed
  • pre-commit run --files ... — all hooks passed

Review scope

#902 and #903 are merged. This PR is based directly on main and contains one dock-state commit. The transport correction is in #901. PR #900 is the full before-and-after reference.

Comment thread roborock/devices/traits/b01/q10/map.py Outdated
@tubededentifrice
tubededentifrice marked this pull request as ready for review July 30, 2026 15:31
Comment thread roborock/devices/traits/b01/q10/map.py Outdated
TraitUpdateListener.__init__(self, logger=_LOGGER)
self._config = map_parser_config or B01Q10MapParserConfig()
self._map_dps = map_dps
self._robot_at_dock = self._map_dps.robot_at_dock

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.

I don't think we want to copy this since it will certainly be stale, so i think we need to always refer to the trait if we want to check it.

assert not notified


# --- Dock state --------------------------------------------------------------

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.

Not sure this is needed

notified: list[None] = []
trait.add_update_listener(lambda: notified.append(None))

with patch(

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.

Seems like this can be an always available fixture

map_dps = MapDpsTrait()
trait = _map_trait(map_dps)
packet = parse_map_packet(FIXTURE.read_bytes())
notified: list[None] = []

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.

Use an asyncio.Event?

Comment thread roborock/devices/traits/b01/q10/map.py Outdated
def update_from_trace_packet(self, packet: Q10TracePacket) -> None:
"""Store a trace-protocol update and render the latest sources."""
self._trace_packet = packet
# A late packet from the completed clean cannot move a robot that the

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.

The intent of this code is to adjust what is rendered. So instead of mutating the state to clear trace packets and worrying about out of order stuff, we can just change what we pass into the render function. That is, the trace packet received is still completely valid, so we shouldn't clear it just because we want to change how its rendered on the map. (What we render can be different than the raw data values).

Instead:

  • Revert the init change
  • Revert the update_from_trace_packet change
  • Revert the _map_dps_updated change
  • In _render add: self._trace_packet if not self._robot_at_dock else None

I think that is equivalent?

Comment thread roborock/devices/traits/b01/q10/map.py Outdated
self._overlays = Q10MapOverlays(
zones=tuple(parse_zone_blob(self.restricted_zone_up)),
virtual_walls=tuple(parse_virtual_wall_blob(self.virtual_wall_up)),
overlays_changed = (

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.

I think we could remove a lot of the logic added in this class if update_from_dps was modified to return False is there was no actual change in values converted. What do you think about that? I think nearly everything likely wants this behavior, but this feels like too much code to get it so looking for something more succint.

@allenporter
allenporter merged commit df75659 into Python-roborock:main Aug 2, 2026
7 checks passed
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