Efficient Rule for Checking Illuminance

I am trying to write a rule for rule machine that checks my outside illuminance measurement and when it reaches a threshold changes a hub variable from false to true (for triggering other rules to turn on/off lights).

I started by setting the trigger to be every minute and then the rule was just a simple if then else statement that would set the variable to true or false depending on the threshold. This worked great except I wanted to write something that was a little more efficient than triggering every minute. So I came up with the attached.

Fun fact - I learned you cant use wait for event here because even though rule machine will let you put a conditional in the wait for event it only waits till the sensor data updates, not till the condition triggers. The triggers for the rule basically assure that the rule should run continuously and resets whenever the variable changes. I only have the time based trigger to "reset" to rule to make sure its running on a reboot of the hub.

Anyways, I wanted to ask if this is an efficient way to go about what I am trying to accomplish. It is more efficient to use wait commands rather than triggering each minute? Does it make a difference? Just trying to learn some best practices from someone who isn't a programmer. Any input is appreciated!

what sensor are you using to report lux?

The Tempest Weather Station. It reports lux values.

One comment:

Replace the "ELSE-IF" with an "ELSE"; you have already tested the condition (well, the negative of it) in the "IF" statement, so there is no need to test it again. The only way it will get here is if the value is greater than the threshold.

Thank you. Makes perfect sense.

Download the Hubitat app