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.23k stars 2.49k forks source link

Unable to log on error #8

Closed raymondjstone closed 1 year ago

raymondjstone commented 1 year ago

Logger: root Source: custom_components/hon/init.py:32 Integration: Haier hOn (documentation, issues) First occurred: 09:07:21 (1 occurrences) Last logged: 09:07:21

Unable to login: 400

Illegal Request
You have sent us an Illegal URL or an improperly formatted request.
image

Andre0512 commented 1 year ago

Hey, sorry for late response :sweat_smile: How often does the problem occur? Can you still log in and use the integration normally?

raymondjstone commented 1 year ago

no the issue happens constantly and the integration does not work because of that, the mobile app works fine but this integration get's this issue constantly

raymondjstone commented 1 year ago

debug logging

2023-04-07 13:02:58.374 ERROR (MainThread) [root] Unable to login: 400

Illegal Request
You have sent us an Illegal URL or an improperly formatted request.

2023-04-07 13:02:58.401 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry hon@xxxxxxxxx for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 32, in async_setup_entry await hon.setup() File "/usr/local/lib/python3.10/site-packages/pyhon/api.py", line 54, in setup headers=await self._headers) as resp: File "/usr/local/lib/python3.10/site-packages/pyhon/api.py", line 48, in _headers raise PermissionError("Can't Login") PermissionError: Can't Login

Andre0512 commented 1 year ago

This could be related to #11. Can you test if the fix in v0.5.0-beta.4 also solves your issue or gives a different error?

raymondjstone commented 1 year ago

still fails

