Is there a way to throttle SMTP / notifications or limit an automation?

I am pretty new to HA. I’m using Home Assistant 2023.1.7 running in VirtualBox on Windows 10.

I have built a device to measure the salt level in my water softener with an ultrasonic distance sensor and a raspberry pi pico. I’ve got it setup to use MQTT, and I’ve setup an automation to send me a notification email when the distance is above a certain threshold (so I know to put more salt in). I’ve tested the device and the automation, and it works fine.

BUT

I’m worried! What if I messed something up in the automation or the device, and it starts triggering SMTP notifications over and over?

Is there a way for me to throttle / limit the number of notifications that HA will trigger? Right now, for instance, there’s no reason that HA should send out more than, say, 10 emails per day. I didn’t see any kind of limit/throttle setting in the docs: SMTP - Home Assistant

Is there a condition or some other setting in an automation that I can use to ensure the notification action of an automation won’t happen more than once per day?

I just noticed a “Delay for a duration” on “Actions”. If I set that to, say, 24 hours, would that keep the whole automation from being triggered again?

Thanks,

Matt

The action can be an “if” condition

If automation.thisone not triggered within 15 minutes of now, do action

Or

Delay 15 minutes after action run and set automation “mode” to “single”

EDIT

I cant tell if your concern is about all automation you may be using in HA or a single automation so I add another suggestions

You may creat an automation the monitors all outgoing messages. If it detect more than xx messages in xx time it could turn OFF all automations that send notification but send notification that requires your response and allows you to take action

“Too many notification in short period”
-stop all notifications
-continue notifications

2 Likes

This would be ideal. Right now, it’s just one that I’m concerned about, but I will keep adding more.

Do you have a more concrete example or maybe a link to the docs page where I could learn how to build a “too many notification in short period” automation?

Use a counter: Counter - Home Assistant

  1. Check if the counter is below your notification maximum
  2. If yes: send your notification and increase the counter
  3. at e.g. midnight reset the counter
2 Likes