So I followed this post here and I saw this edit.
Does this mean we have to interact with the SmartThings app if we need to turn off the light?
So I followed this post here and I saw this edit.
Does this mean we have to interact with the SmartThings app if we need to turn off the light?
If I am not mistaken, it can be done via the app, thru Alexa, or by turning off the wall switch.
(you might want to ask specifics on that page though. @bangali is always helpful)
Just a small note.
The 1st piston on that page is for a dumb switch and smart bulb combo
The 2nd piston on that page is for a smart switch and dumb bulb combo
I use a slightly modified version of the 2nd piston (smart switch with dumb bulbs) and you are correct about the ability to turn the light off with Alexa, the ST app or the wall switch.
At this point my code above is not working. The kitchen light does turn on when detect motion but did not turn off after 2 minutes.
Okay, a couple of basic questions since I’m new.
Hi @2Charlie
1 - Yes but…
2 - Depends.
If your code after condition stops everything then it could stop. (cancel all depending tasks etc)
But normally it will go al the way to the end.
3 - Depends.
if you defined a variable, everytime piston runs it will go back to that…
lets say:
local variables:
variable {teststatus} = false
(piston does lots of things here and at the end you say)
set variable {teststatus} = true
END
unless this piston runs AGAIN, your variable will always remain TRUE
Global variables :
You define them outside of the piston. So, running the piston by it self will never change the value of a global variable. Only what ever YOU say in the piston will.
Just to clarify a tiny bit… If the variable is not defined at the very top, but is written to in the code somewhere, it will remain indefinitely until it is overwritten.
For example, if you run this piston once, the SMS will error (null variable). A moment later, the variable will be set correctly. If you wait a year and then run the piston again, the variable you set a year ago will come thru your SMS message
execute
Send SMS = {variable}
Set variable = "some data"
end execute
No. When the piston runs again, it keeps the old data in the variable until the moment your code writes new data to it
What you describe happens only if you force in a variable in the top ‘define’ section.
Another way to say this:
When a variable is set, it is permanent, and will not ever change.
There are three exceptions:
This is what I have right now and the does not turn off after the motion sensor has changed to inactive.
According to your piston, it should be two minutes after the sensor reports no activity. Depending on your motion sensor, this could be a few minutes longer than 2 minutes. (most sensors report inactivity between 6 seconds and 6 minutes after the last activity)
If you have totally left the room for over 8 minutes (6+2) , and the light is still on, then I would check your variable in the piston to make sure {lightStatus} is true.
How do I check the value of the variable? I removed the variable in the second piston and the light does turn off. So, it’s has something to do with the value for sure. I tried the Test but I wasn’t sure how the debug work.
If you look at your piston on line 17, there should be either true or false at the end.
Without that variable in place, you will no longer be overriding the motion sensor.
(I would go back to using import code ‘tb64’)
The TEST button will do nothing on this piston. Your piston only fires when something happens in your motion sensor and/or White bulb. (notice the lightning bolts in the left largin… Those are your triggers)
Is this after I clicked on the Test button? I do not see anything after the variable or line 17.
Well, line 17 in your screenshot may not be exactly line 17 inside your piston. (but it’s the only visual reference I have) The true/false should be right after “boolean lightStatus
” at the top.
If there is nothing displayed after that, then your piston has not run even once successfully. (remember the TEST button does nothing in this piston. You have to actually walk in front of Motion Sensor 2 and/or toggle White Bulb 1’s switch for your piston to do anything)
If you’re referring to /* false */ at the end of line 12? If so, that explains why it’s not turning off the light after 2 minutes.
I would start by manually turning Kitchen Lights switch off… leaving the room for 5 minutes (so the motion changes to inactive)… and then walk in front of the Kitchen Sensor.
Hopefully, the light comes on.
Then walk back to your computer, and the variable should be /* true */
for the next two minutes.
If I manually turned off the light, the variable value does turn to true. However, when I walked back into the room and motion sensor detected me, the variable value turns to false again. Is this normal behavior?