Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
48mWsPK opened this issue Jul 9, 2024 · 175 comments
Open

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

48mWsPK opened this issue Jul 9, 2024 · 175 comments
Assignees
Labels
bug Something isn't working

Comments

@48mWsPK
Copy link

48mWsPK commented Jul 9, 2024

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):

  • Home Assistant Version: 2024.7.1
  • hOn Integration Version: tryied both v0.13.0 and v0.14.0-beta7
  • pyhOn Version - not sure - whatever the hon HA integration comes with

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:

  • GitHub Web: Use the "Attach files by dragging & dropping, selecting or pasting them." function
  • GitHub Mobile: Upload the zip archive as image
@48mWsPK 48mWsPK added the bug Something isn't working label Jul 9, 2024
@leits
Copy link

leits commented Jul 9, 2024

The issue also occurs when reloading an existing integration.

I delved a little into the error and the issue is here: https:/Andre0512/pyhOn/blob/63752e13d6c8e74284ad72e04306e9fedde58b40/pyhon/connection/auth.py#L123
The response for redirect link is now differs from expected.

@DissiNL
Copy link

DissiNL commented Jul 9, 2024

I've got the exact same issue since today. I'll be able to try something for this on Thursday sadly.

@zawadzkipiter
Copy link
Contributor

same here - Haier did some extra redirection I guess to kill existing intergation.

@addshore
Copy link

addshore commented Jul 9, 2024

Also same here after reloading the integration

@arkadi222
Copy link

the same :(

@Z4RR0
Copy link

Z4RR0 commented Jul 10, 2024

same also for me

@48mWsPK
Copy link
Author

48mWsPK commented Jul 10, 2024

Hi, @ALL!

To be honest - I am kind of worried what is happening to @Andre0512 :
His last comments are dated end of March, and last activity on GitHub is from April:
image

I hope all is good for Andre.

@leits - any ideas what we can change to make this work?

@zawadzkipiter
Copy link
Contributor

zawadzkipiter commented Jul 10, 2024

Any Python expert here? I specialise in Java so code in auth.py is kind of spagetti code for me.
in line:

  url = f"{const.AUTH_API}/services/oauth2/authorize/expid_Login?{params_encode}"
        async with self._request.get(url) as response:
            text = await response.text()

text is now:

<!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%3DCAAAAZChOZbAMDAwMDAwMDAwMDA...'); }  else
            if (window.location.replace){
                window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZChOZbAMDAw....');
            } else {
                window.location.href ='/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZChOZbAMDAwMDAwMDA....';
            }
        }
        redirectOnLoad();
    </script>
</head>
</html>

so it clearly does not have:
url = '(.+?)
any idea how it looked before ?
I tried to redirect like:

            redirect2 = re.findall("window.location.replace\('(.+?)'", text)
            async with self._request.get(f"{const.AUTH_API}" + redirect2[0], allow_redirects=True) as response:
                text2 = await response.text()

but It return main login HTML page.
Any idea how it worked before - I dont think anyone despite of Andre would know. Kinda bummer.

@Kfrard
Copy link

Kfrard commented Jul 10, 2024

Does anyone of you have v0.14.0-beta.7 installed and can tell if the same error occurs?
A push API has been implemented there, maybe it will solve our error.

@zawadzkipiter
Copy link
Contributor

the problem is not with hon but with pyhon lib underneath hon.

@addshore
Copy link

Does anyone of you have v0.14.0-beta.7 installed and can tell if the same error occurs? A push API has been implemented there, maybe it will solve our error.

I tried this just in case, but no, not working using this version for me

2024-07-10 11:55:45.400 ERROR (MainThread) [pyhon.connection.auth] hOn Authentication Error
1 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?sourcexxxx
ERROR - 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?sourcexxxx
if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsourcexxxx'); } else
window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsourcexxxx');
window.location.href ='/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsourcexxxxx';
2024-07-10 11:55:45.401 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry [email protected] for hon
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
File "/usr/local/lib/python3.12/site-packages/pyhon/hon.py", line 104, in setup
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__
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/base.py", line 64, in get
File "/usr/local/lib/python3.12/contextlib.py", line 210, in __aenter__
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 75, in _intercept
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/handler/hon.py", line 64, in _check_headers
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 256, in authenticate
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 104, in _load_login
File "/usr/local/lib/python3.12/site-packages/pyhon/connection/auth.py", line 128, in _introduce
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

@edmund-1
Copy link

Does anyone of you have v0.14.0-beta.7 installed and can tell if the same error occurs? A push API has been implemented there, maybe it will solve our error.

