Ekman / home-assistant-pure-i9

Electrolux Pure i9 robot vacuum integration for Home Assistant.
MIT License
25 stars 5 forks source link

Can't login on my Electrolux account #45

Closed allan-null closed 1 year ago

allan-null commented 1 year ago

I am trying to login on my Electrolux account from this integration, but I am unable to. I even removed any especial characters from my password to prevent issues with unescaped characters, but no luck. I logged in and out from the Electrolux app several times just to make sure my password is correct. This is the log message I am getting:

Logger: purei9_unofficial.util
Source: /usr/local/lib/python3.10/site-packages/purei9_unofficial/util.py:28
First occurred: 23:37:58 (6 occurrences)
Last logged: 23:49:57

Giving up due to no left retries. Wrong credentials?

Any suggestions on how can I dig for more information about this issue?

Ekman commented 1 year ago

Well, let us dig into that!

I've released a new version of the integration 1.3.1 that changes how the integration fetches and updates data from the API. Try installing that and see if that resolves the issue.

If that does not solve it, then add the following to your configuration.yaml file:

logger:
  default: warn
  logs:
    custom_components.purei9: debug
    purei9_unofficial: debug

After that, try again, and then post your logs. If you don't want to post your logs publically, then you can send it to redacted.

allan-null commented 1 year ago

Thanks for the reply! Here are the logs:

2022-12-22 09:59:02.889 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP POST https://api.delta.electrolux.com/api/Clients/Wellbeing
2022-12-22 09:59:06.417 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 200 <Response [200]> (sensitive data not shown)
2022-12-22 09:59:06.417 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP POST https://api.delta.electrolux.com/api/Users/Login
2022-12-22 09:59:08.172 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 200 <Response [200]> (sensitive data not shown)
2022-12-22 09:59:08.173 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP GET https://api.delta.electrolux.com/api/Domains/Appliances
2022-12-22 09:59:09.297 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 200 <Response [200]> [{"applianceName":"Geoffrey","created":"2022-10-01T13:02:13.8254392Z","id":1271455,"modelName":"PUREi9","timeZoneStandardName":null,"pncId":"900921353101005641100106","domainId":790979}]
2022-12-22 09:59:09.298 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP GET https://api.delta.electrolux.com/api/AppliancesInfo/900921353101005641100106
2022-12-22 09:59:10.540 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 404 <Response [404]> {"code":404000,"codeDescription":"NotFound: Could not find the resource.","information":"There is no ApplianceInfo with the requested pnc","message":""}
2022-12-22 09:59:10.540 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP GET https://api.delta.electrolux.com/api/AppliancesInfo/900921353101005641100106
2022-12-22 09:59:11.765 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 404 <Response [404]> {"code":404000,"codeDescription":"NotFound: Could not find the resource.","information":"There is no ApplianceInfo with the requested pnc","message":""}
2022-12-22 09:59:11.766 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP GET https://api.delta.electrolux.com/api/AppliancesInfo/900921353101005641100106
2022-12-22 09:59:13.016 DEBUG (SyncWorker_1) [purei9_unofficial.util] HTTP 404 <Response [404]> {"code":404000,"codeDescription":"NotFound: Could not find the resource.","information":"There is no ApplianceInfo with the requested pnc","message":""}
2022-12-22 09:59:13.016 ERROR (SyncWorker_1) [purei9_unofficial.util] Giving up due to no left retries. Wrong credentials?

Based on a quick packet capture I did, looks like they have different API servers based on different regions. I mean, I am in Brazil and the only API related requests were to the domain: api.ocp.electrolux.one. I tried looking further with an effortless MitM, but the app I was using failed. I still want to figure this out even if I must write my own library to make it work (if the API are not the same). What tool did you use to see through the traffic encryption?

Ekman commented 1 year ago

Thanks for the logs! Seems unnecessary that you create your own integration, it's better if we can focus all our energy on one. I haven't reverse-engineered the API, it's @Phype work. 🙂

Interesting that you still have the robot registered in this API, even though you cannot seem to get all the information that you need.

This integration is using Phype/purei9_unofficial in order to communicate with the API, and that library has a nice CLI interface. If I were you, I'd download that library and switch the API URLs (and probably the client ID/secret as well) and see if that works. Hopefully, the APIs are the same and you could send a PR to Phype/purei9_unofficial to allow for configuring the API URL. If that was available to me, I could just add that as a configuration.

allan-null commented 1 year ago

Thank you for the quick response! Unless I am doing something wrong, it looks like the API structure is different (or at least the URI base path is). Yesterday, I tried a man-in-the-middle strategy on the Electrolux app to figure out what is going on, but the app shows an offline screen and stops sending data every time it detects my proxy. I will still try fiddling with it to discover the source of the problem. But for now, I will take a holiday break. Thank you so much for your attention.

Ekman commented 1 year ago

Happy to be of assistance!

I'm going to close this issue as it's currently hard for me to resolve it.

If you understand the API and create a Python library for it then I'd be happy to include it in this integration by making it configurable. I've never tried it, but maybe setting up an Android emulator on your computer, together with Wireshark, would work.

Merry Christmas and happy new year! 🎄

Ekman commented 1 year ago

Which app are you using? Given that Electrolux has provided three different apps throughout the Pure i9 lifetime (it's a mess), I'm just curious about which one is in use in Brazil.

allan-null commented 1 year ago

The name is just "Electrolux", the package name is com.electrolux.oneapp.android.electrolux. Since I also had to migrate from Electrolux Wellbeing, I am guessing it's the same app.

Ekman commented 1 year ago

Yes, that's the same.

Interesting that they are providing APIs with different structures for different regions. 🤔