Receive warnings only once per day?

G’day,
is there a better way to let Openhab send a notification only the first time it happens until midnight than to create a lock variable that is set true when shot and reset to false when midnight is coming?
Looks too “basic” to me and i hope there is a more elegant way this can be done via Openhab.

Kind Regards,
Norbert

That’s already pretty simple. Not sure how much simpler it can become. You could skip the resetting part and just save a timestamp. Only send subsequent alerts if they occur a certain amount of time after the last alert based on that timestamp.

I have a library called “RateLimit” for JavaScript that will do this for you, but you need to be coding rules in JavaScript and you have to install the library which isn’t super easy right now (git clone and copy).

I have a Rule Template on the Marketplace: Threshold Alert

You can just install and configure it like an add-on. But it doesn’t do exactly what you are asking for. It lets you specify a condition as well as a rate limit (e.g. no more than once every 12 hours) and a do not disturb time period where no alerts will be sent. At the end of the DND period, if the condition is still met then the alert will be sent then.

It’s far from elegant given it runs to a couple hundred lines of code. But all you have to do is install it and instantiate a rule with it. You don’t have to even look at the code. You just set the properties (what’s the condition, threshold value, rate limit and DND period. And by configure it I don’t mean editing some lines at the top of the file, there’s a form.

Thanks a lot Rich for your programming effort and the link. I try to avoid JS as much as possible, better saying i have not used it anywhere up to now.

As normally you have much better approaches on rules, would it be OK to use a lock-var that goes ON when triggered the first time and at midnight it resets to OFF…so the notification rule is ready to trigger/send again?
Kind Regards Norbert

Anything is OK. You just have to be careful that you don’t have more than one rule that triggers that modifies/checks that variable really close together. There is a race condition if you do that.

NOTE: The Threshold Alert template is something you just install. You don’t have to even look at the code. You just install it, instantiate it, and fill out the properties. It doesn’t really even matter what language it’s written in.

The only reason I bring this up yet is because most users can and should get out of the business of writing rules in the first place. Over time rules should become something that is browsed for an installed, not copied form somewhere and modified or coded by hand.

If Threshold Alert can meet your needs, you’re better off using that than coding it yourself. If it doesn’t meet your needs you can request changes and maybe I can make it work the way you need it to, all without you ever having to look at a single line of code, Rules DSL, JavaScript or anything else.