ERROR [string "st/zigbee/device.lua"]:228: bad argument #4 to 'format' (number expected, got table)

Time-to-time when a device is in an idle state, a driver reports an error in the st/zigbee/device.lua.

2023-03-03T12:05:14.076080614+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  Second bedroom curtains device thread event handled
2023-03-03T12:05:24.008095619+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:05:54.015253633+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:06:24.015145648+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:06:54.025642995+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:07:24.025134676+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:07:54.035525691+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:08:24.042274754+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:08:54.062357758+00:00 ERROR Xiaomi/Aqara Blinds 1.1  driver thread encountered error: [string "st/zigbee/device.lua"]:228: bad argument #4 to 'format' (number expected, got table)
2023-03-03T12:09:24.099469761+00:00 DEBUG Xiaomi/Aqara Blinds 1.1  driver device thread event handled
2023-03-03T12:09:54.838555765+00:00 ERROR Xiaomi/Aqara Blinds 1.1  driver thread encountered error: [string "st/zigbee/device.lua"]:228: bad argument #4 to 'format' (number expected, got table)

how do I debug this? Where do I find a stack trace or any details?

Hi, @veonua
Let me ask the engineering team about this. I see in the device.lua file that line 228 has:

log.info_with({ hub_logs = true }, string.format("Doing health check read for [%s]:%04X:%04X", self.device_network_id, cluster, attr))

Which belongs to the function check_monitored_attributes(), so, I’ll ask how we can check what’s going on.

@veonua, following up, the team mentioned this error can happen when you’re using add_configured_attribute and add_monitored_attribute but they are not configured properly. For example, if you’re missing the cluster identifier. Here’s a sample where you can see the configuration used in one of the ST drivers:

Those functions are used by the healthCheck, so, even if you’re device isn’t in use, it is being checked if it’s reachable.
Can you check if you’re using the config properly, please?

Thank you for the link. I believe I have resolved the issue, but it would be beneficial to validate such issues during the compile or start steps. It would be helpful to incorporate a validation process to prevent such issues from occurring in the first place.