Tricky hallway lights

I have a hallway in my basement, which has three doors into it. They are normally all closed, and I want a clever way of activating the light in the area.
All doors has sensors. There are also three light switches that might be used, but should not make any difference to the logic.

I have boiled the whole thing down to this;
If the light is off when opening a door - turn it on.
If the light has been on for one hour - turn it off
If the light has been on for more than 20 seconds when closing a door - turn if off.

I’m thinking this might be my first entry to the glorious PLEG world. But is it possible? I am struggling with the timers… :-[

I haven’t tested this but try:

LightOn Light is turned on
Door1 Door1 sensor is tripped
Door2 Door2 sensor is tripped
Door3 Door3 sensor is tripped

AutoOn Not LightOn and (Door1 or Door2 or Door3)
AllClosed Not Door1 and Not Door2 and Not Door3
AutoOff LightOn and ( (LightOn; Now > 1:00:00) or (AllClosed and (LightOn; AllClosed > 20)) )

AutoOn Turn on Light
AutoOff Turn off Light

Thank you for your detailed recipe! Just what a newbie like myself needed :slight_smile:

Worked first off, and now I also understand how to use PLEG.