Skip to content

Commit fbc9de9

Browse files
committed
fix(v1): skip multi-map rooms without a cloud room id
get_multi_maps_list can list a room entry with an empty iot_name_id that is absent from get_room_mapping and the map. It was reported as an extra selectable room in the home trait rooms. Treat an empty iot_name_id like a missing one so such entries are skipped. Entries with other ids, such as "-1", are still included.
1 parent 321c6d5 commit fbc9de9

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎roborock/data/v1/v1_containers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ class MultiMapsListRoom(RoborockBase):
431431
@property
432432
def named_room_mapping(self) -> NamedRoomMapping | None:
433433
"""Returns a NamedRoomMapping object if valid."""
434-
if self.id is None or self.iot_name_id is None:
434+
if self.id is None or not self.iot_name_id:
435435
return None
436436
return NamedRoomMapping(
437437
segment_id=self.id,

‎tests/data/v1/test_v1_containers.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,28 @@ def test_multi_maps_list_info(snapshot: SnapshotAssertion) -> None:
371371
assert deserialized == snapshot
372372

373373

374+
def test_multi_maps_list_rooms_map_skips_rooms_without_iot_name_id() -> None:
375+
"""Test that room entries with an empty cloud room id are not reported as rooms."""
376+
maps_list = MultiMapsList.from_dict(
377+
{
378+
"map_info": [
379+
{
380+
"mapFlag": 0,
381+
"name": "Home",
382+
"rooms": [
383+
{"id": 1, "tag": 2, "iot_name_id": "1000001", "iot_name": "Kitchen"},
384+
{"id": 2, "tag": 3, "iot_name_id": "1000002", "iot_name": "Bedroom"},
385+
{"id": 3, "tag": -1, "iot_name_id": "", "iot_name": "Room"},
386+
{"id": 4, "tag": -1, "iot_name_id": "-1", "iot_name": "Hall"},
387+
],
388+
}
389+
]
390+
}
391+
)
392+
assert maps_list.map_info
393+
assert maps_list.map_info[0].rooms_map.keys() == {1, 2, 4}
394+
395+
374396
def test_accurate_map_flag() -> None:
375397
"""Test that we parse the map flag accurately."""
376398
s = StatusV2.from_dict(STATUS)

0 commit comments

Comments
 (0)