Here is a piston that I’ve put together to control my front pot lights (dimmable). It’s working well, but it seems that the front door opening is throwing it off - I’m still testing that.
Basically, it controls all aspects of the lighting tied to sunrise, sunset, as well as monitoring two presence sensors, the front doorbell for both the button being pushed as well as motion, and motion of the front camera. During off-hours (ie, outside the normal time the lights would be on, but still between sunset and sunrise), if one of the presence sensors arrives, the doorbell is pushed, or the front door opens, the lights turn on, then automatically turn off when motion stops.
Devices are:
- 1 dimmable switch (ie, front lights)
- 1 door sensor (ie, front door)
- 1 doorbell (monitoring both button pushed, and motion)
- 1 camera/motion sensor
- 2 presence sensors
Global variables are:
- @MorningLightsOnTime - to control when the lights come on in the morning
- @MorningOffOffset - an offset from sunrise when the lights turn off in the morning. Ie, lights are on from @MorningLightsOnTime until $sunrise + @MorningOffOffset
- @EveningLightsOffTime - to control when the lights turn off in the evening
- @EveningOnOffset - an offset from sunset when the lights turn off in the evening/night. Ie, lights are on from $sunset @EveningOffOffset until @EveningLightsOffTime
- @FadeTimeInstant - time period (in seconds) over which time the lights fade. This one happens to be 2 seconds.
- @FadeTimeShort - time period (in seconds) over which time the lights fade. This one happens to be 5 seconds.
- @FadeTimeLong - time period (in seconds) over which time the lights fade. This one happens to be 2 hours.
- @LightsMax - the max percent that the lights will be turned to (has to do with fade levels)
- @LightsMin - the min percent that the lights will be turned to (has to do with fade levels)