Skip to content

fix: recover missing selected maps without caching placeholders - #995

Open
endoftheline818 wants to merge 1 commit into
Python-roborock:mainfrom
endoftheline818:codex/fix-roborock-missing-map
Open

endoftheline818 wants to merge 1 commit into
Python-roborock:mainfrom
endoftheline818:codex/fix-roborock-missing-map

Conversation

@endoftheline818

Copy link
Copy Markdown

Some vacuums show "NO MAP" even though a saved map is already selected. Selecting that same map again restores the image. This change performs that recovery automatically when the vacuum is idle or charging, without interrupting cleaning or a return to the dock.

The fix belongs in HomeTrait, as requested in home-assistant/core#186678:

  • Load the known selected map before fetching its image during single-map discovery and normal refresh. Reuse the existing map-loading delay, and avoid loading a map twice during multi-map discovery.
  • Defer discovery while the device is busy. Translate a refused reload into RoborockDeviceBusy and let refresh read the current map without repeating the rejected command.
  • Keep "NO MAP" placeholders out of the saved map cache, preserve the last good map during a temporary empty response, and remove placeholders cached by older versions.

Fixes #985. Related: home-assistant/core#185133 and home-assistant/core#186678.

Validation:

  • The added recovery and cache tests reproduce the failures before their fixes and pass afterward.
  • Full Linux test suite on Python 3.11: 1,645 passed, 53 expected failures, 11 real-broker tests excluded by the default configuration; 99 snapshots passed.
  • Full Linux test suite on Python 3.14: 1,645 passed, 53 expected failures, 11 real-broker tests excluded by the default configuration; 99 snapshots passed.
  • All pre-commit checks passed, including Ruff, mypy and codespell.
  • Wheel and source distribution builds passed.

Tests use simulated device responses. A physical Q5 Pro has not been tested with this change.

AI assistance: OpenAI Codex helped prepare and test this change under the contributor's direction.

@swastiktawate swastiktawate left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a thorough fix. The recovery path is properly guarded — idle/charging states only, never while cleaning or returning — and the fallback to recover_missing=False on a busy device means a locked action degrades gracefully instead of failing the whole refresh. Filtering placeholder 'NO MAP' images out of both the in-memory and persisted cache is the right call, and the guard matrix plus the exactly-once reload assertion in the tests show the edge cases were thought through.

This branch has not been deployed

No deployments
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.

HomeTrait does not load map (LOAD_MULTI_MAP) when map_present == 0 on single-map devices

2 participants