Turn off lights when Motion has been detected in the last 1 minute


#1

This here is a piston i use for a light scene in a room. Lights go on when motion is detected and go off when there is no motion for 60 seconds. All works fine.

The problem i have is that sometimes the light goes off because i do not move for 60 seconds. I want to fix this by adding a second motion detector in the mix. The second detector is just outside of the room.
The idea is that as long the second detector didnt read any motion in the past 60 seconds i did not leave the room.

So i figure i create something like this: If 60sec no motion + if in the last 60sec detector 2 did have motion (meaning i have left the room) turn off lights. But when i add this the lights do not go off at all anymore, i probably use a wrong command. Anyone can point me in the right direction? Thanks!


#2

I believe the command you need is FOLLOWED BY

IF inside motion is active (you are either in the room or walking out)
AND (instead of and, click on the AND, choose FOLLOWED BY
IF outside motion CHANGES TO active (means you are leaving)
then
Turn off the lights


#3

I thought of that. But does’nt that approach mean that if im in the room (motion is active).
And someone else walks in the hallway and actives the second motion detector they will turn the lights off while im still in the room?

The reason for the second motion detector is to make sure the lights wont go off if i sit still for 60 seconds. The second motion detector is not being used for turning the lights off. It’s there to keep the lights on in some occasions.


#4

Yes you are right that makes sense…

Let me share my solution to similar problem I had, maybe it gives you some ideas…
Sometimes (as you experienced) when you watch a movie or something, motion detector can change to inactive (they are not that sensitive unless it’s on your face :)))))
I started using variables.(I use global variables because I wanted to control the variable with other pistons as well)

@movieroomvariable

IF motion sensor changes to active
and
IF @movieroomvariable is = 1
Turn the lights ON

IF motion sensor stays inactive 60 seconds
and
IF @movieroomvariable is = 1
Turn the lights OFF

(this first part is for regular entry - exit. Lights turn on but when you leave the room lights turn OFF)
(second part, motion detectors are no longer in charge, lights will remain ON until you change the variable)

IF @movieroomvariable Changes to = 2
Turn the lights ON

IF @movieroomvariable Changes to = 1
Turn the lights OFF

YES, you need a trigger to change the variable…
I use one of the following:

  • Alexa
  • Ipad wall mounted
  • Timer
  • Zwave switch
  • Zwave button
  • TV turned ON
  • Projection screen dropped down

this way worked and it was very simple…

I had another idea BUT I had a feeling it was going to get complicated and more than my knowledge can handle
and that was:
Count the times motion sensor gets activated…
if re-activated more than 10 times (lets say)
Change the MODE (assuming I am in the room and not leaving)
But never tried that:))))


#5

I appreciate the creativity in your solution. But it seems pretty hard to do. If i want to do it that way, the trigger you mention should be the second motion detector which can be triggered by another person while i still am in the room. Or have to involve another trigger and make things more complicated even.

Seems like a pretty simple thing i want: turn lights off when motion detector 1 hasnt seen motion in 60sec, but motion detector 2 did see motion. There really isnt an easier way to do this?

I will be playing around with this a bit more i guess)


#6

Lets try this if you don’t mind
tell me what you want (but instead of motion detectors does this or that etc. try something like this:

  • I walk in and lights turn on…
  • I walk out lights turn off
    so on…
    MAYBE I (or someone else) can come up with a simple solution…

#7

I walk in, lights turn on
After i left the room, lights turn off after about a minute.

That’s pretty much it. The complicated thing is that i do not want the lights to go off when i dont move. Plus the second motion detector in the hallway can be triggered by other people.

If i delete row 42 everything works how i want it to. Row 42 is supposed to make sure lights do not turn off when i dont move.

Right now im trying to work with motion detector $status instead motion. Had some results with that in another piston i think, but no luck so far!


#8

In that case the only think I can offer is, instead of 60 seconds use 5 minutes… You will somewhat move and your motion sensors will pick up activity within 5 minutes and your light will remain ON…


#9

Yes, you are right about that. If i cannot make this thing work that is what i will do.
But im a bit surprised i cannot make this work. If motion sensor 1 motion or $status changed in the last 51sec… seems like a pretty straight forward command, i do not understand why it doesnt work.


#10

Personally, I do not mix triggers in the same piston, but it is easy to do with two pistons.

  • The 1st piston is the piston for the “Room’s Motion”
  • The 2nd piston adds a few lines to your current “Hallway’s Motion” piston

This method does require a new global variable so one device can see the status created by the other.
(Let me know if you need help with that)


Here is the Room’s piston:

(notice the 5 minute safety net to make sure the lights don’t stay on too long)


Here is the few lines of code to add to your current Hallway piston:

2_Hall


NOTE:
This method will actually turn off the lights about 70 seconds after you’ve cleared the hallway.

Also, if you decide to tweak the delays, make sure the delay in the hallway is at least 5-10 seconds longer than the delay in the room. (since you have to pass one motion sensor before the other)