Skip to content

Commit 924f106

Browse files
committed
feat: add current_rooms property to the Home trait and include corresponding tests.
1 parent 562b8d3 commit 924f106

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

roborock/devices/traits/v1/home.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ def current_map_data(self) -> CombinedMapInfo | None:
221221
return None
222222
return self._home_map_info.get(current_map_flag)
223223

224+
@property
225+
def current_rooms(self) -> list[NamedRoomMapping]:
226+
"""Returns the room names for the current map."""
227+
return self.current_map_data.rooms
228+
224229
@property
225230
def home_map_content(self) -> dict[int, MapContent] | None:
226231
"""Returns the map content for all cached maps."""

tests/devices/traits/v1/test_home.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ async def test_discover_home_empty_cache(
257257
assert current_map_data is not None
258258
assert current_map_data.map_flag == 0
259259
assert current_map_data.name == "Ground Floor"
260+
assert [room.name for room in home_trait.current_rooms] == [
261+
"Example room 1",
262+
"Example room 2",
263+
]
260264

261265
# Verify the persistent cache has been updated
262266
device_cache_data = await device_cache.get()
@@ -507,6 +511,11 @@ async def test_discover_home_device_busy_cleaning(
507511
assert home_trait.home_map_info.keys() == {0}
508512
assert home_trait.home_map_content is not None
509513
assert home_trait.home_map_content.keys() == {0}
514+
assert [room.name for room in home_trait.current_rooms] == [
515+
"Example room 1",
516+
"Example room 2",
517+
]
518+
510519
map_0_content = home_trait.home_map_content[0]
511520
assert map_0_content is not None
512521
assert map_0_content.image_content == TEST_IMAGE_CONTENT_1
@@ -548,6 +557,10 @@ async def test_discover_home_device_busy_cleaning(
548557
assert home_trait.home_map_info.keys() == {0, 123}
549558
assert home_trait.home_map_content is not None
550559
assert home_trait.home_map_content.keys() == {0, 123}
560+
assert [room.name for room in home_trait.current_rooms] == [
561+
"Room 16",
562+
"Room 17",
563+
]
551564

552565
# Verify the persistent cache has been updated
553566
device_cache_data = await device_cache.get()

0 commit comments

Comments
 (0)