Limit push notifications to only 1 instead multiple

Hi,

I have some binary sensors witch seems to trigger multiple IOS notifications. But i only want 1 notification.

So i tried with delay: 1 sec in the action, but that seems to delay the whole automation and results in a slower notification on my phone.

Tried in the trigger from: ‘off’ to: ‘on’ for: x sec, but that is also delaying the notification.

Is there a way to only send a push notification once regardless the amount of triggers in lets say 1 minute.

Thanks

You can try using a timer and set the condition that the timer is not active.

I do this with an input_boolean.
The input_boolean is set as a condition, and will only allow the notification to run if the input_boolean is off. The notification then turns the input_boolean ON as the final step. I then set up an automation to turn OFF the input_boolean after one minute.

Works without a hitch and allows so that only one notification gets sent during that minute.

You can add a condition to your automation so it does not run if it ran in the last [say] 300 sec:

    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.automation_name.attributes.last_triggered | default(0)) | int > 300)}}'

[EDIT]
Better option that works for any automation and can be copy/pasted without having to edit it:

    - condition: template
      value_template: '{{(as_timestamp(now()) - as_timestamp(this.attributes.last_triggered)) | int(0) > 10 }}'
16 Likes

I kinda like this!

I never thought to approach this type of solution in this capacity. Time to go back and implement this on a few automatons…

Glad you like it. It was a standard feature on the automation app I used before I discovered HA. I use it a lot to ensure things don’t run when they’re not supposed to, like only vacuum the house once a day :wink:

1 Like

Another option, simply turn off your notification automation, insert a delay and then turn it back on.

See example from my config below.

Thank you all for the replies. I do like the solution from lolouk44 and will try to inplement that. Is a universal automation witch can be used easily in multiple automations without addition of extra scripts

This is a pretty neat idea and I’m borrowing it too. However, I’m not that bright. Do I change the ‘300’ to the number of seconds I want my automation disabled for? Thanks for sharing

Almost, replace 300 by the number of seconds that you wish and replace automation_name worth the actual name /alias of your automation

Added your coded with 10 sec for doorbell. Looks promising. But what happens if last_triggered: null is the status when HA has done a reboot?

that’s why I have | default(0) :slight_smile:

Aha. I thought so. Thanks.

Any way to automatically determine the automation you are in so this could be a cut and paste?

Not that I’m aware of, would indeed make cloning automations much easier…

Would there be any issue using 86400 seconds here? i.e that’s not too big an integer for the system to cope with?

works, just tested it.

1 Like

Thank you! I’d have tested it myself but in my ignorance I would have waited a day to be sure it worked correctly!

I know this thread has sat dormant for a while, but I’m trying to do exactly this and can’t get it to work.
My automation looks like this:

- alias: Driveway Motion Notify Telegram
  trigger:
  - platform: state
    entity_id: binary_sensor.driveway_motion
    from: 'off'
    to: 'on'
  condition:    
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(states.automation.automation.driveway_motion_notify_telegram.attributes.last_triggered | default(0)) | int > 30)}}'    
  action:
    service: notify.telegram
    data:
      message: Motion in Driveway
      data:
        photo:
        - url: http://192.168.1.105:81/image/Cam1
          caption: Motion In Driveway

with the condition in the automation I don’t get any notifications. Works fine otherwise. It is just that the motion sensor triggers 4 or 5 times for each car/person/deer/cat up or down the driveway.

Can anyone see what I’m doing wrong?

Thanks

You have double the word automation

1 Like