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

BlueAir 7440i - Found 0 Devices #24

Closed wgalternate closed 2 years ago

wgalternate commented 2 years ago

Hi there,

I can't seem to get my two 7440i devices showing up using the latest version of the plugin. Am I meant to enable the "Enable AWS Connection" option for this?

When doing so, I am getting this error followed by the child bridge restarting

[03/05/2022, 08:57:31] [@fjs21/homebridge-blueair] Got homehost: api-eu-west-1.blueair.io TypeError: Cannot read property 'sessionToken' of undefined at BlueAirApi.awsLogin (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/src/blueair-api.ts:494:44) at processTicksAndRejections (node:internal/process/task_queues:94:5) at BlueAirHomebridgePlatform.discoverAwsDevices (/usr/local/lib/node_modules/@fjs21/homebridge-blueair/src/platform.ts:160:33)

Let me know if any further information is needed, I have Charles Proxy for this.

fjs21 commented 2 years ago

For the 7440i devices you will need to use AWS to connect. @jonato1 has been helping others with the Amazon API support.

jonato1 commented 2 years ago

Hi @wgalternate - I suspect this is because I made the assumption that everything was going to hit US-based APIs, however I'm don't have the full list of global API endpoints. Can you use Charles Proxy on a mobile device and identify the various endpoints that you hit? They should look similar to the ones below, but will probably switch out US for EU, or AWS for Azure.

  1. https://accounts.us1.gigya.com/accounts.login
  2. https://accounts.us1.gigya.com/accounts.getJWT
  3. https://on1keymlmh.execute-api.us-east-2.amazonaws.com/prod/c/login
  4. https://on1keymlmh.execute-api.us-east-2.amazonaws.com/prod/c/registered-devices
  5. https://on1keymlmh.execute-api.us-east-2.amazonaws.com/prod/c/{{deviceName}}/r/initial
  6. https://on1keymlmh.execute-api.us-east-2.amazonaws.com/prod/c/{{deviceUuid}}/a/standby

I'm fairly certain the first two will either has a base url of https://accounts.eu1.gigya.com or https://accounts.eu2.gigya.com. For the latter endpoints, I'm guessing it might be eu-west-2, but there are quite a number of AWS regions. If it is hitting Azure, then I may need more collaboration with you to dig into this.

Looking forward to getting this working for you!

wgalternate commented 2 years ago

Hi @jonato1

Here is the list of endpoints that I'm hitting based on the ones that you specified.

https://accounts.eu1.gigya.com/accounts.login https://accounts.eu1.gigya.com/accounts.getJWT https://hkgmr8v960.execute-api.eu-west-1.amazonaws.com/prod/c/login https://hkgmr8v960.execute-api.eu-west-1.amazonaws.com/prod/c/registered-devices https://hkgmr8v960.execute-api.eu-west-1.amazonaws.com/prod/c/{{deviceName}}/r/initial https://hkgmr8v960.execute-api.eu-west-1.amazonaws.com/prod/c/{{deviceUuid}}/a/standby

Other notable endpoints :

https://api.blueair.io/v2/user/{{username}}/homehost/ https://api-eu-west-1.blueair.io/v2/user/{{username}}/get/ https://api-eu-west-1.blueair.io/v2/token/exchange https://api-eu-west-1.blueair.io/v2/owner/{{username}}/device/

jonato1 commented 2 years ago

@wgalternate This is super helpful! So a follow up question - are you familiar with/comfortable with using Postman? If so, can you import this collection, populate your username and password into the Environment variables, and then run through the requests from top to bottom to see if they all work? If not, feel free to paste the response outputs or any errors you get. https://www.getpostman.com/collections/9318d0666291a14f3d67

Alternatively, if you're not familiar with Postman, I'd be happy to either hop on a Zoom or code it blindly, release it, and iterate through that process until we get it working.

wgalternate commented 2 years ago

@jonato1 The only issue seems to be with the api key that you used with the login session. It should be this instead for the EU West server 3_qRseYzrUJl1VyxvSJANalu_kNgQ83swB1B9uzgms58--5w1ClVNmrFdsDnWVQQCl

jonato1 commented 2 years ago

@wgalternate Gotcha, thanks for that insight. Other than that, it seems like everything worked okay? Also, I don't explicitly have the model # for the 7440i. On the "Get State" call in Postman, what did the configuration.di.hw value show? I assume it's something like "low_1.4" or "high_1.5". This will be the last thing I think I need to get a first iteration of this coded and released.

wgalternate commented 2 years ago

@jonato1 Yes, everything returned a success after I swapped out the api key with the one I posted. As for the configuration.di.hw value, it gives me "low_1.4"

wgalternate commented 2 years ago

@jonato1 7422371000 And this is the model number for my unit.

jonato1 commented 2 years ago

@wgalternate Just a quick update - I think I've got everything updated to enable compatibility. Once v1.1.0 is released (likely in 1-3 days), then you will have to go to Plugin Settings and update your Region to EU. After that, you will need to restart Homebridge. If you run into any issues, please feel free to enable DEBUG mode in Homebridge and share any/all logs.

Cheers! Jon

wgalternate commented 2 years ago

@jonato1 Thanks for the update! Looking forward to testing it out and reporting back!

jonato1 commented 2 years ago

@wgalternate - Just another update. @fjs21 and I are running into issues with an intermittent error that pops up when trying to publish 1.1.0 to NPM. I'll let you know once we get this resolved.

jonato1 commented 2 years ago

@wgalternate Looks like we got it figured out! Let me know how v1.1.0 goes for you.

wgalternate commented 2 years ago

Finally got around to trying this out. Does not seem to work for me though.

[5/7/2022, 6:51:38 PM] [@fjs21/homebridge-blueair] Got homehost: api-eu-west-1.blueair.io TypeError: Cannot read properties of undefined (reading 'sessionToken') at BlueAirApi.awsLogin (/homebridge/node_modules/@fjs21/homebridge-blueair/src/blueair-api.ts:494:44) at processTicksAndRejections (node:internal/process/task_queues:96:5) at BlueAirHomebridgePlatform.discoverAwsDevices (/homebridge/node_modules/@fjs21/homebridge-blueair/src/platform.ts:160:33) [5/7/2022, 6:51:38 PM] [@fjs21/homebridge-blueair] Child bridge process ended

jonato1 commented 2 years ago

@wgalternate Thanks for the update. Can you confirm the following?

If any of the following was not done, can you retry and re-post any logs?

wgalternate commented 2 years ago

@jonato1 Yes, everything is set as you described. Though I just realised that my account is now "temporarily locked out"!

Probably due to all the broken request that was being made by the previous version of the script? The is probably why its erroring out for me. I'll wait to see if my account becomes unlocked, or create a new one and give it another go.

Will report back.

wgalternate commented 2 years ago

@jonato1 A new account worked! Everything seems to be working correctly now.

jonato1 commented 2 years ago

That's great to hear - thanks for the update @wgalternate. I'll close out this issue, but feel free to open a new one if anything changes.