Change of Binary_Sensor-State does not happen

This is what I build:

# Windalam Sensor
binary_sensor:
 - platform: template
   sensors:
      wind_alarm_state:
          entity_id:
            - sensor.wind_speed_station
            - input_number.slider1
            - input_number.slider2
          friendly_name: "Windalarm Status"
          value_template: >-
                  {%- if (states.sensor.wind_speed_station.state|float - states.input_number.slider1.state|float > 0.0 )
                      or (states.sensor.wind_speed_weather.state|float - states.input_number.slider1.state|float > 0.0 ) %}
                  'on'
                  {% else %}
                  'off'
                  {%- endif %}
          device_class: safety

I understood, that all changes in one of the listed items under entity_id will change the value depending on the value_template. I tought it would change from on to off (or the the way round) when I change the input_number.slider1 in a max or minimum using a slider in the gui.
But exactly nothing happens and the state of “wind_alarm_state” is from the begin on ‘off’.
Has anyone any suggestions?

Binary sensor templates must resolve to true or false, not the strings ‘on’ or ‘off’.

Try this:

value_template: >-
  {{ (states.sensor.wind_speed_station.state|float - states.input_number.slider1.state|float > 0.0 )
  or (states.sensor.wind_speed_weather.state|float - states.input_number.slider1.state|float > 0.0 ) }}

And some more parentheses are helping too. And we should not use the states. thing, it is undefined some times.

This is how it works. Thank you for your pling.

# Windalam Sensor
binary_sensor:
 - platform: template
   sensors:
      wind_alarm_state:
              #          entity_id: 
              # - sensor.wind_speed_station
              # - input_number.slider1
              # - input_number.slider2
          friendly_name: 'Windalarm Status'
          value_template: >
                  {% if ((states('sensor.wind_speed_weather') | float) > (states('input_number.slider1') |float) 
                     or (states('sensor.wind_speed_station') | float) > (states('input_number.slider1') |float)) %}
                     true
                  {% endif %}
          device_class: safety

why not follow @tom_l 's suggestion to create a cleaner template? no need using the if , true, endif 's.

simply do:

value_template: >
  {% set slider = states('input_number.slider1')|float %}
  {{ states('sensor.wind_speed_weather') | float > slider or 
     states('sensor.wind_speed_station') | float > slider }}

and it should pass if applicable?
(followed your own maths here, my suggestion is only concerning the template format)

Hi Marius,
thank a lot for showing this.
I am, as you suggest for shure, just at the beginning with this tricky syntax.
I’didnt know about the combination of comands like the “set = …” with other logics in double {{ }} .
That’s cool. Thank you again for your advise! From now on my code will be more tidy at all.
Double thumb up!
Bernd