diff --git a/roborock/devices/traits/v1/rooms.py b/roborock/devices/traits/v1/rooms.py index 021373dce..c699d6f14 100644 --- a/roborock/devices/traits/v1/rooms.py +++ b/roborock/devices/traits/v1/rooms.py @@ -135,6 +135,13 @@ async def refresh(self) -> None: rooms = rooms.with_room_names(self._room_name_map) common.merge_trait_values(self, rooms) + async def clean_segments(self, segment_ids: list[int]) -> None: + """Start cleaning the given segments (rooms) of the current map. + + Segment ids are the `segment_id` values in `rooms`. + """ + await self.rpc_channel.send_command(RoborockCommand.APP_SEGMENT_CLEAN, params=[{"segments": segment_ids}]) + async def _refresh_rooms(self) -> list[HomeDataRoom]: """Fetch the latest rooms from the web API.""" try: diff --git a/tests/devices/traits/v1/test_rooms.py b/tests/devices/traits/v1/test_rooms.py index 9e6d720fa..f0e4442ca 100644 --- a/tests/devices/traits/v1/test_rooms.py +++ b/tests/devices/traits/v1/test_rooms.py @@ -234,3 +234,12 @@ async def test_refresh_shared_room_names_use_shared_device_rooms( ] web_api_client.get_shared_device_rooms.assert_called_once_with(rooms_trait._device_uid) web_api_client.get_rooms.assert_not_called() + + +async def test_clean_segments(rooms_trait: RoomsTrait, mock_rpc_channel: AsyncMock) -> None: + """Test starting a segment clean.""" + await rooms_trait.clean_segments([17, 19]) + + mock_rpc_channel.send_command.assert_called_once_with( + RoborockCommand.APP_SEGMENT_CLEAN, params=[{"segments": [17, 19]}] + )