Seems like a simple thing but I can't figure out how to do it...
Anyway from an app to know 'who' unlocked the door and act on it. Not interested in the actual lock code if I don't need it (seems like a security issue) but just the name associated with it, if possible.
you'll need something along these lines on the app side:
subscribe(myKeypads,"securityKeypad.disarmed",useHandler)
subscribe(myLocks,"lock.unlocked",useHandler)
void useHandler(evt){
def data = evt.data
if (data && !data[0].startsWith("{")) {
data = decrypt(data)
if (data == null) {
log.warn "Unable to decrypt lock code from device:${evt.displayName}"
return
}
}
def codeMap = parseJson(data ?: "{}").find{ it }
if (!codeMap) return
//do your thing here
log.debug "device:${evt.displayName}, lock code user name:${codeMap?.value?.name}"
}