ZHA: User code management on Zigbee door locks

Tags: #<Tag:0x00007fc41dff4040> #<Tag:0x00007fc420103d80>

component/zha/lock.py code is missing 3 important services for the user code management on Zigbee locks, similar to implemented in component/zwave/lock.py

SERVICE_SET_USERCODE = "set_usercode"
SERVICE_GET_USERCODE = "get_usercode"
SERVICE_CLEAR_USERCODE = "clear_usercode"

Please, add.


This! And if we could also find a way to receive the code ID fo who unlocked the door, that would be another plus.

1 Like

@Maxi1134 Well, at least having those functions we can write some wrappers, like described here:

This would be very useful. It would also be nice if there was a way to use the same codes on more than one lock automatically after setting it up for one lock.

1 Like

@VladStar Any new findings thus far?

I was able to use the zigbee cluster commands to set a code and (sort of) get a pin code:

not sure if this will help at all though…


@inishchith sorry, it doesn’t depend on me, but rather on HA Developers to pick this feature request up

1 Like

I don’t understand the lack of love for Zigbee locks. :frowning:

1 Like

Same here. Seems like an obvious addition to me. Maybe it’s more complicated than meets the eye. The team has been consistently adding features to the ZHA integration so let’s hope it’s at least on their todo list.


@stephack agree, even Z-wave JS integration has them from the very beginning


My Zigbee lock is essentially the last thing that I have connected to SmartThings so that I can manage it. What I wouldn’t do to learn python well enough to make all this happen.

Hmmmm… What could this be?


@vilord wow, thanks man! :slight_smile: looks like we have to prepare some beer for ya :slight_smile:

So, this should now be present in 2021.4.0 :smiley: I haven’t tried the release build yet (or even the betas), but at least it worked before that!


Confirm. Works like a charm in the release build.

Now we need a ZHA lock manager add-on

This is so exciting. Thank you @vilord!

edit: Where do I find the documentation for how to use this manually, until it gets integrated into Keymaster?

I added documentation here:

1 Like

Got it. Is there something like a view_lock_codes?

Services do not support return values, so no there is not.

Support is built in for getting lock codes with a key manager, but I have not yet worked with the KeyManager people to get ZHA added.

1 Like

Yay! I’ve updated my HA to the version 2021.4 yesterday and tested - indeed works great.
Many thanks to @vilord ! :slightly_smiling_face: