How to easily query Z-Wave lock for current codes

In the groovy platform it is possible to issue custom zwave commands and request the lock codes. Some of the locks tested have only returned asterisks. Some will return the actual code. We do NOT implement this functionality at a platform level nor do we ever store any lock codes in our platform. Going forward with the new API model it would not even be possible to do this as we are not supporting get lock code as a capability.


Support via a public API or at all? What is Smart Lock Guest Access in the new app using to set codes? Groovy?

We will eventually support set/delete lock codes via lock code management. Those will be supported capabilities. getCode will not be one of those.

1 Like

@jody.albritton thanks so much for your response! Can you go into more detail about how I’d go about issuing the get code zwave command on the Groovy platform?

If you look there is example for sending commands.

These are the command classes

1 Like

Thanks @jody.albritton! I tried copying in this code from the device handler itself. When I run it, I get, “Cannot get property ‘zwave’ on null object @line -1 (requestCode)”. I’ve also tried removing the, “physicalgraph.” and still get an undefined object. I see no other imports in the lock code device handler so don’t understand what I’m missing.

import physicalgraph.zwave.commands.doorlockv1.*
import physicalgraph.zwave.commands.usercodev1.*

def requestCode(codeNumber) {
secure(physicalgraph.zwave.userCodeV1.userCodeGet(userIdentifier: codeNumber))

private secure(physicalgraph.zwave.Command cmd) {

It’s really not something we support, so the docs and the samples I gave you are what I have. There are some zwave gurus in the community that could probably tell you how to get this done in groovy, but I am not one of them.

Ah got it that’s too bad. I guess nobody else has tried this here?

Not really because we all use something like RBoy’s app or the builtin lock manager app and let it handle it on its own. There are already two or three good solutions in the community for managing codes so its not really worth worrying about.


@nathancu glad you found a solution! Unfortunately I can’t use those apps. Anyone who can provide what I’m alluding to above, let me know - I’m also down to hire a consultant if they have the solution.

Curious why you can’t use them?

1 Like

For the purposes of what I’m doing I have to use my own code in a custom SmartApp. Possible we’ll just move to the new Web API that’s in beta and is probably more reliable overall anyway but I’m not sure how far away that is.

But I find it interesting how this all works, it’s pretty unclear to me which functions get exported for use in the SmartApp vs Device Handler, and a few other things after trying to troubleshoot it myself. And how I can’t get a straight answer on this for Smart Things but I can for HASS. Obviously different ecosystems.

Appreciate all of your help though!

1 Like

You know what, I’m diving deeper into RBoy’s offerings and this may be what we need. They’re more extensive than I remember with a lot of updates in the last few months! Thanks all for your recs, I’ll try to let you know how it goes.


© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.