Piston with LUX detection - turns light back on if I manually turn it on


#1

Hello,

I’ve been using the following piston for quite a long time and it really works well. Basically, it turns on certain lights after a certain LUX is reached. Sometimes I end up turning off one of the lights and the piston automatically turns the light back on, I’m sure because of something I have programmed in this piston.

Would someone mind pointing out what needs to be added or removed so the piston won’t reactivate the light if I manually turn it off?

Thanks


#2

At first look, I need a bit more information. Which light do you turn off? Do you use a smart switch to do that?


Your lights will ALWAYS turn on if the above conditions are met. Your logic appears sound. But your piston does not address any external changes to the lights OUTSIDE of this piston (you physically turned one of them off). You can go MANY directions from here.
For instance, do you want that one light that you physically turned off to stay off when the rest turn on? Just off the top of my head, you could set a variable when you physically turn off one of the lights. Then this piston could check that variable and act accordingly. That variable can be automatically reset each day.


#3

Hi,

It’s the first light in the sequence. I have Alexa connected to the smart switch, so I tell her and she turns off the switch. Generally what happens is if the first light in the sequence won’t need to be on, I’ll have Alexa turn it off and then, within minutes, the piston turns it back on because it sees the LUX is within the range I programmed for (which of course I don’t want at that point). I generally don’t mess with the other lights and they are generally already on when I do this. A reset each day for the first light in the sequence would be awesome.


#4

Just so I understand you here…You want your piston to function as normal. BUT, when you turn off the first light with Alexa, you want that light to stay off until the next day?


#5

Post an anonymized copy of that piston so we can import it.


#6

Exactly.


#7

Ok, there are MANY ways to do this and someone else may have a better/easier/creative suggestion. I’m not new to webcore or coding, but certainly I am still learning. Now, I have NOT tested this, but I’m suggesting a boolean switch, First_Pass.

Create a boolean variable First_Pass (or whatever you want to name it). Don’t assign it a value here.
In your first DO, make this change…

DO
    IF First_Pass is true
       THEN
           Wait 10 Minutes;
           Turn on;
           Set level to 10%;
           Set variable First_Pass = False;
    END IF

And add this as the last command in your piston (outside of your first IF)…

every day, at midnight
    DO 
       Set variable First_Pass = True;

Now, you can initialize First_Pass to True in the Variables area after you save your piston. Or, you can wait unit after midnight and it will be set for you.

Also, and this is just an observation…your first trigger statement in your IF :

“Motion Sensor 6 illuminance is less than or equal to 8lux”

How many times a day will the illuminance of that sensor be less than or equal to 8 lux? Possibly several. So, unless I am missing something, your piston may run several times a day and not really do anything after the first run. Now, you may have other things that are acting on your lights and you may need it this way. Just food for thought.


#8

Thank you, I will take a look at this. Here’s the full piston with the code:


#10

This solution should work for your situation…


#11

Thank you for all your help!


#12

What an elegant solution @Pantheon, LOL