ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
135 stars 7 forks source link

Aqara Smart Plug: electricCurrent duplicate key error #142

Closed hellomarb closed 11 months ago

hellomarb commented 1 year ago

Running homebridge-deconz v0.1.18 and exposing an Aqara Smart Plug over ConBee II (2.21.02 / 19.9.2022, 26780700) I get an "electricCurrent duplicate key" error and the device is not available to homekit.

Perhaps it is a deconz problem, but I wanted to report it.

[deCONZ] Phoscon-GW: error: SyntaxError: electricCurrent: duplicate key at Outlet.addCharacteristicDelegate (/usr/lib/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/ServiceDelegate/index.js:229:13) at Function.addResource (/usr/lib/node_modules/homebridge-deconz/lib/DeconzService/Power.js:27:15) at Outlet.addResource (/usr/lib/node_modules/homebridge-deconz/lib/DeconzService/index.js:80:41) at Light.createService (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/index.js:177:17) at new Light (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Light.js:44:14) at Gateway.addAccessory (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:619:25) at Gateway.analyseFullState (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1112:20) at Gateway.poll (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:956:18) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Gateway.heartbeat (/usr/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:352:9)

ebaauw commented 1 year ago

Could you please attach the debug dump file?

hellomarb commented 1 year ago

I've attached the homebridge.log (in debug mode) and the homebridge-deconz.json.gz. Please ignore the erros of the floracare plugin, that's the next project.

homebridge.log homebridge-deconz.json.gz

ebaauw commented 1 year ago

The plug seems to be exposed wrongly de deCONZ, with two ZHAConsumption and two ZHAPower resources.

Resource Type Uniqueid
/lights/1 Smart plug 54:ef:44:10:00:70:f5:ee-01
/sensors/2 ZHAConsumption 54:ef:44:10:00:70:f5:ee-01-0702
/sensors/3 ZHAPower 54:ef:44:10:00:70:f5:ee-01-0b04
/sensors/4 ZHAPower 54:ef:44:10:00:70:f5:ee-15-000c
/sensors/5 ZHAConsumption 54:ef:44:10:00:70:f5:ee-1f-000c

Since the state attributes are empty for /sensors/2 and /sensors/3, I think these are exposed wrongly. I don't know this plug, but I don't think think I've seen a Xioami device using Electrical Measurement nor Simple Metering.

rickyh777 commented 1 year ago

I'm seeing the same error. I just migrated from your homebridge-hue package and it worked fine in that package. It seems it locks out the device though so homebridge-deconz never passes the outlet as a device to homebridge while homebridge-hue seems to pass the light resource so the outlet can be used. Would there be a way to 'soft' fail in the deconz package so the lights resource gets passed?

sieren commented 1 year ago

Seeing the same issue with a Lumi/Aquara Plug (worked fine in homebridge-hue):

[13/08/2023, 11:27:00] [deCONZ] Mattberry: Studio: add accessory
[13/08/2023, 11:27:00] [deCONZ] Studio: LUMI lumi.plug.maeu01 v12-06-2021 (5 resources)
[13/08/2023, 11:27:00] [deCONZ] Studio: Configured Name: warning: 5 listeners
[13/08/2023, 11:27:00] [deCONZ] Studio: On: warning: 5 listeners
[13/08/2023, 11:27:00] [deCONZ] Studio: Consumption: set to 54 W (from 53 W)
[13/08/2023, 11:27:00] [deCONZ] Mattberry: error: SyntaxError: totalConsumption: duplicate key
    at Outlet.addCharacteristicDelegate (/usr/local/lib/node_modules/homebridge-deconz/node_modules/homebridge-lib/lib/ServiceDelegate/index.js:229:13)
    at Function.addResource (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzService/Consumption.js:18:13)
    at Outlet.addResource (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzService/index.js:80:41)
    at Light.createService (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/index.js:170:17)
    at new Light (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Light.js:44:14)
    at Gateway.addAccessory (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:619:25)
    at Gateway.analyseFullState (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1112:20)
    at Gateway.poll (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:956:18)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Gateway.heartbeat (/usr/local/lib/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:352:9)

homebridge-deconz.json.gz

ebaauw commented 1 year ago

Seeing the same issue with a Lumi/Aquara Plug

Also duplicate /sensors resources.

It seems it locks out the device though so homebridge-deconz never passes the outlet as a device to homebridge

Yes, by design. An error trying to expose a device causes the device not to be exposed, but otherwise Homebridge deCONZ continues to work.

homebridge-hue seems to pass the light resource so the outlet can be used

Homebridge Hue has a different design from Homebridge deCONZ. I am surprised that it doesn't actually choke on this device, but I won't be spending any time figuring out why, now that deCONZ support by Homebridge Hue has been deprecated.

Would there be a way to 'soft' fail in the deconz package so the lights resource gets passed?

Technically: probably yes. However, I am not going to implement workarounds for non-critical deCONZ bugs.

I'm not quite sure how deCONZ manages to expose duplicate /sensors resources. The DDF only defines the -000c resources. Maybe deleting the device from deCONZ and re-pairing it will fix the resources, making sure DDFs are enabled. Otherwise, maybe manually deleting the -0702 and -0b04 resources (through the API) solves it. Otherwise, best open an issue with deCONZ.