Correct Z-Wave Lock API Command

I may have worked with a virtual lock briefly out of curiosity but that’s about it. In general terms you have three options to use the API to get the status out of a device. All are GETs.

/devices/{{deviceId}}/status (where {{deviceId}} is the usual UUID) will give you all the data of all of the attributes of all the capabilities of all the components in a hierarchy.

If you know which component you are interested in you can be a bit more precise by using /devices/{{deviceId}}/components/{{componentId}}/status (where an example of {{componentId}} would be main) and you’ll get the data for all of the attributes of all of the capabilities of the one component.

If you know which capability of which component you are interested in you can go one step further and use /devices/{{deviceId}}/components/{{componentId}}/capabilities/{{capabilityId}}/status (where {{capabilityId}} might be lockCodes) and you’ll get the data for all the attributes of that capability for the component.

It doesn’t really make a lot of difference really as you still need to pick the attribute data out of the returned JSON. So in pseudo code it might be components.main.lockCodes.lockCodes.value v lockCodes.lockCodes.value v lockCodes.value, and I’ve no idea what lockCodes.value contains, if indeed it is the right place.

3 Likes

As of now I can confirm this get the lockCodes and all data.

/devices/{{deviceId}}/components/main/status

I will test all other methods and edit this when I can confirm them.

EDIT
This returns only data that has to do with lock codes(qty, slot number & name, max code lenght, etc)

/devices/{{deviceId}}/components/main/capabilities/lockCodes/status
1 Like

Absolutely great stuff, and really appreciate @Jake_Mohl tagging you on this. The “/status” option was almost certainly what I was thinking about when I mentioned “refresh,” but with lack of use things tangled in my head. Sadly not the first time, nor the last, I’m sure.

The latter two options I was unaware of. I’m definitely bookmarking your post.

Thank you @orangebucket you again are a wealth of knowledge and never seem to fail with some insight when it comes to the API.

1 Like

@andresg @nayelyz

There is an unresolved issue here with Code Names that were previously set being cleared and replaced with the Code 1, Code 2, etc. default on certain Z-Wave locks. This issue was not present when the device was using the groovy DTH supplied by @RBoy.

Specifically, the issue is occurring on my older Schlage BE469 locks. It has not, to date, occurred on my newer Schlage BE469ZP locks.

Schlage BE469
Data
MSR: 003B-6341-5044
fw: 104.21
manufacturer: Schlage
networkSecurityLevel: ZWAVE_S0_LEGACY
Raw Description zw:Fs type:4003 mfr:003B prod:6341 model:5044 ver:104.21 zwv:3.42 lib:06 cc:22,72,7A,98,86 sec:5D,85,20,80,70,62,71,63

I can easily replicate this behavior by sending a Refresh command to the lock. I have tried this with and without Smart Lock Guess Access installed, and the results are the same. There may be other ways to trigger this behavior; I don’t know.

Lock Code presentation from the CLI before refresh

"{\"1\":\"John Doe 1\",\"2\":\"John Doe 2\",\"3\":\"John Doe 3\",\"4\":\"John Doe 4\",\"5\":\"John Doe 5\"}"

Lock Code presentation from the CLI after refresh

"{\"1\":\"Code 1\",\"2\":\"Code 2\",\"3\":\"Code 3\",\"4\":\"Code 4\",\"5\":\"Code 5\"}"

Here is the log from the CLI for a single refresh commend.

Click to Expand Log
2023-01-19T19:34:24.131273592+00:00 TRACE Z-Wave Lock  Received event with handler capability
2023-01-19T19:34:24.136786633+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received command: {"args":{},"capability":"refresh","command":"refresh","component":"main","positional_args":{}}
2023-01-19T19:34:24.140329883+00:00 TRACE Z-Wave Lock  Found CapabilityCommandDispatcher handler in zwave_lock
2023-01-19T19:34:24.147364592+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"John Doe 1\",\"2\":\"John Doe 2\",\"3\":\"John Doe 3\",\"4\":\"John Doe 4\",\"5\":\"John Doe 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:24.159712800+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"scanCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"Scanning"},"visibility":{"displayed":false}}
2023-01-19T19:34:24.173189008+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=1}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x01", src_channel=0, version=1}
2023-01-19T19:34:24.181217883+00:00 TRACE Z-Wave Lock  Z-Wave command(2a0aa044) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:24.190739258+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={}, cmd_class="BATTERY", cmd_id="GET", dst_channels={}, encap="AUTO", payload="", src_channel=0, version=1}
2023-01-19T19:34:24.199667467+00:00 TRACE Z-Wave Lock  Z-Wave command(6991177d) queued for radio transmission: CC:Battery, CID:0x02
2023-01-19T19:34:24.203231300+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={}, cmd_class="DOOR_LOCK", cmd_id="OPERATION_GET", dst_channels={}, encap="AUTO", payload="", src_channel=0, version=1}
2023-01-19T19:34:24.211467467+00:00 TRACE Z-Wave Lock  Z-Wave command(f1f2e58a) queued for radio transmission: CC:Door Lock, CID:0x02
2023-01-19T19:34:24.214441383+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:25.561195551+00:00 TRACE Z-Wave Lock  Z-Wave command(2a0aa044) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:26.065817801+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:26.070591801+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="**********", user_id_status="ENABLED_GRANT_ACCESS", user_identifier=1}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x01\x01\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A", src_channel=0, version=1}
2023-01-19T19:34:26.080320926+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:26.083936759+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"Code 1\",\"2\":\"John Doe 2\",\"3\":\"John Doe 3\",\"4\":\"John Doe 4\",\"5\":\"John Doe 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:26.176965593+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"data":{"codeName":"Code 1"},"value":"1 set"},"state_change":true}
2023-01-19T19:34:26.195943259+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=2}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x02", src_channel=0, version=1}
2023-01-19T19:34:26.206590718+00:00 TRACE Z-Wave Lock  Z-Wave command(5ba8b175) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:26.212385759+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:26.231476509+00:00 TRACE Z-Wave Lock  Z-Wave command(6991177d) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:27.651222635+00:00 TRACE Z-Wave Lock  Z-Wave command(f1f2e58a) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:28.061141969+00:00 TRACE Z-Wave Lock  Z-Wave command(5ba8b175) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:30.888305178+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:30.896041345+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="**********", user_id_status="ENABLED_GRANT_ACCESS", user_identifier=2}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x02\x01\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A", src_channel=0, version=1}
2023-01-19T19:34:30.966062137+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:30.975514678+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"Code 1\",\"2\":\"Code 2\",\"3\":\"John Doe 3\",\"4\":\"John Doe 4\",\"5\":\"John Doe 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:30.990496095+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"data":{"codeName":"Code 2"},"value":"2 set"},"state_change":true}
2023-01-19T19:34:31.003263053+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=3}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x03", src_channel=0, version=1}
2023-01-19T19:34:31.011888887+00:00 TRACE Z-Wave Lock  Z-Wave command(7bf38402) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:31.014880053+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:31.036880053+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:31.043693970+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={door_condition=2, door_lock_mode="DOOR_UNSECURED", inside_door_handles_mode=0, lock_timeout_minutes=254, lock_timeout_seconds=254, outside_door_handles_mode=0}, cmd_class="DOOR_LOCK", cmd_id="OPERATION_REPORT", dst_channels={}, encap="S0", payload="\x00\x00\x02\xFE\xFE", src_channel=0, version=1}
2023-01-19T19:34:31.053336387+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock
2023-01-19T19:34:31.056822928+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lock","capability_id":"lock","component_id":"main","state":{"value":"unlocked"}}
2023-01-19T19:34:31.067858887+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:31.132040012+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:31.138226262+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={battery_level=82}, cmd_class="BATTERY", cmd_id="REPORT", dst_channels={}, encap="S0", payload="R", src_channel=0, version=1}
2023-01-19T19:34:31.148172970+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock
2023-01-19T19:34:31.151552720+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"battery","capability_id":"battery","component_id":"main","state":{"value":82}}
2023-01-19T19:34:31.162326178+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:32.472149804+00:00 TRACE Z-Wave Lock  Z-Wave command(7bf38402) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:32.774733138+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:32.778871846+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="**********", user_id_status="ENABLED_GRANT_ACCESS", user_identifier=3}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x03\x01\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A", src_channel=0, version=1}
2023-01-19T19:34:32.788541846+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:32.792138804+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"Code 1\",\"2\":\"Code 2\",\"3\":\"Code 3\",\"4\":\"John Doe 4\",\"5\":\"John Doe 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:32.859507929+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"data":{"codeName":"Code 3"},"value":"3 set"},"state_change":true}
2023-01-19T19:34:32.871686138+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=4}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x04", src_channel=0, version=1}
2023-01-19T19:34:32.880476179+00:00 TRACE Z-Wave Lock  Z-Wave command(0ab42cdd) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:32.883439721+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:33.031110429+00:00 TRACE Z-Wave Lock  Z-Wave command(0ab42cdd) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:37.806997682+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:37.811385432+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="**********", user_id_status="ENABLED_GRANT_ACCESS", user_identifier=4}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x04\x01\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A", src_channel=0, version=1}
2023-01-19T19:34:37.819972515+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:37.824270723+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"Code 1\",\"2\":\"Code 2\",\"3\":\"Code 3\",\"4\":\"Code 4\",\"5\":\"John Doe 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:37.837273307+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"data":{"codeName":"Code 4"},"value":"4 set"},"state_change":true}
2023-01-19T19:34:37.851142473+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=5}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x05", src_channel=0, version=1}
2023-01-19T19:34:37.859228140+00:00 TRACE Z-Wave Lock  Z-Wave command(ec06b512) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:37.862196765+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:39.251258474+00:00 TRACE Z-Wave Lock  Z-Wave command(ec06b512) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:39.764731474+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:39.768937599+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="**********", user_id_status="ENABLED_GRANT_ACCESS", user_identifier=5}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x05\x01\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A", src_channel=0, version=1}
2023-01-19T19:34:39.777980516+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:39.781659599+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"lockCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"{\"1\":\"Code 1\",\"2\":\"Code 2\",\"3\":\"Code 3\",\"4\":\"Code 4\",\"5\":\"Code 5\"}"},"visibility":{"displayed":false}}
2023-01-19T19:34:39.865984016+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"data":{"codeName":"Code 5"},"value":"5 set"},"state_change":true}
2023-01-19T19:34:39.878946474+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=6}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x06", src_channel=0, version=1}
2023-01-19T19:34:39.887464224+00:00 TRACE Z-Wave Lock  Z-Wave command(de1a41d6) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:39.890432641+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:41.229998933+00:00 TRACE Z-Wave Lock  Z-Wave command(de1a41d6) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:41.659786017+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:41.664273267+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="", user_id_status="AVAILABLE", user_identifier=6}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x06\x00", src_channel=0, version=1}
2023-01-19T19:34:41.673833142+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:41.677447600+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"value":"6 unset"},"state_change":true}
2023-01-19T19:34:41.766215725+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=7}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x07", src_channel=0, version=1}
2023-01-19T19:34:41.774828975+00:00 TRACE Z-Wave Lock  Z-Wave command(20af80d5) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:41.777888975+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:43.201213934+00:00 TRACE Z-Wave Lock  Z-Wave command(20af80d5) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:43.528598851+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:43.532720934+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="", user_id_status="AVAILABLE", user_identifier=7}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x07\x00", src_channel=0, version=1}
2023-01-19T19:34:43.571479976+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:43.575178393+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"value":"7 unset"},"state_change":true}
2023-01-19T19:34:43.594814809+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> sending Z-Wave command: {args={user_identifier=8}, cmd_class="USER_CODE", cmd_id="GET", dst_channels={}, encap="AUTO", payload="\x08", src_channel=0, version=1}
2023-01-19T19:34:43.604228309+00:00 TRACE Z-Wave Lock  Z-Wave command(aa06e422) queued for radio transmission: CC:User Code, CID:0x02
2023-01-19T19:34:43.607338309+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled
2023-01-19T19:34:43.982265101+00:00 TRACE Z-Wave Lock  Z-Wave command(aa06e422) transmit status: TRANSMIT_COMPLETE_OK
2023-01-19T19:34:48.555843562+00:00 TRACE Z-Wave Lock  Received event with handler unnamed
2023-01-19T19:34:48.560220853+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> received Z-Wave command: {args={user_code="", user_id_status="AVAILABLE", user_identifier=8}, cmd_class="USER_CODE", cmd_id="REPORT", dst_channels={}, encap="S0", payload="\x08\x00", src_channel=0, version=1}
2023-01-19T19:34:48.569872062+00:00 TRACE Z-Wave Lock  Found ZwaveDispatcher handler in zwave_lock -> Schlage Lock
2023-01-19T19:34:48.573406395+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"codeChanged","capability_id":"lockCodes","component_id":"main","state":{"value":"8 unset"},"state_change":true}
2023-01-19T19:34:48.584695645+00:00 INFO Z-Wave Lock  <ZwaveDevice: { Device ID } [53] (Lock_BE469)> emitting event: {"attribute_id":"scanCodes","capability_id":"lockCodes","component_id":"main","state":{"value":"Complete"},"visibility":{"displayed":false}}
2023-01-19T19:34:48.597588062+00:00 DEBUG Z-Wave Lock  Lock_BE469 device thread event handled

