feat: Simplify device manager creation#570
Merged
allenporter merged 5 commits intoPython-roborock:mainfrom Oct 27, 2025
Merged
Conversation
Remove the need to pass in a home data api by taking all information up front to create the roborock web API in the device manager creation interface. This creates a new Web Api wrapper that will also be used for getting routine information in a followup PR, which was the initial motivation behind this change. Overall this will allow additional code simplification in callers when onboarding the new API, completely removing the need to continue using the Web API directly for devices.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR simplifies device manager creation by consolidating authentication parameters into a UserParams dataclass and creating a new UserWebApiClient wrapper. This removes the need for callers to directly instantiate and manage the home data API, streamlining the initialization flow.
Key Changes:
- Introduced
UserParamsdataclass to encapsulate username, user data, and optional base URL - Created
UserWebApiClientwrapper class to bind API client with user context - Replaced
create_home_data_apifunction with internal_create_web_api_wrapperfunction
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| roborock/web_api.py | Added UserWebApiClient wrapper class to bind API client with user authentication context |
| roborock/devices/device_manager.py | Replaced home data API callable pattern with UserWebApiClient, introduced UserParams dataclass, and updated create_device_manager to accept UserParams |
| roborock/cli.py | Updated to use new UserParams interface instead of calling create_home_data_api |
| tests/devices/test_device_manager.py | Refactored tests to use fixtures for mocking home data and updated to work with new UserParams interface |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Lash-L
approved these changes
Oct 27, 2025
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.
Remove the need to pass in a home data api by taking all information up
front to create the roborock web API in the device manager creation
interface.
This creates a new Web Api wrapper that will also be used for getting
routine information in a followup PR, which was the initial motivation behind this change.
Overall this will allow additional code simplification in callers when
onboarding the new API, completely removing the need to continue using the Web API directly for devices.