Door lock timer

I have a few scenes running an automatic door lock, in case someone doesn’t lock it after 10 minutes. When the door sensor closes, start a 10 minute timer. If the lock is manually locked (from inside or outside) cancel the timer. If the door opens before the 10 minute timer completes, cancel the timer. When the timer completes, lock the door.

I’m trying to move this into PLEG but with an extra step. If someone unlocks the door, but never opens it, I would like it to auto lock.

I’m close but could use another opinion.
[ul][li]If the door unlocks but never opens, after the timer, it will lock.[/li]
[li]If the door opens and remains open, don’t lock it.[/li][/ul]

My problem is that as soon as I close the door, it will lock. Instead I would like to start the timer over when the door closes. I believe that as soon as I unlock the door from the inside, the condition of the door unlocked and the door closed is true, immediately firing off the timer. Is there a better way to do this? Last time I wrote it with a “t_fDoorUnlocked and (t_fDoorUnlocked; NOW > 10:00)” but that also locked the door immediately as I closed it. And in some tests, as soon as I unlocked it.

Trigger:
t_fDoorUnlocked (Door Lock Unlocked)
t_fDoorOpen     (Door Sensor Opened)

Timer:
s_fDoorUnlocked_10m = Self Retrigger / Interval 00:10:00

Conditions:
c_fDoorUnlocked = (t_fDoorUnlocked and !t_fDoorOpen)
c_fDoorLocked = (t_fDoorUnlocked; !s_fDoorUnlocked_10m) and !t_fDoorOpen

Actions:
c_fDoorUnlocked = PLEG starttimer = s_fDoorUnlocked_10m
c_fDoorLocked = Lock the door

You could modify t_fDoorUnlocked and (t_fDoorUnlocked; NOW > 10:00) to t_fDoorUnlocked and (!t_fDoorOpen; NOW > 10:00)

or create a new timer that is triggered when the door sensor goes from open to closed and use that timer in your door lock condition.

[quote=“FilthyBeast, post:2, topic:195446”]You could modify t_fDoorUnlocked and (t_fDoorUnlocked; NOW > 10:00) to t_fDoorUnlocked and (!t_fDoorOpen; NOW > 10:00)

or create a new timer that is triggered when the door sensor goes from open to closed and use that timer in your door lock condition.[/quote]
With t_fDoorUnlocked and (!t_fDoorOpen; NOW > 10:00) wouldn’t the door lock as soon as the door sensor closed, if it were closed anytime after the 10 minutes?

I’m interested in how to write the condition that knows when the sensor has gone from opened to closed. This would correct the issue upon unlocking the door and it hasn’t been opened yet.

[quote=“3rdStng, post:3, topic:195446”][quote=“FilthyBeast, post:2, topic:195446”]You could modify t_fDoorUnlocked and (t_fDoorUnlocked; NOW > 10:00) to t_fDoorUnlocked and (!t_fDoorOpen; NOW > 10:00)

or create a new timer that is triggered when the door sensor goes from open to closed and use that timer in your door lock condition.[/quote]
With t_fDoorUnlocked and (!t_fDoorOpen; NOW > 10:00) wouldn’t the door lock as soon as the door sensor closed, if it were closed anytime after the 10 minutes?

I’m interested in how to write the condition that knows when the sensor has gone from opened to closed. This would correct the issue upon unlocking the door and it hasn’t been opened yet.[/quote]

Yes, if you want to make sure to wait then use a self retriggering timer with a 10 minute interval that is started when the dooropen sensor goes false / closed.

t_fDoorUnlocked and (!t_fDoorOpen; !timer) then will be true when the door is unlocked, door is closed before the timer went false / ended. If you open the door and close it during the timer it will restart.