fjs21 / homebridge-blueair

BlueAir air purifier plugin for homebridge
https://www.npmjs.com/package/@fjs21/homebridge-blueair
Apache License 2.0
51 stars 6 forks source link

Error reading device since latest Homebridge update #395

Open nebosphere19 opened 5 months ago

nebosphere19 commented 5 months ago

Running it as a child bridge which restarts over and over again. Error is:

[4/22/2024, 10:27:25 AM] [@fjs21/homebridge-blueair] Found 1 Blueair AWS-compatible devices.
TypeError: Cannot read properties of undefined (reading '0')
    at BlueAirAwsApi.getAwsDeviceInfo (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:362:92)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at BlueAirHomebridgePlatform.discoverAwsDevices (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/src/platform.ts:214:28)
[4/22/2024, 10:27:25 AM] [@fjs21/homebridge-blueair] Child bridge process ended
[4/22/2024, 10:27:25 AM] [@fjs21/homebridge-blueair] Process Ended. Code: 1, Signal: null

Running Homebridge v1.8.0, NodeJS v20.9.0

dreary-ennui commented 5 months ago

Seeing the same with Homebridge 1.8.0, NodeJS 20.12.2

dreary-ennui commented 5 months ago

With debug logs enabled:

[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] Found 2 Blueair AWS-compatible devices.
[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] ** AWS devices - end **
[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] Checking token expiration date/time. Current token(s) expire at: Tue Apr 23 2024 15:07:04 GMT-0400 (Eastern Daylight Time)
[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] Response Headers for Initial Call:  Headers {
  _headers: {
    'content-encoding': [ 'gzip' ],
    'content-length': [ '56' ],
    'content-type': [ 'application/json' ],
    'x-amz-apigw-id': [ 'WpAGHFbOCdcErbA=' ],
    'x-amzn-errortype': [ 'InternalServerErrorException' ],
    'x-amzn-requestid': [ '2d205991-8de4-4a5c-a3a3-4142f199a48e' ],
    'x-amzn-trace-id': [ 'Root=1-2626c35b-010a04e163519c2f4c28983b' ],
    connection: [ 'keep-alive' ],
    date: [ 'Mon, 22 Apr 2024 19:07:06 GMT' ]
  }
}
[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] Response Body for Initial Call:  undefined
TypeError: Cannot read properties of undefined (reading '0')
    at BlueAirAwsApi.getAwsDeviceInfo (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:362:92)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at BlueAirHomebridgePlatform.discoverAwsDevices (/usr/lib/node_modules/@fjs21/homebridge-blueair/src/platform.ts:214:28)
[4/22/2024, 3:07:06 PM] [@fjs21/homebridge-blueair] Child bridge process ended

Looks like the "initial call" is returning internal server exception, maybe not triggering the catch on line 352 though?

Edit: These sections of code are commented with "do not work" - lol - so maybe these are known issues. And I'm actually seeing these errors going back quite awhile in my logs - well before the upgrade to Homebridge 1.8.0. So maybe there is a difference in HB behavior in 1.8.0 for errors in child bridges?

dreary-ennui commented 5 months ago

Unchecking "Enable AWS API Connection" in the plugin config resolves the issue with the child bridge restarting continuously, but I then lose my devices.

rmanak commented 5 months ago

same issue here...

[22/04/2024, 15:48:25] [@fjs21/homebridge-blueair] ** AWS login complete **
[22/04/2024, 15:48:26] [@fjs21/homebridge-blueair] Found 1 Blueair AWS-compatible devices.
[22/04/2024, 15:48:26] [@fjs21/homebridge-blueair] Restoring existing accessory from cache: BlueBean
TypeError: Cannot read properties of undefined (reading '0')
    at BlueAirAwsApi.getAwsDeviceInfo (/var/lib/homebridge/node_modules/@fjs21/homebridge-blueair/src/blueair-aws-api.ts:362:92)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at BlueAirHomebridgePlatform.findAwsModelAndInitialize (/var/lib/homebridge/node_modules/@fjs21/homebridge-blueair/src/platform.ts:330:18)
    at BlueAirHomebridgePlatform.discoverAwsDevices (/var/lib/homebridge/node_modules/@fjs21/homebridge-blueair/src/platform.ts:203:9)
[22/04/2024, 15:48:26] [@fjs21/homebridge-blueair] Child bridge process ended
[22/04/2024, 15:48:26] [@fjs21/homebridge-blueair] Process Ended. Code: 1, Signal: null
[22/04/2024, 15:48:33] [@fjs21/homebridge-blueair] Restarting Process...
[22/04/2024, 15:48:36] [@fjs21/homebridge-blueair] Launched child bridge with PID 236...
.....
....
(repeats the same logs)

I tried deleting the cache and adding back... still same issue.

rmanak commented 5 months ago

I suspected that it may have something todo with conflicting NPM libraries that plugin uses, and completely uninstalled the plugin and made sure no npm dependency is there and re-installed, still same error, hope that helps with debugging. I do need to learn more nodejs