Trigger on Temperature Compare Only Once Per Day

I've written a rule to notify if outside temp <= inside temp. How do I configure it to only trigger once per day rather than multiple times until no longer true?

Thx

Use time as the trigger and not the temperature. Then do a compare in a conditional.
Or have it run all the time and use a virtual switch to send a notification.
Can set a notifier limit also.

I don't follow.

I cannot predict the time of day the temperature compare will be true. If I could, I wouldn't need to compare temps...

Unless OP wants to know as soon as outside temp<=inside temp, but not again til the next day.

Set a variable to the current date when you get notified, then make a condition comparing the variable to current date and if the same then exit the rule

Just keep in mind you might spam your hub with temperature changing and the rule running a bunch so I'd figure out a way to slow down the checks. Use an interval or something.

What I mean is:
Trigger
run every 5 minutes
Action
If virtual switch on exit rule
If inside <= outside
Turn on virtual switch

Notifier
When such and such switch come on send me a notice but only once a day

Throw in an auto off in 24 hours on the switch. Or at sunrise or whatever you want.

1 Like

Good call with the time interval. Maybe every 15 or 30 minutes run the rule.

Thinking about it more, set the variable to 'warmer' or 'cooler' based on outside vs inside temp and use that to compare as the condition. That way you only get notified after the temperature swaps. You don't need to be notified each day if its been 40f outside for a week.

Trigger: every xx minutes
Action:
Set lastvariable = currentvariable
If inside>=outside then
set currentvariable cooler
Else
set currentvariable warmer
End if
If currentvariable = cooler & currentvariable != lastvariable then
Notify temp is cooler outside
End if

Still need to rate limit the notification.

It should only notify the first time temperature goes cooler outside. Then each subsequent run it will read:

If cooler = cooler & cooler != cooler

Which will skip the notification, until the lastvariable get set to warmer.

Yes but if they are close in temp you could get a bunch in a few runs. The first part of that logic is a little goofy also. Depending on if warmer or cooler you could be comparing indoor to indoor.

True, if the temp bounces above and below the threshold in between runs. Maybe have a 5 degree buffer when setting cooler, or a rate limit as lewis.heidrick suggests.

I'd just compare the temps to each other and leave the warmer cooler thing in your notification.

Just a heads up. Variables can be a pita if not careful. All kinds of stuff could break it.

I may have finally figured out an elegant solution to this. I haven't tested yet but please let me know if you see any issues with the following logic.

Assumes 'Wait for conditions' prevents additional instances of the same rule from executing.

It does not. Waits are cancelled by subsequent triggers.

1 Like

Maybe this will help: I have a rule that compares two temperatures for the purpose of turning an exhaust fan on and off. I know from experience that it only happens once a day. There is one small trick in the rule that pretty much guarantees this outcome, although perhaps not foolproof in really bizarre weather circumstances.

One sensor is outside, and the other is inside my garage. I live in Arizona, so inside the garage will become quite hot in the summer, and the fan can cool it down some. In my use case, I don't want to bother turning on the fan until it is 2 degrees cooler outside than inside. Then it turns off when the two temperatures are the same. This 2 degree difference in the on and off sides of the logic is what makes it work predictably, and not bounce on and off. Pretty much like your use case where you only need to be notified once.

The trigger of the rule is either temperature sensor changes. The rule consists of an IF-THEN-ELSE-IF, where the first test is the 2 degrees cooler outside than in, and the second test is the inside less than or equal the outside temp. In practice this means it turns on as the outside cools faster than inside and turns off when it starts to heat up again outside the next day.

My rule also doesn't do anything unless the garage is over 76°, as the fan is pointless if it's cooler, and I don't want it to run in the winter.

1 Like

I appreciate the suggestion but I don’t believe the scenarios are analogous.

Unless I’m mistaken, your garage fan will receive the On command multiple times whenever either of the temp sensor values changes until your If condition is no longer true. Therefore, I cannot use similar logic and only receive one notification per day.

Does Delay prevent additional instances of the same rule from executing?

Perhaps, but that would be easy to fix, and easy to guard against.

Rules are fired by events. You can introduce logic into the rule to prevent it from doing anything when it fires after 'the first' time, as long as you have some way to reset that logic to re-arm the rule.