Phype / purei9_unofficial

This project includes a client/library to connect to Electrolux and AEG cleaner robots.
https://pypi.org/project/purei9-unofficial
MIT License
27 stars 5 forks source link

Make `cloud -v 3` the default #25

Open Phype opened 1 year ago

Phype commented 1 year ago

After some more testing, i guess we should make the new API the default. I'll leave it to -v 2 for now for some more testing.

Phype commented 1 year ago

Seems the just disabled the old API:

$ python3 -m purei9_unofficial -d cloud -v2 -c <REDACTED> status
2023-06-22 13:54:40,392 - purei9_unofficial.util - DEBUG - HTTP POST https://api.delta.electrolux.com/api/Clients/Wellbeing
2023-06-22 13:54:40,393 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.delta.electrolux.com:443
2023-06-22 13:54:40,821 - urllib3.connectionpool - DEBUG - https://api.delta.electrolux.com:443 "POST /api/Clients/Wellbeing HTTP/1.1" 400 None
2023-06-22 13:54:40,823 - purei9_unofficial.util - DEBUG - HTTP 400 <Response [400]> {"code":400105,"codeDescription":"InvalidClientCredentials: The provided client credentials where not correct.","information":"invalid_client","message":"Bad request"}
2023-06-22 13:54:40,823 - purei9_unofficial.util - DEBUG - HTTP POST https://api.delta.electrolux.com/api/Clients/Wellbeing
2023-06-22 13:54:40,823 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.delta.electrolux.com:443
2023-06-22 13:54:41,097 - urllib3.connectionpool - DEBUG - https://api.delta.electrolux.com:443 "POST /api/Clients/Wellbeing HTTP/1.1" 400 None
2023-06-22 13:54:41,098 - purei9_unofficial.util - DEBUG - HTTP 400 <Response [400]> {"code":400105,"codeDescription":"InvalidClientCredentials: The provided client credentials where not correct.","information":"invalid_client","message":"Bad request"}
2023-06-22 13:54:41,099 - purei9_unofficial.util - DEBUG - HTTP POST https://api.delta.electrolux.com/api/Clients/Wellbeing
2023-06-22 13:54:41,100 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.delta.electrolux.com:443
2023-06-22 13:54:41,351 - urllib3.connectionpool - DEBUG - https://api.delta.electrolux.com:443 "POST /api/Clients/Wellbeing HTTP/1.1" 400 None
2023-06-22 13:54:41,353 - purei9_unofficial.util - DEBUG - HTTP 400 <Response [400]> {"code":400105,"codeDescription":"InvalidClientCredentials: The provided client credentials where not correct.","information":"invalid_client","message":"Bad request"}
2023-06-22 13:54:41,354 - purei9_unofficial.util - ERROR - Giving up due to no left retries. Wrong credentials?
Traceback (most recent call last):
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 22, in do_http
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.delta.electrolux.com/api/Clients/Wellbeing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 22, in do_http
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.delta.electrolux.com/api/Clients/Wellbeing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/__main__.py", line 161, in <module>
    robots = client.getRobots()
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/cloudv2.py", line 244, in getRobots
    r = do_http("GET", self.apiurl + "/Domains/Appliances", headers=self._getHeaders())
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/cloudv2.py", line 228, in _getHeaders
    r = do_http("POST", self.apiurl + "/Clients/" + self.client_id, json={"ClientSecret":self.client_secret})
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 26, in do_http
    return do_http(method, url, retries-1, **kwargs)
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 26, in do_http
    return do_http(method, url, retries-1, **kwargs)
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 29, in do_http
    raise r
  File "/home/philipp/purei9_unofficial/src/purei9_unofficial/util.py", line 22, in do_http
    r.raise_for_status()
  File "/usr/lib/python3/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.delta.electrolux.com/api/Clients/Wellbeing

cloud -v3 works fine. I'l make the change later.

The homeassistant air purifier intergration has the same problem: https://github.com/JohNan/homeassistant-wellbeing/issues/53