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.3k stars 2.46k forks source link

hOn Authentication Error while trying to add a newly created account #230

Open 48mWsPK opened 4 months ago

48mWsPK commented 4 months ago

Describe the bug Trying to setup a newly created non-Gmail account results in hOn Authentication Error 1 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source....

To Reproduce Steps to reproduce the behavior:

  1. Add hon custom component to HA
  2. Add hOn integration
  3. Provide correct account login info - works on mobile
  4. See error

Expected behavior Successfully setup the hOn HA integration

Screenshots image

Environment (please complete the following information):

Additional context n/a

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

Device Log

2024-07-09 15:32:56.764 ERROR (MainThread) [pyhon.connection.auth] hOn Authentication Error
1 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZCcoebLMDAwMDAwMDAwMDAwMDAwAAAA-hPIMSrShOCaS_nzv1mPVc__ZIVsxf5QXEQnXosVHvlPqM5l48WnsXn0y3ZTEczc2c893sBM_EqnVOs_qjyw-gaRmembGvbDX5qykspJ0jdzLGAWTZ0FtME0iRR3LtvxS7mwuO3yIf_4aQ5VGFJS-iIWW8WmFMyiPfb87lq9XcJWfeb0ej0P9TKRjZNzrd9h9c3O_oKChN2Hzx8s8eEja5jIniUVuPMA-t9HcCvyEFD4ed5p7EOlXm-USZClqOq_ibu8ih6ZEKSHmpn72Z7WfU0rzueg6BjlRy49qFpeTAv0fFR60sIaudCnUYkNSJGfX305Tm3h-k5uePSH153yRePTHHIzVWZMPg8XtC2gTl3aFRQyPD05bMpJd6IxVFVI6NAUZRD42uOgfNcSNOA4t0QzcP--N2_40bLOU7g48KxnQkEfPI7bXsbkZU02Q61pmBSjIzT6VyZ1sYnGIITFu8MJIeX_Ay--IjxQkGA4RZ6He1FYnGG9nGGmnrrM6A0bKU4j-COTDoaMRy-A0UjSW_3s8FCmbARLGMiEnM7HcAUq8FlrnA3LzzpHQHr4T0AGA7Wn2l1EWLkKvmUX717UCxmV_VFKsFaB9LD0YI5cY1tWdfH7JyBl1ytqWEn3ppSrI8-sBXNO4x1MRI2V_nGmViCSFjqAvq_1TEX9bEwKR67CpVWhrceVJe7uDkbQnT1Wxtg_RSUJpOxupekVJL5g9vD0Pbn5XbTE0AWbGY2hCE_-MrnqMKtmK4eVz60IRjO7_g%253D%253D%26display%3Dtouch
ERROR - 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZCcoebLMDAwMDAwMDAwMDAwMDAwAAAA-hPIMSrShOCaS_nzv1mPVc__ZIVsxf5QXEQnXosVHvlPqM5l48WnsXn0y3ZTEczc2c893sBM_EqnVOs_qjyw-gaRmembGvbDX5qykspJ0jdzLGAWTZ0FtME0iRR3LtvxS7mwuO3yIf_4aQ5VGFJS-iIWW8WmFMyiPfb87lq9XcJWfeb0ej0P9TKRjZNzrd9h9c3O_oKChN2Hzx8s8eEja5jIniUVuPMA-t9HcCvyEFD4ed5p7EOlXm-USZClqOq_ibu8ih6ZEKSHmpn72Z7WfU0rzueg6BjlRy49qFpeTAv0fFR60sIaudCnUYkNSJGfX305Tm3h-k5uePSH153yRePTHHIzVWZMPg8XtC2gTl3aFRQyPD05bMpJd6IxVFVI6NAUZRD42uOgfNcSNOA4t0QzcP--N2_40bLOU7g48KxnQkEfPI7bXsbkZU02Q61pmBSjIzT6VyZ1sYnGIITFu8MJIeX_Ay--IjxQkGA4RZ6He1FYnGG9nGGmnrrM6A0bKU4j-COTDoaMRy-A0UjSW_3s8FCmbARLGMiEnM7HcAUq8FlrnA3LzzpHQHr4T0AGA7Wn2l1EWLkKvmUX717UCxmV_VFKsFaB9LD0YI5cY1tWdfH7JyBl1ytqWEn3ppSrI8-sBXNO4x1MRI2V_nGmViCSFjqAvq_1TEX9bEwKR67CpVWhrceVJe7uDkbQnT1Wxtg_RSUJpOxupekVJL5g9vD0Pbn5XbTE0AWbGY2hCE_-MrnqMKtmK4eVz60IRjO7_g%253D%253D%26display%3Dtouch
=============== Response ===============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>
function redirectOnLoad() {
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZCcoebLMDAwMDAwMDAwMDAwMDAwAAAA-hPIMSrShOCaS_nzv1mPVc__ZIVsxf5QXEQnXosVHvlPqM5l48WnsXn0y3ZTEczc2c893sBM_EqnVOs_qjyw-gaRmembGvbDX5qykspJ0jdzLGAWTZ0FtME0iRR3LtvxS7mwuO3yIf_4aQ5VGFJS-iIWW8WmFMyiPfb87lq9XcJWfeb0ej0P9TKRjZNzrd9h9c3O_oKChN2Hzx8s8eEja5jIniUVuPMA-t9HcCvyEFD4ed5p7EOlXm-USZClqOq_ibu8ih6ZEKSHmpn72Z7WfU0rzueg6BjlRy49qFpeTAv0fFR60sIaudCnUYkNSJGfX305Tm3h-k5uePSH153yRePTHHIzVWZMPg8XtC2gTl3aFRQyPD05bMpJd6IxVFVI6NAUZRD42uOgfNcSNOA4t0QzcP--N2_40bLOU7g48KxnQkEfPI7bXsbkZU02Q61pmBSjIzT6VyZ1sYnGIITFu8MJIeX_Ay--IjxQkGA4RZ6He1FYnGG9nGGmnrrM6A0bKU4j-COTDoaMRy-A0UjSW_3s8FCmbARLGMiEnM7HcAUq8FlrnA3LzzpHQHr4T0AGA7Wn2l1EWLkKvmUX717UCxmV_VFKsFaB9LD0YI5cY1tWdfH7JyBl1ytqWEn3ppSrI8-sBXNO4x1MRI2V_nGmViCSFjqAvq_1TEX9bEwKR67CpVWhrceVJe7uDkbQnT1Wxtg_RSUJpOxupekVJL5g9vD0Pbn5XbTE0AWbGY2hCE_-MrnqMKtmK4eVz60IRjO7_g%3D%3D'); } else
if (window.location.replace){
window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZCcoebLMDAwMDAwMDAwMDAwMDAwAAAA-hPIMSrShOCaS_nzv1mPVc__ZIVsxf5QXEQnXosVHvlPqM5l48WnsXn0y3ZTEczc2c893sBM_EqnVOs_qjyw-gaRmembGvbDX5qykspJ0jdzLGAWTZ0FtME0iRR3LtvxS7mwuO3yIf_4aQ5VGFJS-iIWW8WmFMyiPfb87lq9XcJWfeb0ej0P9TKRjZNzrd9h9c3O_oKChN2Hzx8s8eEja5jIniUVuPMA-t9HcCvyEFD4ed5p7EOlXm-USZClqOq_ibu8ih6ZEKSHmpn72Z7WfU0rzueg6BjlRy49qFpeTAv0fFR60sIaudCnUYkNSJGfX305Tm3h-k5uePSH153yRePTHHIzVWZMPg8XtC2gTl3aFRQyPD05bMpJd6IxVFVI6NAUZRD42uOgfNcSNOA4t0QzcP--N2_40bLOU7g48KxnQkEfPI7bXsbkZU02Q61pmBSjIzT6VyZ1sYnGIITFu8MJIeX_Ay--IjxQkGA4RZ6He1FYnGG9nGGmnrrM6A0bKU4j-COTDoaMRy-A0UjSW_3s8FCmbARLGMiEnM7HcAUq8FlrnA3LzzpHQHr4T0AGA7Wn2l1EWLkKvmUX717UCxmV_VFKsFaB9LD0YI5cY1tWdfH7JyBl1ytqWEn3ppSrI8-sBXNO4x1MRI2V_nGmViCSFjqAvq_1TEX9bEwKR67CpVWhrceVJe7uDkbQnT1Wxtg_RSUJpOxupekVJL5g9vD0Pbn5XbTE0AWbGY2hCE_-MrnqMKtmK4eVz60IRjO7_g%3D%3D');
} else {
window.location.href ='/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZCcoebLMDAwMDAwMDAwMDAwMDAwAAAA-hPIMSrShOCaS_nzv1mPVc__ZIVsxf5QXEQnXosVHvlPqM5l48WnsXn0y3ZTEczc2c893sBM_EqnVOs_qjyw-gaRmembGvbDX5qykspJ0jdzLGAWTZ0FtME0iRR3LtvxS7mwuO3yIf_4aQ5VGFJS-iIWW8WmFMyiPfb87lq9XcJWfeb0ej0P9TKRjZNzrd9h9c3O_oKChN2Hzx8s8eEja5jIniUVuPMA-t9HcCvyEFD4ed5p7EOlXm-USZClqOq_ibu8ih6ZEKSHmpn72Z7WfU0rzueg6BjlRy49qFpeTAv0fFR60sIaudCnUYkNSJGfX305Tm3h-k5uePSH153yRePTHHIzVWZMPg8XtC2gTl3aFRQyPD05bMpJd6IxVFVI6NAUZRD42uOgfNcSNOA4t0QzcP--N2_40bLOU7g48KxnQkEfPI7bXsbkZU02Q61pmBSjIzT6VyZ1sYnGIITFu8MJIeX_Ay--IjxQkGA4RZ6He1FYnGG9nGGmnrrM6A0bKU4j-COTDoaMRy-A0UjSW_3s8FCmbARLGMiEnM7HcAUq8FlrnA3LzzpHQHr4T0AGA7Wn2l1EWLkKvmUX717UCxmV_VFKsFaB9LD0YI5cY1tWdfH7JyBl1ytqWEn3ppSrI8-sBXNO4x1MRI2V_nGmViCSFjqAvq_1TEX9bEwKR67CpVWhrceVJe7uDkbQnT1Wxtg_RSUJpOxupekVJL5g9vD0Pbn5XbTE0AWbGY2hCE_-MrnqMKtmK4eVz60IRjO7_g%3D%3D';
}
}
redirectOnLoad();
</script>
</head>
</html>
========================================
2024-07-09 15:32:56.764 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ***REDACTED*** for hon
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/hon/__init__.py", line 34, in async_setup_entry
hon = await Hon(
^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 77, in create
await self.setup()
File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 104, in setup
appliances = await self.api.load_appliances()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/api.py", line 86, 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 75, 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 256, in authenticate
if not await self._load_login():
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 104, in _load_login
login_url = await self._introduce()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 128, in _introduce
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

Data Archive For further analysis, please add your appliance data archive here (if available) Navigate to Settings -> Device & Services -> Haier hOn -> your device and press the Create Data Archive button. Then open notifications to download the data zip archive. To attach the file:

KameDomotics commented 4 months ago

Is there any way to control appliances locally without using their cloud? Maybe using an ESP like for Midea air conditioners?

bart1604 commented 4 months ago

Is there any way to control appliances locally without using their cloud? Maybe using an ESP like for Midea air conditioners?

Yes there is, take a look at this: https://esphome.io/components/climate/haier.html

Just installed the first one out of four in our home. Works like a charm! But you need some soldering skills

KameDomotics commented 4 months ago

Is there any way to control appliances locally without using their cloud? Maybe using an ESP like for Midea air conditioners?

Yes there is, take a look at this:

https://esphome.io/components/climate/haier.html

Just installed the first one out of four in our home. Works like a charm! But you need some soldering skills

But it's just for air conditioning, I have a washer and a dryer ☹️

mlewando commented 4 months ago

Is there any way to control appliances locally without using their cloud? Maybe using an ESP like for Midea air conditioners?

Yes there is, take a look at this: https://esphome.io/components/climate/haier.html

Just installed the first one out of four in our home. Works like a charm! But you need some soldering skills

Well... Looks like it's not so easy :(

The new generation of ESP32-Haier devices has encryption enabled, so they can only be flashed with firmware that is signed with a private key. There is no way to make them work with ESPHome, so if you try to do it, the board will get into a boot loop

roberglezz commented 4 months ago

Is there any way to control appliances locally without using their cloud? Maybe using an ESP like for Midea air conditioners?

Yes there is, take a look at this: https://esphome.io/components/climate/haier.html Just installed the first one out of four in our home. Works like a charm! But you need some soldering skills

Well... Looks like it's not so easy :(

The new generation of ESP32-Haier devices has encryption enabled, so they can only be flashed with firmware that is signed with a private key. There is no way to make them work with ESPHome, so if you try to do it, the board will get into a boot loop

You just need to use a new ESP32 and not using the existing one.

iNaiks commented 4 months ago

Really interesting the esp32 for haier, but now I can't solder now. Maybe in the winter I will try. Is Andre0512 active on the project? Maybe need help. Any way to make it run again? Thanks!

kevinnmark commented 4 months ago

Hi all, i was able to make addshore version working using homeassistant container, some manual steps are required because simply adding the custom repo to hacs installs the integration but in a state that is not working because it fails building a dependency for pyhon. So here are the detailed steps to make it work: enter the docker container: docker exec -it homeassistant bash then inside the docker container run this command to install required libraries to build all pyhon dependecies: apk add git cmake make clang build-base llvm-static llvm-dev clang-static clang-dev when it finished, manually install addshore pyhon fork: pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156 now you can just continue installing addshore fork of the hon integration adding this repo to hacs: https://github.com/addshore/hon install the integration, enter email and password and voilà, it's working

Worked perfectly for me. Will try out tomorrow and see if it actually updates though.

I can confirm that following this has allowed me to connected to h0n and add my air conditioner

drjakub commented 4 months ago

Hi all, i was able to make addshore version working using homeassistant container, some manual steps are required because simply adding the custom repo to hacs installs the integration but in a state that is not working because it fails building a dependency for pyhon. So here are the detailed steps to make it work: enter the docker container: docker exec -it homeassistant bash then inside the docker container run this command to install required libraries to build all pyhon dependecies: apk add git cmake make clang build-base llvm-static llvm-dev clang-static clang-dev when it finished, manually install addshore pyhon fork: pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156 now you can just continue installing addshore fork of the hon integration adding this repo to hacs: https://github.com/addshore/hon install the integration, enter email and password and voilà, it's working

Worked perfectly for me. Will try out tomorrow and see if it actually updates though.

I can confirm that following this has allowed me to connected to h0n and add my air conditioner

Finally! i can also confirm that using those steps integration is working properly :)

