How to override motion sensor light?


#41

Another way to say this:

When a variable is set, it is permanent, and will not ever change.

There are three exceptions:

  1. If you manually change the variable (great for testing new code)
  2. If the ‘define’ section is left blank, it will only change if you place code somewhere in your piston, the piston is somehow executed, and the conditions are true for that block. (my preferred method)
  3. If the piston has the variable defined in the top section, each time the piston runs, it will ‘reset’ to that variable. (the only time I hard code in the define section is when I do not change it later in the code)

#42

This is what I have right now and the does not turn off after the motion sensor has changed to inactive.


#43

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.


#44

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.


#45

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)


#46

Is this after I clicked on the Test button? I do not see anything after the variable or line 17.


#47

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)


#48

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.


#49

So the question is, why is line 27 not executed after the light turns on?


#50

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.


#51

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?


#52

I just scrolled back thru this thread, and it seems that none of us have mentioned a key element.

98% of devices make no distinction between “physical” changes and “programmatic” changes.
(Because of this, I am now in the habit of simply choosing “any interaction”)

In all fairness, the coding is there and functional in webCoRE, but the device and/or the device handler either reports it, or most often the case, does not.

So, for most devices, walking into the room turns on the switch and sets the variable. When the switch comes on, your other trigger turns on the light, and resets the variable.

I think there is another thread here with a piston that works around this somehow…


#53

So, I swap line 26 and 27. I move the set variable lightStatus before the turn on and it’s still not set the variable to true. As soon as the sensor detects the motion, the value of the variable turns to false.


#54

I think this is the thread you would benefit from reading.


EDIT
I just realized that I already posted this link. I would import the appropriate piston found there, and test it as is. You can always tweak it afterwards to better suit your house.

(make sure you PAUSE this piston when testing the other piston)


#55

How do I load someone else’s piston by the code?


#56

From your Dashboard, click on + New Piston, and then
temp

Just make sure you import the right version.
One is for smart switch/dumb bulb… and one is for dumb switch/smart bulb


#57

I am using a piston that does just what you are trying to do.


#58

Xraywinedrinker, thanks for the help! I’ll give that a try tonight.


#59

@ xraywinedrinker, what is the Key Pad2?


#60

That’s interesting, I hadn’t noticed that the generic device type is a keypad. This is my xiaomi button that I use to turn off or on the bedroom light which is connected to a wemo mini smart plug. When I turn on the light with the button (keypad 2) it sets the variable {viamotion} to false. In the earlier statement, the light will only turn on with the motion sensor if the variable {viamotion} is true.