Open Select446 opened 11 months ago
The child bridge loads alright, but it crashes due to the "This callback function has already been called by someone else; it can only be called one time." error. The error is actually thrown by HAP-NodeJS, but caused by a bug in Homebridge deCONZ. Not happy the HAP-NodeJS terminates the process (rather than just ignoring the superfluous callback function call). I'll need to guard the callback to prevent the crash.
The duplicate key error is caused by the Aurora DoubleSocket50AU having two ZHAPower resources, which Homebridge deCONZ doesn't expect nor handle. For the devices in #142, this clearly is an error in the deCONZ REST API plugin, exposing superfluous ZHAConsumption and ZHAPower resources.
Looking at the uniqueid
values, and at the fact the the state
attributes on both resources are actually populated with different valid values, it would seem that the Aurora actually reports current consumption (power
) per socket? This the first device, for which I've seen this (apparently already back in 2020, see https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2292, but I completely forgot about that).
I think the fatal error is caused by Homebridge deCONZ setting up two characteristic delegates for the same characteristic. The difference with the devices in #142 is that they only use a single /lights
resource.
I think the Aurora smart plug would need to be exposed as two separate HomeKit accessories, each with a single Outlet service including the corresponding electrical measurement attributes, and a History service.
Could you please try beta v1.0.1-0? It should no longer crash, but will still log errors for the duplicate key and the callback already been called. I'm sorry, but I don't have any device similar to the Aurora smart plug, to test this myself.
If indeed, the beta version no longer crashes, could you please check in Eve (or another deCONZ HomeKit app) whether both Outlet services carry characteristics for current consumption (power), voltage and current?
Thanks for the quick reply and useful info on this issue. I've just tried the beta and can confirm it no longer crashes, but still throws duplicate key error as expected
For Eve, one double socket shows no consumption or energy monitoring at all, the other shows consumption but appears to alternate between the values of the two outlets (regardless of whether i look at outlet A or outlet B)
Thanks for your help, let me know if you need any further log files or to test any updates you make regarding the issue
For Eve, one double socket shows no consumption or energy monitoring at all, the other shows consumption but appears to alternate between the values of the two outlets (regardless of whether i look at outlet A or outlet B)
Thanks, that confirms that there's two delegates setup for the same characteristic. I will come back with an enhancement to expose the plug as two devices, but I need some time to figure out how best to achieve this.
No problem, thanks for your help
Hi Ebaauw,
I have a duplicate key error which appears to be causing my homebridge_deconz to fail and restart:
[25/08/2023, 18:55:14] [deCONZ] Phoscon-GW: error: SyntaxError: electricCurrent: duplicate key at Outlet.addCharacteristicDelegate (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/ServiceDelegate/index.js:229:13) at Function.addResource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzService/Power.js:27:15) at Outlet.addResource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzService/index.js:80:41) at Light.createService (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/index.js:177:17) at new Light (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Light.js:44:14) at Gateway.addAccessory (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:619:25) at Gateway.analyseFullState (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1112:20) at Gateway.poll (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:956:18) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Gateway.heartbeat (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:352:9) [25/08/2023, 18:55:14] [deCONZ] Phoscon-GW: initialised [25/08/2023, 18:55:14] [deCONZ] waiting for 2 jobs [25/08/2023, 18:55:14] [deCONZ] job 1/2: done [25/08/2023, 18:55:14] [deCONZ] job 2/2: done [25/08/2023, 18:55:14] [deCONZ] 1 gateways [25/08/2023, 18:55:14] [deCONZ] flush cachedAccessories [25/08/2023, 18:55:14] [deCONZ] created debug dump file /var/lib/homebridge/homebridge-deconz.json.gz
/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/CharacteristicDelegate.js:397 return callback() ^ Error: This callback function has already been called by someone else; it can only be called one time. at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:12:13 at CharacteristicDelegate._onSet (/var/lib/homebridge/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/CharacteristicDelegate.js:397:14) at ConfiguredName.emit (node:events:525:35) at /var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2596:16 at new Promise ()
at ConfiguredName. (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2594:14)
at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:193:27)
at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:174:57)
at /var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:167:75
at new Promise ()
I've had homebridge_deconz for a while now without any issues (thanks for the great work!) and am currently running version v1.0.0 on node.js 18.16.0, I also run Home Assistant (docker) Deconz integration which seems to be unaffected by the duplicate key so I can get by at the moment
I've had a look through the log files and the errors are from 2 double sockets with individual energy monitoring, at first I thought it wasn't critical as it didn't crash and i'd read this issue: Aqara Smart Plug: electricCurrent duplicate key error #142 - but now I cant get it to load at all
Could you advise me as to how I could trouble shoot this issue please?
homebridge.log(2).txt
homebridge-deconz.json.gz