ndom91 commented 4 months ago

Just wanted to chime in and mention that I was also able to fix this finally. I was on 0.14.beta.7 and I couldn't login anymore. So I did the following:

  1. Delete integration
  2. Reboot
  3. Reinstall 0.13.0 from HACS
  4. Go into the homeassistant container, go to custom_components/hon and run pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156
  5. Reboot homeassistant
  6. Readd / login hOn integration

EDIT: Haha okay so ~30s after I posted that I got an error in the logs

2024-07-28 14:17:42.520 ERROR (MainThread) [pyhon.connection.auth] {'error': {'message': "Cannot read properties of undefined (reading 'PersonAccountId')"}}
2024-07-28 14:17:42.520 ERROR (MainThread) [custom_components.hon.hon] Unexpected error fetching 78-21-aa-bb-cc-dd data
...
pyhon.exceptions.HonAuthenticationError

And all entities are now Unknown :joy:

addshore commented 4 months ago

Hi all,

So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo.

As in https://github.com/Andre0512/hon/issues/230#issuecomment-2220528558 the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo. And then select the 0.13.0 beta that I added to it. The only thing it includes is the login fix. https://github.com/addshore/hon/commit/870323abefb7e2b7b1b826ca11a12f5059c27c88

image

This works out of the box for me, I:

