Rule not running correctly

This rule is ignoring the between sunset and sunrise requirement when it comes to motion. Am I
Missing something?

Without pondering this first comment too heavily at the moment, you might find that it would work better with parentheses around the two OR arguments.

More brain power applied to this solution: move the time requirement to to a required statement to remove some complexity.

1 Like

In what way is it not running correctly? Turn on all logging for the rule and see what you get in "Logs." As of your screenshot, assuming it's daytime now, the condition you mentioned appears to be evaluating correctly. Logs will be your friend to see more -- if it is indeed this rule. I'd also suggest looking at other apps that use the devices in question, assuming that their behavior is why you suspect this rule.

Another option for the rule would be:

Required Expression:
Time between Sunset and Sunrise

Trigger:
Basement Slider contact open
OR
Basement patio Motion Sensor motion active

Action:
On: Basement Patio Light
Wait for event: Basement Slider Contact Closed -> Timeout: 00:05:00
Off: Basement Patio Light

With the “Wait for…” instead of a delay, the “Off” will only occur 5 minutes after the last trigger. So if the slider was open, then motion was detected 4 minutes later, the off command will only occur 5 minutes later, (9 minutes after the slider was opened) instead of 5 minutes after the slider was opened, then on by motion, then off again after 5 minutes.

It should evaluate as

Basement Slider contact open
-OR-
Basement Patio Motion Sensor motion active AND Time between Sunset and Sunrise

Are you saying that when BPMS motion is active and time is not between sunset and sunrise it evaluates as true?

I want the light to only come on if it’s between sunset and sunrise, for both the contact sensor or motion. To provide security lights at the door at night if something would walk up to the door while it’s still closed as well as if someone opens the door from inside to provide lighting. If the door is left open for more than 5 minutes and motion is inactive, the light should turn off. That’s my goal. It was turning the light on outside the sunset to sunrise time aka turning on the light when it’s still daylight out. But the light was only triggering on the motion active, not the contact being opened.

I’ve since modified the rule and will test more tomorrow.

I can foresee unintended operation with the above suggestion. There can be the instance that both if then statements can be true and there by the light would go quickly on/off. Say, the basement motion is active and the door is closed. This may be over thinking on my part and you would know your situation better. And as Sebastian mentioned, a “wait for event” could help. You could wait for the door to close and then turn off the light,

Thinking that through, perhaps you could remove all if thens, have your triggers be for the start of motion or door open, action turns on the light/off after 5 minute wait. Next action - wait for event of door closed, turn off light and don’t forget to cancel the wait.

I can get in front of a computer and sort that out more tomorrow, if needed.

Well I went outside and kept the door open while I had my dogs out. Came inside and didn’t close the door and the light went out. Walked back through the door and triggered motion and as soon as motion stopped detecting, the light went out right away.

What I want is for each event triggered it waits for 5 minutes to shut off the light with the exception that if the contact sensor is open, and it closes it should turn off the light right away.

Ideally if motion is active then it won’t turn the light off at all until motion is inactive. I might have to make a few rules here.

I would recommend you try my suggestion above. It should meet your criteria.

I don't know your setup but suspect you can have motion without opening the slider but not an opened slider without motion. Since you have two triggers and to be conservative, I offer this suggestion.

Required Expression:
Time between Sunset and Sunrise

Trigger Events:
Basement Slider contact open
OR
Basement Patio Motion Sensor motion active

Actions to Run:
On: Basement Patio Light
Wait for expression: Basement Slider contact closed
Wait for expression: Basement Patio Motion Sensor motion inactive:  -> Duration: 00:05:00
Off: Basement Patio Light

Notice that I'm using Wait for expression. This is necessary since the state of the slider might not change even though you get motion. It might not be needed for motion but it won't hurt either.

1 Like

Thanks! ill give this one a shot.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.