Skip to content

Commit 390afc8

Browse files
hCoureauclaude
andauthored
feat(v1): add clean_segments helper to RoomsTrait (#1081)
* feat(v1): add clean_segments helper to CommandTrait Starting a V1 room clean meant building the app_segment_clean payload by hand, while Q7 and Q10 already expose clean_segments(segment_ids). CommandTrait.clean_segments(segment_ids) sends [{"segments": segment_ids}] and does not set a repeat count. * refactor: move clean_segments to RoomsTrait CommandTrait is meant to only expose the low-level send command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Harry Coureau <183213654+hCoureau@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 93f0d98 commit 390afc8

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎roborock/devices/traits/v1/rooms.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ async def refresh(self) -> None:
135135
rooms = rooms.with_room_names(self._room_name_map)
136136
common.merge_trait_values(self, rooms)
137137

138+
async def clean_segments(self, segment_ids: list[int]) -> None:
139+
"""Start cleaning the given segments (rooms) of the current map.
140+
141+
Segment ids are the `segment_id` values in `rooms`.
142+
"""
143+
await self.rpc_channel.send_command(RoborockCommand.APP_SEGMENT_CLEAN, params=[{"segments": segment_ids}])
144+
138145
async def _refresh_rooms(self) -> list[HomeDataRoom]:
139146
"""Fetch the latest rooms from the web API."""
140147
try:

‎tests/devices/traits/v1/test_rooms.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,12 @@ async def test_refresh_shared_room_names_use_shared_device_rooms(
234234
]
235235
web_api_client.get_shared_device_rooms.assert_called_once_with(rooms_trait._device_uid)
236236
web_api_client.get_rooms.assert_not_called()
237+
238+
239+
async def test_clean_segments(rooms_trait: RoomsTrait, mock_rpc_channel: AsyncMock) -> None:
240+
"""Test starting a segment clean."""
241+
await rooms_trait.clean_segments([17, 19])
242+
243+
mock_rpc_channel.send_command.assert_called_once_with(
244+
RoborockCommand.APP_SEGMENT_CLEAN, params=[{"segments": [17, 19]}]
245+
)

0 commit comments

Comments
 (0)