Simple Lighting Piston Problem when motion stops


#1

1) Give a description of the problem
I finally getting around to using WebCoRE (awesome in scope it seems!) but can’t get my head around why this simple piston won’t turn off the lights.

2) What is the expected behavior?
I have a motion sensors in the garage (sensor 7) and utility room (sensor 11). I want the garage lights to come on if either sensor detects motion as the garage lights (controlled by a Fibaro relay - Outlet 1) are slow to come on and you walk through the utility room to get to the garage). I expect the lights to go off once motion stops from both sensors.

3) What is happening/not happening?
This work fine for turning the lights on if either sensor detects movement. The lights also turn off ok if they have been switched as a result of motion. The problem is that the lights never turn off if they have been switched on manually (e.g. using the physical lightswitch or in the Classic app) or by another automation (e.g when the presence sensor in my bike is detected, should I ever get it to work - though that’s for another post).

4) Post a Green Snapshot of the piston!

I have no doubt this is something very simple and will be kicking myself soon…


#2

Hi @black-paladin
When use WAIT in most cases you have to adda NEVER CANCEL TASK

What you want is something like this

IF motion sensor changes to active
lights ON

IF motion sensor stays inactive 1 minute
Lights OFF

Two seperate IFs would do it…

Here is one my pistons I use for entering the room lights ON, leaving the room and 3 minutes later lights OFF
12%20AM


#3

Many thanks @ike2018. I’ve modified the piston to mirror yours but I’m still getting the same behaviour. Oddly though, if I run “Test” in WebCoRE then after a minute the light turns off as expected. But if I just switch the light on (without motion in the Classic app) and leave it, it never turns off, so I’m still baffled.


#4

Yes as expected…
Because when you switch the light ON with ST App your piston will never be triggered, 1 minute count down will never start.
If you turn it ON with the App, but walk into the room and leave…it will turn off because your piston is executed with motion.

Edit : It is possible to create a piston where if you turn the light ON with the app it turns it self OFF after a minute but you need more complex piston for that… I don’t truly understand the real life aplication of it?.. Would you want lights to be on even when there is no one in the room??? or you did that just for testing purposes?
Personally, after i started using webcore I kept ST app out of the picture in terms of automation. I wouldn’t recommend running your house using both.


#5

So sorry I just saw the final part of your post. I should have read it better. My bad.
This is what you wanted from the get go.
Ok in this case we need to start using variables…
Let me scratch something with variables…


#6

There are many ways of doing that. The way I use is splitting the room with global variables. The reason I use global instead of local because it can be controlled from other piston if needed…

Lets split your room in two.
Phase 1 = Only motion sensors controls the lights.
Phase 2 = Other triggers controls the lights.

Create a global variable {@garagephases} (let me know if you need help with that)

(Phase 1)
IF motion sensor 7 or 11 changes to active
AND
IF global variable @garagelights is = 1
Then
Do turn on Lights

IF motion sensor 7 or 11 stays inactive for 1 minute
AND
IF global variable @garagelights is = 1
Then
Do turn off lights.
(now other triggers)
IF Switch turns on or Light bulb turns ON
AND
IF global variable @garagelights = 2
Then
Turn on lights
Wait 1 minute
Turn lights OFF
Set global variable @garagelights = 1

You will need another piston that changes global variable with certain triggers…
Other piston can look like this:

(Presense sensor)
IF my presense sensor changes to ACTIVE(HOME)
Set global variable @garage lights= 2
Turn light on

(manuel switch)
IF my switch changes to ON
Set global variable @garagelights = 2
Turn lights on

(you turn it on with ST app)
IF my bullb changes to ON
and
IF motions sensors have no motion
Set global variable @garagelights = 2

I wrote this very fasy i am sure it needs work…
I don’t know if you want to go down this road?
if yes, will work on it…

These two pistons are my gsarage controls with this PHASE system…
lots of other stuff is happening but it will give you an idea I guess.


#7

Ike has many good ideas here… The one thing that I disagree with is whenever possible, variables should be local variables. From my experience, global variables should only be used as a very last resort, and only if the data is needed in another piston.

The logic is, local variables are instant, yet globals are not written until the piston has completed all of the tasks. Also, if a global changes while a piston is running, it will not be registered in that piston until the next run.

Just to give a point of reference, in my 200+ pistons, I have a couple thousand local variables, and less than 30 global variables.


#8

Thanks @WCmore, I never knew that was the case. But I am scared of re-designing my pistons:))))
Finally (a year later) i had my wife saying - mentioning the house: “well this is working, that’s good”

The only reason I prefer globals (you know my house design so well:))) when A room DOES this, the other can do THAT so the data needed in another piston and ofcourse I can change variable with a simple SIm Switch at anytime…

Thank you so much for the input. Very valuable.