Skip to content

Commit af8a4d1

Browse files
ximexclaude
andauthored
docs(q7): document live map pushes and cover them in tests (#927)
The map content trait's module docstring described a pure pull contract -- `refresh()` does I/O, `parse_map_content()` reparses, fields "are then readable" -- which no longer holds: `update_from_push()` mutates the same cached fields from the MQTT receive callback and notifies listeners, so they can change without the reader calling anything. Spell that out. `docs/DEVICES.md` only mentioned `device.b01_q7_properties` for Q7, so the push path was undiscoverable and consumers would build a polling loop for something the device streams by itself. Name the listener entry point and the fields to read. The push test checked `image_content` and `raw_api_response` but not `map_data`, the field carrying the live pose and cleaning path -- dropping its assignment kept the test green. It also never asserted that no RPC was published, which is the whole point of the push path: unlike `refresh()`, it needs no map id and no round trips. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 7d65d27 commit af8a4d1

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

docs/DEVICES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Cloud and Network.
2121
* Use `device.b01_q10_properties.vacuum` to access vacuum commands (start, pause, stop, dock, empty dustbin, set clean mode, set fan level).
2222
* Use `device.b01_q10_properties.command.send()` for raw DP commands.
2323
* **Vacuums (B01 Q7)**: Use `device.b01_q7_properties` for Q7 series devices.
24+
* The device streams full map frames on its own while cleaning, so the rendered map stays current without polling or a heartbeat. Register `device.b01_q7_properties.map_content.add_update_listener(cb)` and read `image_content` / `map_data` when notified.
2425

2526
## Background: Understanding Device Protocols
2627

roborock/devices/traits/b01/q7/map_content.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
- fields `image_content`, `map_data`, and `raw_api_response` are then readable
77
88
For B01/Q7 devices, the underlying raw map payload is retrieved via `MapTrait`.
9+
10+
Q7 devices additionally stream map frames unprompted while cleaning; those arrive
11+
through `update_from_push()`, which keeps the same cached fields current and
12+
notifies registered update listeners.
913
"""
1014

1115
import asyncio

tests/devices/traits/b01/q7/test_map_content.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ async def test_q7_map_content_updates_from_push(
119119
fake_channel.map_push_callback(pushed_payload)
120120

121121
assert q7_api.map_content.image_content == b"pngbytes"
122+
assert q7_api.map_content.map_data is dummy_map_data
122123
assert q7_api.map_content.raw_api_response == pushed_payload
123124
assert updates == [True]
125+
# No RPC was needed to get here.
126+
assert fake_channel.published_commands == []
124127

125128
await q7_api.close()
126129
assert fake_channel.map_push_callback is None

0 commit comments

Comments
 (0)