SmartThings Community

[RELEASE] Lock Manager

smartapp_locks
(Stephen Johnson) #2132

After updating the device handler it took about a day before I started getting notifications.

Works like it used to again!

#2133

This sucks, I just can’t get it to work.

#2134

How many device handlers do you have listed?

(Stephen Johnson) #2135

Not sure I get what you mean. There are several lock device handlers in the list and I have a Yale lock so I published and assigned ethayer’s Yale lock device handler to the lock - I was using the ‘with codes’ version before. Went into the device handler code and made the change described earlier in the thread and after about 12 - 24 hours I started getting notifications about lock activity.

I should mention that the lock manager smartapp was dead for me - just took errors when I tried to change anything - so I removed and reinstalled it from scratch. I let it do the full sweep to clear all codes and added them back. I only have a couple of codes so it wasn’t a big deal.

#2136

Patch working great. Thanks!

#2138

This is what I have

I first updated the code to ethayers and was not getting any notifications. Last night I updated the code with the patch to the smartthings device and started to get notifications today. Interestingly enough it was gradual, first started to get manual lock/unlock, and then started getting notifications from my users. Funny thing is I am getting error codes on all of my users.

#2139

Here you go, based on this documentation:

private getCommandClassVersions() {
    [		
        0x62: 1,  // Door Lock
        0x63: 1,  // User Code
        0x71: 2,  // Notification (v3)
        0x72: 2,  // ManufacturerSpecific
        0x80: 1,  // Battery
        0x85: 2,  // Association
        0x86: 1,  // Version (v2)
        0x98: 1,  // Security
    ]
}
#2140

After 3 years on Version 1.4, I recently upgraded to the current 2.0 version successfully with my Yale lock. I did not get notifications until I made the change to the DTH (I am using ethayer’s Z-Wave Lock Yale) mentioned in post 2053 by Kianoosh_Karami.

I made three changes to Lock Manager to make it work the way I wanted. The diff for all the changes I made is at the end of this post, but first I will describe the changes.

  1. If the Master Code is used, the Yale lock indicates that it was opened with code 0. I was not getting a notification in this case because Lock Manager did not recognize this use case even though the DTH recognized it. Lock Manager was telling me in a debug message that “Lock was locked by unknown user!” (see line 1179). (This was incorrect in itself since this message was generated after it was determined that the state of the lock was unlocked.) I added code to check if code 0 was used, and, if so, to send a notification that the Master Code was used. If it was not code 0, then the original debug message, corrected to be “unlocked”, would be issued.

  2. No notification was given if the lock was unlocked manually because there was no code in that section to do so, even though there was code if the lock was locked manually (see line 1272). I added the statements to provide notification.

  3. No notifications were given if the lock was locked or unlocked via a SmartThings command. The routine for handling these cases was left empty as shown by the comments (see line 1277). I added code to provide appropriate notifications for this.

Here is the diff from the current Lock Manager code to my version:

1179c1179,1193
< debugger(‘Lock was locked by unknown user!’)

  if (data.usedCode == 0) {
    // Yale locks have code 0 for the Master Code
    message = "${lock.label} was unlocked by Master Code"
    debugger(message)
    if (codeUnlockRoutine) {
      executeHelloPresenceCheck(codeUnlockRoutine)
    }
    if (parent.notifyAccess) {
      sendLockMessage(message)
    }
    if (parent.alexaAccess) {
      askAlexaLock(message)
    }
  } else {
  debugger('Lock was unlocked by unknown user!')

1180a1195

  }

1272a1288,1294

if (notifyManualUnlock) {
  sendLockMessage(message)
}
if (alexaManualUnlock) {
  askAlexaLock(message)
}

1277c1299,1320
< // no options for this scenario yet

def message
if (evt.value == ‘locked’) {
// locked by command
message = “${lock.label} was locked by command”
debugger(message)

if (notifyManualLock) {
  sendLockMessage(message)
}
if (alexaManualLock) {
  askAlexaLock(message)
}

} else if (evt.value == ‘unlocked’) {
message = “${lock.label} was unlocked by command”

if (notifyManualUnlock) {
  sendLockMessage(message)
}
if (alexaManualUnlock) {
  askAlexaLock(message)
}

}
1278a1322

(Chris) #2141

Hi All,
I have a problem with my LockManger. Started a week back or so where it quit writing codes or being able to update/save codes. I uninstalled everything reinstalled what I could (couldn’t find the child apps based on the instructions or in github) On the main app it show the user setup, shows the schedule, but wrote the code to the lock 9 hours later. Orig set the code to be written at 3:30pm and it was written at 12:26am.![Screenshot_20190524-091923_SmartThings|281x500]
(upload://ykaoh4FqQMaoE7XqEWDqZpyApgl.jpeg)

Any help is GREATLY appreciated!!!