KameDomotics commented 4 months ago

Hi all,

So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo.

As in https://github.com/Andre0512/hon/issues/230#issuecomment-2220528558 the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo.

And then select the 0.13.0 beta that I added to it.

The only thing it includes is the login fix.

https://github.com/addshore/hon/commit/870323abefb7e2b7b1b826ca11a12f5059c27c88

image

This works out of the box for me, I:

  • Uninstalled the previous hon integration, leaving the devices and entities etc configured

  • Added my hon repo

  • Installed the 0.13.0 beta release

  • Restarted HA

Unfortunately it doesn't work for me, integration "failed to setup"

addshore commented 4 months ago

Unfortunately it doesn't work for me, integration "failed to setup"

Dam, I might be able to help if you provide additional logs on what is happening for your setup. It could also be that you would also need to re authenticate entirely? Perhaps I did that with some earlier step

SimonCtl commented 4 months ago

Hi all,

So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo.

As in #230 (comment) the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo. And then select the 0.13.0 beta that I added to it. The only thing it includes is the login fix. addshore@870323a

image

This works out of the box for me, I:

  • Uninstalled the previous hon integration, leaving the devices and entities etc configured
  • Added my hon repo
  • Installed the 0.13.0 beta release
  • Restarted HA

Well it didn't worked for me at first. But after another reboot, it finally worked. Thanks !

