Automation setup to limit notification repetition?

I’m wondering how you can set an automation to only be run in the true state like say once a day.

Example:

I want to get notified if it is raining and my windows are open. But often the precipitation state goes from raining to not several times an hour, but I really only want to be notified the first time each day.

Can I just put a delay of 24 hrs as the last action of the automation?

Thanks!

a 24 hour delay isn’t gong to help you. It won’t prevent the trigger from re-firing.
I have used an input_boolean to accomplish this.
When the automation triggers, I send the warning and turn on the input_boolean, but only if the input_boolean is off.
Then, I have another automation at midnight to turn off the input_boolean.

1 Like

Couldn’t you add an action to the automation to disable the automation? Then another script or automation to turn it back on at midnight.

2 Likes

What @treno said should do what you want to only notify once in any 24 period.

If instead you don’t want to notify if for XX minutes (for people searching based on your subject line), this is what I am using to not send a notification from my front door motion sensor if it’s been sent in within the last 4 minutes (240 seconds):

- alias: Front Door Motion Notify Phones
  hide_entity: True
  trigger:
    platform: state
    entity_id: binary_sensor.front_porch_motion_sensor
    from: 'off'
    to: 'on'
  condition:
    condition: template
    value_template: >
      {% if states.automation.front_door_motion_notify.attributes.last_triggered  %}
        {{ (as_timestamp(now()) - as_timestamp(states.automation.front_door_motion_notify.attributes.last_triggered)) > 240 }}
      {% else %}
        true
      {% endif %}
  action:
    - service: notify.all_mobiles
      data:
        message: "Front Door Motion Detected"
8 Likes

Nice solution

Hi, I guess this is an old thread, but I was looking for a solution to limit the number of times an automation can fire over a certain time period. I am new to this and new to templating, but I don’t quite understand the statement above.

Is the first statement basically saying if the last_triggered attribute is defined? Like it the automation is firing for the first time since reboot, it will be undefined? So if it has a value, evaluate whether or not it was fired more than 240 seconds ago.

Otherwise, if no value, it is automatically true.

Is that correct?
Thanks!

A really simple way to ensure a notification doesn’t re-trigger within a set period is actually explained in the docs, and my example which I use is below. All you have to do is use a delay of whatever value you want as the non-retrigger time at the end of your automation action and using the ‘single’ automation mode (default).

action:
      - service: tts.google_cloud_say
        entity_id: media_player.googlehome3019
        data:
          message: 'Hi there, be aware that the alarm system is armed in sleep mode so the sheds will trigger it'
      - delay: '00:02:00'
2 Likes

Thanks, Dave, that’s really helpful and a very simple solution.