I wasn’t sure whether it was appropriate to post this in this thread, or split it off into a new topic. Do with it what you think best.

What driver are you using, the stock driver or [ST EDGE] Z-Wave Lock PH - Devices & Integrations / Community Created Device Types - SmartThings Community from @philh30? His has the option to disable code query on refresh which solved the issue for me. Be sure to also set the code length to your existing length so that the refresh setting doesn’t revert.

1 Like

Stock driver. I tried @philh30 's driver as well, but was unaware of that option!

Upon further investigation, the codeName-clearing issue is present when executing a refresh, reloadAllCodes, or a requestCode command on the BE469. This anomaly came to light as a result of application testing I am doing on behalf of another developer. Neither of the current Edge drivers I have tried to date have resolved this.

Perhaps with this particular lock, it can’t be resolved, just worked around, but I thought you might want to be aware nonetheless. Thanks.

@philh30

Is this something that can be addressed by the driver or is it a lower level issue that ST staff need to look into?

There is something much more fundamental at play here with the Z-Wave locks under EDGE.

Putting aside the code-name clearing issue on the BE469 for the moment, now that we have the ability to set the code names via the API, we should be able to use them when evaluating lock events as well, correct? But neither driver is returning the codeName correctly.

To confirm, I first checked via the CLI to ensure that the names were correctly set (in this instance, on the BE469ZP).

