Rule Machine: Allow trigger max 3 times per day

Is there a simple way to only allow a trigger to occur a maximum number of times per day? I have a irrigation valve triggered by a soil moisture sensor and I don't want to flood my yard if the sensor goes haywire.

Why not just create a variable and increment it each time you irrigate. If the variable is greater than 3, dont irrigate. Reset the variable to 0 at midnight.


I'd add a notification if it tried to do it more than the 3 times as it could be a sign of the opposite problem and the irrigation system not watering at all if the soil is registering that dry so often.


Hey! Stop trying to improve on all my suggestions :joy:


Lol sorry, I should have been focussing on tweaking my lighting scenes anyway. Definitely got attention deficit this morning :smiley:

1 Like

No need for an apology! All of your suggestions are definitely improvements on mine :+1: :grin:

1 Like

If I use a local variable for number of triggers, how do I also trigger the reset at midnight without also triggering the irrigation action? I suppose if the variable were global I could reset using a completely different rule, but that divides the logic between separate rules.

I thought your trigger was the soil sensor? Why would resetting the count trigger the irrigation?

Because the rule runs the irrigation valve. If I add a trigger at midnight (to reset the counter), then I have to inhibit the valve at midnight, which I haven't found an obvious way of doing yet.

Ok, im a bit confused by what youre trying to achieve. What about logic something like this..

Rule 1
Trigger: soil sensor reports dry
If IrigCount <= 3 then
Valve On
Delay 30 mins
Valve Off
IrigCount = IrigCount + 1
Notify User "Excessive irrigation attempts"

Rule 2
Trigger: Time is 00:00
IrigCount = 0

Yes, its 2 rules and a global variable, but sometimes its just easier than trying to cram everything into 1 rule. Resetting the IrigCount doesnt trigger the irrigation

Would this work for you?

You nailed my logic perfectly. Using a global is fine with me, but it felt like I was missing something that would have allowed me to contain the counter within the one rule (easier to debug in the long run). Thank for looking it over and confirming what I was finding.

1 Like

I'm sure there are ways to keep all the logic in a single rule - i didnt check. In my 35+ years experience as a programmer, KISS rules :wink:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.