Correct Z-Wave Lock API Command

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