Passing variables in data_template

i have this automation that on condition of the MQTT message turns on a specific script:

trigger:
  - platform: mqtt
    topic: 'zigbee2mqtt/double_switch_keuken_schuifdeur_links'
action:
  - service: script.turn_on
    data_template:
      entity_id: >
        {%- if "\"left\"" in trigger.payload and is_state("light.light_spots_kozijn", "off")  -%}
        script.light_spots_kozijn_on
        {%- elif "\"left\"" in trigger.payload and is_state("light.light_spots_kozijn", "on")  -%}
        script.light_spots_kozijn_off
        {%- elif "\"left_double\"" in trigger.payload  -%}
        script.light_brightness
        {% else %}
        script.nothing       
        {%- endif -%}   

How do i add a variable that contains the specific light i want to turn on/off our change brightness
light: >
“{{light.light_spots_kozijn}}”
is valid YAML but not accepted in Hass when it’s triggered.

I don’t get this… :frowning:

Need more information… Your automation doesn’t have any lights, you’re only activating scripts. Are you referring to changing the entity_id in your entity_id template or the light inside your scripts?

A little background. The automation is checking a mqtt topic. This gives back 9 different keywords.

Currently with the code above I can trigger a different script for each keyword. But now I also want to pass a variable to the choosen script.

Is this possible or do I need to handle it differently.

I also could use service_template to choose the script to run and put variable in data: and not data_tenplate: ??

Hope you understand.