Turn on light based on ring door bell Motion


#1

1) Give a description of the problem
Turn on porch light during time period when motion is active. Turn off porch light after motion is inactive

2) What is the expected behaviour?
For porch light to turn on when there is motion during time period. Then turn off 2 minutes after motion is inactive

3) What is happening/not happening?
Piston turns on light as expected however does not turn off light after motion is inactive. Light remains on

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
image
image

REMOVE BELOW AFTER READING


#2

I would try something like this:

IF Sensor's motion changes to active
and Time is between X & Y
    Then Turn on Light
END IF

IF Sensor's motion stays inactive for two minutes
    Then Turn off Light
END IF

One IF completely ends before the second IF begins.
(No wait needed with this method)


#3

Thank you for the help. I have expanded the piston with separate if statements. The only statement not working as expected is to turn off the switch between 9:44PM and 9:45PM. Maybe there is a way to reference a specific time. But I would think this if statement would work how I have set up. Does anyone has suggestion on what to changes are needed in order for the switch to turn off? Right now the result is the light switch stays on between 9:44PM and 9:45PM and does not turn off. Again all other if statements seem to work as expected. thank you


#4

You can change lines 39-47 to:

Every day at 9:44
    Then Turn off Switch 2
END EVERY

Also, I recommend turning all your ASYNC back into normal IFs, otherwise troubleshooting in the future will be much tougher than necessary. (in thousands of pistons, I use ASYNC less than 1% of the time)


#5

Thank you this worked


#7

Do you think using this method is better than a wait command?


#8

This question is too vague for me to answer…


#9

In your solution of using 2 IF statements (motion inactive for x minutes), you specifically mention that it doesn’t use a wait command. So I was wondering if that’s preferred?


#10

I often use WAITS, but if I can include that in part of the logic, I will always choose that path.

So my answer is yes. That is my preferred method.

It restarts the timer each time there is activity seen.