Create multiple Rules with similar configuration for different items

I am having multiple Rooms, each with the same base setup. Each room has a chromecast, a buttonboard with 5 Buttons, one PIR and at least one controlled lamp.

Even though the rooms have different configurations, the config base is always the same.

When Button 1 is pressed, the Volumet of the Chromecast in that room should be lowered, Button 2 Increases the volume and button 3 cycles through different scenes for that room.

However I don’t want to create the same rules for every room by hand. Is there a way to automate the creation of these rules?

In python I would do something like that:

def createRoomRules(devices):
    ... Create the rules ...

roomDevices : [
  (room1_cc, room1_b1, room1_b2, ...),
  (room2_cc, room2_b1, room2_b2, ...),
  (room3_cc, room3_b1, room3_b2, ...)

createRoomRules(devices) for device in roomDevices

You may want to look into JSR223, it is a Jython interface to write python-like rules and seemingly tap into the power of python (disclaimer: I am just a reader of the forum here). There is some documentation available, however, you may want to search the forum as this is an area under development and the docs are lacking behind as far as I understand.
this here: [JSR223-Jython] Simplified rule definition (similar to Rules DSL) and universal decorator and here: Jython scripting examples using lucid, an openHAB 2.x jsr223 Jython helper library may help you further.

Example Items