fjs21 / homebridge-blueair

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

this.blueair.devices is not iterable (API issue) #4

Closed Teone55 closed 2 years ago

Teone55 commented 2 years ago

I have an error with continuous reboot:

TypeError: this.blueair.devices is not iterable at BlueAirHomebridgePlatform.discoverDevices (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/dist/platform.js:73:43) at processTicksAndRejections (node:internal/process/task_queues:96:5)

fjs21 commented 2 years ago

Can you enable debugging in the homebridge UI and see what is being reported when the device list is queried from BlueAir? It will be immediately after the "x-auth-token" log.

Teone55 commented 2 years ago

[10/12/2021, 10:57:19] [BlueAir] x-auth-token: eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6Im1hdHRlby5jYWNjaWFAZ21haWwuY29tIiwianRpIjoiMjhhZTk3YmQtMmFiNy00MDNhLTk1ZWItZTY1ODFlYmM5NjJmIiwiZXhwIjoxNjcwNjY2MjM5MTQxLCJleHBpcmF0aW9uRGF0ZSI6MTY3MDY2NjIzOTE0MX0.5orQyixr0g9dGZqo6_iIyUrqQ2xMiqL-T3wCt6tPCco [10/12/2021, 10:57:19] [BlueAir] { message: "Can't find address for service HandshakeLab", propagatedException: null, requestedUri: '/v2/owner/myemail@myemail/device/', stack: '[obfuscated]', state: 503 } [10/12/2021, 10:57:19] [BlueAir] Found undefined devices. [10/12/2021, 10:57:19] TypeError: this.blueair.devices is not iterable at BlueAirHomebridgePlatform.discoverDevices (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/dist/platform.js:73:43) at processTicksAndRejections (node:internal/process/task_queues:96:5)

[10/12/2021, 10:57:19] Got SIGTERM, shutting down Homebridge...

fjs21 commented 2 years ago

Ok. This looks like the server returned an error message from the API request to list all the devices in your system.

To be honest, I'm not sure what is causing this. What type of BlueAir device do you have in your account? This plugin has only been tested with the Classic series (280i and 680i). I know there are issues with HealthProtect models, see #1.

Please doublecheck the settings to make sure your username and password are accurate.

I will issue a patch to make sure this error is being handled better by the plugin and instead just causes the plugin to fail and not cause the continuous reboot of Homebridge.

Teone55 commented 2 years ago

I have BlueAir Classic 205.

Let me know if you need something else (log, debug, tests, etc)

On 10 Dec 2021, at 15:48, Fraser Sim @.***> wrote:

 Ok. This looks like the server returned an error message from the API request to list all the devices in your system.

To be honest, I'm not sure what is causing this. What type of BlueAir device do you have in your account? This plugin has only been tested with the Classic series (280i and 680i). I know there are issues with HealthProtect modes, see #1.

Please doublecheck the settings to make sure your username and password are accurate.

I will issue a patch to make sure this error is being handled better by the plugin and instead just causes the plugin to fail and not cause the continuous reboot of Homebridge.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

motaker commented 2 years ago

Hi, I have 480i and 205. It seems have same error caused by 205.

Teone55 commented 2 years ago

Let me add one thing that maybe could help: with the previous plugin (from mylesgray, that I know is one of your sources) my 205 worked perfectly until some weeks ago.

On 11 Dec 2021, at 09:58, motaker @.***> wrote:

 Hi, I have 480i and 205. It seems have same error caused by 205.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

fjs21 commented 2 years ago

Which BlueAir server are you going to? It should be on a previous line in the log.

Mine is: api-us-east-1.blueair.io

I was reading that 503 can mean "service unavailable". I just want to see if this is server or account specific issue.

Teone55 commented 2 years ago

Got homehost: api-eu-west-1.blueair.io

lensherm commented 2 years ago

@fjs21 , I posted this in another issue, but I have a feeling they might be related. Take a look at this, when you get a chance:

https://github.com/fjs21/homebridge-blueair/issues/2#issuecomment-992112073_

fjs21 commented 2 years ago

@fjs21 , I posted this in another issue, but I have a feeling they might be related. Take a look at this, when you get a chance:

#2 (comment)_

The "iterable" error just means the format of the response from the server is not in the format expected by the code. For #2, this is due to the absence of the datapoint functionality hence a blank data response which triggers the error. In this case, the error is generated because the response isn't JSON formatted at all - and instead just an error message from the server.

This one is very tricky to fix because it suggests that API is different. We'd need the postman response when using the app to find out what's actually being sent to/received from the BlueAir server.