JohNan / homeassistant-wellbeing

Get the status from your Electrolux devices connected to Wellbeing
MIT License
76 stars 20 forks source link

Despite last update - not working (again) #98

Open cpohli opened 1 month ago

cpohli commented 1 month ago

The last update worked for a couple of hours, now i'm getting:

Logger: custom_components.wellbeing
Quelle: custom_components/wellbeing/api.py:490
Integration: Electrolux Wellbeing (Dokumentation, Probleme)
Erstmals aufgetreten: 11:03:27 (35 Vorkommnisse)
Zuletzt protokolliert: 11:05:23

Error, got error 403 (Forbidden) from server https://api.ocp.electrolux.one/one-account-authentication/api/v1/authenticate - 403, message='Forbidden', url=URL('https://api.ocp.electrolux.one/one-account-authentication/api/v1/authenticate') 

i checked the app on my phone, logged out and in again (no new terms to accept though), restarted HA. App on the iPhone is working fine. Any ideas?

apachelance commented 1 month ago

Also having issues since a few days. I think Electrolux integrated a OTP via email to login. At least the app is not using a password anymore and is sending an OTP via email.

I am getting this error: Error, got error 429 () from server https://api.ocp.electrolux.one/one-account-authorization/api/v1/token - 429, message='', url=URL('https://api.ocp.electrolux.one/one-account-authorization/api/v1/token')

FSHelgeland commented 1 month ago

Electrolux has added the verify with apple/google also. Would have been lovely if in some way home assistant could have supported verify with apple/google. I think this will be more common, and I am unsure of how easy it will be for JohNan to fix this. Some kind of Oauth identification needed then.

forgenator commented 1 month ago

We do not have our account linked to google/apple, but when we logged in, it sent an email with verification number in it. So i think the solution would be to log in via the integration, and then have the integration request the verify code from your email. After which the integration should be able to log in. :thinking:

throw-new-customException commented 1 month ago

Googling I found this https://developer.electrolux.one I think they are closing the possibility to use other API, it seems to be an official website

FSHelgeland commented 1 month ago

I just added log in with apple through the iphone app, it is also possible to choose google. If they are removing the possibillity to use HA, then it is time to trow it away. I need to change the bearings, but if I can not use it in HA, then well ...

FSHelgeland commented 1 month ago

As I read the info from Electrolux this should be possible to fix.

https://developer.electrolux.one/documentation/authorization

forgenator commented 1 month ago

So the idea is that every use needs to create electrolux group account, which is the same as their current account, create and fetch the api key, and then we need to modify the code to use that api key in the integration.

FSHelgeland commented 1 month ago

Yes and this need to be built in to the integration to be managable for the users of the integration.

JohNan commented 1 month ago

I also saw the new public API and it looks like what we need. It is however rate limited so using it would require each user to generate their own API key an supply it during the integration configuration.

I would suggest to make the API integration as a separate python module so it can be be used by others too.

My time is limited at the moment, so any contributions are welcome.

FSHelgeland commented 1 month ago

If I had have the ability too, then I would have tried to help. Hope someone with the knowhow, is willing to help.

forgenator commented 1 month ago

I will try to do something probably in the next few days when i have free time, might not be pretty at first.

forgenator commented 1 month ago

Sadly, when i try to log into the developer portal it gives me error 500 in the background, so i cannot test this completely because i cannot fetch an api key or jwt keys... I will try and see if i can somehow reset stuff. Will still try to do some coding in the mean while with the info i have.

dezeroku commented 1 month ago

FWIW I was able to get some responses by straight up hardcoding the apikey and access token in the code. It seems there are few differences in the response format too. I'd be happy to help in the development / testing.

JohNan commented 1 month ago

I have started on a api client which you can find here: https://github.com/JohNan/pyelectroluxgroup

It is still a lot to do and contributions are welcome. Example output