lacko-hub commented 4 months ago

Hi all,

So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo.

As in #230 (comment) the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo. And then select the 0.13.0 beta that I added to it. The only thing it includes is the login fix. addshore@870323a

image

This works out of the box for me, I:

  • Uninstalled the previous hon integration, leaving the devices and entities etc configured
  • Added my hon repo
  • Installed the 0.13.0 beta release
  • Restarted HA

image

Does not work on my end either - on HA Supervised, core 2024.7.3. Login works correctly in official APP.

Steps I did: Uninstalled all hon apps via HACS/removed rest of files/erased cache/REBOOTed system/installed 0.13.0 beta release

I've also tried manually install pyh0n through terminal -> pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

Still no luck :/ - hOn Authentication Error 1 200

Some additional report: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, 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 256, in authenticate if not await self._load_login(): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 104, in _load_login login_url = await self._introduce() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 128, in _introduce 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

Botap commented 4 months ago

Hi, it doesn't work for me either :-( If I use this integration https://github.com/gvigroux/hon I don't have the login issue but it doesn't provide all the functionality I would like to use. May be looking at this integration might help with a solution?

addshore commented 4 months ago

So, I'll briefly step through how I got to the fix for me (which still appears to be working on my setup on a Pi).

Looking at the auth code. https://github.com/addshore/pyhOn/commit/afb5b8c3ea53ed62e6922f95c8563517e13b9d9c#diff-8548bfc42a8848701a32e05ea48488f674e52ff239c8f02cf8193693c728c399R110-R119

It ends up making a request to a URL that looks something like this...

https://account2.hon-smarthome.com/services/oauth2/authorize/expid_Login?response_type=token+id_token&client_id=3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9.HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6&redirect_uri=hon%3A//mobilesdk/detect/oauth/done&display=touch&scope=api openid refresh_token web&nonce=60d62aca-551e-cc8e-380b-3fcf2ab0c680

Ultimately, this is what the pyHon lib uses to login, and the layout of the HTML codes there is important.

I see the following https://gist.githubusercontent.com/addshore/b8bd609f2b7009e67e3412f8e8f8e7a8/raw/76d7de0b203d12fa6dda4a5600e6a0c79b2071f4/gistfile1.txt

This is passed through a regex until the URL is matched /(?:url|href) ?= ?'(.+?)'/gm for example https://regex101.com/r/uathbB/1

So, the HTML I see matches a url like this /NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%xxx-xxx-xxx-xxx-xxx-xxx-xxx%3D%3D

Which I then simply add https://account2.hon-smarthome.com/s/login/ to the start of.

Everything else currently around login is the same with my alterations. So, at a guess, something regarding this HTML page is different for some people? or in some locations? If anyone could step through the above that would be great, paste the HTML somewhere and or check it against the regex and see what happens.

If you want to check the login using python see this branch, https://github.com/addshore/pyhOn/tree/printingForIssue and the example.py that you can add your username and password to, it will output the URLs and HTML it is looking at as part of the loin process

May be looking at this integration might help with a solution?

For me, this unfortunatly doesnt currently cover my devices

Doktor-X commented 4 months ago

Hi all, So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo. As in #230 (comment) the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo. And then select the 0.13.0 beta that I added to it. The only thing it includes is the login fix. addshore@870323a image This works out of the box for me, I:

  • Uninstalled the previous hon integration, leaving the devices and entities etc configured
  • Added my hon repo
  • Installed the 0.13.0 beta release
  • Restarted HA

image

Does not work on my end either - on HA Supervised, core 2024.7.3. Login works correctly in official APP.

Steps I did: Uninstalled all hon apps via HACS/removed rest of files/erased cache/REBOOTed system/installed 0.13.0 beta release

I've also tried manually install pyh0n through terminal -> pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

Still no luck :/ - hOn Authentication Error 1 200

Some additional report: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, 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 256, in authenticate if not await self._load_login(): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 104, in _load_login login_url = await self._introduce() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 128, in _introduce 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

Did you try edit manifest right after installing addon and then restart HA. For me it works that way

BartVPL commented 4 months ago

Hi all, So given the continued conversation here I made a slight alteration to my fork for now, making a 0.13.0 compatible fixed repo. As in #230 (comment) the easiest way to get this is to add https://github.com/addshore/hon as a custom HACS repo. And then select the 0.13.0 beta that I added to it. The only thing it includes is the login fix. addshore@870323a image This works out of the box for me, I:

  • Uninstalled the previous hon integration, leaving the devices and entities etc configured
  • Added my hon repo
  • Installed the 0.13.0 beta release
  • Restarted HA

