Adding 'for' in a template

I have a working binary_sensor.
It turns sensor.warmtepomp_boiler ‘on’ or ‘off’

I want an extra condition added to this:
is_state('binary_sensor.qbus_status_warmtepomp', 'off')

This should only be valid when this state is off for 60 seconds, and not immediately, like it is now.

Browsing the forum, I found that I have to add something like:
if trigger.for.seconds|int >= 60
and I have to change
is_state into to_state

But how do I get this in this template, I’m not sure about the correct placing and syntax.

binary_sensor:
  - platform: template
    sensors:
      warmtepomp_boiler:
        friendly_name: Warmtepomp Boiler                      
        value_template: >
          {% if is_state('binary_sensor.qbus_status_warmtepomp', 'off') and (states('sensor.flukso_warmtepomp_vermogen')|int > 500) %}
          on
          {% else %}
          off
          {% endif %}

Thank you

Try this, this should only show true if the template evaluates to true for 60 seconds.

binary_sensor:
  - platform: template
    sensors:
      warmtepomp_boiler:
        friendly_name: Warmtepomp Boiler                      
        value_template: >
          {{ is_state('binary_sensor.qbus_status_warmtepomp', 'off') and (states('sensor.flukso_warmtepomp_vermogen')|int > 500) }}
        delay_on:
          seconds: 60

It looks that syntax is only for use in an automation since they are the only entities that have the trigger object available. So that won’t work.

Try as suggested above.

Okay, I understand.

And… it works with “delay_on”

Thank you both !

Would you please mark my post as the solution then, so that others will find it quickly in the future and that the topic will be marked as solved.

Done
Sorry, new here, but learning by trying.

Thanks again !

1 Like