Appliance ID: XXXX
Appliance name: Luftrenare
 -- Serial number: XXXX
 -- Brand: ELECTROLUX
 -- Model: A9
 -- Device Type: AIR_PURIFIER
 -- State --
 ---- PM10: 1
 ---- PM2.5: 1
 ---- PM1: 0
 ---- Temperature: 25

Once this client is working and fetching all necessary data we can start integrate it in this integration.

giovesoft commented 1 month ago

Sadly, when i try to log into the developer portal it gives me error 500 in the background, so i cannot test this completely because i cannot fetch an api key or jwt keys... I will try and see if i can somehow reset stuff. Will still try to do some coding in the mean while with the info i have.

Probably you have a pending action on the mobile app side. Try to use the mobile app to complete the login phase at least one time and in case logout/login. Then retry to use the portal.

FSHelgeland commented 1 month ago

wow, I have noticed work has been done, but did not realise there was something that was out there. I am so happy that my Pure A9 is up running again. I can see that you still have some issues but this is great work guys.

tomas0620 commented 1 month ago

Hi, great work :) I noticed that the controls for the ionizer, child lock, and UI light are missing on my Pure A9. Is this due to the new Electrolux API, or is it a bug?

cpohli commented 1 month ago

The latest update brings everything (both of my A9s) back to life and to normal. I'm using the API, Token etc. Works perfect. The 3 controls mentioned by @tomas0620 are missing here as well, though the sensors are there and working (indicating the status of the 3 things). Thanks for all that effort to keep this running, it's very much appreciated! :-)

apachelance commented 1 month ago

I removed the old version and installed the new one. However I am getting this error if I try to configure it: image

The log says: Unable to install package pyelectroluxgroup==0.2.0: ERROR: Cannot install pyelectroluxgroup==0.2.0 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

JohNan commented 1 month ago

I removed the old version and installed the new one. However I am getting this error if I try to configure it: image

The log says: Unable to install package pyelectroluxgroup==0.2.0: ERROR: Cannot install pyelectroluxgroup==0.2.0 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

You probably need to update to latest HomeAssistant because the library uses a recent version of aiohttp. I think the library also works with olders versions, so I might be able to make the version requirements more loosely.

JohNan commented 1 month ago

Hi, great work :) I noticed that the controls for the ionizer, child lock, and UI light are missing on my Pure A9. Is this due to the new Electrolux API, or is it a bug?

These controls has been removed from the API for some reason. 🤷

apachelance commented 1 month ago

@JohNan Thx, updated to the latest HA version and it is working now.

dezeroku commented 1 month ago

@JohNan that's pretty interesting, does the API return any capabilities for you? In my case I just get (or at least used to get) an empty dict, but could still send commands overriding some values (like workmode or Fanspeed) and these worked. Maybe it's similar for the safety lock and ionizer?

FSHelgeland commented 1 month ago

I guess the refresh token does not work yet? At least it doesnt for me. So I need to deactivate/activate and paste in new tokens. Sometimes getting errors when toggling like example the fan, but it toggles.

FSHelgeland commented 1 month ago

Hi, great work :) I noticed that the controls for the ionizer, child lock, and UI light are missing on my Pure A9. Is this due to the new Electrolux API, or is it a bug?

These controls has been removed from the API for some reason. 🤷

I get status update from those entities but can not toggle them.

apachelance commented 1 month ago

This morning the integration became unavailable and I had to reauthenticate with API key and tokens.

FSHelgeland commented 1 month ago

This morning the integration became unavailable and I had to reauthenticate with API key and tokens.

I dont think they have solved the problem with storing the refresh token yet, this is work in progress. So until then I belive we have to be patience.

apachelance commented 1 month ago

Yes, I know. I just wanted to let them know.

JohNan commented 1 month ago

Thanks for reporting all problems that you have. I'm seeing most of them myself as well and working on fixes. My time is limited so please have patience, or help out by submitting a PR.

I currently only have my cell phone atbhand, so iterating issues/fixes in my live environment is a bit tedious 😕

JohNan commented 1 month ago

