Motion Controlled Lighting

I’ve researched the forum, but I cannot seem to find anything that points me in the right direction.

At 10pm, I have multiple lights in my house turn off.
However, if someone turns on my loft light after 10pm, I want it to turn off 20 minutes after the last motion is detected.

I’m using PLEG, and I have this logic:
LFT_Light_Trg and (LFT_Motion; NOW > 20:00) and !(06:00:00; Now; 22:00:00)

LFT_Light_Trg = My loft light trigger (it’s turned on and after 10pm).
LFT_Motion = The motion trigger.

The problem that I have is that I cannot turn ON the light unless the motion sensor is tripped, after 10pm.
I would like to be able to turn on the lights (via the switch or the app), and if no motion is detected for 20 minutes THEN the light gets turned off.



Upon further reflection, I’m fairly certain it’s due to the exclusive timeframe… !(06:00:00; Now; 22:00:00)
But, if I make it inclusive, I cannot figure out how to make it span dates. Meaning, from 10pm (tonight) to 6am (tomorrow).

Help from a guru would be greatly appreciated.

The expression !(06:00:00; Now; 22:00:00) will be true from 22:00:00 until 06:00:00 - which I think is what you wanted. So that is not the problem.

You can probably get what you want by using a timer rather than the sequence expression. If you start/restart the timer whenever the motion sensor is tripped or the light is turned on, you can turn off the light when the timer completes. You could have this work at all times or just overnight as you wish.

Timer20m OnType: SelfReTrigger, OffType: Interval 00:20:00

LFT_Timer (Rpt=Y) LFT_Motion or LFT_Light_Trg
LFT_Light_Off LFT_Light_Trg and !Timer20m and (LFT_Light_Trg; !Timer20m)

LFT_Timer This PLEG, StartTimer timerName=Timer20m
LFT_Light_Off LFT_Light, turn off

Lesson learned:
Don’t mess with the home automation system while your girlfriend is trying to clean the house. Especially at night when she actually needs the light.