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.27k stars 2.48k forks source link

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

Open 48mWsPK opened 2 months ago

48mWsPK commented 2 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:

leits commented 2 months ago

The issue also occurs when reloading an existing integration.

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

DissiNL commented 2 months ago

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

zawadzkipiter commented 2 months ago

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

addshore commented 2 months ago

Also same here after reloading the integration

arkadi222 commented 1 month ago

the same :(

Z4RR0 commented 1 month ago

same also for me

48mWsPK commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

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

addshore commented 1 month ago

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 xxxxx@gmail.com 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 commented 1 month ago

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

Z4RR0 commented 1 month ago

Try last beta same issue

Il Mer 10 Lug 2024, 13:39 DarkStar @.***> ha scritto:

Does anyone of you have v0.14.0-beta.7 https://github.com/Andre0512/hon/releases 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.png (view on web) https://github.com/Andre0512/hon/assets/134559937/e06bb1b8-85a4-4b3b-9b1d-17e9ba80d0e3

ā€” Reply to this email directly, view it on GitHub https://github.com/Andre0512/hon/issues/230#issuecomment-2220292909, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXSCLWNBDLEW4EAWEDCAPTTZLUMORAVCNFSM6AAAAABKS2LP4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRQGI4TEOJQHE . You are receiving this because you commented.Message ID: @.***>

edmund-1 commented 1 month ago

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

addshore commented 1 month ago

So https://github.com/Andre0512/pyhOn/pull/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://github.com/Andre0512/pyhOn/pull/29/files And the python package is installable via pyhOn @ git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156

Beunhaaz commented 1 month ago

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

zawadzkipiter commented 1 month ago

@addshore hero! How did you reach Andre ?

edmund-1 commented 1 month ago

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://github.com/Andre0512/pyhOn/pull/29/files And the python package is installable via pyhOn @ git+https://github.com/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 commented 1 month ago

@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 https://github.com/addshore/hon/commit/c5cff776ee5d6cb331f94714077b259f78818a00 for example I'm not actually sure the best way to update this within HA just yet :)

terierul commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

same here

edmund-1 commented 1 month ago

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://github.com/Andre0512/pyhOn/pull/29/files

dm-christian commented 1 month ago

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 commented 1 month ago

So, I https://github.com/addshore/hon/commit/c5cff776ee5d6cb331f94714077b259f78818a00 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://github.com/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 :)

dm-christian commented 1 month ago

It was kind of out of the fact that my climate automations stopped working ....

Well i just tried it out with the information here. If someone want to bypass it instead of doin it the right way:

If you manualy log into the given URL in .... window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZChOZbAMDAw....'); .... you get back this html with

window.location.replace('hon://mobilesdk/detect/oauth/done#access_token=xxxxxxxx.....

in it. grab this url and update the auth.py:

async def _get_token(self) -> bool: self._parse_token_data('hon://mobilesdk/detect/oauth/done#access_token=xxxxxxxxxxxxxxxxxxxx&refresh_token=xxxxxxxxxxxxxxxxx ...') return True

and

async def authenticate(self) -> None: self.clear() try: if not await self._get_token(): raise exceptions.HonAuthenticationError("Can't get token") if not await self._api_auth(): raise exceptions.HonAuthenticationError("Can't get api token") except exceptions.HonNoAuthenticationNeeded: return

Thats quite hacky for sure :)

edmund-1 commented 1 month ago

https://github.com/addshore/hon

Your beta is not working on my end: image

logs:

This error originated from a custom integration.

Logger: pyhon.connection.auth
Source: custom_components/hon/__init__.py:34
integration: Haier hOn (documentation, issues)
First occurred: 16:55:23 (1 occurrences)
Last logged: 16:55:23

hOn Authentication Error 1 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZCiE8UBMDAwMDAwMDAwMDAwMDAwAAAA-jAe22-s8U9nfJq7CMUyE9-a5-Y59Cs9IrEEwKHVM9OOQ_Py1thaLqdxLgpexHh7zeFa1x1-Ya47ORlpEuU2VthPDj9xsd6_J88xcW-yTPflUii9SWvs5WbiY6OqTf_KcVBuvvG_Vxr2l-F9X9bYDTu0t2ZNlL0kqlXLSdT_sPQMhbLDBKzEcKi1pWq4-Hpqn4Qh4rt3AZH_JZeKSMZrvjTdQkqe5-mdZQ-xcUC8C0D5AJvz8Cm9k3LAOVD045EMwsuOH59J5SL9XCeny0UEKHVF-5ME18HM3XatEgwD9I7YAMoEiZ3N5CXCp0kTEMEZe2lWNPcFSapYtl4Mn2j7jNFee9JA5w5zCpF5Lib0PWz-N6UZUacG5qugVpUC1al-L-r71oMlkj_2s3GMCtGMishzbi_C_Tzktl5S8Fh2Z_J647wAYfPYhgQP3iBzFV33cLl-x1nnWrYEMhqZa1EGi0Msb58bfEV2t0ta132ZFxE-yWbb0o25ON0ZOtFsDc_54vdNVZ_IhSDj_qz4OFVQP2TrGbIuKkApHSglPQCzoxbf2Cq2Q3FxFlpFvbBLmOPiphGzTkhh5DHOTKAYgXYZ9niaKib8gLIGmgJu2hOK7BVYxWxwx-jIL0wRr_wVknW6NvXQNwq2Dw3wWUpbPEWBMUCjU8QZKG35X-fQeAkS4paX3RKzbXVM4_jYpqbF2zg_GvXQQqfukt0fcS9EA31dUhQwb0Hiy8egrFtzqA1PT7yC6jqooLw110fiNzz8hSj66A%253D%253D%26display%3Dtouch ERROR - 200 - https://account2.hon-smarthome.com/hOnRedirect?startURL=/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAZCiE8UBMDAwMDAwMDAwMDAwMDAwAAAA-jAe22-s8U9nfJq7CMUyE9-a5-Y59Cs9IrEEwKHVM9OOQ_Py1thaLqdxLgpexHh7zeFa1x1-Ya47ORlpEuU2VthPDj9xsd6_J88xcW-yTPflUii9SWvs5WbiY6OqTf_KcVBuvvG_Vxr2l-F9X9bYDTu0t2ZNlL0kqlXLSdT_sPQMhbLDBKzEcKi1pWq4-Hpqn4Qh4rt3AZH_JZeKSMZrvjTdQkqe5-mdZQ-xcUC8C0D5AJvz8Cm9k3LAOVD045EMwsuOH59J5SL9XCeny0UEKHVF-5ME18HM3XatEgwD9I7YAMoEiZ3N5CXCp0kTEMEZe2lWNPcFSapYtl4Mn2j7jNFee9JA5w5zCpF5Lib0PWz-N6UZUacG5qugVpUC1al-L-r71oMlkj_2s3GMCtGMishzbi_C_Tzktl5S8Fh2Z_J647wAYfPYhgQP3iBzFV33cLl-x1nnWrYEMhqZa1EGi0Msb58bfEV2t0ta132ZFxE-yWbb0o25ON0ZOtFsDc_54vdNVZ_IhSDj_qz4OFVQP2TrGbIuKkApHSglPQCzoxbf2Cq2Q3FxFlpFvbBLmOPiphGzTkhh5DHOTKAYgXYZ9niaKib8gLIGmgJu2hOK7BVYxWxwx-jIL0wRr_wVknW6NvXQNwq2Dw3wWUpbPEWBMUCjU8QZKG35X-fQeAkS4paX3RKzbXVM4_jYpqbF2zg_GvXQQqfukt0fcS9EA31dUhQwb0Hiy8egrFtzqA1PT7yC6jqooLw110fiNzz8hSj66A%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%3DCAAAAZCiE8UBMDAwMDAwMDAwMDAwMDAwAAAA-jAe22-s8U9nfJq7CMUyE9-a5-Y59Cs9IrEEwKHVM9OOQ_Py1thaLqdxLgpexHh7zeFa1x1-Ya47ORlpEuU2VthPDj9xsd6_J88xcW-yTPflUii9SWvs5WbiY6OqTf_KcVBuvvG_Vxr2l-F9X9bYDTu0t2ZNlL0kqlXLSdT_sPQMhbLDBKzEcKi1pWq4-Hpqn4Qh4rt3AZH_JZeKSMZrvjTdQkqe5-mdZQ-xcUC8C0D5AJvz8Cm9k3LAOVD045EMwsuOH59J5SL9XCeny0UEKHVF-5ME18HM3XatEgwD9I7YAMoEiZ3N5CXCp0kTEMEZe2lWNPcFSapYtl4Mn2j7jNFee9JA5w5zCpF5Lib0PWz-N6UZUacG5qugVpUC1al-L-r71oMlkj_2s3GMCtGMishzbi_C_Tzktl5S8Fh2Z_J647wAYfPYhgQP3iBzFV33cLl-x1nnWrYEMhqZa1EGi0Msb58bfEV2t0ta132ZFxE-yWbb0o25ON0ZOtFsDc_54vdNVZ_IhSDj_qz4OFVQP2TrGbIuKkApHSglPQCzoxbf2Cq2Q3FxFlpFvbBLmOPiphGzTkhh5DHOTKAYgXYZ9niaKib8gLIGmgJu2hOK7BVYxWxwx-jIL0wRr_wVknW6NvXQNwq2Dw3wWUpbPEWBMUCjU8QZKG35X-fQeAkS4paX3RKzbXVM4_jYpqbF2zg_GvXQQqfukt0fcS9EA31dUhQwb0Hiy8egrFtzqA1PT7yC6jqooLw110fiNzz8hSj66A%3D%3D'); } else if (window.location.replace){ window.location.replace('/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZCiE8UBMDAwMDAwMDAwMDAwMDAwAAAA-jAe22-s8U9nfJq7CMUyE9-a5-Y59Cs9IrEEwKHVM9OOQ_Py1thaLqdxLgpexHh7zeFa1x1-Ya47ORlpEuU2VthPDj9xsd6_J88xcW-yTPflUii9SWvs5WbiY6OqTf_KcVBuvvG_Vxr2l-F9X9bYDTu0t2ZNlL0kqlXLSdT_sPQMhbLDBKzEcKi1pWq4-Hpqn4Qh4rt3AZH_JZeKSMZrvjTdQkqe5-mdZQ-xcUC8C0D5AJvz8Cm9k3LAOVD045EMwsuOH59J5SL9XCeny0UEKHVF-5ME18HM3XatEgwD9I7YAMoEiZ3N5CXCp0kTEMEZe2lWNPcFSapYtl4Mn2j7jNFee9JA5w5zCpF5Lib0PWz-N6UZUacG5qugVpUC1al-L-r71oMlkj_2s3GMCtGMishzbi_C_Tzktl5S8Fh2Z_J647wAYfPYhgQP3iBzFV33cLl-x1nnWrYEMhqZa1EGi0Msb58bfEV2t0ta132ZFxE-yWbb0o25ON0ZOtFsDc_54vdNVZ_IhSDj_qz4OFVQP2TrGbIuKkApHSglPQCzoxbf2Cq2Q3FxFlpFvbBLmOPiphGzTkhh5DHOTKAYgXYZ9niaKib8gLIGmgJu2hOK7BVYxWxwx-jIL0wRr_wVknW6NvXQNwq2Dw3wWUpbPEWBMUCjU8QZKG35X-fQeAkS4paX3RKzbXVM4_jYpqbF2zg_GvXQQqfukt0fcS9EA31dUhQwb0Hiy8egrFtzqA1PT7yC6jqooLw110fiNzz8hSj66A%3D%3D'); } else { window.location.href ='/NewhOnLogin?display=touch%2F&ec=302&startURL=%2F%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAZCiE8UBMDAwMDAwMDAwMDAwMDAwAAAA-jAe22-s8U9nfJq7CMUyE9-a5-Y59Cs9IrEEwKHVM9OOQ_Py1thaLqdxLgpexHh7zeFa1x1-Ya47ORlpEuU2VthPDj9xsd6_J88xcW-yTPflUii9SWvs5WbiY6OqTf_KcVBuvvG_Vxr2l-F9X9bYDTu0t2ZNlL0kqlXLSdT_sPQMhbLDBKzEcKi1pWq4-Hpqn4Qh4rt3AZH_JZeKSMZrvjTdQkqe5-mdZQ-xcUC8C0D5AJvz8Cm9k3LAOVD045EMwsuOH59J5SL9XCeny0UEKHVF-5ME18HM3XatEgwD9I7YAMoEiZ3N5CXCp0kTEMEZe2lWNPcFSapYtl4Mn2j7jNFee9JA5w5zCpF5Lib0PWz-N6UZUacG5qugVpUC1al-L-r71oMlkj_2s3GMCtGMishzbi_C_Tzktl5S8Fh2Z_J647wAYfPYhgQP3iBzFV33cLl-x1nnWrYEMhqZa1EGi0Msb58bfEV2t0ta132ZFxE-yWbb0o25ON0ZOtFsDc_54vdNVZ_IhSDj_qz4OFVQP2TrGbIuKkApHSglPQCzoxbf2Cq2Q3FxFlpFvbBLmOPiphGzTkhh5DHOTKAYgXYZ9niaKib8gLIGmgJu2hOK7BVYxWxwx-jIL0wRr_wVknW6NvXQNwq2Dw3wWUpbPEWBMUCjU8QZKG35X-fQeAkS4paX3RKzbXVM4_jYpqbF2zg_GvXQQqfukt0fcS9EA31dUhQwb0Hiy8egrFtzqA1PT7yC6jqooLw110fiNzz8hSj66A%3D%3D'; } } redirectOnLoad(); </script> </head> </html> ========================================

I will try @dm-christian approach

Update1: Still the same issue. My assumption is if you have the integration already installed, this will work. If not... wait for @Andre0512 to fix it or use other integrations.

Update2: Integration: https://github.com/gvigroux/hon works without issues image

dm-christian commented 1 month ago

Update2: Integration: https://github.com/gvigroux/hon works without issues !

Oh thats good to hear.

Just looked into it. It doesnt rely on pyhon for the login process. its using a different approach to authenticate.

48mWsPK commented 1 month ago

If @addshore's changes are to be used, it looks like @Andre0512 needs to take in the changes.

Or we need a proper pyhOn fork for this to work.

If there is a fork of pyhOn with a different name at pypi.org - https://pypi.org/project/pyhOn/ , and a hon fork that refences the forked pyhOn python library - things can get moving again.

Seems the most reasonable course of action given how Andre has dissapeared and there is no activity from him for months now.

Anyone up for the task?

edmund-1 commented 1 month ago

Update2: Integration: https://github.com/gvigroux/hon works without issues !

Oh thats good to hear.

Just looked into it. It doesnt rely on pyhon for the login process. its using a different approach to authenticate.

As mentioned above, @addshore changes on auth.py worked for me (pyhOn command + authentication, returned values), but the problem was with Haier integration.

image image

terierul commented 1 month ago

the fix is done, but it needs the owner approval

Z4RR0 commented 1 month ago

Is possible to have a recap what i do to fix manually?

Tnx

Il Mer 10 Lug 2024, 18:50 Alex @.***> ha scritto:

the fix is done, but it needs the owner approval

ā€” Reply to this email directly, view it on GitHub https://github.com/Andre0512/hon/issues/230#issuecomment-2221009750, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXSCLWJZMYMCBQRUQGHVXPDZLVQ6NAVCNFSM6AAAAABKS2LP4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRRGAYDSNZVGA . You are receiving this because you commented.Message ID: @.***>

48mWsPK commented 1 month ago

@Z4RR0 hon HomeAssistant integration relies on pyhOn. @addshore has a fix for pyhOn, but that needs to get pulled by Andre.

Otherwise, the path is fork pyhOn on pypi.org with a different name, adjust a fork of hon HA integration to use the forked pypi module, and everything should work.

bart1604 commented 1 month ago

@Andre0512, is I see. There is an action for you to do to fix this issue. I have the same, could you please pull this?

terierul commented 1 month ago

the issue is that the owner is not active since April...

arkadi222 commented 1 month ago

I've tried another integration (mentioned by @dm-christian): https://github.com/gvigroux/hon for now it's a good alternative. there aren't some sensors, but I think it's sufficient for me: image and there are some services I don't remember in Andre integration: image I have to change some of my node-red flows, but it looks better for my solution - in one call_service I can set temperature, fan speed and direction,

dmd79 commented 1 month ago

I have tried https://github.com/gvigroux/hon but login fail

Screenshot_20240711-161438

arkadi222 commented 1 month ago

I'd uninstalled Andre integration prior to new haier integration (they use the same folder custom_integration/hon) - maybe this is a clue.

dmd79 commented 1 month ago

Me too don't work

jm314159 commented 1 month ago

Well, I am a bit lost... The hOn integration has been working for me, however, I noticed some time ago that the ambient temperature is not being updated automatically even after a few minutes. It updates on a param change (e.g. increase temperature, change the direction angle etc.). I assumed I could play with different versions to compare results. After I restarted the core, I lost hOn.

So, I was fighting with different versions also with the latest v0.14.0-beta.8-addshore the entire afternoon today, but always failed to login. At about 4 pm I decided to give a downgraded version of the core a try, and, to my surprise, the integration has got recovered. I had then v0.14.0-beta.8-addshore. Finally, I restored all settings to the newest, now, I am running the latest core, and it is all fine šŸ¤”

Can it be so that Haier plays somehow badly during the day?

dm-christian commented 1 month ago

Can it be so that Haier plays somehow badly during the day?

Well Haier definetly likes to play with the community as we saw how they treatened Andre for his work.

I think they pushed him so hard around that he is scared to work on the project again so the community has to solve this kind of problems by there own.

For now im glad that my hacky solution works for me. I have 7 AC Devices that work well with my automations. I was worried yesterday then they just disappeared in my home assistant after i restarted it.

I hope that one with the right amount of python knowledge will fix it and makes the integration work out of the box again.

But im pretty sure that this was not the last time Haier tries to mess up this solution. Its a shame. The products are working but the try to keep the controller in the box they made. This shitty hOn App that is slow and buggy as hell. I rather use the IR remotes than this peace of crap.

dmd79 commented 1 month ago

@dm-christian how did you fixed? I've tried v0.14.0-beta.8-addshore even downgrade core but still no luck

jm314159 commented 1 month ago

Just modified manifest.json of v0.13.0 by changing the pyhOn requirements to what @addshore updated:

  "requirements": [
    "pyhOn @ git+https://github.com/addshore/pyhOn.git@3f39be53f31885fb84d72f91fb4123c2e39e7156"
  ],

At the moment, the integration works fine for me on both old 2024.6.4 and new 2024.7.2 cores, obraz obraz

which confirms perhaps what has already been said - the issue is in pyhOn. Having that version set, I hope for automatic state updates. We'll see. I eventually accept one minute delay, but let it happen.

There is a setting "iot_class": "cloud_polling" in v13 compared to "iot_class": "cloud_push" to be found since v14. I'm pretty lame in programming such things, if you could please answer, whether it is a key setting for the updates or not only that, or even not at all.

dmd79 commented 1 month ago

@jm314159 pyHon need to manual install after the manifest edit?

jm314159 commented 1 month ago

@jm314159 pyHon need to manual install after the manifest edit?

I edited the manifest locally, then uploaded all files to /config/custom_components/hon, removed /config/custom_components/hon/__pycache__, and restarted HA core.

dmd79 commented 1 month ago

@jm314159 thank this work for me but I have to downgrade ha core and then work also with up to date core

sirfalo commented 1 month ago

So far non of those trick didn't help... :(

edmund-1 commented 1 month ago

As mentioned few days back, in my case, https://github.com/gvigroux/hon worked. It is poor in features, but at least I was able to see my washing machine.

image

image

dm-christian commented 1 month ago

@dm-christian how did you fixed? I've tried v0.14.0-beta.8-addshore even downgrade core but still no luck

I did not fix the problem i bypassed it. you need to follow my instructions. Log in to get your access key and edit the auth.py.

As i saw today the "refresh token" mechanism fails in this hack. So after 2 days it logs me out and doesnt connect from it self again.

Ill try another aproach today.

lindap1978 commented 1 month ago

Hi Guys, is there any plan to fix this? Make a temporary repository and issue a fix there?