Use Dashboard to Manage Lock Codes

Hi @Angus_M - this is my driver. It's not the complete code, but as an example it shows how to use the groovy.json jsonSlurper .

Learned a bit more about Groovy and removed a lot of the hard coding. Looks like even attribute definitions can be added programatically. 2021-01-02

Hope this helps:-

import groovy.json.*
	
metadata {
definition (name: "Virtual JSON Parser", namespace: "timtuxworth", author: "Tim Tuxworth")     {
   capability "Actuator"
    
    command   "sendLockCodes",["string"]
    
    attribute "lockcodeslist", "string"
    attribute "lastUpdated", "string"
    
    attribute "slotlabel", "string"
    attribute "codelabel", "string"
    attribute "namelabel", "string"

    Integer s;
    for(s = 1; s <= 9; s++)
    {
        attribute "slot" + Integer.toString(s), "number"
        attribute "code" + Integer.toString(s), "string"
        attribute "name" + Integer.toString(s), "string"
    }
}
def sendLockCodes(lockcodesjson) {

sendEvent(name: "lockcodeslist", value: lockcodesjson, displayed: true)

def jsonSlurper = new JsonSlurper()
def lockobjects = jsonSlurper.parseText(lockcodesjson)

assert lockobjects instanceof Map

sendEvent( name: "slotlabel", value: "#")
sendEvent( name: "codelabel", value: "Code")
sendEvent( name: "namelabel", value: "Name")

Integer s;
for(s = 1; s <=9; s++)
{
    sendEvent( name: "slot" + Integer.toString(s), value: Integer.toString(s))
    sendEvent( name: "code" + Integer.toString(s), value: "-")
    sendEvent( name: "name" + Integer.toString(s), value: "-")
}

// for this to work the JSON passed in must be in the format, by adding attributes you could extract any number of rows.
// {"1":{"name":"Test1","code":"1111"},
//  "2":{"name":"Jo2","code":"2121"},
//  "3":{"name":"XX","code":"1234"}
// }

log.debug(lockobjects.toString())
lockobjects.each { lockobject ->
    def slot = lockobject.key
    
    sendEvent( name: "slot" + slot, value: slot)
    sendEvent( name: "code" + slot, value: lockobjects[slot].code)
    sendEvent( name: "name" + slot, value: lockobjects[slot].name)
}

lastUpdated = new Date()
sendEvent( name: "lastUpdated", value: lastUpdated.format("MM-dd - h:mm:ss a") )

}
3 Likes

I have the problem you're describing about the virtual device for LockCode not showing as possible device in dashboard. How do you add permission? I don't see anything when creating the variable.

Go to the Apps tab, scroll down to Hubitat Dashboard, and select the child app corresponding to the dashboard you want it available in. Variable device should be available there to check for inclusion.

1 Like

@thebearmay thanks!!! Both for quick response and that it worked!

Anyone have update on when this sort of feature would be formally supported. While this is a nice 'workaround', it's really just that.... a workaround. Being able to configure the LockCodeManager app remotely via Dashboard would be really helpful for those of us who have VRBO / AirBnB locations.

1 Like

I use the VPN service available in my router, combined with a Dynamic DNS entry to log into my network from a remote location and then run the apps.

There is an upcoming service for remote access. Below is a recent thread that speculates about this service. It is likely coming to the next update or two if it is showing in the Hubitat app. No formal details about this service have been released that I am aware of.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.