@JohNan that's pretty interesting, does the API return any capabilities for you? In my case I just get (or at least used to get) an empty dict, but could still send commands overriding some values (like workmode or Fanspeed) and these worked. Maybe it's similar for the safety lock and ionizer?

I received readwrite access to Fanspeed and Workmode. Nothing more. I tried sending commands for toggling Ionizer but got an error in response. So I have based the switches on what capabilities match Ionizer, Safety Lock and UiLight

See here https://github.com/JohNan/homeassistant-wellbeing/blob/main/custom_components/wellbeing/switch.py#L12

JohNan commented 1 month ago

This morning the integration became unavailable and I had to reauthenticate with API key and tokens.

I dont think they have solved the problem with storing the refresh token yet, this is work in progress. So until then I belive we have to be patience.

I think I have solved the issues with the tokens. Please try the beta release 1.2.2 and let me how it works out for you.

FSHelgeland commented 1 month ago

I updated now, and only had to paste in the api key again. The tokens were stored and they were good. Great work.

apachelance commented 1 month ago

Thanks for the update. I just installed the beta. Will check tomorrow if the login expired.

apachelance commented 1 month ago

Today the integration stopped working again. Authentication was not possible anymore with the latest beta. It says username/password wrong. However I copied the API key and a newly generated token into the form. I also removed the integration, reinstalled it and still no success.

Validating credentials failed - 429, message='', url='https://api.developer.electrolux.one/api/v1/appliances'

JohNan commented 1 month ago

Today the integration stopped working again. Authentication was not possible anymore with the latest beta. It says username/password wrong. However I copied the API key and a newly generated token into the form. I also removed the integration, reinstalled it and still no success.

Validating credentials failed - 429, message='', url='https://api.developer.electrolux.one/api/v1/appliances'

Error 429 means that the rate limit has been reached. I think the default update interval is 30 seconds, which seems to be a bit too often. Try to change it to 120 seconds instead

FSHelgeland commented 1 month ago

I will try that

yazz007 commented 1 month ago

Today the integration stopped working again. Authentication was not possible anymore with the latest beta. It says username/password wrong. However I copied the API key and a newly generated token into the form. I also removed the integration, reinstalled it and still no success. Validating credentials failed - 429, message='', url='https://api.developer.electrolux.one/api/v1/appliances'

Error 429 means that the rate limit has been reached. I think the default update interval is 30 seconds, which seems to be a bit too often. Try to change it to 120 seconds instead

According to Electrolux, the rate limits are: 10 calls/second 5 concurrent calls 5000 calls/day

jgaalen commented 3 weeks ago

I've updated the plugin for domoticz and I came across the same issue with the Ionizer etc., which are not part of the capabilities. Somehow there should be a way to get it working, as the app can still toggle the ionizer. We should only know how the api request looks like the app does, although I was unable to record the request from the app.

JohNan commented 3 weeks ago

If you know your way around python scripts, you can try the command line interface for the library that this integration uses. You can send raw commands and try toggle the features that are no longer available

https://github.com/JohNan/pyelectroluxgroup

Let me know if you find any that works. Here's the documentation for the API and sending commands https://developer.electrolux.one/documentation/reference#sendCommandToAppliance

jgaalen commented 3 weeks ago

@JohNan did you had it working? I've tried many different ways to send the command for the Ionizer:

{"Ionizer": False} {"Ionizer": "On"} {"Ioniser": False}

tried the old /v2 api

Nothing works

JohNan commented 3 weeks ago

I reached out to Electrolux dev team about not being able to toggle these features. I got this reply today

We found the bug, we will fix it in a few days. Thank you 😉

So hopefully we can get our toggles back in a few days 😁

FSHelgeland commented 3 weeks ago

I have an automation running, If I get home or if I close the door then the Fan is supposed to turn on, unless the filter is 0. The filter is 0 now and when checking it I get an error not able to read even though it really does. I also get some api-errors. The logs are deleted now, but I can reproduce them if necessary. The behaviour is that the fan turns on, even if the automation stops before it it comes to the step for turning it on.