Error setting up entry hon@xxxxxxx.com for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 31, in async_setup_entry hon = await Hon( File "/usr/local/lib/python3.10/site-packages/pyhon/hon.py", line 26, in create await self.setup() File "/usr/local/lib/python3.10/site-packages/pyhon/hon.py", line 34, in setup for appliance in (await self._api.load_appliances())["payload"]["appliances"]: File "/usr/local/lib/python3.10/site-packages/pyhon/connection/api.py", line 39, in load_appliances async with self._hon.get(f"{const.API_URL}/commands/v1/appliance") as resp: File "/usr/local/lib/python3.10/contextlib.py", line 199, in aenter return await anext(self.gen) File "/usr/local/lib/python3.10/site-packages/pyhon/connection/handler.py", line 34, in get async with self._intercept(self._session.get, *args, **kwargs) as response: File "/usr/local/lib/python3.10/contextlib.py", line 199, in aenter return await anext(self.gen) File "/usr/local/lib/python3.10/site-packages/pyhon/connection/handler.py", line 81, in _intercept kwargs["headers"] = await self._check_headers(kwargs.get("headers", {})) File "/usr/local/lib/python3.10/site-packages/pyhon/connection/handler.py", line 76, in _check_headers raise PermissionError("Can't Login")

and

Logger: pyhon.connection.auth Source: custom_components/hon/init.py:31 Integration: Haier hOn (documentation, issues) First occurred: 20:26:59 (1 occurrences) Last logged: 20:26:59

Unable to login: 400

Illegal Request
You have sent us an Illegal URL or an improperly formatted request.
<!-- ................................................

Andre0512 commented 1 year ago

Sorry I had implemented the error handling a bit messy, I can absolutely not localize where the problem occurs. I have now improved the error handling a bit and published a new beta, can you please test the latest version v0.5.0-beta.5 and send me the error message? I hope then I can say more about this :slightly_smiling_face:

raymondjstone commented 1 year ago

Latest version

hOn Authentication Error 1 401 - https://he-accounts.force.com/SmartHome/setup/secur/RemoteAccessAuthorizationPage.apexp?source=CAAAAYd15NhvMDAwMDAwMDAwMDAwMDAwAAAA8rGLCzmMClXPcostjourJYsd41oGhfUUcorFGYXTPejXEpIoBY1mV7_agIwAp46riD2R-zAZuydLA8pB9ommqwBNQhN-yjXQs1J8BfNfS9-LAtZmJ5fAyq6FIUk6uXoGev_PVt1G6nrs-k-7kQxtCZ1waeV70gNYzIkEUzIoc6kYjFThRjreg_YI_jg9iP1tvTvpT1ZUNKu5vobK4wkjzyV5Z5bLVHM4avVOtl5FqqQoD7AqrHzGtVFZKhapuvZYIGDyGqHwmc3s99pQaoeFUrMqgjrX2XKWNX0MXLj5m5nltYfgdIruYqUHaX4tVzm4YlrpDt84CEE09Tif-VG0MeniHTAkOJwx-_mIAcU9PZ_jCvJm3dXkFwwZxXg5Kt7qeRsZeXsRb8l-9tMNnxgsUGLM3Ovkwxv4XpiFHl9oZGC7fe_hiN4n_AewGdHruvqHDbEZNDW2xLzy--ElnhnaSiu-uhMj5gQHYU7Scr81EGoDQ6nuQWfcJIqjd-BLccpdY1O-fH-M9ntXJU9LZ_di8-iB8RggULK5hXwyyTvRHOW_B3Nq0GwRaII7bf1tM1Pnv7iTqx9xIkkCxTVafqNh_6b6khEC9vEmJ9lvL8IsyfO5hfaUHiL0A0ObnshRLp2hKisfHZC26W4RmZ8LQc7ZU3AalVtIJrhsqhuJbUYROG2tUIOqMbyQ0_PuqBoqSDpQVtJ8Yh226mIlyHJMBh86TVU%3D&display=touch 2 302 - https://he-accounts.force.com/SmartHome/s/login?display=touch&ec=302&inst=68&startURL=/SmartHome/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAYd15NhvMDAwMDAwMDAwMDAwMDAwAAAA8rGLCzmMClXPcostjourJYsd41oGhfUUcorFGYXTPejXEpIoBY1mV7_agIwAp46riD2R-zAZuydLA8pB9ommqwBNQhN-yjXQs1J8BfNfS9-LAtZmJ5fAyq6FIUk6uXoGev_PVt1G6nrs-k-7kQxtCZ1waeV70gNYzIkEUzIoc6kYjFThRjreg_YI_jg9iP1tvTvpT1ZUNKu5vobK4wkjzyV5Z5bLVHM4avVOtl5FqqQoD7AqrHzGtVFZKhapuvZYIGDyGqHwmc3s99pQaoeFUrMqgjrX2XKWNX0MXLj5m5nltYfgdIruYqUHaX4tVzm4YlrpDt84CEE09Tif-VG0MeniHTAkOJwx-_mIAcU9PZ_jCvJm3dXkFwwZxXg5Kt7qeRsZeXsRb8l-9tMNnxgsUGLM3Ovkwxv4XpiFHl9oZGC7fe_hiN4n_AewGdHruvqHDbEZNDW2xLzy--ElnhnaSiu-uhMj5gQHYU7Scr81EGoDQ6nuQWfcJIqjd-BLccpdY1O-fH-M9ntXJU9LZ_di8-iB8RggULK5hXwyyTvRHOW_B3Nq0GwRaII7bf1tM1Pnv7iTqx9xIkkCxTVafqNh_6b6khEC9vEmJ9lvL8IsyfO5hfaUHiL0A0ObnshRLp2hKisfHZC26W4RmZ8LQc7ZU3AalVtIJrhsqhuJbUYROG2tUIOqMbyQ0_PuqBoqSDpQVtJ8Yh226mIlyHJMBh86TVU%253D%26display%3Dtouch 3 301 - https://he-accounts.force.com/SmartHome/s/login/?display=touch&ec=302&inst=68&startURL=/SmartHome/setup/secur/RemoteAccessAuthorizationPage.apexp?source%3DCAAAAYd15NhvMDAwMDAwMDAwMDAwMDAwAAAA8rGLCzmMClXPcostjourJYsd41oGhfUUcorFGYXTPejXEpIoBY1mV7_agIwAp46riD2R-zAZuydLA8pB9ommqwBNQhN-yjXQs1J8BfNfS9-LAtZmJ5fAyq6FIUk6uXoGev_PVt1G6nrs-k-7kQxtCZ1waeV70gNYzIkEUzIoc6kYjFThRjreg_YI_jg9iP1tvTvpT1ZUNKu5vobK4wkjzyV5Z5bLVHM4avVOtl5FqqQoD7AqrHzGtVFZKhapuvZYIGDyGqHwmc3s99pQaoeFUrMqgjrX2XKWNX0MXLj5m5nltYfgdIruYqUHaX4tVzm4YlrpDt84CEE09Tif-VG0MeniHTAkOJwx-_mIAcU9PZ_jCvJm3dXkFwwZxXg5Kt7qeRsZeXsRb8l-9tMNnxgsUGLM3Ovkwxv4XpiFHl9oZGC7fe_hiN4n_AewGdHruvqHDbEZNDW2xLzy--ElnhnaSiu-uhMj5gQHYU7Scr81EGoDQ6nuQWfcJIqjd-BLccpdY1O-fH-M9ntXJU9LZ_di8-iB8RggULK5hXwyyTvRHOW_B3Nq0GwRaII7bf1tM1Pnv7iTqx9xIkkCxTVafqNh_6b6khEC9vEmJ9lvL8IsyfO5hfaUHiL0A0ObnshRLp2hKisfHZC26W4RmZ8LQc7ZU3AalVtIJrhsqhuJbUYROG2tUIOqMbyQ0_PuqBoqSDpQVtJ8Yh226mIlyHJMBh86TVU%253D%26display%3Dtouch 4 200 - https://he-accounts.force.com/SmartHome/s/login/?language=en_US&display=touch&ec=302&inst=68&startURL=%2FSmartHome%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3DCAAAAYd15NhvMDAwMDAwMDAwMDAwMDAwAAAA8rGLCzmMClXPcostjourJYsd41oGhfUUcorFGYXTPejXEpIoBY1mV7_agIwAp46riD2R-zAZuydLA8pB9ommqwBNQhN-yjXQs1J8BfNfS9-LAtZmJ5fAyq6FIUk6uXoGev_PVt1G6nrs-k-7kQxtCZ1waeV70gNYzIkEUzIoc6kYjFThRjreg_YI_jg9iP1tvTvpT1ZUNKu5vobK4wkjzyV5Z5bLVHM4avVOtl5FqqQoD7AqrHzGtVFZKhapuvZYIGDyGqHwmc3s99pQaoeFUrMqgjrX2XKWNX0MXLj5m5nltYfgdIruYqUHaX4tVzm4YlrpDt84CEE09Tif-VG0MeniHTAkOJwx-_mIAcU9PZ_jCvJm3dXkFwwZxXg5Kt7qeRsZeXsRb8l-9tMNnxgsUGLM3Ovkwxv4XpiFHl9oZGC7fe_hiN4n_AewGdHruvqHDbEZNDW2xLzy--ElnhnaSiu-uhMj5gQHYU7Scr81EGoDQ6nuQWfcJIqjd-BLccpdY1O-fH-M9ntXJU9LZ_di8-iB8RggULK5hXwyyTvRHOW_B3Nq0GwRaII7bf1tM1Pnv7iTqx9xIkkCxTVafqNh_6b6khEC9vEmJ9lvL8IsyfO5hfaUHiL0A0ObnshRLp2hKisfHZC26W4RmZ8LQc7ZU3AalVtIJrhsqhuJbUYROG2tUIOqMbyQ0_PuqBoqSDpQVtJ8Yh226mIlyHJMBh86TVU%253D%26display%3Dtouch&System=IoT_Mobile_App&RegistrationSubChannel=hOn 5 400 - https://he-accounts.force.com/SmartHome/s/sfsites/aura?r=3&other.LightningLoginCustom.login=1 ERROR - 400 - https://he-accounts.force.com/SmartHome/s/sfsites/aura?r=3&other.LightningLoginCustom.login=1 =============== Response ===============

Illegal Request
You have sent us an Illegal URL or an improperly formatted request.
========================================

Typhonragewind commented 1 year ago

I'm also facing this issue. Could this be a problem with illegal characters in the password field?

raymondjstone commented 1 year ago

It is possible depending on how badly they have written their api or if python is doing silly things

my password includes these characters lower case letters, upper case letters, numbers and %

Andre0512 commented 1 year ago

This was a good hint! That was the problem, my python code did do silly things :smiley: I json decoded the data but didn't use url encoding. I fixed it in new release version v0.5.0, please test if you can login now.

raymondjstone commented 1 year ago

sucess image

cddevlin6 commented 1 year ago

Hi, I'm still receiving an error with the integration. I have uninstalled and reinstalled and even tried the beta version. The following is the error I am getting in the log:

`This error originated from a custom integration.

Logger: homeassistant.config_entries Source: custom_components/hon/init.py:32 Integration: Haier hOn (documentation, issues) First occurred: 11 April 2023 at 10:45:03 pm (4 occurrences) Last logged: 6:57:20 pm

Error setting up entry xxx@xxx.co.uk for hon Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/hon/init.py", line 32, in async_setup_entry await hon.setup() File "/usr/local/lib/python3.10/site-packages/pyhon/api.py", line 54, in setup headers=await self._headers) as resp: File "/usr/local/lib/python3.10/site-packages/pyhon/api.py", line 44, in _headers if await auth.authorize(self._email, self._password, self._mobile_id): File "/usr/local/lib/python3.10/site-packages/pyhon/auth.py", line 144, in authorize if not await self._get_token(session, url): File "/usr/local/lib/python3.10/site-packages/pyhon/auth.py", line 116, in _get_token async with session.get(url[0]) as resp: File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 508, in _request req = self._request_class( File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 305, in init self.update_host(url) File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 364, in update_host raise InvalidURL(url) aiohttp.client_exceptions.InvalidURL: /SmartHome/setup/secur/RemoteAccessAuthorizationPage.apexp?source=CAAAAYd3bd4XMDAwMDAwMDAwMDAwMDAwAAAA8kcOnxVr6g47ysXKy_8XChFcO6DI_s5gsaOcJ_q2EXSgq_es7J1yTL6Q_JEnPi659KQLaVTasBfwZTtEZKXfPExld4Dt8mfAFRJ98JCzC2Axt_kJF2U5_5WXJ4bQXCx0zmYNOES33kkvCbAIrj1xlcac3DsaXXHu4-a7HnJxPs9XyFHxgMYUXeBgrUlSLlOxQ2_XdBfIi5QT4xcmODlwaryXlTu_ZT7fOsVwl-tgYNskPRBOzhkeVVj4vhqMwSJE6oCW7aW6AxB8ZlIFgFi-hr38nqg3VGpdJwb-bQvEXSKFOPmRuDNhc807i4fZ9pwIGgvl_hfXA5LduNqX8dlVEg8UMYUNk-vLM0kLmDsQ5MGjiOgCfMvQXqdcrzVe3F_gUz-pCRix1NfRJHWyzMKZTn3RqzSDrrhMxzHmPoFAhAnRxkAlDnmQufTpcqHt0vBr-n47mzWvXSv_lPkOsZoJOD-oMxDa22Esa5JjRJVdk9FjegKe3QPu4mHtysZLrPZu_ywrZGuM1MEPHqYn_WMUZhYWxUcFWb2e722zybZK7HVkf_BP1EgMYl-NWB3OD9Lb3KiDIlV_IVVYp0CsvdyBqypTjZ-qzVpZLfJOX0cFatpB2DZEAE_D60Da46YMFtfhYJumnmBww4FquCuWOvXoXlIoZDdYJAngk4JtTYU8sqNFfPLAjA406fH6tyzTqbMEI4xfko-yZNoLu9TGkkz6-uI `

Andre0512 commented 1 year ago

Hi, which version do you use? I'm really sure this is from an older version before v0.5.x :thinking: Do you have restarted home assistant after installation?

cddevlin6 commented 1 year ago

I tested it numerous times last night with no luck. After a restart and on the beta version it now seems to work. Again, appreciate your time in making this integration. Hopefully, things go smoothly from here.

Andre0512 commented 1 year ago

Nice, you always need a restart if you install or update a custom integration via HACS. With pleasure! I hope that too :smile: