jgriss / FusionSolarPy

A basic client to the Huawei Fusion Solar cloud interface for solar power plants
MIT License
30 stars 12 forks source link

Error when using different subdomain #8

Closed dobber81 closed 1 year ago

dobber81 commented 1 year ago

Hello,

I'm running in to some issues when using your code. If I use the default region01eu5 I get a wrong username or password message. In Home Assistant I use eu5.fusionsolar.huawei.com and I can connect just fine there with the same username and password. Am I doing something wrong, or is there an issue with the code? Also, the username and password is an API account, not an account that can actually login to the huawei portal, if this makes any differance.

Btw: # client = FusionSolarClient("my_user", "my_password", huawei_subdomai="region01eu5") <--this line is missing a "n" in "huawei_subdomain" :)

Traceback (most recent call last): File "/home/dobber/test.py", line 10, in client = FusionSolarClient("my_super_secret_username", "my_super_secret_password", huawei_subdomain="eu5") File "/home/dobber/.local/lib/python3.9/site-packages/fusion_solar_py/client.py", line 82, in init self._login() File "/home/dobber/.local/lib/python3.9/site-packages/fusion_solar_py/client.py", line 112, in _login r = self._session.post(url=url, params=params, json=json_data) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 590, in post return self.request('POST', url, data=data, json=json, kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request resp = self.send(prep, send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send resp = conn.urlopen( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request self._validate_conn(conn) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 1012, in _validate_conn conn.connect() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 353, in connect conn = self._new_conn() File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn conn = connection.create_connection( File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 69, in create_connection return six.raise_from( File "", line 3, in raise_from urllib3.exceptions.LocationParseError: Failed to parse: '.fusionsolar.huawei.com', label empty or too long

jgriss commented 1 year ago

Hi @dobber81

Thanks a lot for your feedback!

Unfortunately yes, it does make a difference. This package only works with credentials for the Web interface.