Well it didn't worked for me at first. But after another reboot, it finally worked. Thanks !

Done as described step by step, with 2 reboots and still no luck authentication error shows up logs the same as previously.

drjakub commented 4 months ago

for me the most important part was to run

pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

followed by

docker exec -it homeassistant bash

inside home assistant container and to do that first i had to disable protected mode in SSH plugin, then install all dependencies: apk add git cmake make clang build-base llvm-static llvm-dev clang-static clang-dev

Once those were done i installed addshore fork and login worked without any issues and all my devices are now visibne in HA. image image

lacko-hub commented 4 months ago

Reference in new issue

Reference in new issue

Repository hon Title

I've hardly installed required pyh0n version via terminal as mentioned before -> Successfully installed pyhOn-0.17.5 Also it seems like version 0.13.0-beta.1-addshore already contains updated json.

andrewQwer commented 4 months ago

So, I'll briefly step through how I got to the fix for me (which still appears to be working on my setup on a Pi).

Looking at the auth code. addshore/pyhOn@afb5b8c#diff-8548bfc42a8848701a32e05ea48488f674e52ff239c8f02cf8193693c728c399R110-R119

It ends up making a request to a URL that looks something like this...

https://account2.hon-smarthome.com/services/oauth2/authorize/expid_Login?response_type=token+id_token&client_id=3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9.HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6&redirect_uri=hon%3A//mobilesdk/detect/oauth/done&display=touch&scope=api openid refresh_token web&nonce=60d62aca-551e-cc8e-380b-3fcf2ab0c680

Ultimately, this is what the pyHon lib uses to login, and the layout of the HTML codes there is important.

I see the following https://gist.githubusercontent.com/addshore/b8bd609f2b7009e67e3412f8e8f8e7a8/raw/76d7de0b203d12fa6dda4a5600e6a0c79b2071f4/gistfile1.txt

This is passed through a regex until the URL is matched /(?:url|href) ?= ?'(.+?)'/gm for example https://regex101.com/r/uathbB/1

So, the HTML I see matches a url like this /NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%xxx-xxx-xxx-xxx-xxx-xxx-xxx%3D%3D

Which I then simply add https://account2.hon-smarthome.com/s/login/ to the start of.

Everything else currently around login is the same with my alterations. So, at a guess, something regarding this HTML page is different for some people? or in some locations? If anyone could step through the above that would be great, paste the HTML somewhere and or check it against the regex and see what happens.

If you want to check the login using python see this branch, https://github.com/addshore/pyhOn/tree/printingForIssue and the example.py that you can add your username and password to, it will output the URLs and HTML it is looking at as part of the loin process

May be looking at this integration might help with a solution?

For me, this unfortunatly doesnt currently cover my devices

I have the following response:

2024-07-29 10:46:59.225 ERROR (MainThread) [pyhon.connection.auth] hOn Authentication Error
1 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZEC0j7rMDAwMDAwMDAwMDAwMDAwAAAA-sgx_Bh1imPThpE7SKhEBRA5F-lilcRqkON8f3Pdw88EKjdaTw2011u6pK6PdjOAyAXHSB69i0Pgl22mYIDdeSizZ3LGU7YVKsE_AlPY8AR-gPLBypDui7ExhFdGM56FhoTNC06RdAS8GuRhFpPuh4y3iD48qAIqNAiH059a0f-SUFXJ1EFFVcLiji_861BypkWRScbRFo3zSorkehADGSmc3SFlkiEA8TPYj85BsS5H4B9tuKeLNMJzuoPYZ7rJbWkhYUpSm4a68JQMQgd9E4Ec90Quftl4oejg3p3MaNDfJwnMkj1_Qev60IR-Ri9WPLsewEf2nR8AO7CAEDyFnwexp_hJSPo9dyYuxWV7ZGRfIe50KeDGvLBirN2umiHSN5tpivEfokFTC_VMKmio2e9rQ-sUg93Kfq-3e9da5mhslfZSk6yEalrYH_B8JAOy16yfQsvbeMxqSXQ7IKxmRAbUXRhgIGYNb5XnuKG7wkGAXE5DY5Bnq0KOC1MmueOSMrhEM8uoLBdwY-NnZrzMkIoimpSfY85h6pGetnrG1r6uZH4qg_BmUMmQo-APtGG1a4oe6Z0IBaI-PqwZmzwci78MasYA-zGTYmpNaZLtZQNHj4g3-MlHAYtk2P9wmPiLdOD-8xEJIOUMNK28-bJjGRWfWx8_Suu4fh1s3RI6bnOTIGOxyVvOqRS4J8ewS3aWHGYWSlYYljczS1EfXqCpd-0ECKuvK-ZjRp5m4qOJB52r0sXmExh6wE0qupI7TvtaXA%253D%253D%26display%3Dtouch
ERROR - 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZEC0j7rMDAwMDAwMDAwMDAwMDAwAAAA-sgx_Bh1imPThpE7SKhEBRA5F-lilcRqkON8f3Pdw88EKjdaTw2011u6pK6PdjOAyAXHSB69i0Pgl22mYIDdeSizZ3LGU7YVKsE_AlPY8AR-gPLBypDui7ExhFdGM56FhoTNC06RdAS8GuRhFpPuh4y3iD48qAIqNAiH059a0f-SUFXJ1EFFVcLiji_861BypkWRScbRFo3zSorkehADGSmc3SFlkiEA8TPYj85BsS5H4B9tuKeLNMJzuoPYZ7rJbWkhYUpSm4a68JQMQgd9E4Ec90Quftl4oejg3p3MaNDfJwnMkj1_Qev60IR-Ri9WPLsewEf2nR8AO7CAEDyFnwexp_hJSPo9dyYuxWV7ZGRfIe50KeDGvLBirN2umiHSN5tpivEfokFTC_VMKmio2e9rQ-sUg93Kfq-3e9da5mhslfZSk6yEalrYH_B8JAOy16yfQsvbeMxqSXQ7IKxmRAbUXRhgIGYNb5XnuKG7wkGAXE5DY5Bnq0KOC1MmueOSMrhEM8uoLBdwY-NnZrzMkIoimpSfY85h6pGetnrG1r6uZH4qg_BmUMmQo-APtGG1a4oe6Z0IBaI-PqwZmzwci78MasYA-zGTYmpNaZLtZQNHj4g3-MlHAYtk2P9wmPiLdOD-8xEJIOUMNK28-bJjGRWfWx8_Suu4fh1s3RI6bnOTIGOxyVvOqRS4J8ewS3aWHGYWSlYYljczS1EfXqCpd-0ECKuvK-ZjRp5m4qOJB52r0sXmExh6wE0qupI7TvtaXA%253D%253D%26display%3Dtouch
=============== Response ===============
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>
function redirectOnLoad() {
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZEC0j7rMDAwMDAwMDAwMDAwMDAwAAAA-sgx_Bh1imPThpE7SKhEBRA5F-lilcRqkON8f3Pdw88EKjdaTw2011u6pK6PdjOAyAXHSB69i0Pgl22mYIDdeSizZ3LGU7YVKsE_AlPY8AR-gPLBypDui7ExhFdGM56FhoTNC06RdAS8GuRhFpPuh4y3iD48qAIqNAiH059a0f-SUFXJ1EFFVcLiji_861BypkWRScbRFo3zSorkehADGSmc3SFlkiEA8TPYj85BsS5H4B9tuKeLNMJzuoPYZ7rJbWkhYUpSm4a68JQMQgd9E4Ec90Quftl4oejg3p3MaNDfJwnMkj1_Qev60IR-Ri9WPLsewEf2nR8AO7CAEDyFnwexp_hJSPo9dyYuxWV7ZGRfIe50KeDGvLBirN2umiHSN5tpivEfokFTC_VMKmio2e9rQ-sUg93Kfq-3e9da5mhslfZSk6yEalrYH_B8JAOy16yfQsvbeMxqSXQ7IKxmRAbUXRhgIGYNb5XnuKG7wkGAXE5DY5Bnq0KOC1MmueOSMrhEM8uoLBdwY-NnZrzMkIoimpSfY85h6pGetnrG1r6uZH4qg_BmUMmQo-APtGG1a4oe6Z0IBaI-PqwZmzwci78MasYA-zGTYmpNaZLtZQNHj4g3-MlHAYtk2P9wmPiLdOD-8xEJIOUMNK28-bJjGRWfWx8_Suu4fh1s3RI6bnOTIGOxyVvOqRS4J8ewS3aWHGYWSlYYljczS1EfXqCpd-0ECKuvK-ZjRp5m4qOJB52r0sXmExh6wE0qupI7TvtaXA%3D%3D'); } else
if (window.location.replace){
window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZEC0j7rMDAwMDAwMDAwMDAwMDAwAAAA-sgx_Bh1imPThpE7SKhEBRA5F-lilcRqkON8f3Pdw88EKjdaTw2011u6pK6PdjOAyAXHSB69i0Pgl22mYIDdeSizZ3LGU7YVKsE_AlPY8AR-gPLBypDui7ExhFdGM56FhoTNC06RdAS8GuRhFpPuh4y3iD48qAIqNAiH059a0f-SUFXJ1EFFVcLiji_861BypkWRScbRFo3zSorkehADGSmc3SFlkiEA8TPYj85BsS5H4B9tuKeLNMJzuoPYZ7rJbWkhYUpSm4a68JQMQgd9E4Ec90Quftl4oejg3p3MaNDfJwnMkj1_Qev60IR-Ri9WPLsewEf2nR8AO7CAEDyFnwexp_hJSPo9dyYuxWV7ZGRfIe50KeDGvLBirN2umiHSN5tpivEfokFTC_VMKmio2e9rQ-sUg93Kfq-3e9da5mhslfZSk6yEalrYH_B8JAOy16yfQsvbeMxqSXQ7IKxmRAbUXRhgIGYNb5XnuKG7wkGAXE5DY5Bnq0KOC1MmueOSMrhEM8uoLBdwY-NnZrzMkIoimpSfY85h6pGetnrG1r6uZH4qg_BmUMmQo-APtGG1a4oe6Z0IBaI-PqwZmzwci78MasYA-zGTYmpNaZLtZQNHj4g3-MlHAYtk2P9wmPiLdOD-8xEJIOUMNK28-bJjGRWfWx8_Suu4fh1s3RI6bnOTIGOxyVvOqRS4J8ewS3aWHGYWSlYYljczS1EfXqCpd-0ECKuvK-ZjRp5m4qOJB52r0sXmExh6wE0qupI7TvtaXA%3D%3D');
} else {
window.location.href ='/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZEC0j7rMDAwMDAwMDAwMDAwMDAwAAAA-sgx_Bh1imPThpE7SKhEBRA5F-lilcRqkON8f3Pdw88EKjdaTw2011u6pK6PdjOAyAXHSB69i0Pgl22mYIDdeSizZ3LGU7YVKsE_AlPY8AR-gPLBypDui7ExhFdGM56FhoTNC06RdAS8GuRhFpPuh4y3iD48qAIqNAiH059a0f-SUFXJ1EFFVcLiji_861BypkWRScbRFo3zSorkehADGSmc3SFlkiEA8TPYj85BsS5H4B9tuKeLNMJzuoPYZ7rJbWkhYUpSm4a68JQMQgd9E4Ec90Quftl4oejg3p3MaNDfJwnMkj1_Qev60IR-Ri9WPLsewEf2nR8AO7CAEDyFnwexp_hJSPo9dyYuxWV7ZGRfIe50KeDGvLBirN2umiHSN5tpivEfokFTC_VMKmio2e9rQ-sUg93Kfq-3e9da5mhslfZSk6yEalrYH_B8JAOy16yfQsvbeMxqSXQ7IKxmRAbUXRhgIGYNb5XnuKG7wkGAXE5DY5Bnq0KOC1MmueOSMrhEM8uoLBdwY-NnZrzMkIoimpSfY85h6pGetnrG1r6uZH4qg_BmUMmQo-APtGG1a4oe6Z0IBaI-PqwZmzwci78MasYA-zGTYmpNaZLtZQNHj4g3-MlHAYtk2P9wmPiLdOD-8xEJIOUMNK28-bJjGRWfWx8_Suu4fh1s3RI6bnOTIGOxyVvOqRS4J8ewS3aWHGYWSlYYljczS1EfXqCpd-0ECKuvK-ZjRp5m4qOJB52r0sXmExh6wE0qupI7TvtaXA%3D%3D';
}
}
redirectOnLoad();
</script>
</head>
</html>
========================================
2024-07-29 10:46:59.225 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ***@gmail.com for hon
lacko-hub commented 4 months ago

