Limit Notifications to X/hour

Wondering if there is a way to limit notifications that are sent to something X per hour? I have a notification that checks a temperature and if it is below a certain temp then send me a notification, but it is sending me one every 10 mins(polling cycle of the temperature device)

1 Like

You could put the notification in a script with a delay of 10 min (after the notification is sent). If you trigger a script that’s already running, it won’t run again (you’ll see an “already running” error in the logs).

Otherwise, you might be able to use the last_triggered attribute in an automation as a condition. You’ll have to structure things so that one automation triggers another.

I like the sound of using the last triggered. Looks like that is part of the state, but not seeing a way to use it yet.

Template trigger.

In case you haven’t found a solution, here is how I did it. The automation basically sends the notification and then calls a script that turns off the automation for 15 minutes:

- alias: 'Sump Water Detected'
  trigger:
    platform: state
    entity_id: binary_sensor.sump_water_detect
    state: 'on'
    for:
      seconds: 15
  action: 
    - service: notify.notify
      data:
        title: 'HASS - DANGER: Sump Pump Detected Water @  "{{now().strftime("%H:%M:%S %m-%d")}}"'
        message: 'HASS - Water was detected in the sump pump room at "{{now().strftime("%H:%M:%S %Y-%m-%d")}}". The current is {{ states.sensor.sump_water_detect.state }} Amps'
    - service: homeassistant.turn_on
      entity_id: script.sump_water_notify_rate_limit

script:
sump_water_notify_rate_limit:
  alias: Rate Limit Sump Pump Water Detect Notifications
  sequence:
    - service: homeassistant.turn_off
      entity_id: automation.sump_water_detected
    - delay: '00:15:00'
    - service: homeassistant.turn_on
      entity_id: automation.sump_water_detected

Feedback on this rate-limits for group notifications? I did it in group.notify since that seemed like a nice place to add the extra complexity rather than making it fundamental to notify.