lockCodes “{“1”:“John Doe”,“2”:“Jane Doe”,“3”:“Bill Smith”,“4”:“Guest 1”,“5”:“Guest 2”}”

I then unlocked the door using John Doe’s code and checked the event log. Note the codeName (in boldface) that was returned in the data attribute.

2023-01-25T14:25:41.694333783+00:00 INFO Z-Wave Lock <ZwaveDevice: {deviceId} [57] (BE469ZP)> emitting event: {“attribute_id”:“lock”,“capability_id”:“lock”,“component_id”:“main”,“state”:{“data”:{“codeId”:“1”,“codeName”:“Code 1”,“method”:“keypad”},“value”:“unlocked”}}

If this were working correctly, codeName should say “John Doe,” not “Code 1.”

Sorry to keep drumming on these locks, but these are serious issues for lock automation. @andresg we really need a response and some attention given to this.

2 Likes

It’s not clear to me if the lock itself is storing the lockCodes or if they are attributes of the lock that are part of the ST Cloud/API platform. It’s clear the event is returning a codeName that doesn’t match what is stored in lockCodes, but whether there is a mapping function in either the platform or an accessible method for the drivers to do that mapping is available or not. @philh30 might be able to provide some insight on this.

I don’t think philh30 can shed any more light on this. His driver is just the stock driver with the ability to set the stock parameters with in the driver itself.

