Checking value of an input_select

I have an input_select.sonos which holds my radio stations:

options: None,.977 80’s Hits,Ambi Nature Radio (Sleep, Relaxation & Meditation),Gary Stadler,GotRadio Folklore,Nirvana Meditation Radio,Relax Zone,SomaFM: ThistleRadio
friendly_name: Sonos
icon: mdi:radio

I choose an option from the list and my sonos change the station… that is ok!

Now I want to add an automation that must cycle on the stations:

- id: cube_bianco_change_radio
  alias: "MiCube2 Shake - Sono Cambia Radio"
  initial_state: 'on'
    platform: event
    event_type: cube_action
      entity_id: binary_sensor.cube_158d00010fce06
      action_type: shake_air
    - service: input_select.select_option
        entity_id: input_select.sonos
        option: >
          {% if is_state("input_select.select_option","GotRadio Folklore")  %}
            Gary Stadler
          {% elif is_state("input_select.select_option","Nirvana Meditation Radio") %}
            GotRadio Folklore
          {% else %}
            Ambi Nature Radio (Sleep, Relaxation & Meditation)
          {% endif %}

The automation starts but alway fallback to else statement : “Ambi Nature…”

What I am doing wrong?


Blame on me: I am too tired!

{% if is_state(“input_select.select_option”…

must be:

{% if is_state(“input_select.sonos”…

Sorry… too tired! :persevere:

I think you can make it even easier by using the input_select.select_next service instead. See here.

1 Like