How to Send a Unique ID from Command Handler to Z-Wave Handlers

I want to send a unique id when sending the command to the device

local function getSettingsHandler(driver, device, command)
  for i = 1, 20 do
    device.thread:call_with_delay(i, function()
    device:send(Configuration:Get({ parameter_number = i }))
  end)
  end
end
local function configuration_report_handler(self, device, cmd)
  log.info("Reporting args >>>>" .. json.encode(cmd.args))
end

To check what command unique id it is reporting for
I know that we can use device:set_field to save a unique id but what if the report handler is triggered by another command handler then it would mess the whole logic up

I think what you’re asking for is a way for a device to return an token that you send as part of the query. For instance, in your CONFIGURATION GET request, you’d send an token along that the device would then return in its CONFIGURATION REPORT.

  1. I’m not sure why this would be needed or helpful.
  2. Zwave command classes in general do not have a field allocated to use at the application level for this purpose. There’s no way to have the device reflect back a value in a REPORT that was sent in a corresponding GET.
  3. Zigbee does support the concept of a “sequence number” that the coordinator will assign and send as part of requests over the radio. That number will be echo’ed back by the device in its responses. Its not assignable at the application level though. The protocol uses it internally and I’ve used it for debugging (to know which response goes with which request when they might come back out of order).
  4. Zwave does have some encapsulation classes (such as SUPERVISION and TRANSPORT) that have fields that could be used for this purpose (SUPERVISION supports a session ID to track responses to a specific request), but SmartThings doesn’t support SUPERVISION and only specific devices do anyway.
3 Likes