Help me with this script

I’m hoping someone with a big brain can help me with my script (pasted at the bottom of this post) because I don’t have a good handle on how templates, and what I have doesn’t work. I presume because of restrictions with how data templates work.

I have a card that calls this script. Now within the script I want to be able to check whether input_boolean.deebot_lounge_rug is on. If it is I want the script to output from the tempate

  - service: vacuum.send_command
    data:
      command: spot_area 
      entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2 
      params:
         map: 200.0,2000.0,1800.0,-1300.0

otherwise I want it to output

  - service: vacuum.send_command
    data:
      command: spot_area 
      entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2 
      params:
         area: *## and then whatever number is on*

Here’s my script

vacuum_clean_zone:
  alias: Cleaning Zone
  sequence:
  - service: vacuum.send_command
    data_template:
      command: spot_area 
      entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2 
      params: >- 
        {% if is_state('input_boolean.deebot_lounge_rug', 'on') %} 
            map: >-
              {%- set x = "" %}
              {% if is_state('input_boolean.deebot_lounge_rug', 'on') %}
                {% set x = x + "200.0,2000.0,1800.0,-1300.0 " %}
              {% endif %}
            {{x[:-1]}}      
        {% else %}
            area: >-
              {%- set x = "" %}
              {% if is_state('input_boolean.deebot_kitchen', 'on') %}
                {% set x = x + "5," %}
              {% endif %}
              {% if is_state('input_boolean.deebot_masterwir', 'on') %}
                {% set x = x + "2," %}
              {% endif %}
              {% if is_state('input_boolean.deebot_guest','on') %}
                {% set x = x + "4," %}
              {% endif %}  
              {% if is_state('input_boolean.deebot_flynnbed','on') %}
                {% set x = x + "7," %}
              {% endif %}
              {% if is_state('input_boolean.deebot_masterbed', 'on') %}
                {% set x = x + "1," %}
              {% endif %}  
              {% if is_state('input_boolean.deebot_mainbath', 'on') %}
                {% set x = x + "3," %}
              {% endif %}
              {% if is_state('input_boolean.deebot_lounge', 'on') %}
                {% set x = x + "0," %}
              {% endif %}
                {{x[:-1]}}
        {% endif %}         

#        cleanings: >-
#              {%- if is_state('input_boolean.deebot_times', 'on') -%}2{%- else
#              -%}1{%- endif -%}
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_kitchen 
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_masterwir
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_guest
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_flynnbed
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_masterbed
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_mainbath
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_lounge
  - service: input_boolean.turn_off
    data:
       entity_id: input_boolean.deebot_lounge_rug   
vacuum_script_set_water:
  alias: set vacuum water level
  sequence:
  - service: vacuum.send_command
    data:
      command: set_water_level
      entity_id: vacuum.4c5b488e_71ab_4b1f_b14e_ad1b90f8b9d6_2
      params:
        level: low|medium|high

There are options within the body of the template (map and area) and that’s not allowed.

You can only use a template to generate a value for an option. You cannot use a template to include/exclude options.

Yep I had a rough idea that was likely to be the issue. I don’t know then how otherwise I could do it. I thought, maybe I could have 2 scripts that separately deal with map and area, but then it’s one card that I use to call the script. I’m stuffed if I know how I would write the script call to have options.

This is the card code:

card:
  color: white
  entity: null
  icon: 'mdi:view-dashboard-outline'
  name: Room
  styles:
    card:
      - font-size: 12px
      - background-color: black
      - color: white
  tap_action:
    action: call-service
    service: script.vacuum_clean_zone
  type: 'custom:button-card'
entities:
  - input_boolean.deebot_lounge_rug
  - input_boolean.deebot_kitchen
  - input_boolean.deebot_lounge
  - input_boolean.deebot_masterbed
  - input_boolean.deebot_masterwir
  - input_boolean.deebot_guest
  - input_boolean.deebot_flynnbed
  - input_boolean.deebot_mainbath
type: 'custom:config-template-card'