Closed sylvix closed 4 months ago
It's better to wait other users with same issue. This integration uses many years. You right, you first with this issue.
Hi, I would like to add that I also encountered this exact same issue. The solution above has worked for me as well. I am from India so my region is Asia as well. I am not sure if this issue is specific to the asia region.
Initially the plugin was working fine for me without issue, but after a few reboots I got a notification at home assistant asking me to reconfigure the add-on. That is when I encounted this issue. I did a reinstall of the add-on but that didn't help.
I'm in Brazil and having same issue after upgrading my homeassistant to 2024.03.3
Worked after changing only countryCode in cloud.py
"countryCode": "+55",
Steps to reproduce:
Now, my eWeLink account is registered in Kyrgyzstan, which is Asia, and it might be important.
Error in getting user region from global!
The debug logs show something similar without any more clarification. While I was debugging this issue the error code was 10005. This error does not show up every time. Actually I can't reproduce it right now while creating this issue, but the version of this integration is the same as when this error occured. It might be that API somehow now works for my account after one successful login with correct region API URL.
What I understood and temporary workaround
By default login method tries EU server which is hard-coded into
XRegistryCloud
class. Also for some reason thecountryCode
is hard-coded as"+86"
. As I understand in the login method of the same class there is a check which catches10004
error and tries logging in using URL of another region which is actually returned in response.But it wasn't working for me for some reason. I changed my password not long ago so it might be related.
You can change the following lines in the
custom_components/sonoff/core/ewelink/cloud.py
to make it work:Line 88:
region = "eu"
- change it to another region from dictionary above (Line 22: "API", one of the "cn" - China, "as" - Asia, "us" - USA, "eu" - Europe)Line 117:
"countryCode": "+86",
- change it to your country code that you registered your account with. Might not be needed, but after I changed both of these lines together I was able to log in.Proposed fixes
I guess I might be the only person that encountered this error, because I could find neither that error code or message anywhere in Google or this repository issues. But it might be a good idea to make a fix or provide an explanation if this happens to anyone else.
So, the first option - the login procedure might check every login API URL one by one if that error code happens since it doesn't return a "region" key in its response. But if it also needs a correct countryCode phone prefix then it won't work.
So the next proposition - add "optional" parameters to login credential dialog window where you can select a region and country ("phone") code, so if login doesn't work for anyone with default settings, that person could fiddle with those settings and possibly get logged in.