ebaauw / homebridge-deconz

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

TypeError: Cannot read properties of null (reading 'replace') #213

Closed fezzz closed 7 months ago

fezzz commented 7 months ago

Hi,

node.js: v20.11.1 homebridge 1.7.0

after updating to [homebridge-deconz] 1.0.10 (child bridge) I get the following Error - it doesn't break functionality, just seems to be handled as a warning:

[2/25/2024, 8:09:26 PM] [deCONZ] Phoscon-GW: error: TypeError: Cannot read properties of null (reading 'replace') at new Resource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/Deconz/Resource.js:200:31) at Gateway.analyseResource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1198:22) at Gateway.analyseFullState (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1049:16) at new Gateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:71:12) at DeconzPlatform.foundGateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:112:29) at DeconzPlatform.findHost (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:122:18) at processTicksAndRejections (node:internal/process/task_queues:95:5) at DeconzPlatform.init (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:158:11)

(...)

[2/25/2024, 8:09:27 PM] [deCONZ] Phoscon-GW: error: TypeError: Cannot read properties of null (reading 'replace') at new Resource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/Deconz/Resource.js:200:31) at Gateway.analyseResource (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1198:22) at Gateway.analyseFullState (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:1049:16) at Gateway.poll (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:965:18) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Gateway.heartbeat (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzAccessory/Gateway.js:357:9)

Thanks, Felix

ebaauw commented 7 months ago

The error suggests deCONZ exposes a resource with empty or missing manufacturername. Could you please attach the debug dump file, so I can check this?

fezzz commented 7 months ago

Hi Eric, thanks a lot for your Plugin, I appreciate it very much.

In the debug dump for me it seems to be the ..."manufacturername":null,"modelid":null,"name":"Dimmer switch 18"... although I can't figure out what device this should be. Maybe a scene in deconz.

Thanks, Felix homebridge-deconz Kopie.json.gz

ebaauw commented 7 months ago

It's a lights resource. It has the same mac address in the uniqueid as the Waschkeller-Fenster contact sensor. I think the resource was created (in error) by the legacy code, not sure why. Maybe deCONZ read the wrong endpoints and clusters, maybe the data in the database has been corrupted. What happens of you simply delete the resource of the API? And if you delete and re-pair the contact sensor?

it doesn't break functionality, just seems to be handled as a warning:

Indeed, as far as I can tell, the error is caught correctly, and Homebridge deCONZ continues processing other resources, ignoring the invalid resource. Since manufacturername and modelid are mandatory attributes in the deCONZ API, this really is a bug in deCONZ, and I don't feel the need to change Homebridge deCONZ to issue a "normal" warning (like "missing manufacturername"), without a stack trace.

fezzz commented 7 months ago

Hi Eric, deleting it from the cache was not sufficient as you assumed. I will try and remove the whole device from deconz and re-add it. Thanks, Felix

microfx commented 7 months ago

I have the same error sadly... first I thought it's maybe my node 18 version. Switched to 20.11.1 .. still the same. Also it's flooding my logs... did readding help? I just had to do that ... so not keen to do it again just now.

fezzz commented 7 months ago

Just readded the device and I can confirm that the situation disappeared. Somehow strange, this was one of about 10-12 aqara window/door sensors of the same kind that I added several years ago.

Just noticed, I also have some warnings: "Phoscon-GW: warning: Button: exposed by legacy code". Did I understand correctly, that a DDF File for the devices is already available but not used? Is there also a re-add necessary? (deconz 2.26.1/ conbee3 FW: 26500900)

Thanks, Felix

microfx commented 7 months ago

Can confirm... those warnings went away after a few minutes/hours

ebaauw commented 7 months ago

Just noticed, I also have some warnings: "Phoscon-GW: warning: Button: exposed by legacy code". Did I understand correctly, that a DDF File for the devices is already available but not used?

Most likely, there’s no DDF (yet) for the device. Best open a device request in deCONZ. What type of button is this?

microfx commented 7 months ago

I would also like to know this... I have the same button that is flooding my logs still (without the warnings now tho).

Has anyone seen this error in homebridge?

CONBEE Button: Programmable Switch Event: Single Press
fezzz commented 7 months ago

Quite a lot devices are causing the warnings during startup, these are:

There are also warnings that seem to be caused by trying to fetch the ddl of the devices: [3/3/2024, 3:49:02 PM] [deCONZ] Phoscon-GW: Alex-Button-R: add accessory [3/3/2024, 3:49:02 PM] [deCONZ] Alex-Button-R: LUMI lumi.remote.b1acn01 v20180525 (1 resources) [3/3/2024, 3:49:02 PM] [deCONZ] Phoscon-GW: request 42: GET /devices/00:15:8d:00:04:5f:77:f3/ddf [3/3/2024, 3:49:02 PM] [deCONZ] Phoscon-GW: warning: request 42: http status 404 Not Found

microfx commented 7 months ago

I own Osram Plugs and Aqara... so probably the button on my Aqara Temp/Humidity Sensor is pinging into my logs... is there a reason for this? (If it was only at startup or whatever I'd be fine but it's every minute!)

ebaauw commented 7 months ago

Please stay on topic: the "cannot read properties of null" error.

For warnings during startup due to devices being exposed by legacy code (i.e. not having a DDF), please create a device support request in the deCONZ REST API repo.

For the "CONBEE Button: Programmable Switch Event: Single Press", see the many (closed) issues in Homebridge deCONZ about this.