fix: show docked Q10 robot on map - #904
Conversation
418af61 to
f3f025d
Compare
| 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 |
There was a problem hiding this comment.
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 -------------------------------------------------------------- |
There was a problem hiding this comment.
Not sure this is needed
| notified: list[None] = [] | ||
| trait.add_update_listener(lambda: notified.append(None)) | ||
|
|
||
| with patch( |
There was a problem hiding this comment.
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] = [] |
| 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 |
There was a problem hiding this comment.
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?
| 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 = ( |
There was a problem hiding this comment.
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.
f3f025d to
bec2e85
Compare
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
Q10PropertiesApiindependent of map rendering detailsBefore and after
These images are from the Home Assistant map card in #900.
Validation
pytest -q— 895 passed, 86 snapshots passedpre-commit run --files ...— all hooks passedReview scope
#902 and #903 are merged. This PR is based directly on
mainand contains one dock-state commit. The transport correction is in #901. PR #900 is the full before-and-after reference.