Motion Based Light EXCEPT when Manually turned On

manual
except
off
light
motion

#267

Does anyone have a handler for switches for which physical and programmatic conditions work as expected?


#268

I am trying to learn how this works so I can apply it to my current lighting program. I have a smart dimmer switch and a motion sensor.

I have the motion sensor set to turn the light on at specific dim level at specific times.

I would like to be able to override the code with manually hitting the switch on a 120mintue timer. So of I turn the smart switch off, then the lights turn off for 120 mins then the motion turns back on. Same for if I manually turn the smart switch on then I would like the light to set the level to 100% for 120minutes and then restart the motion program.


#269

No one has an answer to this?


#270

Biggest issue is normally it senses motion for you can manually press button (My scenario), and the secondary issue is that not all switches/DTH differentiate manual press of button so pressing button after it has been turned on would not do anything. Please provide exact scenarios and any possible logs.


#271

Hey little help on this piston. I want the light to turn off immediately after motion stops not 30 seconds and I want the light to stay on until manually turned off IF I toggle the light to 100%.

How would I do this as I’m so confused. Thanks!


#272

Looks great! If i wanted to use the same logic for all of the lights and motion sensors in the house, how would i modify the code to do so, or would I have to keep duplicating the piston for each light and motion sensor combo in the house?


#273

Hello @bangali thanks for this great example! Its working perfect. However i do have one question: what happens at line 31 of the code?

thanks in advance for your reply!


#274

ik found out that: (isBetween($now,time(“06:00”),time(“16:00”)) ? 85 : 60) defines two timeframes which correspondates to %light. Does anyone know how i can add a thirth timeframe + %light in that code?


#275

Without seeing what you are working with, I would try something like this:

(isBetween($now, X, Y) ? 85 :
(isBetween($now, Y, Z) ? 70 : 55))

What this sample says is:
IF $now is between X and Y, then use 85
ELSE
IF $now is between Y and Z, then use 70
ELSE
Use 55


Pro Tip:

You can also replace “isBetween” with “lt(for less than) or “gt(greater than).

You can see more boolean examples on the Wiki / Functions.


#276

On this original post, here is the variant I use of this piston.

I find the exits serve two purposes:

  • updates the piston state so I know on/off, etc
  • deals with older zwave devices that may report states differently/slowly (the original writing assumes the device state changes as soon as the command is issued, which is not always true).


#277

Doesnt seem to work:

Basically what i want is between 06:00 and 16:00 lights come on at 80%. Then between 16:00 and 20:00 its 50% and from 20:00 to midnight lights come on at 30%. What would even be nicer, no idea if it works…is that it time of the day will calculate intensity of lights…no idea how to program that tho.


#278

Here is that Expression written out:

(isBetween($now,time(“06:00”),time(“16:00”)) ? 80 :
(isBetween($now,time(“16:00”),time(“20:00”)) ? 50 : 
(isBetween($now,time(“20:00”),time(“23:59”)) ? 30 : 10)))

This Expression is actually one long line, but it’s OK to split it on three lines in the Expression box…


Note: You did not mention from midnight to 6am, but I added it as the very last number (10).
(If you want the light off during those hours, change the 10 to 0)


#279

Thanks alot @WCmore ive implemented the lines in my webcore pistons. Lets see how it goes! Keep you posted, once again; THANKS A BUNCH!


#280

A slight twist on the original concept. I dont want the motion sensor to turn the lights on until the light is manually turned on without motion.

2) What is the expected behaviour?
During day mode, i’d like the light to turn on 100% when motion is detected and off after there hasn’t been motion for 2 minutes. Day mode currently gets changed at sunrise. The caveat is I don’t want motion to trigger the light to turn on if I’m still in bed and happen to move and trigger the motion sensor. I need to account for me being in bed or out of bed. When the system is in evening mode, motion should trigger the light to light to turn on 20%, and off after 20 minutes of no motion.

3) What is happening/not happening?
I cant figure out how to account for me being in bed or not. I dont want to flood the room with light if I happen to move in my sleep and the system is in day mode. Perhaps motion wont be turned on in day mode until the smart dimmer is physically turned on at the wall, or a google assistant command triggers a routine that slowly illuminates the light.


#281

My apologies, but this is the “Example Pistons” category, and not really the place to troubleshoot new ideas.

Well that plus, you have already started a thread for this.


#282

Total newbie here. I was looking for a way to do exactly this. I want my front porch light to turn on via motion and turn off when motion stops, but not turn off if it was already turned on rather than turned on by the motion. I am having a very hard time understanding the purpose of the programmatic variable in nc4jh. Would this not serve the purpose of turning off the light only if it was turned on by motion:


#283

What’s weird is when I import this piston (nc4jh), the rebuild asks for three devices, yet as best as I can tell the piston is only using 2. I can’t find the “Switch 21”. What am I missing?

  • Motion sensor

#284

Thank you @bangali for these examples.
I’ve just set this up, and read through the whole thread.
I have it working with my motion sensor and 1 light.

What I want to do, is to apply this to multiple lights.

So -
If they’re all OFF, turn them all ON for X minutes. Then turn OFF. (Which I can do with the piston in the first post)

If they’re all ON, then effectively do nothing. (Which I can do with the piston in the first post)

If some are ON and some are OFF, then turn those that are OFF, ON for X minutes, and only turn OFF those that were previously OFF, leaving those that were previously ON, still ON.

Make sense?

Any help would be appreciated.

Thanks


#285

I just left Switch 21 as ‘Nothing selected’ … I think it was a hangover from a previous attempt


#286

Thanks for posting this!! It does exactly what I need for my kitchen cabinet light. It now goes on with motion and stays on for 30 seconds, but I am also able to make it stay on via the wall switch.

I have another use for this functionality but it is a little more complicated.
I have a smart switch for my porch lights that goes on for 2 minutes with a motion sensor inside the house, but it also goes on with motion on a camera outside that activates a virtual switch-virtual switch goes on and porch light goes on for two minutes.
I would like to be able to turn the porch light on via the wall switch and have it STAY on until turned off by that switch.
I know this is an old thread-hopefully you’re still out there.
TIA