Andre0512 / hon

Home Assistant integration for Haier hOn: support for Haier/Candy/Hoover home appliances like washing machines and air conditioners in 28 languages.
MIT License
1.25k stars 2.49k forks source link

Can not login with correct email and password #215

Open maxifly opened 1 month ago

maxifly commented 1 month ago

v0.13.0

I use EVO application on my phone.| I setup addon to HA, enter correct email and password (I check this information by logout/login on phone) In HA log I see that hon can not login In integration setting I see my email "Setup fail" and "No device or entityes".

Environment (please complete the following information):

Additional context Add any other context about the problem here.

Home Assistant Logs Check System -> Logs if you can find any logs related to this integration and post it here.

Device Log Post your device info here (if available) 2024-06-01 17:10:34.864 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry maxxxx@mail.ru for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hon/init.py", line 41, in async_setup_entry hon = await Hon(*kwargs).create() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 74, in create await self.setup() File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 105, in setup appliances = await self.api.load_appliances() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/api.py", line 84, in load_appliances async with self._hon.get(f"{const.API_URL}/commands/v1/appliance") as resp: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/base.py", line 64, in get async with self._intercept(args, **kwargs) as response: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 74, in _intercept kwargs["headers"] = await self._check_headers(kwargs.get("headers", {})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 64, in _check_headers await self.auth.authenticate() File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 258, in authenticate if not (url := await self._login()): ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 195, in _login await self._error_logger(response) File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 96, in _error_logger raise exceptions.HonAuthenticationError("Can't login") pyhon.exceptions.HonAuthenticationError: Can't login

tomaszwozniak commented 2 weeks ago
  1. Reset password in you hon app
  2. Remove integration entry in haier h0n integration
  3. Add again
Feirbran commented 2 weeks ago

Hello there, I'm having the same issue and I also tried what @tomaszwozniak suggested but gives me the same error. My Logs: Dettagli registro (ERRORE) Registratore: homeassistant.config_entries Fonte: config_entries.py:594 Prima occorrenza: 12:39:22 (7 occorrenze) Ultima registrazione: 12:46:00

Error setting up entry fxxxxxxxxxxxx@gmail.com for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hon/init.py", line 41, in async_setup_entry hon = await Hon(*kwargs).create() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 74, in create await self.setup() File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 105, in setup appliances = await self.api.load_appliances() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/api.py", line 84, in load_appliances async with self._hon.get(f"{const.API_URL}/commands/v1/appliance") as resp: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/base.py", line 64, in get async with self._intercept(args, **kwargs) as response: File "/usr/local/lib/python3.12/contextlib.py", line 210, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 74, in _intercept kwargs["headers"] = await self._check_headers(kwargs.get("headers", {})) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 64, in _check_headers await self.auth.authenticate() File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 258, in authenticate if not (url := await self._login()): ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 195, in _login await self._error_logger(response) File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 96, in _error_logger raise exceptions.HonAuthenticationError("Can't login") pyhon.exceptions.HonAuthenticationError: Can't login

ikreis commented 1 week ago
  1. Reset password in you hon app
  2. Remove integration entry in haier h0n integration
  3. Add again

This fixed it for me. Seems so easy in the end, but was reluctant to choose "delete".

mateuszfl commented 1 week ago

Yes, I had exactly the same problem today, but before deleting it (because I had similar concerns) I tried to persistently add the integration again, it ended with an empty window without any message. It wasn't until I looked at the server's response that I saw the actual error information (duplicate).

Also, remove and re-add according to the instructions.

daemon76 commented 1 week ago

Log in to the website https://account2.hon-smarthome.com using your login and password and turn off Two-Factor Verification in your account settings. It worked for me.

mschmiedel commented 3 days ago

Hmmm, I don't get it, I tried what is suggested here:

  1. Delete Integration
  2. Reset pwd
  3. Login as @daemon76 suggested and make sure 2FA is deactivated
  4. Readd Integration

I am stuck with the "Can't login" message posted by @Feirbran.

Maybe one thought, we had our account configured with Google Social Login, I reset the pwd today for the first time in like a year to get the integration to work. Might there be a difference on accounts that support social login? Could other people who have posted and cannot fix this confirm if this is the case on their account too?

daemon76 commented 3 days ago

I did not use a social account, but it is possible that a social account is handled differently.

pt., 28 cze 2024 o 18:13 mschmiedel @.***> napisał(a):

Hmmm, I don't get it, I tried what is suggested here:

  1. Delete Integration
  2. Reset pwd
  3. Login as @daemon76 https://github.com/daemon76 suggested and make sure 2FA is deactivated
  4. Readd Integration

I am stuck with the "Can't login" message posted by @Feirbran https://github.com/Feirbran.

Maybe one thought, we had our account configured with Google Social Login, I reset the pwd today for the first time in like a year to get the integration to work. Might there be a difference on accounts that support social login? Could other people who have posted and cannot fix this confirm if this is the case on their account too?

— Reply to this email directly, view it on GitHub https://github.com/Andre0512/hon/issues/215#issuecomment-2197250986, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANSG6LRKK6PBQVUEVIUIOI3ZJWDR7AVCNFSM6AAAAABIUGJELWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJXGI2TAOJYGY . You are receiving this because you were mentioned.Message ID: @.***>

mschmiedel commented 2 days ago

@daemon76 , just to make it clear, I do not use the social login for the integration (this cannot work!), just created a pwd which I can use on the app and on the account2.hon-smarthome.com by hand, but not on the integration.

I just checked the pyhOn library:

Exception is raising here:

image

Last thing it prints is this: homeassistant | 1 200 - https://account2.hon-smarthome.com/setup/secur/RemoteAccessAuthorizationPage.apexp?source

along with the full response body of that page, which has a few js if conditions for some redirect, but if I understand the code correctly from the auth.py, it seems to be looking for some "url=" regex or the access token, which it cannot find...

Redirects want to go to https://account2.hon-smarthome.com/loginflow/loginFlowOnly.apexp?retURL=...

However, these are js manual redirects, not http (30X) ones...

What is very strange, if I do the login in a browser, I never see the "RemoteAccessAuthorizationPage" in the log...

Maybe a feedback for @Andre0512: I activated debug in the HomaAssistant Integration, for the auth flow, it would be great if in that case every visited URL with response codes would be logged.

mschmiedel commented 2 days ago

One more comment here. I checked out the phyOn library and made a manual test from my pc. I can successfully login outside of HomeAssistant using the library. So I guess it might be some difference with the aiohttp HomeAssistant provides (maybe not in every case). I will see if I find a way to log stuff like the user-agent headers (in case they are set) and such...

mschmiedel commented 2 days ago

This is very strange, I just retested (without deleting and adding the integration) and it worked, maybe it was just a coincidence that something was wrong on server-side and I tested the lib manually after the fix. Now it works and I got the entities...