diff --git a/roborock/data/v1/v1_containers.py b/roborock/data/v1/v1_containers.py index 7ff1f97fd..91dc98f0b 100644 --- a/roborock/data/v1/v1_containers.py +++ b/roborock/data/v1/v1_containers.py @@ -431,7 +431,7 @@ class MultiMapsListRoom(RoborockBase): @property def named_room_mapping(self) -> NamedRoomMapping | None: """Returns a NamedRoomMapping object if valid.""" - if self.id is None or self.iot_name_id is None: + if self.id is None or not self.iot_name_id: return None return NamedRoomMapping( segment_id=self.id, diff --git a/tests/data/v1/test_v1_containers.py b/tests/data/v1/test_v1_containers.py index 8ade27b90..ee0bb1963 100644 --- a/tests/data/v1/test_v1_containers.py +++ b/tests/data/v1/test_v1_containers.py @@ -371,6 +371,28 @@ def test_multi_maps_list_info(snapshot: SnapshotAssertion) -> None: assert deserialized == snapshot +def test_multi_maps_list_rooms_map_skips_rooms_without_iot_name_id() -> None: + """Test that room entries with an empty cloud room id are not reported as rooms.""" + maps_list = MultiMapsList.from_dict( + { + "map_info": [ + { + "mapFlag": 0, + "name": "Home", + "rooms": [ + {"id": 1, "tag": 2, "iot_name_id": "1000001", "iot_name": "Kitchen"}, + {"id": 2, "tag": 3, "iot_name_id": "1000002", "iot_name": "Bedroom"}, + {"id": 3, "tag": -1, "iot_name_id": "", "iot_name": "Room"}, + {"id": 4, "tag": -1, "iot_name_id": "-1", "iot_name": "Hall"}, + ], + } + ] + } + ) + assert maps_list.map_info + assert maps_list.map_info[0].rooms_map.keys() == {1, 2, 4} + + def test_accurate_map_flag() -> None: """Test that we parse the map flag accurately.""" s = StatusV2.from_dict(STATUS)