From 9188b2cfa05b8bb9c370a2c7d9e3a2423cfbb320 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 5 Apr 2026 10:17:27 -0700 Subject: [PATCH 1/2] fix: support home discovery when there are no maps --- roborock/devices/traits/v1/home.py | 8 ++++++-- tests/devices/traits/v1/test_home.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) 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..7eaa74af 100644 --- a/tests/devices/traits/v1/test_home.py +++ b/tests/devices/traits/v1/test_home.py @@ -370,8 +370,10 @@ async def test_discover_home_no_maps( [{"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() + await home_trait.discover_home() + + assert home_trait.home_map_info == {} + assert home_trait.home_map_content == {} async def test_refresh_updates_current_map_cache( From ad89a0ee6b2caf6a51550bc26bb3b4b29121f524 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Sun, 5 Apr 2026 10:20:39 -0700 Subject: [PATCH 2/2] test: update home discovery test to verify refresh behavior and state consistency --- tests/devices/traits/v1/test_home.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/devices/traits/v1/test_home.py b/tests/devices/traits/v1/test_home.py index 7eaa74af..9c070e01 100644 --- a/tests/devices/traits/v1/test_home.py +++ b/tests/devices/traits/v1/test_home.py @@ -367,13 +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": []}], ] + # 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(