Simple piston to turn off lights after no motion


#1

I’m trying to create a piston to turn off several lights if motion isn’t detected on two sensors after 30 minutes. Right now it’s…

If each of Motion Sensor A,B,C was inactive for at least 30 minutes… turn off switch D.

The problem here is the light doesn’t turn off after 30 minutes UNLESS, sensor A,B,C is tripped again. That is, 30 minutes pass. The light is still on. I walk past sensor A (waking it up?), then light turns off.

The sensors are either SmartThings or directly paired Hue motion sensors. The switches are either Lutron or Leviton.

This behaviour happens on two separate routines and lights so it’s my logic that’s at fault, or something else?


(Robin) #2

IF
Any of motion x y or z is active
Then
Turn on
Else
Wait 30 minutes (cancel on condition change)
Turn off


(Robin) #3

Or if you don’t want the on part:

If
All of motion x y and z is inactive
Then
Wait 30 minutes (cancel on condition change)
Turn off


#4

Thanks. Seems like I needed to think about this a different way. So the end result looks like…

If…
Each of MOTIONA, MOTIONB or MOTIONC is inactive. <— current state true, which is good
Using location…
Wait 30 minutes, Task cancellation policy {cancel on condition state change}
Using SWITCH1, SWITCH2 > Turn Off

Sound right?


(Robin) #5

The wait and the turn off need to be within the same ‘using’ block.

IF

Each of MOTIONA, MOTIONB or MOTIONC is inactive

THEN

Using SWITCH1, SWITCH2…
Wait 30 minutes
Turn Off
Task cancellation policy {cancel on condition state change}


(Robin) #6

Have you considered upgrading to webCoRE?

I could have just posted a ready made example for you to import :wink:


#7

Web. Core. Uh. I better look that up. I know I’ve published it (just because it’s in the repo) but haven’t used it :slight_smile:


(Robin) #8

And here’s a video I posted about it on Monday:


#9

Thanks much! There’s my next spare time block gone :slight_smile:


#10

Ok time to watch that video. Unfortunately what I proposed didn’t work. I used it at two locations with same result.

All switches and lights were off.
Turned on the light using switch.
Walked into the room, tripping a motion sensor.
It’s been more than 30 minutes since the sensor was active.
The room light turned off in about 10 seconds (processing time I guess).

Light1, Light2 on.
Sitting down for 30 minutes not moving.
Walk past sensor.
Turn off light 1 by switch.
Same code but added a second condition of AND Iight 1 is off.
In 10 seconds, light 2 also turns off.

In both cases it took the 30 minutes as already elapsed… and either didn’t save the condition or check for change amd cancel.


(Robin) #11

Can you post the dadhboard screenshot of your piston.

You should change the wait to 1 minute for testing.


#12


(Robin) #13

The wait and turn off need to be in the same ‘using’ block.


#14

Oh, I’ll give that a try. I thought it was serial meaning if the previous action didn’t execute, it just stops.


#15

Hmmmm not seeing how to put them in the same block. Going to have to use the webcore and pull the code.


(Robin) #16

Loose the ‘using location’ section.

Using master bathroom shower light…
.>wait 15 minutes
.>turn off

After adding the wait, scroll down and click on ‘add task’ to add the turn off action after the wait.


#17

Oh that makes so much sense now. I never realized that WAIT (and other options) are exposed after selecting a device. I always though WAIT was exposed only when using the LOCATION (first toggle). This explains why some other experiments with WAIT doesn’t work.

Ok, so where you have “Using Bathroom…” should be “Using…” whatever needs to be affected such as light 1 light 2 light 3… wait 15 minutes, then turn off.

Ok, now all this logic makes sense and it will probably work now – I was just misunderstanding how to add a wait (thought it was an independent statement).


(Jimmy) #18

I love CoRE, but unless i’m missing something, this is super easy to setup in smart lighting.


(Robin) #19

Smart lighting can’t keep reseting the timer every time motion changes back to active. Light would just turn off 15mins after first motion regardless of new motion.