How to group a sensor that emits multiple on/off within few seconds?

I made my “dumb” bell into a smart bell by adding a door sensor next to the magnetic coil. Works perfectly, but with a downside:

When someone rings at the door, depending on length of pressing the button outside, the sensor lists 10+ on/off messages, thus I get 10+ notifications. (I am trying to flash my ceiling lights few times when someone rings.).

How do I get my sensor grouped into one bell? I tried templating, but seems not working or i might have set it up wrong.

What platform are you using for the bell? Zwave, RFXTRX, something else? Please share to let us help you.
And show us your config, because that might be the cause.

It’s a simple binary door/window sensor from Xiaomi (https://www.home-assistant.io/components/binary_sensor.xiaomi_aqara/).

It use it everywhere and it works just fine, except that I modified one just for the doorbell and I need it to behave differently than the others. I’ll post the config later.

trigger:
- entity_id: binary_sensor.door_window_sensor_id
  platform: state
  to: 'off'
action:
- data:
    message: 'Somebody is at the door. (Binary)'
  service: notify.telegram_info

That gives me for example within 6 notifications within 2 seconds of pressing our doorbell.

 Somebody is at the door. (Binary)
 Somebody is at the door. (Binary)
 Somebody is at the door. (Binary)
 Somebody is at the door. (Binary)
 Somebody is at the door. (Binary)
 Somebody is at the door. (Binary)

Now what I want is to group all these notifications into one notification for the time being and trigger it (or trigger the first one and skip the concurrent ones).

But how/what’s the best way to achieve this? Add a duration after trigger? Or detect when state hasn’t been ‘on’ for a second and trigger afterwards?
My logical mind is at a loss here.

Can’t you just add in a delay of say 5 seconds? So it only sends a second message if the state is still off after 5 seconds?

What about using

  • an input_boolean that’s triggered when somebody rings the doorbell,
  • then the change of the input-boolean triggers a notofication, and
  • after 10-12-20 seconds the input_boolean is reset.

This way you’ll receive only on message every 10, 12, or 20 seconds - no matter how long or how many times the button is pushed.

That’s exactly what I said in this thread with working example:

I’m using a delay to debounce my doorbell:

# configuration.yaml

automation:
  - alias: Send notification if the door bell rings
    trigger:
      platform: state
      entity_id: binary_sensor.door_window_sensor_158d00015ae7a8
      from: 'on'
      to: 'off'
    condition:
      condition: state
      entity_id: script.debounce_door_bell
      state: 'off'
    action:
      service_template: script.debounce_door_bell

script:
  debounce_door_bell:
    sequence:
        - service: notify.html5
          data:
            title: Door bell
            message: The door bell rings!
        - delay: '00:00:10'

A input_boolean isn’t needed. The script has an “on” (running) and “off” state.

3 Likes

Thanks a lot for the inputs, everyone. I will try them all and look which one is suitable.