Motion Based Light EXCEPT when Manually turned On

motion
light
manual
except
off

#1

This piston will turn on a light with motion and off after 5 minutes of no motion. But if user switches the light on it will not be turned off by motion, instead user will need to turn if off from the ST app. If motion turned on the light and you want it to stay on till you turn it off, just switch the light off and on. The isBetween check sets the light level to 100% when between 4am to 11pm otherwise to 10% only when turned on by motion. note that while i use a light in this example it could be any device controlled by motion.

image

EDIT: edited the description to clarify that when you need to take the light out of the stay on mode, you turn off the light from the ST app.

EDIT2: added the following version as well which can be found in the thread below for use with smart switch and dumb bulb. the first version works with dumb switch and smart bulb combo. this has the additional option of not controlling the lights unless it was turned on by this piston.


Improve motion light piston to consider physical interaction
Help: Auto light ON with motion EXCEPT when TV is ON
Tun ON & OFF using alexa/GH
Ignore new motion on physical switch off
Door turns on light but motion turns it off
#2

Interesting, I do something similar but reverse. I will have to get it posted.

I do like the simplicity of the bulb event watching to toggle programatic mode.


#3

thank you. i am a big fan of simplicity. :slight_smile:


#4

Was thinking of how to incorporate manual intervention for my motion triggered bulbs and like how you have used the variable to distinct between that and a manual turn on. Thanks man!


#5

you are welcome.


#6

Thanks for this - I will likely use it in reverse.


#7

you are welcome. share as an example when you ready. :slight_smile:


#8

Okay - so I’m tryig to figure this out until I gave up and came here. Your example is exactly what I was intending to do, but when I was doing it manually ,I can’t find the set variable action. soo…

Where in g-d’s green H-E-double hockey sticks do you add an action to set variable? I cannot find it for the life of me in Actions.


#9

looking for this?


#10

URGH! sorry - that “location” thing threw me off. I was like, no i am not interacting with Location.

Okay okay - time to fire this thing up now. seriously, my only reason for even trying web/CoRE is to solve this problem that I just couldn’t with the ST ide. will probably end up moving other stuff here as well.

Thanks!


#11

great - got it working like a charm … now, what’s the cleanest way to do something like this:

set lamp to 80% from sunset minus 30 minutes through 9pm, and 20% from 9pm to sunrise + 30 minutes?

I really like the isbetween that’s already there, but trying to figure out if we can tweak it without replicating the logic. I’m guessing either precalculate it at the top, or perhaps just copy the do section?


#12

If you have modes that line up, you could tie it to them:

But I’m also curious how to modify the original expression.


#13

ehh, no reason to be sorry … we all go through this.

thats how we all started. :slight_smile:


#14

add another condition to the if statement:

isBetween($now, addMinutes($sunrise, 30), addMinutes($sunset, -30)) is false

then with the light do this

turn on
set level to (isBetween($now, addMinutes($sunset, -30), time("21:00")) ? 80 : 20)

this assumes that you dont want the light turning on between sunrise + 30 and sunset - 30


#15

I’m probably missing something, but doesn’t this all fall apart the minute a user manually turns on a light?

When a user turns on a light it stays on until he turns it off.
When a user turns off the light there literally no longer power available to the light. The only way to get the light back on is to manually turn it on - and now we’re back to the beginning.

What am I missing?


#16

use the ST app to turn off the light, not physical switch.

but, the scenario you describe could be handled as well … let me know if you need it.


#17

I’m definitely interested in a solution for that case, yes. Probably just as interested (maybe more) in seeing how it’s done. Thank you!


#18

since you dont really need it and are just interested, heres a way to do it but havent tested it :slight_smile:

note: this will always work with a smart switch and dumb or smart bulb combo. it will also work with a dumb switch / smart bulb but only when the switch is not physically turned off rather the smart bulb is turned off / on thru the ST app when you want it to stay on or exit that mode.


#19

Hi,

I’ve modified what you wrote for what I need this to do for me, but I want to make sure I did it correctly (I don’t think it’s exactly right yet.) I’d like the sensor to detect movement and stay on…if it doesn’t detect movement, it can turn off in 20 seconds…As far as the light switch being turned on manually, I don’t think I need this, but I didn’t remove that part, I don’t think…anything I need to modify to get this to work for the above scenario?

Thanks


#20

you are doing good. just add the motion sensor to the first to 2 if statements and it should work for what you need.