Inner workings of zwave.userCodeV1.userCodeSet()

I am currently building a driver for one of my RFID keypads and I am having a bit of trouble understanding how the function userCodeSet is handling the the userCode parameter.

My device is expecting the userCode (RFID Identifier) to be sent over zwave as a 10 hex pairs string, but when using the HE function the userCode is getting converted incorrectly.

I have setup a small code snippet to try and debug / understand what is happening:

Raw ZWave Command:

def rx_rfid = [143, 182, 75, 40, 133, 80, 1, 4, 0, 0] as byte[] // Received RFID Identifier
def code = new BigInteger(rx_rfid, 16)
def raw_cmd = [ 0x63, // User Code Command Class
                0x01, // User Code Set Command
                3,    // User Slot
                1,    // UserCodeSet.USER_ID_STATUS_OCCUPIED
                code
              ]
raw_cmd = raw_cmd.collect { String.format("%02x", it).toUpperCase() }.join('')
println raw_cmd // 630103018FB64B28855001040000

HE ZWave Command:

def he_cmd = zwave.userCodeV1.userCodeSet(userIdentifier: 3, userIdStatus: UserCodeSet.USER_ID_STATUS_OCCUPIED, userCode: [143, 182, 75, 40, 133, 80, 1, 4, 0, 0] as byte[]).format()
log.info he_cmd
Execution #1: 630103015B42403435653130633233
Execution #2: 630103015B42403230383032653139

Now if we compare the Raw commands we see that they both start as expected with `63010301` but then the rest of the code just gets converted in a strange way. Another thing I also don't get is that at every execution the raw command is different even if I don't change the function input parameters.

Questions:

  1. What is the expected or possible types / formats of the userCode parameter?
  2. Why is the raw command changing at every execution?
  3. Is it currently possible to make the function userCodeSet work as I described on the Raw ZWave Command section?
    I would prefer to use internal CC instead of having to construction my own raw commands.

Thanks in advance for any help, Seb
1 Like

I've never worked with raw commands or user codes. I think this might be a good question for @mike.maxwell.

This parameter is a string.

@mike.maxwell, But what if the content that it is expecting? Byte Array, Hex, Dec...?

It's expecting a string.
If the user code is 1234, then userCode is "1234"

@mike.maxwell, In the case the use code is a Hex, I think the userCodeSet methods is performing some kind of pre-convertion and this is what is causing the issue.

For the moment have a working workaround, but just wanted to understand hot this works in HE.

What about my question #2, is this expected or am I messing something?

Just found this thread looking for the arguments for zwave.userCodeV1.userCodeSet and I'm writing a driver for my keypad here too :slight_smile: Have a Zipato Z-Wave RFID Keypad here. What are you working on? Would be good to join forces here.

Checkout @mhutchy 's adaptation for inspiration on strings and bytes:

@MFornander,
Haha this is the one I am working with.

I have written from scratch the driver for this device and its now working 100% with all the parameter and features, I will be releasing it today or tomorrow I just need to finish the documentation..

1 Like

Perfect! Can't wait to see it. I'm curious how you balanced the tag and code configuration since codes can but pushed in the config page but tags require the keypad to send the bytes to be associated with the user. Publish it and let me try it :slight_smile:

@MFornander
it's in the wild! [RELEASE] Zipato Mini RFID Keypad

2 Likes