How to override motion sensor light?


#1

1) Give a description of the problem
When I manually press the switch to on, I want this action to override the motion sensor.
2) What is the expected behavior?
If I press manually turned on the switch, I want this behavior to override the motion sensor and have the light to be on indefinitely until I manually turned it off. Else, the motion sensor will turn on the light when it sense motion and stay on for 2 minutes.
3) What is happening/not happening?
At this point, regardless if I manually turned on the light or not, the light will turned off in 2 minutes.
4) Post a Green Snapshot of the pistonimage
I don’t have one yet. However, before I start developing one, I like to know if there is any existing ones that I can use or modify to meet my needs.

5) Attach any logs (From ST IDE and by turning logging level to Full)
Again, I don’t have one yet. I’m just starting. If are any that already exist, links to them are much appreciated.

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Hi @2Charlie
You can do that with a simple variable…

variable = {lightstatus}

if motion sensor changes to active
and
if {light status} is true
then
with lights TURN ON

if motion sensor stays inactive for 2 minutes
and
if {light status} is true
then
with lights TURN OFF

If switch turned on
then
set variable {light status} = false
turn on lights

If switch turned OFF
then
set variable {light status} = true
turn lights OFF

this is just a draft and it can be written better.
I didn’t want to share my working example because many other things in the piston might be confusing… But if you want I can share it.


#3

Thanks! That’s pretty straight forward. I’ll give it a try and see what happens.


#4

What should I set the initial value of the variable lightstatus to?


#5

Second question, how do I specify “2 minutes” in the if statement? I don’t see that option. All I see is the following:


#6

What do you see (options) when click on "What kind of comparision)


#7

These are the options.


Second question: On the “if switch turned on”, do I need to create a virtual switch? Or is this “switch” referring to the physical light switch I turned on and off?


#8
  • you need to post the piston because these are conditions but we need triggers.
  • I assume your switch is SMART SWITCH on the wall right? not a regular switch.

#9

I apologize for the newbie questions but what do you mean by “post the piston”. Below are the trigger options. Which one should I use for the 2 minutes inactivity?


#10

Okay, I think this is what I need.


#11

Yes exactly…


#12

For the “if switch turned on”, I don’t think the following looks right. The “Kitchen Light” is a physical mart switch on the wall. I do not see the option “turn on” or “Turn Off” under Compare to.


#13

Changes to ON and OFF means TURN ON and TURN OFF
And I don’t think you need PHYSICAL INTERACTION but test it…


#14

What’s the different between “physical interaction” and “Any interaction”? My guess is “Physical interaction” means when I physically press the paddle on the switch to turn on or off. And with “Any interaction” is that it includes both physical and when the switch is turned/off via code or some type of automation.


#15

I never use physical interaction so I don’t know/…
But even for the smart switches on the wall I always use ANY


#16

Okay, so I think I’m done with the script. How do I start testing it? This is my first time using webCore with SmartThings. Do I need to remove my existing Smart Lighting automation rules first?


#17

Yes for sure remove that…

and pls post the picture of your piston just to make sure.
IMPORTANT : Before posting it please clik on the green camera picture and post the safe version of your piston


#18

Okay, here’s my piston. I do not see the lightStatus variable declaration in here but it does show up in the Global variables on the right side.


#19

Line 18
Change that to CHANGES TO ACTIVE so it becomes a trigger. Now it’s a condition.

Line 50
Change that to CHANGES TO OFF so it becomes a trigger. Now it’s a condition.

other than that looks good to me… but you can’t be sure (since I am not a pro coder :smiley:) until you test it…


#20

I agree with Ike. Line 18 & 50 should be triggers as he mentioned…

Other than that, it looks good…

The only other change I would make is to change your global variables to local variables. They are quicker to respond, and motion sensors have a habit of changing very frequently.