Motion Based Light EXCEPT when Manually turned On

manual
except
off
light
motion

#264

Doesn’t change much…state is now true but the light still closes after a minute when I’ve walked in the room after switching on manually the lutron


#265

I tried to turn aroung the logic but it did again the same thing

it’s like it’s not taking into account the first condition lutron switch must be off


#266

My earlier logic:

1   IF Sensor's motion changes to active  <-- Trigger
2   Then
3       IF LutronCaseta is off            <-- Condition
4       Then
5           Turn on lights
6       END IF
7   END IF

…only works if the device(s) on line 3 are different from the device(s) on line 5

(Ideally, line 3 should be a SimSwitch, but you can use a real light there IF it is not mentioned on line 5)


If you go this route, the turn off portion should be similar:

IF Sensor's motion stays inactive for X minutes  <-- Trigger
Then
    IF LutronCaseta is off                       <-- Condition
    Then
        Turn off lights
    END IF
END IF

This way, the motion sensor won’t do anything if that SimSwitch is on.


#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