Repository: home-assistant/core
File: homeassistant/components/roborock/vacuum.py (Python)

Code before:
    async def async_send_command(
        self,
        command: str,
        params: dict[str, Any] | list[Any] | None = None,
        **kwargs: Any,
    ) -> None:
        """Send a command to a vacuum cleaner."""
        await self.send(command, params)

    async def get_maps(self) -> ServiceResponse:
        """Get map information such as map id and room ids."""
        home_trait = self.coordinator.properties_api.home
        return {
            "maps": [
                {
                    "flag": vacuum_map.map_flag,
                    "name": vacuum_map.name,
                    "rooms": {
                        # JsonValueType does not accept a int as a key - was not a
                        # issue with previous asdict() implementation.
                        room.segment_id: room.name  # type: ignore[misc]
                        for room in vacuum_map.rooms
                    },
                }
                for vacuum_map in (home_trait.home_map_info or {}).values()
            ]
        }

    async def get_vacuum_current_position(self) -> ServiceResponse:
        """Get the current position of the vacuum from the map."""
        map_content_trait = self.coordinator.properties_api.map_content
        try:
            await map_content_trait.refresh()
        except RoborockException as err:
            _LOGGER.debug("Failed to refresh map content: %s", err)
            raise HomeAssistantError(
                translation_domain=DOMAIN,
                translation_key="map_failure",
            ) from err
        if map_content_trait.map_data is None:
            raise HomeAssistantError(
                translation_domain=DOMAIN,
                translation_key="map_failure",
            )
        if (robot_position := map_content_trait.map_data.vacuum_position) is None:
            raise HomeAssistantError(
                translation_domain=DOMAIN, translation_key="position_not_found"
            )

        return {
            "x": robot_position.x,

Review comment (suggestion):
```suggestion
            parts = seg_id.split(":", maxsplit=1)
```

Code after:

    async def async_set_vacuum_goto_position(self, x: int, y: int) -> None:
        """Send vacuum to a specific target point."""
        await self.send(RoborockCommand.APP_GOTO_TARGET, [x, y])

    async def async_get_segments(self) -> list[Segment]:
        """Get the segments that can be cleaned."""
        home_map_info = self._home_trait.home_map_info
        if not home_map_info:
            return []
        return [
            Segment(
                id=f"{map_flag}:{room.segment_id}",
                name=room.name,
                group=map_info.name,
            )
            for map_flag, map_info in home_map_info.items()
            for room in map_info.rooms
        ]

    async def async_clean_segments(self, segment_ids: list[str], **kwargs: Any) -> None:
        """Clean the specified segments."""
        parsed: list[tuple[int, int]] = []
        for seg_id in segment_ids:
            # Segment id is mapflag:segment_id
            parts = seg_id.split(":")
            if len(parts) != 2:
                raise ServiceValidationError(
                    translation_domain=DOMAIN,
                    translation_key="segment_id_parse_error",
                    translation_placeholders={"segment_id": seg_id},
                )
            try:
                # We need to make sure both parts are ints.
                parsed.append((int(parts[0]), int(parts[1])))
            except ValueError as err:
                raise ServiceValidationError(
                    translation_domain=DOMAIN,
                    translation_key="segment_id_parse_error",
                    translation_placeholders={"segment_id": seg_id},
                ) from err

        # Because segment_ids can overlap for each map,
        # we need to make sure that only one map is passed in.
        unique_map_flags = {map_flag for map_flag, _ in parsed}
        if len(unique_map_flags) > 1:
            map_flags_str = ", ".join(str(flag) for flag in sorted(unique_map_flags))
            raise ServiceValidationError(
                translation_domain=DOMAIN,
                translation_key="multiple_maps_in_clean",
                translation_placeholders={"map_flags": map_flags_str},