Roborock vacuum multiple rooms based on input booleans

I have a Roborock vacuum integrated using the built in HA integration. I also have rooms setup and they are working correctly.
I would like to make it so that, in my dashboard, I can select multiple rooms using input booleans, and then have one main vacuum button to trigger the vacuuming.

The documentation for the integration gives this example:

service: vacuum.send_command
  command: app_segment_clean
    - segments:
        - 22
        - 23
      repeat: 2
  entity_id: vacuum.s7_roborock

I’m trying to add if/else templating to the segments section. Wondering why this isnt working for me?

service: vacuum.send_command
  command: app_segment_clean
    - segments: >-
        {% if is_state('input_boolean.rolf_rom_gang', 'on') %}- 19{% endif %} 
        {% if is_state('input_boolean.rolf_rom_kjokken', 'on') %}- 18{% endif%}
        {% if is_state('input_boolean.rolf_rom_spisebord', 'on') %}- 16{% endif %}
        {% if is_state('input_boolean.rolf_rom_stue', 'on') %}- 17{% endif %}   
      repeat: 1
  entity_id: vacuum.rolf

Could you just copy the service call from you lovelace GUI and roll that into a custom button card for ease of setup? Then you can execute specific vac modes also and assosciated buttons.

Im not great at this but thats what I have done for what sounds like you have described.

  "domain": "vacuum",
  "service": "send_command",
  "serviceData": {
    "command": "app_segment_clean",
    "entity_id": "vacuum.yourvacname",
    "params": [
        "segments": [
        "repeat": 1

The idea is to enable vacuuming of for example the kitchen and bathroom. Then press a button to execute the vacuuming of those two rooms.

With your solution it sounds like I have to start vacuuming the kitchen first, then when its finished go back into HA and vacuum the bathroom?

This is a script doing both rooms in one’action’ and is actioned by a button which is place in dashboard. I usually just trigger this script with a voice command or when I drop out of wifi.

Is this what you mean?

alias: vac kitchen and bath
  - service: xiaomi_miio.vacuum_clean_segment
      entity_id: vacuum.cleanopatra
      segments: 16 17
mode: single

Sort of, but that is hardcoded to do those rooms? I want to make it dynamic so sometimes I want to vacuum room 16 and 18, another time 16 and 21. I was hoping a if template could help me do that, but it might not be possible.

That script is hardcoded to do those rooms, yes?
You can create several of your normal combinations in scripts to do this?
are you using the miio integration?
If you have several zones/rooms. Might be better just using the map and clicking where you want to vacuum from your dashboard and vacuum away? Providing you are using miio and map extractor?

This is another much more exhaustive but clever option: