Lock Code Manager and custom drivers

I'm writing a custom driver for a lock keypad, and I'm having trouble integrating it with lock code manager. When it tries to get the codes from my device, I get this error in the log:

Unable to decrypt lock code from device

... but the codes I'm returning aren't encrypted.

So, two questions for anybody who might know the answer:

  1. What is the expected format that getCodes() should return?
  2. How would I implement lock code encryption in a custom driver?

getCodes() should fetch lockCodes which is documented as a JSON_OBJECT. (LockCdes in Driver Capability List | Hubitat Documentation)

For encryption HE has 2 methods defined in Common Methods | Hubitat Documentation

  • String encrypt(String value)
  • String decrypt(String value)

Thanks.

Do you know what the format of that JSON_OBJECT is? Is it just a string, or something else? Do you know of any example code?

Should be:

{"<positionNumber>":{"code":"<codeValue>","name":"<codeName>"},"<positionNumber>":{"code":"<codeValue>","name":"<codeName>"},...}
1 Like