Template compare states Problem

Hi everyone,

My automation yaml:

- id: bedroom_samsung_home_theater_radio_station_changed
  alias: Bedroom Samsung Home Theater radio station changed
  initial_state: 'on'
  # Looking for radio station change
  trigger:
    - platform: state
      entity_id: input_select.bedroom_samsung_home_theater_radio_station_select
  action:
    # Writing radio station number for selected one
    - service: input_number.set_value
      data_template:
        entity_id: input_number.bedroom_samsung_home_theater_radio_station_number_select
        value: >
          {%- if is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'Ziniu radijas') -%}
            1
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'LRT - Opus') -%}
            2
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'M-1') -%}
            3
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'ZIP FM') -%}
            4
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'Easy FM') -%}
            5
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'Relax FM') -%}
            6
          {%- elif is_state('input_select.bedroom_samsung_home_theater_radio_station_select', 'M-1 plius') -%}
            7
          {%- endif -%}
    # Checking if selected radio station number isn't equal current one
    - service_template: >
    {%- if states('input_nuber.bedroom_samsung_home_theater_radio_station_number_select') == states('input_nuber.bedroom_samsung_home_theater_radio_station_number_actual') -%}

and this automation my problem is this line:

    {%- if states('input_nuber.bedroom_samsung_home_theater_radio_station_number_select') == states('input_nuber.bedroom_samsung_home_theater_radio_station_number_actual') -%}

I never get this if = TRUE.

I have tried:

    {%- if states('input_nuber.bedroom_samsung_home_theater_radio_station_number_select') | float == states('input_nuber.bedroom_samsung_home_theater_radio_station_number_actual') | float -%}

and

    {%- if states('input_nuber.bedroom_samsung_home_theater_radio_station_number_select') | float == 4.0 -%}

and even

    {%- if states('input_nuber.bedroom_samsung_home_theater_radio_station_number_select') < states('input_nuber.bedroom_samsung_home_theater_radio_station_number_actual') -%}

All the time this if = FALSE.

Is that a typo, i.e. meant to be ‘number’?

2 Likes

Your 100% correct. Thanks a lot. This was my silly mistake.