After watching the last Hubitat Live, I went through and rewrote most of my rules that had two states to them (e.g. motion and contact). I'm now trying to apply the same theory to rules that have triggers with lots of states (e.g. illumination, and temperature). The example below is a simple rule for my front porch. It comes on when it is near dark or when the mode changes to evening. It turns off when the mode changes to day. The reason for the IF statement is that I call the actions of this rule from another one ("run rule actions).
As seen in the log files, it is triggering even though the illumination sensor was higher than 5 around 6:30 this morning. Is there a way to lower the amount of triggering on this rule ?
Can you check the box in the logging section of the rule to include triggers and then post a portion of the log file? I'm curious if yours is also firing every time either of the illuminance sensors are reporting changes.
My question in writing rules like this is whether it makes any sense to use a qualifier in the trigger section or just leave it as "changed" and build out the IF since the rule seems to be firing no matter what.
That's what I thought. I think I might be mistaken in how the triggers are applied. Even though the events are outside the range in both of our examples, the rules are still triggering, which means the actions are still being evaluated.
I could then go on to theorize that if a person had a lot of "multi-state" sensors triggering, then maybe that might be part of a slow-hub issue.
@bravenel Are there any ideas you can guide us with?
Try checking both the trigger and actions box and watch your log.
If a trigger requires evaluation, e.g. temp > x, then obviously it has to evaluate that. Only if the evaluation is true, does it trigger. RM will log the event, and then log the triggering. So something like temp > x will run RM for every reported event. Something like switch on will only run RM when the on event happens.
Then I am clearly missing something. With the actions and triggers turn on, I have the following in my log:
So even though the condition is being evaluated returning as false since the light sensor is above 5, it's still firing the rule.
Am I getting my terms mixed up. As I'm seeing it now, the rule is triggering based on an evaluation and regardless of that, it is still firing.
Do you have all of the logging turned on? If not, please do so, and post that log.
Here is the logs with Triggers, Actions and Events checked:
I have written rules like to debouce. My question come before that. If the trigger is outside the range it's set to/for, then why is the whole rule running? Which leads back to my other question which is if there is any difference between setting a condition in the trigger section vs. just using "changed"
As a side note, I use the local variable for that. It easier for me if the rule gets out of sync to change the variable.
The log is showing that it's turning off the front porch over and over again because all you have is a ELSE statement. Every time the illumation changes it fires.
If you changed that to a ELSE-IF statement with something to evaluate against, it wouldn't keep turning your light off.
Good question, I don't know. I'll look into it.
Here's something of interest. I removed the "mode becomes changed" from the trigger list and now it has stopped firing. There was nothing that would have caused the mode to change.
Here I have a rule for my clothes dryer. It also has two triggers setting a range but is not firing every time the dryer sensor reports back a value outside the range:
I look at this in three stages:
- Trigger is evaluated
- Rule is executed
- Devices receive commands
I've spent a lot of time between steps 2 and 3 doing things like putting in PBs or variables to stop the devices from getting sent commands if they are already in the desired state (e.g. not turning on a light when the it is already on).
The Hubitat Live got me thinking how to reduce things between steps 1 and 2.
This bug has been identified and fixed. Will be in the next release.
That couldn't have been easy to find.
This bug has been fixed in Release 184.108.40.206.