Help with creating a webcore piston

I have some automation to turn on my garage lights when any door is open or or motion is detected in the garage. What I’m trying to do is find a way to turn off the lights if no motion is detected in 15 min. So this would be easy if I would trigger the motion sensors everytime, but sometimes I open my garage door, the lights come on, but then close the door without setting off a motion sensor. In this case the light stay on. I have installed webCore, but not sure how to handle this issue. I see it’s easy to setup an if/then to see if the motion has not been triggered for X min, but setting that I have the same issue as using the normal app automation. It only works if the motion detector is triggered every time the lights come on.

This is probably best asked on the WC forums but otherwise sounds relatively easy. I would write a piston that looks to see if the lights already on, and then if there is no motion for 15 minutes to turn the light off.

edit, if you have a piston started, post it on the WC forums and I can assist in getting it dialed in.

Thanks Sergl! My issue with setting the 15 min timer is that if motion is not triggered, I will never hit that 15 min timer. So if I open a door, look in the garage fast and close it the lights never turn off, even though I have them set to turn off 15 min of no motion.

You can write it so that there is not dependency on the initial motion trigger.

IF light is on AND motion sensor was not active for 15 minutes DO turn off light

A different approach would be to use a Smart Lighting routine that turns the lights on triggered by the motion sensor and a simulated motion sensor, with the 15 minute timeout that turns off the light when motion stops. Then have the doors turn on and off the simulated motion sensor rather than the light.

Try the webCore community - https://community.webcore.co

There are many garage door pistons discussed there. If you don’t find what you’re looking for, post a question AND your piston. Someone will have the solution.

I like that idea. Sounds simple and will do the trick. I’ll let you know how it works.

Add a second condition to your motion piston that says something to the effect of

If garage door closes
If garage motion stays off
With garage light
Turn off
End with
End if
End if

(I can’t remember the exact syntax for the motion detection doesn’t sense motion for a certain period but I think you’ll be able to figure it out…)

Well I think I have something working now! Below is what I did.

/ execute

if

Garage Light’s switch is on

and

Garage Light Motion’s motion is inactive

then

do

withGarage Lightdo

Wait 20 minutes;

end with;

if

Garage Light’s switch is on

and

Garage Light Motion’s motion did not change in the last 15 minutes

then

withGarage Lightdo

Turn off;

end with;

end if;

end do;

end if;

end execute;

Edit

You’ll want to change that wait state before turning off the light to motion inactive for more than 20 minutes.

Long waits are notorious for issues because of long complicated discussion about re entering the piston and task cancelation policy…

The way its written now it’ll work most of the time and you’ll have random cases where it won’t shut off like you expect.