Rule machine code that doesn't work well

Hi all,

I wanted to set a rule the if the time between 8am to 9pm and the motion sensor is active, the light goes on. It works perfectly well but between 9pm to 8am, if i'm trying to manually turn on the light, it turns off immedietly.

What am I missing?

Remove the time check from the IF and move it to a "Required Expression"

Currently the way you have it, if you turn it on manually outside of that time and then motion is triggered right after, the rule would fire. The IF would fail due to the time check and then turn it off.

Using the time check in the Req expression would make it so the rule wont even start unless it is during that time.

3 Likes

Because regardless of you switching the light on, the motion sensor is still going active/inactive. It's not between 8AM and 9PM so your rule follows "ELSE" and turns off the light as you've told it to.

1 Like

As @jtp10181 has said...put the time in the required expression.

Your trigger probably just wants to be 'motion active'

Actions:
On Bathroom light
Wait for event - kids bathroom motion inactive 'and stays that way' for ? minutes
Off Bathroom light