Implementing capability.lockCodes - need guidance on a couple commands

Sorry about the lack of documentation on lockCodes. The capability isn’t finished, so it will likely still change, but here’s the run down:

lock.setCode(2, "0486") to set code #2 to 0486

You need to subscribe to “codeReport” to get the result of that, same with lock.requestCode(). The actual code is in the event data, accessed as evt.jsonData.code.

Subscribe to “codeChanged” to get notified when codes are deleted or changed manually, if you use lock.deleteCode(3) you should get a “codeReport” with blank code.

updateCodes takes JSON format like so:

lock.updateCodes('{"code2":"0486","code4":"2626","code5":""}')

Note the empty string to delete code 5.

lock.reloadAllCodes() will go through and getCode each code in order. You’ll get a big bunch of events so use it sparingly. It’s basically a stopgap since our system currently doesn’t support returning values from device methods.

There may be bugs, so let me know if you run into issues.

4 Likes