[ST Edge] Issue with the doConfigure lifecycle

I have found a execution error that occurs in drivers that call the doConfigure lifecycle when the Hub has a reboot..
I found out yesterday when the Hub was rebooted by updating to firmware 41.06.
It is not a problem with this firmware since it also happens with firmware 40.06

For example in your stock zigbee power meter driver the lifecycle handler calls do_Configure, which performs device:configure() .

  lifecycle_handlers = {
    init = device_init,
    doConfigure = do_configure,
  }
local device_init = function(self, device)
  device:set_field(zigbee_constants.SIMPLE_METERING_DIVISOR_KEY, 1000, {persist = true})
  device:set_field(zigbee_constants.ELECTRICAL_MEASUREMENT_DIVISOR_KEY, 10, {persist = true})
end
local do_configure = function(self, device)
  device:refresh()
  device:configure()

  -- Additional one time configuration
  if device:supports_capability(capabilities.energyMeter) or device:supports_capability(capabilities.powerMeter) then
    -- Divisor and multipler for EnergyMeter
    device:send(ElectricalMeasurement.attributes.ACPowerDivisor:read(device))
    device:send(ElectricalMeasurement.attributes.ACPowerMultiplier:read(device))
    -- Divisor and multipler for PowerMeter
    device:send(SimpleMetering.attributes.Divisor:read(device))
    device:send(SimpleMetering.attributes.Multiplier:read(device))
  end
end

When executing the bind requets it gives a missing value error in the device_management.lua module, line 77.

This logs is from a driver that have the same code of the stock zigbee power meter

2022-01-16T15:48:35.980262670+00:00 ERROR Zigbee Switch Power Mc  Caldera thread encountered error: [string "st/dispatcher.lua"]:229: Error encountered while processing event for <ZigbeeDevice: 92d80935-27ff-4d7f-ba4d-70ac7c0db9e7 [0xCCC5] (Caldera)>:
    arg1: init
[string "st/zigbee/device_management.lua"]:77: Missing necessary values for bind request
2022-01-16T15:48:36.040540337+00:00 TRACE Zigbee Switch Power Mc  Received event with handler _resync
2022-01-16T15:48:36.088176337+00:00 TRACE Zigbee Switch Power Mc  Received event with handler device_lifecycle

If the device was already configured, there is no problem, but if the driver has to perform other actions in that function, it does not do them anymore and jumps from the do_configure function to the next function or method.

For example in my case driver have to restart a Timer too, which stops if the Hub is restarted and remains stopped.

I have seen it in two drivers, in one of them I can attach exactly what it was going to execute when the error occurs

In this line give ethe error:

---battery configure
 print("Battery Config >>>>>>>>>")
  device:send(device_management.build_bind_request(device, PowerConfiguration.ID, self.environment_info.hub_zigbee_eui))
2022-01-16T15:21:50.674286084+00:00 PRINT Zigbee Sensor v6 Battery Config >>>>>>>>>
2022-01-16T15:21:50.683695+00:00 ERROR Zigbee  Sensor v6 A A A A  Sensor thread encountered error: [string “st.dispatcher”]:229: Error encountered while processing event for <ZigbeeDevice: 94025b9a-c7ec-41ab-a333-ee180eef1c9a [0x67BC] (A A A A  Sensor)>:
arg1: init
[string “st.zigbee.device_management”]:77: Missing necessary values for bind request
2022-01-16T15:21:50.759002834+00:00 TRACE Zigbee  Sensor v6 Received event with handler _resync

@philh30

This is the error that not reconfigure thepower and energy divisor and multiplier when the hub is reboot

It’s been my impression that doConfigure is not called on a normal hub reboot. The developer docs reference also calling it when the hub thinks the device needs to be configured, but I’m not really sure when those times are. I could see a hub firmware update being one of those times.

The issue I see with that driver, documented here, is that init is called far more frequently than doConfigure and therefore wins out in the end.

I haven’t seen the bind errors you’re documenting in your post. I’m not in a position to be able to watch logs right now so can’t be of more assistance.

Indeed, with the reboot of the hub it does not call doConfigure, but there are drivers and subdrivers where the lifecycle init calls the battery voltage configuration and there it could give the error.

It also calls the driverSwitched lifecycle where I have set some drivers to do the configuration since the device needs different report configurations depending on the driver.

Could you give an example, please? Are you referring to the drivers released by SmartThings or your own?

In this section, do you also receive an error every time you change the driver?

Hello @nayelyz,

All stock drivers that have a subdriver to handle the 0x0020 battery voltage attribute have a lifecycle init defined that calls the configuration of that attribute.

I don’t have any device that uses the 0x0020 attribute for the battery and I can’t test it.

I have seen the error in any driver that performs the device:configure() configuration or configures some custom attribute with lifecycle driverSwitched or init after a hub reboot.