1 Like

I haven’t taken the time to fully digest what the default handlers are doing with code names. They’re definitely storing those names in a field within the driver, and there’s logic to name it “Code 1” if the driver doesn’t already know the code name. I’m guessing what’s missing is logic for the driver to pull names from the lockCodes capability, which is where SLGA is populating names.

3 Likes

This is the line of code that sets the local variable code_name:

code_name = LockCodesDefaults.get_code_name(device, code_id)

There is special handling for code_id of 0 to map code_name “Master”.
Once code_name is set, it is passed to the event message here:

event.data = {codeName = code_name}

LockCodesDefaults mentions lockCodes which could be the same structure where the codeId to codeName mappings are stored, but I’d have to find that code to do some more digging.

LockCodesDefaults = require “st.zwave.defaults.lockCodes”

A little more digging and it looks like st.zwave.defaults.lockCodes is a default capability handler for the proposed capability lockCodes. I presume that ST supplies that handler and if so, there is likely some issue in that capability handler. I haven’t been able to find code for that handler and this is the only documentation of the capability that I can find Proposed Capabilities | SmartThings Developers which doesn’t even mention the capability commands that are being used in the driver.

Default handlers are in the lua_libs tar shown under assets on the page below

Ok, so here’s the code for getting the codeName:

local function get_code_name(device, code_id)
  if (device:get_field(constants.CODE_STATE) ~= nil and device:get_field(constants.CODE_STATE)["setName"..code_id] ~= nil) then
    -- this means a code set operation succeeded
    return device:get_field(constants.CODE_STATE)["setName"..code_id]
  elseif tonumber(code_id) == MASTER_CODE_INDEX then
    return "Master Code"
  elseif (get_lock_codes(device)[code_id] ~= nil) then
    return get_lock_codes(device)[code_id]
  else
    return "Code " .. code_id
  end
end
lock_code_defaults.get_code_name = get_code_name

And the routine it calls:

local function get_lock_codes(device)
  local lock_codes = device:get_field(constants.LOCK_CODES)
  if (lock_codes == nil) then
    return {}
  end
  return utils.deep_copy(lock_codes)
end
lock_code_defaults.get_lock_codes = get_lock_codes

Not sure how to read all the conditions in the If/Then, but it looks like it’s falling all the way to the last else where it returns “Code” concatenated with the code_id. @nayelyz Since we can see the codeName in the set event and we can retrieve the codeName array with code/name pairs present, there is clearly something messed up in the logic of the default handler’s name retrieval methodology since it falls all the way to the final behavior of the logic. What’s the best way to report this bug?

2 Likes

Not really my thing, but I find myself more intrigued by this code in the lock notification report …

st/zwave/defaults/lock.lua

          local lock_codes = device:get_field(constants.LOCK_CODES)

>8 – Snip a bit – >8

          local code_name = lock_codes[code_id] == nil and lock_codes[code_id] or "Code " .. code_id
          event["data"] = { codeId = code_id, codeName = code_name, method = event["data"].method}

I can’t get my head around how that code could be right. I want it to say ~= nil.

As it stands I see:

If the slot doesn’t have a name then use the name which it doesn’t have, but as it doesn’t have one use ‘Code x’.
If the slot does have a name then use ‘Code x’.

1 Like

Just as a contrast, here is the corresponding code for Zigbee.

st/zigbee/defaults/lock_defaults.lua

      local code_name = "Code "..code_id
      local lock_codes = device:get_field("lockCodes")
      if (lock_codes ~= nil and
          lock_codes[code_id] ~= nil) then
        code_name = lock_codes[code_id]
      end
      event.data = {method = METHOD[0], codeId = code_id .. "", codeName = code_name}

In contrast to the Z-Wave version, this makes sense. It sets the name to ‘Code x’ and then replaces it with the slot name if there is one defined.

2 Likes

Brilliant!

And you said this wasn’t really your thing. :smile:

1 Like