Same issues with betas:

image

addshore added a commit to addshore/pyhOn that referenced this issue Jul 10, 2024
@Z4RR0
Copy link

Z4RR0 commented Jul 10, 2024 via email

addshore added a commit to addshore/hon that referenced this issue Jul 10, 2024
@edmund-1
Copy link

edmund-1 commented Jul 10, 2024

@zawadzkipiter , where can I find the pyhOn auth.py file?

@addshore
Copy link

So Andre0512/pyhOn#29 fixes the login in the python package for me
I tried folding that into a fork version of the integration for folks to use, but I'm not really sure what I am doing there :D

Anyway, these small changes should work for you https:/Andre0512/pyhOn/pull/29/files
And the python package is installable via pyhOn @ git+https:/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

@Beunhaaz
Copy link

I'm having the exact same issue on both 0.13 and 0.14 beta 7

@zawadzkipiter
Copy link
Contributor

@addshore hero! How did you reach Andre ?

@edmund-1
Copy link

edmund-1 commented Jul 10, 2024

So Andre0512/pyhOn#29 fixes the login in the python package for me I tried folding that into a fork version of the integration for folks to use, but I'm not really sure what I am doing there :D

Anyway, these small changes should work for you https:/Andre0512/pyhOn/pull/29/files And the python package is installable via pyhOn @ git+https:/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

@addshore , on my end fails with:

usage: pyhOn [-h] [-u USER] [-p PASSWORD] [-i [IMPORT]] COMMAND ...
pyhOn: error: argument COMMAND: invalid choice: '@' (choose from 'keys', 'export', 'translate')

@addshore
Copy link

addshore commented Jul 10, 2024

@addshore , on my end fails with:

usage: pyhOn [-h] [-u USER] [-p PASSWORD] [-i [IMPORT]] COMMAND ... pyhOn: error: argument COMMAND: invalid choice: '@' (choose from 'keys', 'export', 'translate')

Sorry, this is how you would define pyhOn in integration
See addshore@c5cff77 for example
I'm not actually sure the best way to update this within HA just yet :)

@terierul
Copy link

terierul commented Jul 10, 2024

same issue to me after I have updated HA to the last core 1h ago and restarted

LE - did someone tried to reset the pass in HOS web site and delete the integration and re-added in HASS?

@edmund-1
Copy link

edmund-1 commented Jul 10, 2024

@addshore , on my end fails with:
usage: pyhOn [-h] [-u USER] [-p PASSWORD] [-i [IMPORT]] COMMAND ... pyhOn: error: argument COMMAND: invalid choice: '@' (choose from 'keys', 'export', 'translate')

Sorry, this is how you would define pyhOn in integration See addshore@c5cff77 for example I'm not actually sure the best way to update this within HA just yet :)

@addshore, I manually edited /usr/lib/python3.12/site-packages/pyhon/connection/auth.py with your changes,
image

and the washing machine can be query:
image

however, Haier integration still fails to setup:
image

and log details:
image

image

Note: I never had this integration installed before. Founded it yesterday, when the issue was there already.

@jimiflowers
Copy link

same here

@edmund-1
Copy link

same issue to me after I have updated HA to the last core 1h ago and restarted

LE - did someone tried to reset the pass in HOS web site and delete the integration and re-added in HASS?

Most probably it will have the same result. I never used this integration before, and have the issue, even after manually applying @addshore "fix" on pyhOn.
Ref: https:/Andre0512/pyhOn/pull/29/files

@dm-christian
Copy link

I think ill wait for pyhon version officially went up to 0.17.5.

I tried that changes but didnt get it to run.

I bypassed the login process for now and injected the "access_token" "refresh_token" text manually in the auth.py. that works for now.

@addshore
Copy link

So, I addshore@c5cff77 currently installed, and it all appears to be working for me now, but it did require an additional restart of HA too?

image

If you want to do this the "easy" way, you can add https:/addshore/hon as a custom HACS repo, and then use the 0.14.0-beta.8-addshore release that should be available, which has the updated python dependency.
Or you can go for what @dm-christian mentioned above.

Ultimately, i dont plan on maintaining this fork / release / repo, so I hope it gets released here too :)

@addshore
Copy link

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
Copy link

However

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

@addshore
Copy link

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
Copy link

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.

@FelipeSanchezCalzada
Copy link

In my case I made the mistake of installing version 0.13.0 (not beta) and the python packages were stuck even when installing 0.13.0 beta. I had to restore backup made with Proxmox from a few hours earlier. I couldn't disable the python cache, although it's probably a simple thing.

