I have a rule that when the temp drops below 32 I want to turn on my outside lights at a low level so they don't go offline. The problem is 1) selecting a trigger and 2) not getting it to fire each time the temp changes. I have tried several ways of writing it but they all end up repeating because of the temp changes.
Anyone have an idea of how to do this so it only fires once when the temp goes below 32? Thanks
Just throwing this out there but how about turning a virtual switch on when temp falls below 32.
Then put the switch 'changed' in your rule as a trigger.
Also, do you want them to turn off if mode is day?
@bobbles I thought about a virtual switch instead of boolean but I thought maybe they were pretty much the same. Turn on a switch and then turn it back off or turn on boolean and turn it back off. Not sure. Last IF statement I thought would turn them off? No?
If you have more than Day, Evening, and Night modes, then use this:
IF (Mode in Evening, Night) THEN
Color Temperature: Deck Light: 5000: 5
Color Temperature: Front Porch Light: 5000: 25
ELSE-IF (Mode in Day) THEN
Off: Deck Light, Front Porch Light
END-IF
If you only have Day, Evening, and Night modes, then use this:
IF (Mode in Evening, Night) THEN
Color Temperature: Deck Light: 5000: 5
Color Temperature: Front Porch Light: 5000: 25
ELSE
Off: Deck Light, Front Porch Light
END-IF
Actually, the wording on triggers can be confusing, but a trigger of "Temperature < 32" will fire any time any temperature reading comes in and is < 32, even if it is not the first. For example, consecutive reports of 31 to 30 will match that trigger both times. Here's an example rule you can use to test that:
and the output you'd get (I left trigger and action logging enabled for maximum clarity, but if you're doing it on your own, the log action in the rule actions alone should be enough to see) when that sensor goes from 33 to 32 to 31 to 30:
What I would do to catch only one reading below 32 is the Private Boolean trick as suggested in the docs for other uses (and as attempted above, but you need to set it back to True when the temperature goes above that again, something you can't do if your only trigger is <32). The general format of that (you'd have to add in whatever you want to do here instead of my log action) would be something like:
Trigger:Temperature *changes*
Actions:
IF (Temperature < 32) THEN
IF (Private Boolean is True) THEN
Log: "This is the first time it's below 32"
Set Private Boolean False
END-IF
ELSE
Set Private Boolean True
END-IF
You'll still have the issue that the "ELSE" (where PB is set back to True here) will run every time the temperature reads above 32, but I'm not sure exactly what you're trying to do or if that would be problematic for you. If so, you could create a similar rule that also triggers on temperature changes but checks for the reverse and tracks the threshold with PB in a similar manner.
Yes, that logic would definitely work for a one time <32 event. I have quite a number of rules that I did basically the same way (I prefer a dead band on the Private Boolean reset to prevent chattering) - and they all work.
Ah, sorry. I should have read more carefully. I do it similar to what bert said. I don't have any comments/adders to the mode conditions that @aaiyar mentioned.
The "Set Private Boolean" action allows you to choose any rule, not just the current rule, in which to set the Private Boolean. Apparently, if you have "This Rule" selected, it keeps pointing to the original rule (not the new-current rule) even after a clone. Never tried that myself (I usually avoid cloning), but I assume that explains what you see.
I'd probably do that, too, unless the sensor isn't very sensitive or doesn't report in often. I left this out for simplicity, but you could certainly replace the "plain" ELSE with something ELSE-IF (Temperature >= 33) to create this effect.