I was going to get a new log today for you and I saw the following:

  • In the same driver “Zigbee Temp Sensor with Thermostat Mc”
  • Depends on the elapsed time since the reboot of the hub when the configuration is executed, then error occurs and stops the function or misconfigures the device with the hub EIU = 00000000000. I know this has to be my Hub EIU because I see it in all the logs
  • If driver have performed other tasks in the init lifecycle before to perform driverSwitched, where device:configure() is, it performs it without giving an error with Hub EIU=00000000000

2022-01-17T17:54:14.271674338+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler device_lifecycle
2022-01-17T17:54:14.284201338+00:00 INFO Zigbee Temp Sensor with Thermostat Mc <ZigbeeDevice: 16fa2ff4-00ca-4b65-b1db-5af142511d65 [0x9CFB] (Termostato)> received lifecycle event: driverSwitched
2022-01-17T17:54:14.374079005+00:00 DEBUG Zigbee Temp Sensor with Thermostat Mc Termostato device thread event handled
2022-01-17T17:54:14.383349005+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler environment_info
2022-01-17T17:54:14.399243338+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Found DeviceLifecycleDispatcher handler in st-zigbee-motion
2022-01-17T17:54:14.499422338+00:00 INFO Zigbee Temp Sensor with Thermostat Mc <ZigbeeDevice: 16fa2ff4-00ca-4b65-b1db-5af142511d65 [0x9CFB] (Termostato)> sending Zigbee message: < ZigbeeMessageTx || Uint16: 0x0000, < AddressHeader || src_addr: 0x0000, src_endpoint: 0x01, dest_addr: 0x9CFB, dest_endpoint: 0x01, profile: 0x0000, cluster: 0x0021 >, < ZDOMessageBody || < ZDOHeader || seqno: 0x00 >, < BindRequest || src_address: 00124B00245CE6EB, src_endpoint: 0x01, cluster: PowerConfiguration, dest_addr_mode: 0x03, dest_address: 0000000000000000, dest_endpoint: 0x01 > > >

  • If you add a device:configure() in lifecycle init it gives error in both lifecycle handlers:
[string “st.zigbee.device_management”]:77: Missing necessary values ​​for bind request
the error is when you run the first bin request:
device:send(device_management.build_bind_request(device, PowerConfiguration.ID, self.environment_info.hub_zigbee_eui))

2022-01-17T18:03:27.070548670+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler _resync
2022-01-17T18:03:27.080615670+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler environment_info
2022-01-17T18:03:27.128781671+00:00 DEBUG Zigbee Temp Sensor with Thermostat Mc Z-Wave hub node ID environment changed.
2022-01-17T18:03:27.345197671+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Found DeviceLifecycleDispatcher handler in st-zigbee-motion
2022-01-17T18:03:27.482988337+00:00 ERROR Zigbee Temp Sensor with Thermostat Mc Termostato thread encountered error: [string “st/dispatcher.lua”]:229: Error encountered while processing event for <ZigbeeDevice: 16fa2ff4-00ca-4b65-b1db-5af142511d65 [0x9CFB] (Termostato)>:
arg1: init
[string “st/zigbee/device_management.lua”]:77: Missing necessary values for bind request
2022-01-17T18:03:27.504780337+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler _resync
2022-01-17T18:03:27.558385671+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler device_lifecycle
2022-01-17T18:03:27.600678004+00:00 INFO Zigbee Temp Sensor with Thermostat Mc <ZigbeeDevice: 16fa2ff4-00ca-4b65-b1db-5af142511d65 [0x9CFB] (Termostato)> received lifecycle event: driverSwitched
2022-01-17T18:03:27.635653004+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Found DeviceLifecycleDispatcher handler in st-zigbee-motion
2022-01-17T18:03:27.750811337+00:00 ERROR Zigbee Temp Sensor with Thermostat Mc Termostato thread encountered error: [string “st/dispatcher.lua”]:229: Error encountered while processing event for <ZigbeeDevice: 16fa2ff4-00ca-4b65-b1db-5af142511d65 [0x9CFB] (Termostato)>:
arg1: driverSwitched
arg2: table: 0x1f21ab8
[string “st/zigbee/device_management.lua”]:77: Missing necessary values for bind request
2022-01-17T18:03:27.775133337+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler environment_info
2022-01-17T18:03:27.788239671+00:00 TRACE Zigbee Temp Sensor with Thermostat Mc Received event with handler environment_info

In normal operation everything goes well, the configuration is carried out without problems

It seems that the drivers should be given more time to start running after a reboot

Thanks

@nayelyz,
As an update on this problem:

I have solved the errors in the restart of the Hub or update of the driver, executing device:configure() with a delay of 5 sec, after lifecycle init or driverSwitched is called

-----driver_switched
local function driver_switched(self,device)
  device.thread:call_with_delay(5, function() do_configure(self,device) end)
end
2 Likes