Automation based on input_select problem

Hi all,
I’m trying to make that happen - automation based on input_select.
This my automation code:

- alias: spotify_minix
  trigger:
    platform: state
    entity_id: input_select.minix_spotify
  action:
    - service: script.turn_on
        entity_id_template: >
          {% if it is state("input_select.minix_spotify", "Electronic") %}
            script.spotify_minix_electronic
          {%-elif is_state("input_select.minix_spotify", "Regae") %}
            script.spotify_minix_regae
          {%-elif is_state("input_select.minix_spotify", "Rock") %}
            script.spotify_minix_rock
          {%-elif is_state("input_select.minix_spotify", "S") %}
            script.spotify_minix_s
          {%-elif is_state("input_select.minix_spotify", "Stop i wyłącz amplituner") %}
            script.spotify_minix_stop
          {% else %}
            none
          {% endif %}

I will be grateful for any help

Read the example here:

Under the heading : USE TEMPLATES TO DETERMINE THE ATTRIBUTES

1 Like

Thanks, after that it should like to be:

- alias: spotify_minix
  trigger:
    platform: state
    entity_id: input_select.minix_spotify
  action:
    - service: script.turn_on
      data_template:
        entity_id: >
          {% if is_state("input_select.minix_spotify", "Electronic") %}
            script.spotify_minix_electronic
          {%-elif is_state("input_select.minix_spotify", "Regae") %}
            script.spotify_minix_regae
          {%-elif is_state("input_select.minix_spotify", "Rock") %}
            script.spotify_minix_rock
          {%-elif is_state("input_select.minix_spotify", "S") %}
            script.spotify_minix_s
          {%-elif is_state("input_select.minix_spotify", "Stop i wyłącz amplituner") %}
            script.spotify_minix_stop
          {% else %}
            none
          {% endif %}

It works! :slight_smile:

1 Like