NorthernMan54 / homebridge-alexa

Expose your homebridge controlled devices to Amazon Alexa.
https://www.homebridge.ca
442 stars 77 forks source link

Cannot read properties of undefined (reading 'forEach') #500

Open rcoletti116 opened 2 years ago

rcoletti116 commented 2 years ago

I get this error on startup. I don't think it's affecting anything I use, but I wanted to share it in case it affects anyone else and needs to be addressed.

TypeError: Cannot read properties of undefined (reading 'forEach')
    at HAPNodeJSClient._reconnectServer (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:332:39)
    at EventEmitter.emit (node:events:390:28)
    at Socket.<anonymous> (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/lib/eventedHttpClient.js:90:24)
    at Socket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
NorthernMan54 commented 2 years ago

Could you turn on debug logging, restart, and the information prior to the error.

This message is from the events/routines portion of the code so any potential issue would be with routines being triggered within Alexa.

rcoletti116 commented 2 years ago

Here are the only two additional log lines preceding the error.

2022-02-04T21:52:05.544Z hapHttpClient Disconnected from server 10.0.0.75:51012 0E:FC:C1:5D:09:B4
2022-02-04T21:52:05.546Z hapNodeJSClient HAPevent events Reregister { server: '10.0.0.75:51012', deviceID: '0E:FC:C1:5D:09:B4' }
[04/02/2022, 16:52:05] TypeError: Cannot read properties of undefined (reading 'forEach')
    at HAPNodeJSClient._reconnectServer (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/HAPNodeJSClient.js:332:39)
    at EventEmitter.emit (node:events:390:28)
    at Socket.<anonymous> (/usr/local/lib/node_modules/homebridge-alexa/node_modules/hap-node-client/lib/eventedHttpClient.js:90:24)
    at Socket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
rcoletti116 commented 2 years ago

I’ve been looking through the logs to see if anything stands out about this error. Nothing does, and there’s not much there, and it only happens at startup.

I did notice something that drew my curiosity in the logs though. It seems like the plugin is actually discovering all HomeKit devices on my network, not just my homebridge devices. Is there a functional reason for this?

NorthernMan54 commented 2 years ago

The discovery of native HomeKit devices is expected, as I’m using the HomeKit api and interface. But as the interface is secured, I’m not able include them into the service.

NorthernMan54 commented 2 years ago

@rcoletti116 Do you know what type of device this is ?

0E:FC:C1:5D:09:B4

Native HomeKit, Homebridge or ???

rcoletti116 commented 2 years ago

I just about went crazy looking for this on my network, but turns out it doesn't exist! It's a dummy sensor in Homebridge from the dummy-contact plugin.