thomasgermain / vaillant-component

Multimatic integration for Home Assistant (also compatible with sensoAPP)
MIT License
137 stars 24 forks source link

Unable to fetch data from vaillant API, API says: {'errorCode': 'NullPointerException'}, status: 500 #7

Closed smmoroz closed 4 years ago

smmoroz commented 4 years ago

The components works for a few hours and after that I receive the following error every two minutes.

Here is the stacktrace:

2020-04-22 21:51:49 ERROR (MainThread) [custom_components.vaillant.hub] Unable to fetch data from vaillant API, API says: {'errorCode': 'NullPointerException'}, status: 500 Traceback (most recent call last): File "/config/custom_components/vaillant/hub.py", line 67, in _update_system self.system = await self._manager.get_system() File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 77, in get_system hvac_state = await hvac_state_req File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 582, in _call_api return await self._connector.request(method, url, payload) File "/usr/local/lib/python3.7/site-packages/pymultimatic/api/connector.py", line 171, in request payload=payload) pymultimatic.api.error.ApiError: Cannot get https://smart.vaillant.com/mobile/api/v4/facilities/XXX/hvacstate/v1/overview 2020-04-22 21:53:51 ERROR (MainThread) [custom_components.vaillant.hub] Unable to fetch data from vaillant API, API says: {'errorCode': 'NullPointerException'}, status: 500 Traceback (most recent call last): File "/config/custom_components/vaillant/hub.py", line 67, in _update_system self.system = await self._manager.get_system() File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 77, in get_system hvac_state = await hvac_state_req File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 582, in _call_api return await self._connector.request(method, url, payload) File "/usr/local/lib/python3.7/site-packages/pymultimatic/api/connector.py", line 171, in request payload=payload) pymultimatic.api.error.ApiError: Cannot get https://smart.vaillant.com/mobile/api/v4/facilities/XXX/hvacstate/v1/overview

Several times I received a message that my login and password were not correct, although they are definitely correct. I can reconnect with them after reboot.

thomasgermain commented 4 years ago

Hi,

thanks for posting it here.

So.. actually I don't know what's happening since the API doesn't give any (correct) error message. Error says NullPointerException (I don't know if your are familiar to programming, but this is basically a bug + unhandled error at API side).

Regarding the second problem (incorrect login/password) when and where does it occur ?

As I said in the HA forum, i'm working on a new version to have more aggressive reconnection when there is any kind of error coming from the API. I'm currently testing it. I hope I can release it this week end.

regards,

Thomas

smmoroz commented 4 years ago

Hi,

Yes, I know that NullPointerException means and that it is not easy to debug.

As for your questions

As for login/password problem, I saw it two just times and I'm not able to reproduce it. So, I suggest to forget about it for the moment.

I'm ready to wait for a new version to test it. Maybe it will solve the issue.

Please let me know if I can help you to debug/test it somehow.

Best regards, Sergey.

thomasgermain commented 4 years ago

Ok fine, I'm quite confident that the new version should fix your problem given what you said. I don't need the real SN, it was just to be sure that it was correct (I had another bug because a guy actually owns 2 serial number and the component picked up the (wrong) first one and nothing was working).

Do you have any error when HA is dying ? I can't believe HA is crashing because of the component, but I will check what can happen in case of recurring error.

Kr,

Thomas

smmoroz commented 4 years ago

Ok. I'll wait for a new version to test it.

As for dying HA, I'm still trying to get at least something in the log. As soon as I get it, I will post it here.

smmoroz commented 4 years ago

Hi, Thomas,

As I'm very new to HA, I played a bit more with it and with vaillant-component (VC for short). Here are a few results.

  1. I reinstalled everything from scratch, but without VC. After few days of experiments I found the reason, why HA was dying every few hours. This is because of a broken Broadcom WiFi in my RPi4. This fact is actually known to the community. Just for the record, I attach a part of dmesg output here:

[13234.388583] brcmfmac: _brcmf_set_multicast_list: Setting allmulti failed, -110 [13236.948057] brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout [13236.948448] brcmfmac: brcmf_sdio_checkdied: firmware trap in dongle [13239.508088] brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout [13239.508577] brcmfmac: brcmf_sdio_checkdied: firmware trap in dongle [13239.508615] brcmfmac: brcmf_cfg80211_get_channel: chanspec failed (-110) [13242.068127] brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout [13242.068606] brcmfmac: brcmf_sdio_checkdied: firmware trap in dongle [13242.068643] brcmfmac: _brcmf_set_multicast_list: Setting BRCMF_C_SET_PROMISC failed, -110 [13244.628136] brcmfmac: brcmf_sdio_bus_rxctl: resumed on timeout [13244.628620] brcmfmac: brcmf_sdio_checkdied: firmware trap in dongle [13244.628657] brcmfmac: brcmf_cfg80211_get_tx_power: error (-110)

Good news, VC is not responsible for HA freeze.

  1. I switched to wired connection and installed VC. I still have NullPointerException and more more error (see below). But VC recovers without HA reboot after 10-20 minutes after the crash. Good news again.

Logger: custom_components.vaillant.hub Source: custom_components/vaillant/hub.py:51 First occurred: 3:16:42 PM (6 occurrences) Last logged: 4:56:53 PM Unable to fetch data from vaillant API, API says: {'errorCode': 'NOT_AUTHORIZED'}, status: 401 Traceback (most recent call last): File "/config/custom_components/vaillant/hub.py", line 51, in _hvac_update await self._manager.request_hvac_update() File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 546, in request_hvac_update state = mapper.map_hvac_sync_state(await self._call_api(urls.hvac)) File "/usr/local/lib/python3.7/site-packages/pymultimatic/systemmanager.py", line 582, in _call_api return await self._connector.request(method, url, payload) File "/usr/local/lib/python3.7/site-packages/pymultimatic/api/connector.py", line 164, in request await self.login(True) File "/usr/local/lib/python3.7/site-packages/pymultimatic/api/connector.py", line 68, in login await self._authenticate(token) File "/usr/local/lib/python3.7/site-packages/pymultimatic/api/connector.py", line 126, in _authenticate raise ApiError("Unable to authenticate", response=auth_res) pymultimatic.api.error.ApiError: Unable to authenticate

Login and password are definitely correct, because I can connect to the system and get the readings.

Best regards, Sergey.

thomasgermain commented 4 years ago

Hi Sergey,

I'm glad to here VC is not causing HA to crash.

I'm also glad to announce you that I released the new version 1.2.2 (ok ok, a bit latter then expected :smile:). Basically, it includes a more aggressive reconnexion in case of error. It means you will still see some error, but the component his doing its best to ask for a new session/cookie. So the error should happen once and you should get rid of it.

I also have the NOT_AUTHORIZED error (while my credentials are also valid of course). I guess this is a bug, or it might also be some kind of protection, after X requests to the API, the session is considered invalid.

Let me know if you still have issue with the last release.

Thanks,

Thomas

smmoroz commented 4 years ago

Hi, Thomas,

Thank you for a new version. I have installed it. And I'm currently testing it. So far I didn't see any NullPointerException. I will keep testing 1.2.2 for a few more days. If there are no exceptions, I will close the this issue.

Best regards, Sergey.

lh14576 commented 4 years ago

My errors were getting away when I set up a dedicated Vaillant user just for homeassistant and use a different account for the official app. Running totally smooth since then

thomasgermain commented 4 years ago

My errors were getting away when I set up a dedicated Vaillant user just for homeassistant and use a different account for the official app. Running totally smooth since then

Yes, this is also what I'm doing, I'll advice that in the readme. It seems one user can only be connected once to the API.

smmoroz commented 4 years ago

I don't see any errors anymore. Thus I close the issue.