Skip to content

Commit 011c9d1

Browse files
authored
fix: support home discovery when there are no maps (#809)
* fix: support home discovery when there are no maps * test: update home discovery test to verify refresh behavior and state consistency
1 parent f0eb62a commit 011c9d1

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

roborock/devices/traits/v1/home.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ async def discover_home(self) -> None:
107107

108108
await self._maps_trait.refresh()
109109
if self._maps_trait.current_map_info is None:
110-
raise RoborockException("Cannot perform home discovery without current map info")
110+
_LOGGER.debug("Cannot perform home discovery without current map info")
111+
self._discovery_completed = True
112+
await self._update_home_cache({}, {})
113+
return
111114

112115
home_map_info, home_map_content = await self._build_home_map_info()
113116
_LOGGER.debug("Home discovery complete, caching data for %d maps", len(home_map_info))
@@ -198,7 +201,8 @@ async def refresh(self) -> None:
198201
if (current_map_info := self._maps_trait.current_map_info) is None or (
199202
map_flag := self._maps_trait.current_map
200203
) is None:
201-
raise RoborockException("Cannot refresh home data without current map info")
204+
_LOGGER.debug("Cannot refresh home data without current map info")
205+
return
202206

203207
# Refresh the map content to ensure we have the latest image and object positions
204208
new_map_content = await self._refresh_map_content()

tests/devices/traits/v1/test_home.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,25 @@ async def test_discover_home_no_maps(
367367
"""Test discovery when no maps are available."""
368368
# Setup mock to return empty maps list
369369
mock_mqtt_rpc_channel.send_command.side_effect = [
370-
[{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}]
370+
# Discover home
371+
[{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}],
372+
# Refresh
373+
[{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}],
371374
]
372375

373-
with pytest.raises(Exception, match="Cannot perform home discovery without current map info"):
374-
await home_trait.discover_home()
376+
# Discover home should not change anything
377+
await home_trait.discover_home()
378+
assert home_trait.current_map_data is None
379+
assert home_trait.home_map_info == {}
380+
assert home_trait.home_map_content == {}
381+
assert home_trait.current_rooms == []
382+
383+
# Refresh should not change anything
384+
await home_trait.refresh()
385+
assert home_trait.current_map_data is None
386+
assert home_trait.home_map_info == {}
387+
assert home_trait.home_map_content == {}
388+
assert home_trait.current_rooms == []
375389

376390

377391
async def test_refresh_updates_current_map_cache(

0 commit comments

Comments
 (0)