Template: x > y for 5minutes - how?

Hi! i have googled a lot but can’t find a solution for my problem.

i want to compair a sensor with a value or in another case a input_text.NUMBER and trigger something if the sensor is greater or less for 3 minutes.

something like {{ states(‘sensor.p_paradies’)|int > 100 for 3 minutes }}

any idea?

thank you!

The easiest way is to use a Numeric state trigger:

trigger:
  - platform: numeric_state
    entity_id: sensor.p_paradies 
    above: 100
    for: "00:03:00"

For more complex equations it is often easier and more reliable to create a template sensor or binary sensor, then use that sensor as the basis for a State trigger with a for: duration instead of trying to write a template that covers both the equation and duration.

template:
  - binary_sensor:
      - name: "Paradies Above Salon" 
        state: >
          {{ states(sensor.p_paradies) | int > states(sensor.p_salon) | int }}
trigger:
  - platform: state
    entity_id: binary_sensor.paradies_above_salon
    to: 'on'
    from: 'off'
    for: '00:03:00'

Yes for numbers but how to do that when a compare with another sensor value?

SensorA < SensorB for 5 minutes

Ahh!! Could something like this work?

trigger:
  - platform: numeric_state
    entity_id: sensor.p_paradies 
    above: {{ states(‘sensor.p_salon’)|int }}
    for: "00:03:00"

Have to try it later :crossed_fingers:

above and below don’t support templates.
However they do support number and (numeric ) sensor entities.

trigger:
  - platform: numeric_state
    entity_id: sensor.p_paradies 
    above: sensor.p_salon
    for: "00:03:00"

From the documentation for Numeric State Trigger:

1 Like

YES! Thank you guys!

You’re welcome!

However I believe you should assign the Solution tag to Didgeridrew’s post because it was the first to suggest using a Numeric State Trigger and that’s the answer to your original question.