diff --git a/roborock/devices/traits/v1/home.py b/roborock/devices/traits/v1/home.py index 5034d33c..2d9d7bb1 100644 --- a/roborock/devices/traits/v1/home.py +++ b/roborock/devices/traits/v1/home.py @@ -107,7 +107,10 @@ async def discover_home(self) -> None: await self._maps_trait.refresh() if self._maps_trait.current_map_info is None: - raise RoborockException("Cannot perform home discovery without current map info") + _LOGGER.debug("Cannot perform home discovery without current map info") + self._discovery_completed = True + await self._update_home_cache({}, {}) + return home_map_info, home_map_content = await self._build_home_map_info() _LOGGER.debug("Home discovery complete, caching data for %d maps", len(home_map_info)) @@ -198,7 +201,8 @@ async def refresh(self) -> None: if (current_map_info := self._maps_trait.current_map_info) is None or ( map_flag := self._maps_trait.current_map ) is None: - raise RoborockException("Cannot refresh home data without current map info") + _LOGGER.debug("Cannot refresh home data without current map info") + return # Refresh the map content to ensure we have the latest image and object positions new_map_content = await self._refresh_map_content() diff --git a/tests/devices/traits/v1/test_home.py b/tests/devices/traits/v1/test_home.py index f2871637..9c070e01 100644 --- a/tests/devices/traits/v1/test_home.py +++ b/tests/devices/traits/v1/test_home.py @@ -367,11 +367,25 @@ async def test_discover_home_no_maps( """Test discovery when no maps are available.""" # Setup mock to return empty maps list mock_mqtt_rpc_channel.send_command.side_effect = [ - [{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}] + # Discover home + [{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}], + # Refresh + [{"max_multi_map": 0, "max_bak_map": 0, "multi_map_count": 0, "map_info": []}], ] - with pytest.raises(Exception, match="Cannot perform home discovery without current map info"): - await home_trait.discover_home() + # Discover home should not change anything + await home_trait.discover_home() + assert home_trait.current_map_data is None + assert home_trait.home_map_info == {} + assert home_trait.home_map_content == {} + assert home_trait.current_rooms == [] + + # Refresh should not change anything + await home_trait.refresh() + assert home_trait.current_map_data is None + assert home_trait.home_map_info == {} + assert home_trait.home_map_content == {} + assert home_trait.current_rooms == [] async def test_refresh_updates_current_map_cache(