for me the most important part was to run

pip install pyhOn@git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

followed by

docker exec -it homeassistant bash

inside home assistant container and to do that first i had to disable protected mode in SSH plugin, then install all dependencies: apk add git cmake make clang build-base llvm-static llvm-dev clang-static clang-dev

Once those were done i installed addshore fork and login worked without any issues and all my devices are now visibne in HA. image image

Yeah that was of course the first step but not from HA SSH addon, however directly accessed docker from terminal on running Linux distro. It seems like I've all dependencies + actual pyh0n version correct. System returns for all listing 'Requirement already satisfied' but still no luck.

BartVPL commented 4 months ago

Done all the steps with pyHon install via terminal described above, installed hon with addshore no luck still authentication issue. Seems the integration does not have sense here due to lack of support from thw author.

addshore commented 4 months ago

Also it seems like version 0.13.0-beta.1-addshore already contains updated json.

Indeed

I have the following response:

@andrewQwer that HTML looks fine, and matches the regex for my fix. The only thing that I can assume for you is that the python code for auth has not updated to the version with the fix for one reason or another.

I really don't know much about the home assistant internals and how it deals with all of this integration packaging stuff and dependencies :/

andrewQwer commented 4 months ago

Also it seems like version 0.13.0-beta.1-addshore already contains updated json.

Indeed

I have the following response:

@andrewQwer that HTML looks fine, and matches the regex for my fix. The only thing that I can assume for you is that the python code for auth has not updated to the version with the fix for one reason or another.

I really don't know much about the home assistant internals and how it deals with all of this integration packaging stuff and dependencies :/

I use the latest beta version just in case: image

addshore commented 4 months ago

I use the latest beta version just in case:

As far as I know the 0.14.0 versions might have other issues.

Hence the release of a 0.13.0 beta version which includes the fix as well!

lacko-hub commented 4 months ago

Also it seems like version 0.13.0-beta.1-addshore already contains updated json.

Indeed

I have the following response:

@andrewQwer that HTML looks fine, and matches the regex for my fix. The only thing that I can assume for you is that the python code for auth has not updated to the version with the fix for one reason or another.

I really don't know much about the home assistant internals and how it deals with all of this integration packaging stuff and dependencies :/

Current pyh0n version is present in my system.

image

Interesting that https://github.com/gvigroux/hon extension can login correctly, however it contains sensors only, without possibility actively work with loaded devices.

bduartept commented 4 months ago

Also it seems like version 0.13.0-beta.1-addshore already contains updated json.

Indeed

I have the following response:

@andrewQwer that HTML looks fine, and matches the regex for my fix. The only thing that I can assume for you is that the python code for auth has not updated to the version with the fix for one reason or another. I really don't know much about the home assistant internals and how it deals with all of this integration packaging stuff and dependencies :/

Current pyh0n version is present in my system.

image

Interesting that https://github.com/gvigroux/hon extension can login correctly, however it contains sensors only, without possibility actively work with loaded devices.

I'm unable to login also with 0.13.0-beta1-addshore but with this gvigroux 0.7.4 repository (https://github.com/gvigroux/hon) i can login without any problem's.. unfortunately this repo just have sensor's.

lacko-hub commented 4 months ago

I was able to successfully login via 0.13.0-beta1-addshore version with these steps:

-> installed gvigroux version [0.7.4] / restart -> logged with gvigroux version [0.7.4] -> installed 0.13.0-beta1-addshore version /restart -> logged out from gvigroux version [0.7.4] -> removed gvigroux version [0.7.4] with HACS / no restart -> redownload previously installed 0.13.0-beta1-addshore version with HACS / no restart -> logged in with installed 0.13.0-beta1-addshore version

