Binary sensor with delay_on

Hi,

I have had these binary sensors for quite some time and they worked fine. I was collecting the data for these entities every 5 minutes. I am now able to collect it every 45 seconds. This has led to these sensors triggering a lot more often when we export or import from the grid for a short period of time. I added the delay_on.

Am I using this right? The sensor will not trigger an on state unless we export or import for 2 minutes, but it will trigger an off state straight away?

template:
  - binary_sensor:
      - name: Binary On Grid
        state: "{{ states('sensor.lux_power_from_grid_live') | int(-1) > 0 }}"
        delay_on:
            minutes: 2
      - name: Binary Exporting To Grid
        state: "{{ states('sensor.lux_power_to_grid_live') | int(-1) > 0 }}"
        delay_on:
            minutes: 2

Yes you understand it correctly.

Is there a way to see it trigger and see the two minute wait? I want to confirm it is triggering, but waiting. Hope that makes sense.

Sure. On the history panel observe the binary sensors and their source sensors.

Thank you very much

Just in case it helps others. Mine looks like this. If the sun comes out later and I start to export, I will show what it looks like when one triggers.

Tracking the sensor history has been helpful. My automation to notify me I was exported triggered, but they notification to say I am no long exporting did not.

I can it did wait 2 minutes to trigger the status is off, but off never triggered the notificationScreenshot 2023-08-02 at 13.14.38

Show your automation config.

I think it is working. It looks like it is working. I think the example above was just bad luck. It seemed to trigger after 2 minutes and it then immediately went off.

alias: Grid - Exporting To The Grid Status
description: Grid - Exporting To The Grid Status
trigger:
  - platform: state
    entity_id: binary_sensor.binary_exporting_to_grid
condition:
  - condition: time
    after: "07:00:00"
    before: "21:00:00"
action:
  - service: notify.notify
    data:
      message: |
        {% if trigger.to_state.state == 'off' %}
          No longer exporting
        at {{ now().strftime('%H:%M') }}
        {% else %}
          Exporting {{ states("sensor.lux_power_to_grid_live") }} watts to the grid
        at {{ now().strftime('%H:%M') }}
        {% endif %}
      title: Exporting Status
mode: single

Looks like it is all working. Thanks for the help. The monitoring was a big help. I thunk I was just unlucky with the previous notification.

1 Like