Know 'who' unlocked the door?

Seems like a simple thing but I can't figure out how to do it... :grin:

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.

ie.
if(lock == "Backdoor Lock" && whoDidIt == "Bryan") {

Thanks!

Sorry, @mike.maxwell. Don't want to use RM but from an user developed app. Which is why I posted in Developers and not Rule Machine. :wink::grin:

1 Like

Is this to answer the question "...Who let the dog out?....." :slight_smile:

Sorry, I couldn't help it.

John

1 Like

LOL, do you think I read the categories?

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}"
}
4 Likes

Thank you!