Automatic Porch Lighting that increases in brightness with motion

I wrote this rule to automatically turn on the porch light at sunset to 10% brightness and turn it off later in the night (10:30 PM). In addition to that, if there is a person detected by my Nest camera it'll turn the light up to 50% brightness and then after a minute return it back to its original brightness (10%).


I'm just getting started, so I'm sure there may be ways to improve this. Feel free to leave feedback. :slight_smile:
My wife already pointed out that I probably should've used else ifs instead of the 2nd and 3rd if statements, because currently there might be race conditions (e.g. if someone steps in front of the camera at the exact second that the sun sets, then both conditions could be fired :sweat_smile:), but I'm not too worried about that exact scenario happening and am just going to leave it as is.

Why the Capture? Wouldn't that capture the light at 50% if there is motion twice within a minute?

it would probably, I would add something like this to avoid re-trigger while light is raised;

AND Dimmer level of Lamp: Hallway Bench(30) is < 50(T) [FALSE]) THEN

1 Like

I have something similar in webcore. Even if you don't use webcore you should be able to follow the logic. Main difference here is that I have a separate rule that turns the lights on to 50% at sunset, and off at sunrise. This piston (what they call rules in webcore) just turns the lights to 100% if motion is detected from any of three sensors, then restores the original level after a few minutes. If the lights weren't on in the first place, then nothing happens.

Good point!

Thanks! I've added this additional condition to the second IF statement.

1 Like

A motion zone would probably work well for this as well since you could have multiple camera triggers before the zone goes inactive to prevent capturing the state inadvertently. I do something similar for my garage but it can be used with only one sensor.

Download the Hubitat app