See Design Pattern: Encoding and Accessing Values in Rules for a number of techniques of embedding the ID of the room with the Item.
See Design Pattern: Working with Groups in Rules for all sorts of things you can do with Groups.
Given those, let’s say you’ve encoded the ID in the Item name, as you have kind of done already.
Then you can do something like
val rooms = gVacRoom.members.filter[ room | room.state == ON ].map[ name ].reduce[ ids, name | ids = ids + ", " + name.replace("room", "") ]
Roborock.sendCommand("app_segment_clean["+ids+"]")
I just typed in the above and there might be typos or the like, but it along with the two design patterns should get you going.