Run script based on input_select value

I have an input_select with following options:
Daylight, Warm, Relax, Night

For each room, I have a series of scripts
Living_warm, living_relax, dining_warm, dining relax etc.
which set a number of lights to the relevant setting

Now i am trying to have one automation which calls the relevant script based on the option set in the input_select

Here is my code, but I am not getting the right values in the call.

alias: 'cycle_living_light'
  initial_state: true
  trigger:
    - platform: state
      entity_id: input_select.cycle_living_lights
  action:
    - service: script.turn_on             # lauch relevant script
      data_template:
        entity_id: script.livingroom_{{ states('input_select.cycle_living_lights') }}

That last line is obviously wrong!

It was pretty close though. Single line templates need to be enclosed in quotes.

  action:
    - service: script.turn_on             # lauch relevant script
      data_template:
        entity_id: "script.livingroom_{{ states('input_select.cycle_living_lights') }}"

The other way to do it is with a service template:

  action:
    - service_template: "script.livingroom_{{ states('input_select.cycle_living_lights') }}"

Because scripts are services. There is a caveat with calling a script like that though: Scripts - Home Assistant

Doing it with the service template will wait for the script to complete before moving to the next action (if there is one). Doing it with script.turn_on will run the script and the next action in parallel.

That did it.
Thanks a lot
E

The automation is triggered by input_select.cycle_living_lights. That means its state is available in the action via the Trigger State Object. The template doesn’t have to request the input_select’s state but can simply get it via trigger.to_state.state like this:

alias: 'cycle_living_light'
  initial_state: true
  trigger:
    - platform: state
      entity_id: input_select.cycle_living_lights
  action:
    - service: script.turn_on             # lauch relevant script
      data_template:
        entity_id: "script.livingroom_{{ trigger.to_state.state }}"