[ST Edge Zwave] `driver.environment_info.hub_zwave_id` is nil in doConfigure & init handlers

Hi, i am trying to set association during init or doConfigure lifecycle. My problem is that the hub id is not set in the driver argument. ie. driver.environment_info.hub_zwave_id is nil.

Is this a bug ? or am I missing something ?

Thank you.

Welcome to the SmartThings Community, @David_Alexandre!

You can get the device network ID using this command:

driver.device_api.get_device_info(device.id)

This will give you a JSON where you’ll find the property device_network_id which is unique for the device.

Note: you can use it in either init, added, or doConfig lifecycles depending on the other actions you’ll perform.

This call sends a nil value only in the init lifecycle, from added this property already has a value. If it’s really necessary you have it in the first lifecycle, you can add the delay like @philh30 mentioned below but take into consideration the warning included for that function.

I’m seeing the same. A 1s delay seems to give enough time for the hub node ID to be populated though. First log statement in the function below shows nil, while the second returns the correct value.

local function init(driver, device)
  log.debug(string.format("Hub node ID (no delay): %s",driver.environment_info.hub_zwave_id))
  local function delayed_setup()
    log.debug(string.format("Hub node ID (1s delay): %s",driver.environment_info.hub_zwave_id))
  end
  device.thread:call_with_delay(1,delayed_setup)
end

Thank you for your replies. I’ll try this approach.

OK, I see that adding the 1s delay populates the hub id. So now I have to ask how I can wait for the hub Node ID is populated. Is the only way to put the rest of the init code within the body of the delayed_setup? Seems counterintuitive.

Thanks