Motion Based Light EXCEPT when Manually turned On

manual
except
off
light
motion

#172

Sorry in advance, I’m very new to this and trying to figure this stuff out.

I Imported this piston as it does everything I’ve been looking to do (use motion sensor to turn on my front porch light via a smart switch/dumb bulb if it is 30 min before sunset or 30 min before sunrise for X amount of time upon motion detection, unless the light was turned on manually by the switch).

I only have one smart switch in this system tho, when I import the code it assigns a null value to the un-used switch value which I cannot remove from the code later (well, I can’t figure out how to remove it, at least).

Also, How would I tell it to turn off the porch light at 30 min after sunrise if it was manually turned on?


#173

Ok, I figured out how to remove the second switch. Everything appears to be right/working. I guess I’ll know in a few days if it’s correct.

FWIW, I originally had this controlled via smart things but wanted to understand webcore better so I’m trying to replicate it here.


#174

Sorry for the newbie question, but am I supposed to click on and enter anything for “Programmatic” and “ViaMotion”?


#175

if this is for piston code nc4jh no need to add anything for those variables.


#176

Thank you!


#177

Is there a reason my lights are ignoring sunrise?


#178

just a thought but if sunrise is being reported at 6:25 then the time would never be between 6:25 and sunrise it would end up being either or.


#179

Sunrise is 8:14 at the moment so there’s something else wrong with the code.


#180

please share a green snapshot of the piston.


#181


#182

thanks but don’t see a reference to this partial snippet you posted earlier?


#184

Sorry that one doesn’t work either and that’s the one I used the wizard for.

This is the one from the snippet:


#186

That’s where the time is on the very first post in this thread so I copied that.


#187

right but that is so the light can always come on but at different levels during different times of the day.

for what you seem to want you should do what @rsmith179 suggested above.


#188

That makes sense, I’ll try that.
Thanks


#189

In my never ending quest to complicate things, I’ve added a second bulb to this piston. So far so good, except that I can’t get the “turn off” timers to run concurrently and have to use a condition vs trigger to turn them both off.

1: No matter where I use “async”, the longer timer won’t start until the shorter one expires.
2: If I use a trigger instead of condition on line 50, the first “if” will fire but not the second.


#190

select both the withs one by one under the if motion inactive block and change TSP to allow multiple and remove the asyncs.

image


#191

Excellent. Thank you.

Thinking out loud here, but, on line 50, if I edit to “Changes to” (trigger), then once line 60 is evaluated, line 76 trigger becomes true and that action fires off, but also cancels my “turn off” timer (line 69).
Does any trigger in a piston restart it and cancel pending tasks? I guess I could use TCP to keep the timer running, but doing so would prevent the light from staying on if motion restarts, right?


#192

yeah i cant think of a clean and easy way of getting this to work with 2 different timers. can be done but might be easier to use 2 pistons instead.


#193

I used a variable to define two different timer times. I haven’t been able to do two timers within a single piston unfortunately.