Vacuum only selected rooms through input_boolean

Hello,

I want to control my robot vacuum to vacuum only the areas of which the input_boolean are true.

I have two robot vacuums at home. One from Roborock and one from iRobot. I manages to get the Roborock one working (see code below), because the command only requires a room_id. The iRobot requires a type and region. Is there a way on how to customize my script for iRobot? Both scripts will be named differently, so no need for backwards compatibility with Roborock.

The group contains all the input_booleans.

Script:

vacuum_plumette_clean_area:
  description: "Clean specific area with vacuum Plumette"
  sequence:
  - service: vacuum.send_command
    data: 
      command: app_segment_clean
      params:
      - segments: "{{ expand('group.vacuum_beneden') | selectattr('state', 'eq', 'on') | map(attribute= 'attributes.room_id') | reverse | list }}"
        repeat: 1
    target:
      entity_id: vacuum.plumette

customize.yaml:

input_boolean.vacuum_boog:
  room_id: 18
  
input_boolean.vacuum_eetkamer:
  room_id: 17
  
input_boolean.vacuum_gang:
  room_id: 20
  
input_boolean.vacuum_keuken:
  room_id: 19

# Boven
input_boolean.vacuum_logeerkamer:
  region_id: 9
  type: 'rid'
  
input_boolean.vacuum_babykamer:
  region_id: 8
  type: 'rid'
  
input_boolean.vacuum_slaapkamer:
  region_id: 10
  type: 'rid'
  
input_boolean.vacuum_gang_boven:
  region_id: 1
  type: 'rid'

Thanks!

With a lot of Google and trial and error I managed to come to a solution.
For futute reference and to help others, here the code.

Cheers

script:

  service: vacuum.send_command
  data:
    entity_id: vacuum.roomba
    command: start
    params:
      pmap_id: "<removed>"
      regions: |
        {% set ns = namespace(regions=[]) %}
        {% for bool in expand('group.vacuum') | selectattr('state', 'eq', 'on') | reverse  %}
          {% set region = state_attr(bool.entity_id, "region_id") | string  %}
          {% set type = state_attr(bool.entity_id, "type") %}
          {% set ns.regions = ns.regions + [{'region_id': region, 'type': type} ] %}
        {% endfor %}
        {{ ns.regions }}
      user_pmapv_id: "<removed>"

and in customize.yaml:

homeassistant:
  customize:
    input_boolean.vacuum_<area name>:
      region_id: 1
      type: 'rid'

output:

[
  {
    "region_id": "2",
    "type": "rid"
  },
  {
    "region_id": "6",
    "type": "rid"
  },
  {
    "region_id": "1",
    "type": "rid"
  },
  {
    "region_id": "7",
    "type": "rid"
  }
]