@nayelyz There is an error in the zigbee-power-meter driver that will cause the divisors reported by the device to be overwritten by hard-coded values each time the driver restarts.
The behavior that I’ve seen with lifecycles is that doConfigure is called only once, when the device is added. The init lifecycle is called whenever the driver restarts, including during driver updates and hub reboots.
With the driver as written (below), the divisors for a newly added device are first set by the device_init function to the hard-coded 1000 and 10, then are updated to the correct values when the device responds to the do_configure function’s read attribute calls. However, whenever the driver restarts it will call the device_init function and reset the divisors to the hard-coded 1000 and 10.
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
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