fix: support home discovery when there are no maps#809
fix: support home discovery when there are no maps#809allenporter merged 2 commits intoPython-roborock:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the V1 HomeTrait discovery/refresh flow to tolerate devices that currently have no maps, so Home Assistant can complete “home discovery” without raising and aborting initialization.
Changes:
- Make
HomeTrait.discover_home()no-op (cache empty data) instead of raising when there’s no current map info. - Make
HomeTrait.refresh()return early (instead of raising) when current map info isn’t available. - Update/extend the unit test coverage for the “no maps” discovery scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
roborock/devices/traits/v1/home.py |
Avoid exceptions when MapsTrait has no current map info; cache empty discovery results and make refresh a safe no-op. |
tests/devices/traits/v1/test_home.py |
Adjust expectations for “no maps” discovery (and refresh) to ensure the trait remains stable and empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _LOGGER.debug("Cannot perform home discovery without current map info") | ||
| self._discovery_completed = True | ||
| await self._update_home_cache({}, {}) | ||
| return |
There was a problem hiding this comment.
current_map_info is None can occur for reasons other than “no maps” (e.g., StatusTrait.current_map not refreshed / is None, or the current map flag not present in map_info). In those cases this path marks discovery as completed and persists an empty cache, which can mask a real precondition error and prevent refresh() from attempting full discovery later. Consider narrowing this branch to the explicit “no maps” case (e.g., self._maps_trait.multi_map_count == 0 and not self._maps_trait.map_info) and otherwise keep the previous failure behavior (raise) or leave _discovery_completed false and return without overwriting the cache.
| _LOGGER.debug("Cannot perform home discovery without current map info") | |
| self._discovery_completed = True | |
| await self._update_home_cache({}, {}) | |
| return | |
| if self._maps_trait.multi_map_count == 0 and not self._maps_trait.map_info: | |
| _LOGGER.debug("No maps available for home discovery") | |
| self._discovery_completed = True | |
| await self._update_home_cache({}, {}) | |
| return | |
| raise RoborockInvalidStatus("Cannot perform home discovery without current map info") |
There was a problem hiding this comment.
I'm not sure this is worth changing.
There was a problem hiding this comment.
I think I agree?
Our cache should be able to handle going from None to new data I believe on any errors or anything
Allow home discovery to continue without any current homes.
Issue: home-assistant/core#159737