Skip to content

fix: support home discovery when there are no maps#809

Merged
allenporter merged 2 commits intoPython-roborock:mainfrom
allenporter:fix-no-current-mapa
Apr 6, 2026
Merged

fix: support home discovery when there are no maps#809
allenporter merged 2 commits intoPython-roborock:mainfrom
allenporter:fix-no-current-mapa

Conversation

@allenporter
Copy link
Copy Markdown
Contributor

Allow home discovery to continue without any current homes.

Issue: home-assistant/core#159737

Copilot AI review requested due to automatic review settings April 5, 2026 17:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +110 to +113
_LOGGER.debug("Cannot perform home discovery without current map info")
self._discovery_completed = True
await self._update_home_cache({}, {})
return
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
_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")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is worth changing.

Copy link
Copy Markdown
Collaborator

@Lash-L Lash-L Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I agree?

Our cache should be able to handle going from None to new data I believe on any errors or anything

@allenporter allenporter merged commit 011c9d1 into Python-roborock:main Apr 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants