feat: Allow device manager to perform rediscovery of devices#674
Merged
allenporter merged 5 commits intoPython-roborock:mainfrom Dec 15, 2025
Merged
feat: Allow device manager to perform rediscovery of devices#674allenporter merged 5 commits intoPython-roborock:mainfrom
allenporter merged 5 commits intoPython-roborock:mainfrom
Conversation
This adds an opton to skip the cache, but also supports fallback to the old device list. Adds tests exercising redisocvery and various cache falblack cases on failure.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to perform device rediscovery by introducing a prefer_cache parameter to the discover_devices() method. When set to False, the device manager will fetch fresh home data from the API instead of using cached data, allowing the system to discover newly added devices. The implementation includes fallback logic to use cached data if the API call fails.
- Added
prefer_cacheparameter todiscover_devices()method (defaults toTruefor backward compatibility) - Implemented exception handling with fallback to cached data when API calls fail
- Added comprehensive test coverage for cache logic, fallback behavior, and rediscovery scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/mock_data.py | Added type annotation to HOME_DATA_RAW for better type safety |
| tests/devices/test_device_manager.py | Parametrized existing cache test and added new tests for cache fallback and device rediscovery scenarios |
| roborock/devices/device_manager.py | Modified discover_devices() to support cache bypass with prefer_cache parameter and added exception handling with cache fallback |
💡 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>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Lash-L
previously approved these changes
Dec 14, 2025
Lash-L
approved these changes
Dec 15, 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.
This adds an opton to skip the cache, but also supports fallback to the old device list. Adds tests exercising rediscovery and various cache falblack cases on failure.
We currently never refresh home data once it is loaded, so we need to add a mechanism to discover new devices outside of the cache. This is a first step, and later we'll add automated polling to rediscover deivces.
Discussion in home-assistant/core#158818 has context about the problem.