How to turn a light on only at night when motion is sensed?

I have a motion sensor, and a light… I managed to create a scene that’ll turn the light on when the motion sensor detects something and it turns itself off after 5 minutes. That works pretty good…

how do i modify or make a scene that will only do this after sunrise and before sunset? I tried this with a trigger (after sunset and another for before sunrise) but it’s still turning on during the day…

is there a better way to turn it off rather then waiting 5 minutes? e.g. can i make it turn off 1 minute after the motion sensor stops detecting motion somehow? I don’t see a way to do this with the basic scene options given…

Thanks!

I use PLEG. Works great.

whats a PLEG? :slight_smile:

This is a super common question that has been answered many times. There are several solutions.

As already suggested, you could use the Program Logic Event Generator(PLEG) plugin to do this and a whole lot more.

You could also use Lua code to do this; see @RexBeckett’s Conditional Scene Execution: Some Examples.

But, the quick and dirty option is to ad the following snippet of code to the LUUP tab of your scene. The code will allow the scene to run only between sunset and sunrise.

return luup.is_night = true

awesome, thanks z-waver. I’ll start reading up…

I have a video series on that very topic, this particular video shows the PLEG code and Vera interface:

It makes use of the Day/Night app. to give a day or night reading.

@gwitchman if you are looking at fairly simple way to do this (not 100% fool proof but works 99% of time)

(1) when you create trigger using motion sensor armed and detects motion then at the same window you have 1 more options in scene menu which allows you to run this scene during certain hrs + trigger condition to me met (look for small clock indicator towards top right) - you can use this to define your time lest say after 10PM and before 6 AM ANd trigger of motion sensor

(2) you can create another scene which disables the motion sensor when ambient light in room is greater then certain level, which means even if at night light is already on then your scene will not trigger making it more better and it will only arm the motion sensor when light falls below lets say <3 Lux and motion sensor will turn on lights only when it detects the motion … so you are practically meeting 2 conditions (or 3 if u use time schedule also) to trigger ur lights.

however i agree the method of PLEG is much more powerful.