Auto lock door only after door is closed using PLEG

I know that an older post on the auto door was started some time ago ([url=http://forum.micasaverde.com/index.php/topic,13961.0.html]http://forum.micasaverde.com/index.php/topic,13961.0.html[/url]), but its been since anyone posted so I wanted to start a new topic.

I have a Schlage Motorized touchscreen deadbolt lock that I have configured with my veralite. It’s been working very well so far, but recently I had a mishap that made me want to reconfigure my PLEG settings that would prevent my kids from destroying the lock and the molding around the door frame. I had used RichardTSchaefer suggested configuration for PLEG and it worked wonderfully. I had it so that when the door was unlocked it would lock itself in about 3 minutes. However, I found out my kids like to chat with the neighborhood kids with the front door open. After 3 minutes of being unlocked the script fires and the dead bolt is extracted while the door is open. My kids either forget or don’t notice the deadbolt is extracted and after their 10 minute conversation they close the door slamming the extracted deadbolt on the door frame molding.

I have a DSC wireless door sensor on this door, I’d like to add to the PLEG configuration that it should start the 3 minute countdown only after the door has been closed and that specific zone has been secured. Has anyone tried this, if so could you kindly share how you did it? Cheers.

I have been working on something similar for a couple of days now, when time permits.

What I am trying to accomplish is a way to emulate the Schlage hardware’s 30 second relock, specifically a way to temporarily turn the autolock off. Using the Schlage method, you have to unlock with a PIN, then manually lock and unlock within 10 seconds. I want this to work without having to enter the PIN.

I created a scene that is triggered by the front door being unlocked. A second scene was created (scene #32) which only locks the front door. This is the LUA code I am using:

Function TimeFrontDoorUnlocked(stuff)
local lul_args = {}
If gFDoor == 1 then
lul_args[“SceneNum”]=“32”
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,lul_args,0)
end
gFDoor = 0
end
if gFDoor == 1 then
gFDoor = 0
else
gFDoor = 1
luup.call_timer(“TimeFrontDoorUnlocked”, 1, “30”, “”, “”)
end

What this code does is if the scene is run twice within 30 seconds, the second invocation will reset gFDoor, and the subsequent 30 second timer will not attempt to relock.

Unfortunately, this is working, but only sort-of. It appears that my network has timing delays in reporting the door lock/unlock back to Vera, which messes with this logic. I am working on trying to find what is really happening that makes it fail sometimes (usually locking when it should not). Unfortunately, life is interfering with my fun here!

You could do something similar, but instead of the “gFDoor” flag, check the status of your door open sensor.

[quote=“ubun2Junky, post:1, topic:181809”]I know that an older post on the auto door was started some time ago ([url=http://forum.micasaverde.com/index.php/topic,13961.0.html]http://forum.micasaverde.com/index.php/topic,13961.0.html[/url]), but its been since anyone posted so I wanted to start a new topic.

I have a Schlage Motorized touchscreen deadbolt lock that I have configured with my veralite. It’s been working very well so far, but recently I had a mishap that made me want to reconfigure my PLEG settings that would prevent my kids from destroying the lock and the molding around the door frame. I had used RichardTSchaefer suggested configuration for PLEG and it worked wonderfully. I had it so that when the door was unlocked it would lock itself in about 3 minutes. However, I found out my kids like to chat with the neighborhood kids with the front door open. After 3 minutes of being unlocked the script fires and the dead bolt is extracted while the door is open. My kids either forget or don’t notice the deadbolt is extracted and after their 10 minute conversation they close the door slamming the extracted deadbolt on the door frame molding.

I have a DSC wireless door sensor on this door, I’d like to add to the PLEG configuration that it should start the 3 minute countdown only after the door has been closed and that specific zone has been secured. Has anyone tried this, if so could you kindly share how you did it? Cheers.[/quote]

You probably had setup a condition like:

DoorUnlocked AND (DoorUnlocked; NOW > 00:03:00)

which triggers the door-lock action after being unlocked for more than 3 minutes

Change it to:

DoorUnlocked AND DoorClosed AND (DoorClosed NOW > 00:03:00)

Where:

  • DoorUnlocked is a trigger on your Schlage lock, true while it’s unlocked
  • DoorClosed is a trigger for your DSC door sensor while it’s not tripped/when the door is closed

so that it’ll lock > 3 minutes after you closed the door, but only when the door is still closed and it is currently unlocked

Documentation & examples: [url=http://rts-services.com/Vera/Plugin/PLEG/]http://rts-services.com/Vera/Plugin/PLEG/[/url]

duiffie;

Thanks I’ll definitely give this a try. I always have a hard time understanding the need to have the first “DoorUnlocked” in “DoorUnlocked AND (DoorUnlocked; NOW > 00:03:00)”. In my head I figure I just need the second part of it “DoorUnlocked; NOW > 00:03:00” and that should do it.

[quote=“ubun2Junky, post:4, topic:181809”]duiffie;

Thanks I’ll definitely give this a try. I always have a hard time understanding the need to have the first “DoorUnlocked” in “DoorUnlocked AND (DoorUnlocked; NOW > 00:03:00)”. In my head I figure I just need the second part of it “DoorUnlocked; NOW > 00:03:00” and that should do it.[/quote]

A short explanation then:
DoorUnlocked AND DoorClosed AND (DoorClosed NOW > 00:03:00)

DoorUnlocked - It only makes sense to lock the door if it’s currently unlocked, so add this to the condition
(DoorClosed; NOW > 00:03:00) - the door must be closed more than 3 minutes ago
DoorClosed - add this to prevent locking while the door is currently open. remember that the above statement is about closing the door; the door can be opened again within these 3 minutes. If you don’t include this, the condition will be true if the door is currently open, but was previously closed more than 3 minutes ago

In your example:
“DoorUnlocked AND (DoorUnlocked; NOW > 00:03:00)”

the first DoorUnlocked is there because, when using timers, PLEG checks every minute if the times has completed. If you don’t include the first DoorUnlocked, then the condition will fire every minute because 4 > 3, 5 > 3, 6 > 3 and so on. To prevent this ‘loop’, only try to lock the door if it’s not already locked. If it’s already locked, then the condition will be false every minute PLEG checks it.

[quote=“ubun2Junky, post:4, topic:181809”]duiffie;

Thanks I’ll definitely give this a try. I always have a hard time understanding the need to have the first “DoorUnlocked” in “DoorUnlocked AND (DoorUnlocked; NOW > 00:03:00)”. In my head I figure I just need the second part of it “DoorUnlocked; NOW > 00:03:00” and that should do it.
[/quote]

But you need the first part because you want to make sure the door is still unlocked. Sequences don’t care about the current state, just how long ago they were true. What if you manually locked it after entering?

Here is mine in case someone want’s to use it:

FrontDoorUnlocked1 AND (FrontDoorUnlocked1; NOW > 10:00) AND LockDoor2 AND FrontDoorClosed AND ( FrontDoorClosed; NOW > 2:00 )

FrontDoorUnlocked1 is true when the front door is unlocked
LockDoor2 is mapped to a multiswitch button which allows me to say if I want to use the auto lock functionality. For instance, if I’m having a party and don’t want to door to lock or I’m doing a lot of work out front.
FrontDoorClosed lets me know when the door sensor is NOT tripped (door is closed)

So, in plain English here is what the above code says:

The front door is currently unlocked and it has bee unlocked for over 10 minutes. IN addition, I have enabled the “auto lock” funtion. And finally the front door is currently closed and it has been closed for at least 2 minutes.

Note that if I didn’t have the bolded part of:

FrontDoorClosed AND ( FrontDoorClosed; NOW > 2:00 )

Then it would my last sentence above would say:

And finally the front door was closed at least 2 minutes ago, but it could be open now.

Great info… Thank you very much I sincerely appreciate the explanations, it makes things a lot clearer. I’m going to have to go back and clear up some of my other PLEG devices I created.

Note that I said they only care when they were last true. I don’t think this is always the case. For instance if you put ![trigger], it will be when it’s last FALSE because the ! says “not”.

So in my example above if I instead used my “DoorLocked” trigger it might be:

!DoorLocked AND (!DoorLocked; NOW > 10:00)

or, the Door is currently not locked and DoorLocked was last false more than 10 minutes ago.

So this is what my PLEG device looks like:

Trigger:
tFrontDoorClosed (Front Door Z1 is not tripped)
tFrontDoorLockUnlocked (Front Door Lock is Opened)

Conditions:
cAutoLockDoor:
tFrontDoorLockUnlocked and tFrontDoorClosed and (tFrontDoorClosed;NOW > 00:01:00)

Action:
cAutoLockDoor (set to lock the front door Schlage lock)

So when I close the door after it’s been open I’ve set it to close one minute after it’s closed. When I time it, it doesn’t lock a minute later, instea it locks after a minute and a half. I’m wondering why the extra 30 seconds?

In the Pleg docs, it says that Now will be evaluated every minute (not exact)…so it will vary randomly to actually firing from 1:00 to 1:59.

If you want precise timing then you need to look at some of the self triggered timer examples.

[quote=“ubun2Junky, post:9, topic:181809”]So this is what my PLEG device looks like:

Trigger:
tFrontDoorClosed (Front Door Z1 is not tripped)
tFrontDoorLockUnlocked (Front Door Lock is Opened)

Conditions:
cAutoLockDoor:
tFrontDoorLockUnlocked and tFrontDoorClosed and (tFrontDoorClosed;NOW > 00:01:00)

Action:
cAutoLockDoor (set to lock the front door Schlage lock)

So when I close the door after it’s been open I’ve set it to close one minute after it’s closed. When I time it, it doesn’t lock a minute later, instea it locks after a minute and a half. I’m wondering why the extra 30 seconds?[/quote]

I’m trying to set up the same rule with my schlage and vera lite. I don’t see an armed/not armed option in the triggers drop down. I do see locked vs unlocked. Should I be looking somewhere else?

Thanks

Added DoorUnlocked AND (DoorUnlocked; NOW> 00:01:00) but now I get a notification on my Schlage Deadbolt “Sorry, the node reports it’s busy. Please try again later.”

Is the PLEG first DoorUnlocked polling the deadbolt every minute?

joelc73;

Unfortunately the Schlage door lock cannot provide you with information of whether the door is closed or open. For this reason I’m using my door sensors from my DSC alarm system to determine whether the door is open or not. I’m then using the status of the schlage lock to determine if the lock is open or closed.

The armed/not armed comes from the alarm system door sensor that will tell me if the the door is opened or closed. Hope this helps.

VallejoIII;

Like AgileHumor had stated on an earlier post, it sometimes varies. That’s why I wanted to play it safe and set mine to 3 mins. Try increasing the time on yours and see if that resolves your issue. If you need it less than 3 mins for example, you may want to take a look at some self triggered timer examples like RichardTSchaefer suggested.

Conditions:
cAutoLockDoor:
tFrontDoorLockUnlocked and tFrontDoorClosed and (tFrontDoorClosed;NOW > 00:03:00)

ubun2Junky;

Thanks!

Well after about 3 minutes the “Sorry, the node reports it’s busy. Please try again later.” message went away.

It is all working and notifying me correctly. Door now auto locks if someone turns the deadbolt in 1 minute then notifies me that the door has locked. And now shows correct position of the deadbolt.