Schlage Name and Code Data

I just (painlessly) move my Schlage BE469 from ST to Hubitat. So far so good. I seem to be getting better response times in Hubitat. Only problem I have is getting code/name information when someone unlocks the door with the keypad. In ST, I had modified the DH for this lock to "sendEvent(customEventName,eventData" when someone used the keypad with a code. A groovy app would "subscribe(customEventName,codeandNameHandler). I can not figure out how I can do this in Hubitat.

I know I can get evt.descriptiveText as well as evt.data but I would like to be able to construct my own message which would include the name as well as the code used. The evt.data ({"1":{"name":"Cor and Kathy","code":"5875"}}) contains all the info I need but I cant for the likes of me figure out how to parse it into name and code values.

Any help would be appreciated

Look at %value% in your rule.

That should be set to the "Name" value of the code that was entered on a rule triggered by the "Lock Code Entered" event.

1 Like

I use notifier app to push to my phone. Here is how mine is built. Notifies us based on user code.

1 Like

I assume you are referring to RM? I should have made myself clearer. I am not using RM and looking at getting this data via a groovy app.

1 Like

never mind

One you're building or one already done?

That works really well once I figured out I was using the wrong DH for my Pushover devices. Basically, thats al I need, however......

Anyone want to create their own customize groovy app, start with this

import groovy.json.JsonSlurper
import groovy.json.JsonBuilder






def subscribeToEvents() {
	subscribe(myLock, "lock", eventHandler)
}


def eventHandler(evt) {
    if (evt.data) {                                            // Door was opened with code
        def codeData = new JsonSlurper().parseText(evt.data)
        log.info codeData
        def theName = codeData["1"]["name"]
        def theCode = codeData["1"]["code"]
        pushoverDevice.deviceNotification("$evt.displayName was opened by $theName using code $theCode")
    }
    else {                                                    // Door was opened manually
        pushoverDevice.deviceNotification(evt.descriptionText)
    }
}
1 Like

Oops... That only works for slot #1. The correct way would look something like

    slot = codeData.toString().substring(1,2) 
    theName = codeData["$slot"]["name"]
    theCode = codeData["$slot"]["code"]

That will work for slots 1-9