zyonse / homebridge-dreo

Apple HomeKit integration for Dreo Smart Devices
https://www.npmjs.com/package/homebridge-dreo
Apache License 2.0
29 stars 17 forks source link

Axios 401 Crash #2

Closed bwp91 closed 1 year ago

bwp91 commented 1 year ago

(sorry deleting template!)

Please see this reddit issue here with a user running this plugin who is experiencing a crash from this plugin.

https://www.reddit.com/r/homebridge/comments/1360gvr/dreo_plugin_help/

guessing it is to do with axios returning a 401. just need to get this error caught and logged properly rather than crashing.

Was hoping this could be fixed asap 😀

thanks!

chloke commented 1 year ago

I was able to fix this issue by changing every API url in the DreoAPI.js from "us" to "eu" (example: "https://app-api-us.dreo-cloud.com/api/oauth/login" would now be "https://app-api-eu.dreo-cloud.com/api/oauth/login") Additionally I changed the country in the headers from US to DE, but I'm not sure if this change was really necessary. Maybe add a toggle in the initial setup to let the user select the correct region.

zyonse commented 1 year ago

@chloke Thanks, I'll add a region selector in the config after I add some error handling for Axios.

Also sorry for the delay in addressing this, now that I'm done with exams I can work on it.

zyonse commented 1 year ago

@chloke Can you test the axios-401-crash branch? It should now auto-detect what country your account is in.

chloke commented 1 year ago

can't test it right now, but the first api url is missing '+auth.countryCode+' if I'm not mistaken. I am going to test it later.

zyonse commented 1 year ago

can't test it right now, but the first api url is missing '+auth.countryCode+' if I'm not mistaken. I am going to test it later.

The first request is the one that gets the account region from the Dreo servers. They only check the country code for the requests after that.

chloke commented 1 year ago

@zyonse I just tested it, country and region is correct, but got an error getting the device list: "error retrieving device list: undefined"

zyonse commented 1 year ago

@zyonse I just tested it, country and region is correct, but got an error getting the device list: "error retrieving device list: undefined"

I made a small change to the error statement, can you try it now? (make sure to redact any personal info if present).

bwp91 commented 1 year ago

my comment here isn’t related to particularly this specific issue but generally due to the fact this error was crashing homebridge. as a verified plugin this shouldn’t happen. and i totally appreciate cases like this come up (even my own verified plugins end up crashing homebridge sometimes) but the great thing is that you were swift to respond and hopefully the issue is resolved 😁 it’s not like we are going to unverify the first moment that an issue comes up!

Please feel free to close this issue when a fix has been made to general release channel.

Thanks!

zyonse commented 1 year ago

@chloke I'm closing this issue because the Homebridge crashing problem is fixed. If you're still having account region issues please open a new pull request.

NTK421 commented 1 year ago

Have you removed this plugin. Whenever I search for it in the UI it comes up blank and now when I use terminal to install I get no where. Can you please elaborate