Automatically Lock after X Minutes in Away Mode

Thanks for the modifications Eric.

I came across some code from @milktea that performs a check on the door to ensure it locked properly. If it didn’t then it sends a push notification. I like this a lot because sometimes if I don’t close the door all the way the deadbolt will hit the edge of the opening and not lock. I updated some variables and added it to your code to see if it would work but I haven’t got it working yet. Any ideas?

Here is the code from @milktea: Schlage Z-wave Lock Command Works Occasionally - #9 by milktea

It is added after line 84 in @erocm1231 code above.

def checkDoorIsLocked() {
log.debug (“checkDoorIsLocked fired”)
if ((contact.latestValue(“contact”) == “closed”) && (lock1.latestValue(“lock”) != “locked”)) {
sendPush(“Door auto-locking failed”);
runIn(30, checkDoorIsLocked);

Here is the code that tells ST to run the checkDoorIsLocked method.

def lockDoor(){
log.debug “Locking the door.”
lock1.lock()
send(“${lock1} locked after ${contact} was closed for ${minutesLater} minutes!”)
//Added next line to check door lock.
runIn(10, checkDoorIsLocked)
}

The one idea I had was that the 10 seconds is not long enough after the door tries to lock. Maybe it needs longer to update? Does anyone have any ideas ?