I can confirm that the 0.13.0-beta.1-addshore works if you install it at first.

Thanks addshore and [Andre0512](https:/Andre0512 for this work of art. Plase Haier, pay this two developers some bills and stop going against them, this integration is the only reason I bought Haier.

@BartVPL
Copy link

BartVPL commented Aug 1, 2024

Guys,
Can anyone tell me how to proceed step-by-step?
I've restored my HA before I made any fixes mentioned and now I just need info from where to start.
Remove official add-on amd then after restart install addshore one? Any additinal thinga I need to do?

Edit.
Okay I removed old version, removed all entities, installed addshore (does not work on core 6.4) updated to 7.4 and magic happens it started to work like a charm. Unfortunately weather chart stopped to work at all blank lovelace page appears no idea how it's connected nevertheless haier is more important than lovelace :-) Thanks for all of your support!!!

@mf76130
Copy link

mf76130 commented Aug 2, 2024

Just got my new Haier Dryer yesterday and of course nothing worked in HA.
So i installed the addshore(0.14.0 beta8), configured it - not working.
Downgraded HA to version 2024.6.4 using this command ha core update --version=2024.6.4
And the integration works.
Then upgraded back to the newest HA version 2024.7.4 and it all still works.

@gioefede90
Copy link

is there any way to let it work without downgrading HA?
i've already the 2024.7.4 with addshore 0.13.0-beta-1 but it doesn't work, this is my manifest:

QUOTE
{
"domain": "hon",
"name": "Haier hOn",
"codeowners": [
"@Andre0512"
],
"config_flow": true,
"documentation": "https:/Andre0512/hon/",
"iot_class": "cloud_polling",
"issue_tracker": "https:/Andre0512/hon/issues",
"requirements": [
"pyhOn @ git+https:/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156"
],
"version": "0.13.0-beta.1-addshore"
}
UNQUOTE

@mf76130
Copy link

mf76130 commented Aug 2, 2024

Downgrade is pretty easy and doesn't take long. 5min downgrade and 5 min Upgrade

@edmund-1
Copy link

edmund-1 commented Aug 2, 2024

I had an issue with hOn app on Android as well. The app is so well designed that you must share credentials if the appliance is used by more than one family member. => security sucks.
Because I am using hOn integration (the other one, https:/gvigroux/hon ), and because me and my wife are using hOn on Android for our washing machine, after few days the appliance disappear from the app.
I opened a ticket with Haier Europe and apparently, they introduced a limit of 5 different devices that can use one account. For hOn on Android this is not a problem, most probably a flag is being used to not create a new device each time user logon, but this flag is not being used by hOn HA integration and here is the issue.
After few days, the issue in hOn on Android is back, apparently because of HA integration.
Workaround: In my case, cycle logging from hOn on Android (log off / log on) solved the issue, and the appliance is back.

Note
Maybe this information will help @addshore for a permanent fix.

email received from Haier Europe Support, translated from Romanian:
dear customer,

On the system we see that he only has two smartphones connected that he uses, but we see that he also started using the Home Assistant plugin that created the problem you described.

This is because you can have a maximum of 5 devices connected at the same time, the 6th will disconnect the first device.

Every time you use the Home Assistant plugin, it "adds" a connecting device and disconnects one of your two phones.

We have cleaned your account and created a "clean" situation, please update the Home Assistant plugin and try again.

Please note that in this case we cannot help you as this is not our plugin and we cannot make changes to solve problems with it.

Let us know.

Greetings,
Haier Europe

@jm314159
Copy link

jm314159 commented Aug 2, 2024

[...] I opened a ticket with Haier Europe and apparently, they introduced a limit of 5 different devices that can use one account.

Have you noticed #157 by chance, followed by the description of the release v0.13.0? Do you mean that release has not resolved the issue?

@kubasaw
Copy link

kubasaw commented Aug 9, 2024

for me the most important part was to run

pip install pyhOn@git+https:/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.

Burdening the target machine with additional dependencies like clang just for the purpose of compiling a package isn't very efficient. It's much better to cross-compile the package on a more powerful machine and then install the precompiled package on the target machine.

This compilation issue started with the introduction of the awsiotsdk package in Python, which is used only for communication with Haier servers using the MQTT protocol. I forked Andre0512's repositories, replaced this library with the standard paho-mqtt client used in Home Assistant, and it seems to be working stably without unnecessarily burdening Haier's servers with requests.

https:/IoTLabs-pl/hon

You might encounter issues because Home Assistant does not reinstallf the pyhOn package if there is some version installed. To address this, you can run the following command on your host machine:

docker exec homeassistant pip uninstall pyhOn -y

This ensures that after the next reboot, the forked version of pyhOn will be installed instead of attempting to use the older, previously installed version.

@deezid
Copy link

deezid commented Aug 9, 2024

for me the most important part was to run
pip install pyhOn@git+https:/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.

Burdening the target machine with additional dependencies like clang just for the purpose of compiling a package isn't very efficient. It's much better to cross-compile the package on a more powerful machine and then install the precompiled package on the target machine.

This compilation issue started with the introduction of the awsiotsdk package in Python, which is used only for communication with Haier servers using the MQTT protocol. I forked Andre0512's repositories, replaced this library with the standard paho-mqtt client used in Home Assistant, and it seems to be working stably without unnecessarily burdening Haier's servers with requests.

https:/IoTLabs-pl/hon

You might encounter issues because Home Assistant does not reinstallf the pyhOn package if there is some version installed. To address this, you can run the following command on your host machine:

docker exec homeassistant pip uninstall pyhOn -y

This ensures that after the next reboot, the forked version of pyhOn will be installed instead of attempting to use the older, previously installed version.

Sounds good. Would you be able to do version 0.13 as well?
0.14 doesn't seem to work for most people.

@danyeet
Copy link

danyeet commented Aug 9, 2024

Has anybody tried with HA version 2024.8.0 ?
Dunno if it causes issues (doesn't seem to work with any of the last few repos in the comments.)

@Doktor-X
Copy link

Doktor-X commented Aug 9, 2024

Has anybody tried with HA version 2024.8.0 ? Dunno if it causes issues (doesn't seem to work with any of the last few repos in the comments.)

Works just fine

@danyeet
Copy link

danyeet commented Aug 9, 2024

Has anybody tried with HA version 2024.8.0 ? Dunno if it causes issues (doesn't seem to work with any of the last few repos in the comments.)

Works just fine

Running it in a Home Assistant VM (in proxmox) fixed it it seems.

@albertopizzorno
Copy link

Hi guys, I'm a beginner with HA, I read the 200 answers but, in money, I didn't understand what to do... I have the (non-beta) version installed by HACS.. What should I do to make it work?

@KameDomotics
Copy link

for me the most important part was to run

pip install pyhOn@git+https:/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.

Burdening the target machine with additional dependencies like clang just for the purpose of compiling a package isn't very efficient. It's much better to cross-compile the package on a more powerful machine and then install the precompiled package on the target machine.

This compilation issue started with the introduction of the awsiotsdk package in Python, which is used only for communication with Haier servers using the MQTT protocol. I forked Andre0512's repositories, replaced this library with the standard paho-mqtt client used in Home Assistant, and it seems to be working stably without unnecessarily burdening Haier's servers with requests.

https:/IoTLabs-pl/hon

You might encounter issues because Home Assistant does not reinstallf the pyhOn package if there is some version installed. To address this, you can run the following command on your host machine:

docker exec homeassistant pip uninstall pyhOn -y

This ensures that after the next reboot, the forked version of pyhOn will be installed instead of attempting to use the older, previously installed version.

Sounds good. Would you be able to do version 0.13 as well?

0.14 doesn't seem to work for most people.

I tried the command in HomeAssistant SSH Terminal, but I get this error:

image

@Doktor-X
Copy link

Doktor-X commented Aug 9, 2024

I dont run homeassistent OS, i use supervise install on armbian tv box, so i cant be 100% shure but i think that you dont have docker install

@KameDomotics
Copy link

I have Home Assistant OS on Raspberry

@quifago
Copy link

quifago commented Aug 10, 2024

https:/IoTLabs-pl/hon

You might encounter issues because Home Assistant does not reinstallf the pyhOn package if there is some version installed. To address this, you can run the following command on your host machine:

docker exec homeassistant pip uninstall pyhOn -y

It work well for me! thanks @kubasaw

@iNaiks
Copy link

iNaiks commented Aug 11, 2024

How to run "docker exec homeassistant pip uninstall pyhOn -y" with HA OS on Proxmox?. Can't use the integration for a wile...

@arthanoss
Copy link

How to run "docker exec homeassistant pip uninstall pyhOn -y" with HA OS on Proxmox?.

@KameDomotics @iNaiks use the "Advanced SSH & Web Terminal" addon from Home Assistant Community Add-ons instead of the official "Terminal & SSH". You'll also have to disable protection mode in addon settings.

@iNaiks
Copy link

iNaiks commented Aug 11, 2024

How to run "docker exec homeassistant pip uninstall pyhOn -y" with HA OS on Proxmox?.

@KameDomotics @iNaiks use the "Advanced SSH & Web Terminal" addon from Home Assistant Community Add-ons instead of the official "Terminal & SSH". You'll also have to disable protection mode in addon settings.

It worked! Thanks!
All working with the add shore 13.1 beta

Any plan to update the package of @Andre0512 ?

Also I've done this to be working:

Frist remove the pyhOn package "docker exec homeassistant pip uninstall pyhOn -y"
Then the steps above:

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:/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

now you can just continue installing addshore fork of the hon integration adding this repo to hacs:

https:/addshore/hon

install the integration, enter email and password and voilà, it's working

PS: Tried with repository of @Andre0512 and didn't work... Where are you @Andre0512 !!!!

@KameDomotics
Copy link

KameDomotics commented Aug 11, 2024

Now everything works! Thank you so much for your precious help
@kubasaw @arthanoss

@kubasaw
Copy link

kubasaw commented Aug 12, 2024

To sum up:
Haier changed their login page, which caused the pyhOn library to fail when attempting to log in on behalf of the user. @addshore fixed this issue and released the pyhOn library with two tags: 0.14.0-beta.8-addshore and 0.13.0-beta.1-addshore. In order to install hon component with patched communication library you will need add its URL as custom repository in HACS.

The 0.13 library is essentially the same as the one previously used: it periodically queries Haier's servers (though less frequently after discussion with Haier), which results in excessive resource consumption on Haier's side.

The 0.14 library is new and communicates with the servers using the MQTT protocol. This allows the device state to be updated almost in real-time (Haier informs us when something changes without us needing to query), and it doesn't strain server resources. For example, my washing machine runs for no more than an average of 1 hour per day, so it doesn't make sense to query Haier's servers every minute for the remaining 23 hours.

However, the 0.14 library uses the awscrt package underneath, which requires compilation. Precompiled packages are available for x86_64 (e.g., all NUCs, etc.) and aarch64 (e.g., newer Raspberry Pis, etc.) architectures. If your Home Assistant runs on a different processor architecture (e.g., armv6, armv7, or armhf), there are two options.

The first option seems less ideal: install all the necessary build tools (cmake, clang, llvm, and others), and the library will compile automatically. The downside is that you're loading your disk (SD card) with tools that take up hundreds of MB (or even GB) to build a 20MB executable file. These tools won't be needed after the build.

The second option is what I implemented in my fork: I removed the awsiotsdk library (which requires the problematic awscrt) and replaced it with paho-mqtt, which is installed by default with HA (as it is used by the standard MQTT integration).

Additional tip: Every custom HA integration has a manifest file that declares which libraries are required for it to function. This repository specifies a particular version of pyhOn, while my fork and addshore's fork point to the appropriate Git repositories with the patched version. When Home Assistant loads these forks, it cannot determine the version required by the fork (since the Git reference points to a commit, not a version). As a result, it concludes that a version of pyhOn is already installed and doesn't install the patched version. By manually running the command docker exec homeassistant pip uninstall pyhOn -y, after the next HA restart, no pyhOn will be present, so the patched fork will be installed.

Finally, since there's currently no contact with @Andre0512, I plan to carry out a significant refactor of the 0.14 version in my fork soon. I believe there are some areas where performance and maintainability can be improved. However, I can't promise that this will happen on any regular basis.

@deezid
Copy link

deezid commented Aug 12, 2024

@kubasaw
installed your fork (0.14 beta 9) on my Home Assistant green (HA core 2024.8.1) and used "docker exec homeassistant pip uninstall pyhOn -y" before installing it, which said it was sucessful. But still, my washer (sensor.washing_machine_control and many others) doesn't seem to connect/update during a wash at all.

If you need some logs during the next cycle, let me know.

@KameDomotics
Copy link

@kubasaw

installed your fork (0.14 beta 9) on my Home Assistant green (HA core 2024.8.1) and used "docker exec homeassistant pip uninstall pyhOn -y" before installing it, which said it was sucessful. But still, my washer (sensor.washing_machine_control and many others) doesn't seem to connect/update during a wash at all.

If you need some logs during the next cycle, let me know.

Unfortunately I noticed I have the same problem, the entities do not update during the cycle ☹️

@InCrustWeTrust
Copy link

@kubasaw

Thanks that worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests