zyonse / homebridge-dreo

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

region detection #4

Closed chloke closed 1 year ago

chloke commented 1 year ago

Hey, sorry for not answering your last request on time. I just tested it and saw the reason for the error in the log. The problem is that your code adds the country code to the url instead of the region. For example I live in Germany so my country code is DE. The url your plugin is trying to connect to is now app-api-de.dreo-cloud.com but every dreo account in a country in Europe shares the same url which is app-api-eu.dreo-cloud.com. So the current region detection code won't work unfortunately. I guess the easiest solution would be to check if a connection to the us servers is successful, if not use the eu url, regardless of the country code.

NTK421 commented 1 year ago

What's going on with this issue. I'm having the same error when starting the plugin. I'm in the UK

czitooo commented 1 year ago

With respect for having this plugin available at all... for a 'verified' plugin this really should have been sorted by now since it's a fairly simple fix. I'm also in the UK and changing the region to 'eu' manually (eg. 'app-api-eu.dreo-cloud.com') works instantly by going into the code, as mentioned by @chloke The best fix surely is just let the user select the correct region upon setup since many countries are grouped together?

zyonse commented 1 year ago

I took another look at the API calls that the app makes when connecting to the Dreo servers, and it looks like the app keeps an internal list of what countries/regions are assigned to each server. Going to try to implement similar logic in the plugin.

Also let's try to keep the comments constructive here.

zyonse commented 1 year ago

@czitooo Can you test the code I just pushed?

edit: published as v2.0.2

daveramirez5 commented 1 year ago

It worked for me from Mexico

NTK421 commented 1 year ago

Worked for me perfectly in the UK

czitooo commented 1 year ago

@zyonse Works perfectly, nicely done 👍