Guess it works thanks to pycache, but it works also after reboot.

image

KameDomotics commented 4 months ago

I was able to successfully login via 0.13.0-beta1-addshore version with these steps:

-> installed gvigroux version [0.7.4] / restart

-> logged with gvigroux version [0.7.4]

-> installed 0.13.0-beta1-addshore version /restart

-> logged out from gvigroux version [0.7.4]

-> removed gvigroux version [0.7.4] with HACS / no restart

-> redownload previously installed 0.13.0-beta1-addshore version with HACS / no restart

-> logged in with installed 0.13.0-beta1-addshore version

Guess it works thanks to pycache, but it works also after reboot.

image

Sorry, I followed these steps but it still doesn't work

Logger: homeassistant.config_entries
Source: config_entries.py:575
First occurred: 17:29:51 (2 occurrences)
Last logged: 17:31:06

Error setting up entry xxxxxx@gmail.com 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 256, in authenticate
    if not await self._load_login():
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 104, in _load_login
    login_url = await self._introduce()
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 128, in _introduce
    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
Triskae commented 4 months ago

Do you guys think this issue is related to recent problems with Haier Europe and this integration ? I'm kinda of worried about Andre0512, he is not active since a long, I hope he's doing fine

addshore commented 4 months ago

@KameDomotics

Sorry, I followed these steps but it still doesn't work

File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 256, in authenticate

This line shows me that you are not on the patched version of the python dependency. Even though, you should be given the version of the integration that you are running.

Line 256 matches the old code https://github.com/addshore/pyhOn/blob/main/pyhon/connection/auth.py#L256 and not the new code https://github.com/addshore/pyhOn/blob/updatedLogin/pyhon/connection/auth.py#L256

I would expect HA to just install the correct dependencies? But apparently it doesn't always do that, and also doen't tell you? I wonder if there are any additional logs hidden anywhere from install time of the integration?

paulmeyer2503 commented 4 months ago

After todays Core-Update 0.13.0-beta.1-addshore is working for me.

dannybosman commented 4 months ago

After todays Core-Update 0.13.0-beta.1-addshore is working for me.

I can confirm! Works like a charm again (im on 0.14.0-beta.7)

bduartept commented 4 months ago

I can confirm also, after HAOS core update 2024.7.4 the repro 0.13.0-beta.1-addshore is working fine

KameDomotics commented 4 months ago

So with version 2024.5.4 it can't work? I haven't updated yet because I'm fixing other issues

andrewQwer commented 4 months ago

Works on my side as well after HA updates.

Michelvd91 commented 4 months ago

I can confirm to! After the core update it works again! 0.13.0-beta.1-addshore.

iNaiks commented 4 months ago

Hi, tried to install addshore 13.1 and HA 2024.7.4. But didn't work. Need to install something else? or in the future will be updated automatically?

thanks

jotheman0303 commented 4 months ago

I uninstalled both Andre as well as gvigroux's integrations and reinstalled your version addshore and all is well with the world again!

I'm really happy about this, thanks for all the effort in fixing this! I do hope Andre is OK, but I appreciate you picking up the holy work 😉

KameDomotics commented 4 months ago

It doesn't work for me, I tried and tried again several times, even restarting the host. It doesn't work.

iNaiks commented 4 months ago

It doesn't work for me, I tried and tried again several times, even restarting the host. It doesn't work.

Same for me

andrewQwer commented 4 months ago

It doesn't work for me, I tried and tried again several times, even restarting the host. It doesn't work.

Did you install 0.13.0-beta.1-addshore or 0.14.beta after ha updated to the latest version? I updated HA core to the latest version when 0.14.beta was already installed and it worked.

Z4RR0 commented 4 months ago

hi, for me worked this step.

1) i removed previous hon integration 2) restart ha and update core last version 3) added on hacs addshore github and installed 0.13 beta 4) restart ha 5) added device and work!!

thank's addshore!

Il giorno mer 31 lug 2024 alle ore 09:05 Andrey Karavaychik < @.***> ha scritto:

It doesn't work for me, I tried and tried again several times, even restarting the host. It doesn't work.

Did you install 0.13.0-beta.1-addshore or 0.14.beta after ha updated to the latest version? I updated HA core to the latest version when 0.14.beta was already installed and it worked.

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

Triskae commented 4 months ago

Yey !! I can confirm too ! 0.13.0-beta.1-addshore. 🎉

KameDomotics commented 4 months ago

So it's a Home Assistant issue, not a hOn integration issue...

addshore commented 4 months ago

So it's a Home Assistant issue, not a hOn integration issue...

No, i don't believe so, the original issue was something to do with the underlying login of the hOn integration.

That is fixed by the 2x betas that I patched.

However, these then also for some reason broke due to a change in HA? Which is now fixed?

KameDomotics commented 4 months ago

However

I only have beta 1 in Hacs, have you released a new version?

addshore commented 4 months ago

I only have beta 1 in Hacs, have you released a new version?

The only things I have done is 0.14.0-beta.8-addshore and 0.13.0-beta.1-addshore

KameDomotics commented 4 months ago

I only have beta 1 in Hacs, have you released a new version?

The only things I have done is 0.14.0-beta.8-addshore and 0.13.0-beta.1-addshore

Even installing 0.14 beta 8 still installs 0.13 beta 1. I wanted to try beta 8, but I give up, I've already tried too many times.