Skip to content

Conversation

@allenporter
Copy link
Contributor

This updates the Home trait to allow the current map to be refreshed even if initial discovery fails. The caller can invoke discovery at startup, but then after just invoke refresh and the right thing should happen.

We now track discovery explicitly and only persist the cache when we have completed discovery to avoid persisting an incomplete view of all available maps.

Copilot AI review requested due to automatic review settings November 8, 2025 15:41
@allenporter allenporter closed this Nov 8, 2025
@allenporter allenporter reopened this Nov 8, 2025
This updates the Home trait to allow the current map to be
refreshed even if initial discovery fails. The caller can
invoke discovery at startup, but then after just invoke
refresh and the right thing should happen.

We now track discovery explicitly and only persist the cache when we have completed discovery to avoid persisting an incomplete view of all available maps.
Copy link
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 refactors the HomeTrait.refresh() behavior to handle scenarios where home discovery hasn't completed yet, particularly when the device is busy cleaning. The key improvement is allowing refresh to fall back to updating only the current map when full discovery cannot be performed.

  • Modified refresh() to attempt discovery when not completed, gracefully falling back to current map refresh when device is busy
  • Updated _update_current_map() to conditionally update persistent cache based on discovery completion status
  • Removed obsolete test for error condition that no longer exists, added comprehensive test for refresh behavior during device busy state

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
roborock/devices/traits/v1/home.py Added _discovery_completed flag to track discovery state; refactored refresh() to attempt discovery first and fall back to current map refresh; updated _update_current_map() to conditionally persist cache based on discovery status
tests/devices/traits/v1/test_home.py Removed test for obsolete error condition; added verification of persistent cache updates in discovery test; expanded device busy test to cover refresh attempts during and after cleaning

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

allenporter and others added 2 commits November 8, 2025 08:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed redundant assertion for home_map_info length.
# then we'll fall through below to refresh the current map only.
try:
await self.discover_home()
return self
Copy link
Collaborator

Choose a reason for hiding this comment

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

not against it but do we utilize anywhere the fact that this is returning self?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, agreed, we never use it and it only adds typing pain. I'll remove it in a followup PR.

@allenporter allenporter merged commit 44680e3 into Python-roborock:main Nov 11, 2025
6 of 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.

2 participants