WebCore Piston Help for Motion Sensor and Lights


(Joseph Fattizzi) #1

I have a motion sensor and a light switch. I would like to auto turn OFF the switch when motion stops for xx minutes if the switch is ON.

The kids always leave these lights on and I would like to alleviate having them on when no one is in the kitchen for 10 minutes.

(Bob) #2

What type of switch is it?
Is it a Smart switch.
There are numerous ways of doing this.
Have you looked at Smart Lighting?

(Joseph Fattizzi) #3

It is a lutron caseta dimmer control for my kitchen high hats over a counter.

(Bob) #4

Use Smart Lighting.
In the mobile app go to the Marketplace tab.
Then SmartApps.
Now select Smart Lighting.
You just go through the menus.

(Joseph Fattizzi) #5

But I want to use WebCore! lol.

(Bob) #6

I don’t blame you.
In that case import this.

The red N is to never cancel tasks.
This way if there is motion in the 10 minute window the timer will reset.

(Joseph Fattizzi) #7

thank you!!!

(Sully) #8

Wait “Never Cancel Task”? Wouldn’t that keep the timer going regardless of whether motion restarts or not? As soon as motion is inactive, the wait starts and doesn’t stop, regardless of the conditions, or am I getting something backwards?

(Bob) #9

I was wondering if someone was going to query that.
It doesn’t sound right does it.
If you go into the settings for Task Cancellation Policy in the dropdown there are various options.
What it means is if there is a piston state or condition state change the task will cancel.
If you select ‘never’ then the task will always complete UNLESS the piston becomes true again. In that case the Timer stops. When it becomes false again, the Timer restarts. I hope that makes sense.

(Sully) #10

Ok, I see what you’re saying… Just one thing I’m confused on. You said when it becomes true again, the timer stops, and when it becomes false, the timer restarts… Ok, so just so I’m following the first part… the true again thing makes sense enough, but the timer is supposed to start if the piston is true, so why would it have to become false again to restart the timer? (Trying to understand, not be snarky)

Also, using your logic, if I walked out of the room while fixing dinner, motion goes inactive, and the timer starts. If I walk back in and keep cooking for longer than 10 minutes, the piston never becomes true again, so the lights would still go out, wouldn’t they?

Again, still trying to wrap my head around all this. Thanks!

(Bob) #11

Spot on. I got my trues and falses back to front. :blush: (No offence taken by the way).
So here goes again.

If you select ‘never’ then the task will always complete UNLESS the piston becomes false again. (i.e. there is motion or the light is manually turned off). In that case the Timer stops.
When it becomes true again, the Timer restarts. (i.e. switch is on and motion sensor is inactive).

Really sorry about that.

(Joseph Fattizzi) #12

So is the code for the piston good? Seems to work, but I am not home to test the motion part.

(Bob) #13

Yes. I’m pretty sure the code will work OK.

(Bob) #14

Did this work OK for you?
I’m worried there may be an issue with how I’ve written it.
I’m not saying though in case it is OK!!! :wink:

(Joseph Fattizzi) #15

I am still testing. Will let you know more tomorrow.

(Bob Adams) #16

How does this light ever turn on? Another piston?


It looks like this is for situations in which the light is turned on manually, otherwise you could use motion to turn on the light within the same piston.