feat(q10): add status update listener callback API#770
Merged
allenporter merged 3 commits intoPython-roborock:mainfrom Feb 21, 2026
Merged
feat(q10): add status update listener callback API#770allenporter merged 3 commits intoPython-roborock:mainfrom
allenporter merged 3 commits intoPython-roborock:mainfrom
Conversation
Greptile SummaryAdds a public callback API to
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Home Assistant
participant ST as StatusTrait
participant CL as CallbackList
participant CB as Callback
Client->>ST: add_update_listener(callback)
ST->>CL: add_callback(callback)
CL-->>ST: unsubscribe function
ST-->>Client: unsubscribe function
Note over ST: Device sends DPS update
ST->>ST: update_from_dps(decoded_dps)
ST->>ST: Update trait fields
ST->>CL: __call__(decoded_dps)
CL->>CB: callback(decoded_dps)
CB-->>CL:
CL-->>ST:
Client->>ST: unsubscribe()
ST->>CL: remove callback
CL-->>ST:
ST-->>Client:
Note over ST: Subsequent DPS update
ST->>ST: update_from_dps(decoded_dps)
ST->>ST: Update trait fields
ST->>CL: __call__(decoded_dps)
Note over CL: No callbacks to invoke
CL-->>ST:
Last reviewed commit: 5ca5b6e |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a clean callback API for Q10 devices to receive status updates from decoded DPS (Data Point System) messages. The implementation allows Home Assistant and other integrations to subscribe to status updates without monkey-patching, improving code maintainability and providing a proper public API.
Changes:
- Added
add_update_listener()method toStatusTraitthat returns an unsubscribe callable - Modified
update_from_dps()to invoke registered callbacks after updating status - Enhanced type annotations from
dicttodict[B01_Q10_DP, Any]for better type safety - Added comprehensive test coverage for listener registration and unsubscribe behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| roborock/devices/traits/b01/q10/status.py | Implements callback API using CallbackList, adds __init__ to initialize callbacks, updates update_from_dps signature with proper typing, and invokes callbacks on updates |
| tests/devices/traits/b01/q10/test_status.py | Adds test for listener registration, callback invocation, and unsubscribe functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
21 tasks
allenporter
approved these changes
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a small public callback API on
StatusTraitfor Q10 decoded DPS updates.StatusTrait.add_update_listener(callback)returning an unsubscribe callableStatusTrait.update_from_dps(...)Why
Home Assistant currently has to monkey-patch
update_from_dpsto capture Q10 push updates. With this API, integrations can subscribe cleanly to status updates without runtime patching.Test plan
ruff check roborock/devices/traits/b01/q10/status.py tests/devices/traits/b01/q10/test_status.pypytest tests/devices/traits/b01/q10/test_status.pypytest tests/devices/traits/b01/q10/test_status.py tests/devices/traits/b01/q10/test_vacuum.py