PLTS, PLEG or Mental Asylum?

I’m really struggling to get my head around how to complete what feels like a simple and common scenario. However after spending way too much time and way too much of my sanity in to I’m going to swallow my pride and ask for help. I think I’m over complicating it and can’t see the wood for the tree any long.

I’m trying to use PLTS but can use PLEG is needed.

I have some electric gates, a motion sensor and a virtual switch which I am using to turn on and off my outside lights.

The behaviour I would like is;
If it is after sunset but before sunrise and gates open, motion is sensed or the switch is turned on; turn on the lights.
When the gates close or the switch is turned off start 10 min timer.
If motion is detected start / reset the same timer.
If the gates stay open or the switch stays on the lights should stay on until sunrise.
When the gates have been shut, the switch is off and no movement has been detected for that 10 mins the lights should turn off.

Can anyone give me a starting point on this? Even let me know if this is possible in PLTS?

Attached flow chat to maybe help see what what I mean.

TIA

I am not too experienced in PLEG and I have never used PLTS. What I would do is only use PLEG.

I would create a schedule for the sunset/sunrise, a 10 minute self-retrigger schedule, create device properties for the gate and motion sensors, create conditions for these inputs, then create the actions to turn on/off lights.

Here is an excellent primer on using PLEG: http://forum.micasaverde.com/index.php/topic,21603.0.html and to help debug PLEG: http://forum.micasaverde.com/index.php/topic,14385.0.html

After a few weeks of playing, it will start to make sense. I have a PLEG device just for testing.

Thanks Don.

Gives me a starting point. Will try this approach and see how far I get.

Here it is using PLEG …
I assume you want the lights to be on AND stay on at Night if the Virtual switch is set.
[hr]
Input:
NightTime Schedule - On 10 Minutes after Sunset Off 10 minutes before Sunrise
LightDelay Schedule - On Self Retrigger Off Interval 10 minutes
Motion Trigger - Motion Sensor detects Motion
GateOpen Trigger - Gate is opened
VirtSwitchOn Trigger - Virtual Switch indicates you want Lights On.

Conditions:
LightsOn NightTime AND (Motion OR GateOpen OR VirtSwitchOn)
LightsOff !NightTime OR ((LightsOn; !LightDelay) AND !VirtSwitchOn)

LightsOn (Turn Repeats On)

Actions:
LightsOn Turn on Lights
Use the PLEG device and the StartTimer action to start the timer LightDelay

LightsOff Turn Off Lights

@RTS, looking at your example if someone/something turn ON the virtual switch the light will be on always during the NightTime schedule? Mike

That’s what I indicated in my opening remarks.
There was not any user specification on how the Virtual Switch was to be used.

Richard, thanxs for the confirmation… “I guess you can teach an Old Dog…” ;D