1st piston help - Best way to set a motion commanded light


#1

I have set a couple of pistons that do the job but I’m not sure if it’s the most efficient way to do it

I need a light to turn on when a bunch of motion sensor detects motion or any door opens, and the light to turn off after 90 seconds of inactivity if a virual switch is off (i use it to deactivate the timer)

I set a Piston to turn on the light when the conditions are met, and then to launch another piston, which evaluates if the virtual switch is off and then run the 90 seconds timer, after it it turns off the light.
Apparently it works perfectly

Is there another way to do it? Maybe in a single piston?
I tried but whenever a condition (motion or door) became false, it killed the piston and so the timer, and the light remained lit on.



#2

In the first piston, under Turn On, put wait 90 seconds then Turn Off.
Also click on the ‘with’, the the settings cog at the bottom and set Task Optimisation Policy, (TCP) to never.
You can delete the second piston.


#3

Thanks a lot, that’s what I was searching for!::
A question: setting TCP to never, won’t make it turn the light off even if the condition (motion or opening) happens again during the timer?

EDIT
That is probably the Task Scheduling Policy set to Override, right?


#4

The way it works is when motion is detected the light comes on and the tasks start to run.
Turn on
Wait
Turn off.
As soon as motion stops, the piston changes to false and if TCP is set to never cancel the tasks will mature. If not the tasks will cancel.

If during the wait countdown motion is detected again the piston becomes true and the tasks start again from the top.
I.e. The timer restarts.
So in theory the wait could be set to 2 minutes but if motion is detected continuously for 30 minutes the piston will remain true and the timer will never mature.
Hope this all makes sense.


#5

The way this works is by canceling tasks which now can not be cancelled because TCP is set to never cancel.

So when the actions start they will not stop until completed.

I find it’s best to split into two if statements.

If motion changes to active
Then
Turn on lights
End if
If motion changes to inactive
Then
Wait XX time
Turn off lights
End if


#6

Try whichever method you feel comfortable with.
How I have described works well for me and everything is in one simple IF statement.
You pay your money you take your choice. :smile:


#7

This is only true if motion is not detected again within the wait period. If motion is detected within the wait period countdown, the timer resets and starts again when motion is inactive again.
In theory the 2 minute timer could carry on for 30 minutes if motion keeps occurring within the wait countdown.


#8

Thanks a lot to both,
It’s been clear and very “educative”


#9

So long as motion is not continuously active it will work as you say, It needs to reset and go inactive so that it can go active again.


#10

Fortunately that is how all my motion sensors work. They go inactive and then have a blind time before they can report again.


#11

Yes mine too, I use Aeotec Multisensor 6 that have a minimum of 20 sec blind time