Help with Lights and Motion


#1

1) Give a description of the problem
(Lights wont turn off with motion)

2) What is the expected behaviour?
(if no motion is detected in 15 min turn off the lights)

3) What is happening/not happening?
(LIght wont turn off)

I have tried to create a few pistons, but cant get it to do what I want. My issue is I have 4 doors on the garage that will trigger the garage lights. Some of these doors will not trigger the motion detector so my lights never turn off. I think i have one working, but was told on the smartthings forum that I should not use long wait commands like 20 min. Here is what I have and it seems to work. How can I do this same thing without the wait command?

if

Garage Light’s switch is on

and

Garage Light Motion’s motion is inactive

then

do

withGarage Lightdo

Wait 20 minutes;

end with;

if

Garage Light’s switch is on

and

Garage Light Motion’s motion did not change in the last 15 minutes

then

withGarage Lightdo

Turn off;

end with;

end if;

end do;

end if;


#2

Can you post a green snapshot of your piston please?

The wait command can be finicky due to run time and condition changes so I would use the time as a condition and not a command.

IF garage light switch is on AND motion is inactive for xx minutes THEN WITH garage light switch turn off


#3

The problem with that is motion would be inactive for XX min because I never triggered motion. So when I try that as soon as I turn on the lights, it shuts them back off.


#4

Also I was not sure how to add the screenshot so i pasted the code. I see the green camera to click, but not sure what to do with the image.


#5

Right Click the image, save as whatever on your desktop and then when replying here click the little picture box to add it as a picture.

So make the light turning on the trigger and set the condition of xx amount inactivity as the condition to turn off.

Kinda like this?


#6

Sergi, I have tried that, but that does not always work. If I open a door and the motion sensor is never set to active, then the inactive time will be great than 15 min and the lights go out.


#7


#8

You know this for a fact because you have tested this? Just curious because the way I understood it is that the light going on triggers the 15 minute window to look for inactivity, In my understanding it would not look at any time inactive before the trigger fired the piston.

If you in fact have tested it and this is how it behaves you would be on the correct path in the piston you posted for using the time interval as a command instead of a condition.


#9

I just tried this and it’s not quite the same, but close. This ran, but I don’t see that it will run again to shut them off.


#10

So you have in fact tried it the way that I wrote it out in mxe8g and it did not work correctly? you could obviously change the 15 to 1 minute for testing purposes.


#11

Cool, I did not know I could use your import code. I just tried that, but when I turn on the light, it shuts it off as soon as it runs. This is what happened when I tried a few things similar.


#12

Please pardon my interruption, but I would approach this from another angle…

IF Bulb 1 stays on for 20 minutes  <-- Trigger
Then
    IF Motion is inactive          <-- Condition
        Then Turn off Bulb 1
    END IF
END IF

This gets rid of WAITS entirely… and fires once precisely 20 min after the light comes on. If the motion is inactive, the light turns off… If the motion is active, then you can use your original logic to turn it off after X minutes… Such as adding a new block at the bottom:

IF Motion stays inactive for 20 min  <-- Trigger
    Then Turn off Bulb 1
END IF

(this last IF should be outside of any other IFs)


This double approach means:

  • If you avoid the Motion sensor, the light turns off in 20 minutes…
  • If you walk past the Motion sensor, it turns off about 21 min later.
    (the extra min is because the Motion sensor takes a “moment” to revert back to inactive)

#13

I have tons of long waits in my pistons and never had a problem???

I understand your problem and I know you are asking help with your current situation but I have to recommend getting a simple open close sensors for the doors that can’t trigger the motion sensors, or a couple of more motion sensors…

A good smarthouse needs well written pistons but also enough devices to support your needs.


#14

I read the original thread. I think the intention was to warn that TCP was out there waiting to trap the unwary, but the message got rather lost.


#15

WCmore, thanks for the idea. I think I have it all working now. I already had something in place to kill the lights if the motion trigger gets activated so I did not add that to the code.