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

Integration stops working after few hours #404

Open
mcervar opened this issue Apr 25, 2024 · 16 comments
Open

Integration stops working after few hours #404

mcervar opened this issue Apr 25, 2024 · 16 comments

Comments

@mcervar
Copy link

mcervar commented Apr 25, 2024

First of all, this new version is way faster when updating thermostats, really good job! For some reason after > 6h, integration simply stops working, everything becomes unavailable, if I restart the integration it again works perfectly for few hours and then same problem occurs. Tried completely uninstalling integration and repo, and then reinstalling it from scratch, didnt help.

image

Bosch component version is v0.25.1

Debug SCAN doesnt provided anything, it only say nothing is available (more information can be seen in debug logs attached)

bosch_HA_debug_log.txt

Everything works in this log output until around ~ 01:01:00, after that time in this example, most of the requests are getting null response, but the wierd thing is that some request got proper reply like current temperatures of the thermostats.

@Pommes2910
Copy link

same here

@pszafer
Copy link
Collaborator

pszafer commented Apr 25, 2024

Disable most sensor and leave only one climate entity enabled. Might be too many requests to bosch servers and you got locked temporarily.

@mcervar
Copy link
Author

mcervar commented Apr 25, 2024

khmm, but if they lock me out, then it shouldn't work immediately if I restart the integration. From the sensors I only use battery status for each thermostat which is really important to me, this shouldnt be a problem.

Even from the logs its visible after the problem occurs, some of the requests like current temperature and set temperature is succesfully fetched, but device or entity becomes unavailable for some reason

@pszafer
Copy link
Collaborator

pszafer commented Apr 25, 2024

Do it just for testing so we could try to find out why there is no response from server.

@mcervar
Copy link
Author

mcervar commented Apr 27, 2024

Found what the problem is in the logs today, integration (homeconnect sub lib, sseclient file ) implements oauth for auth towards bosch cloud api, token after X hours expires which causes communication to stop working.

I suggest using refresh token if possible, and if refresh token is to be expired, then new refresh token should be also requested. It would be good to have try catch exceptions on all api calls towards bosch cloud or at least on important functions (not crucial but long term good to have) if not already implemented. :D

`Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/homeconnect/sseclient.py", line 81, in next
next_chunk = next(self.resp_iterator)
^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/homeconnect/api.py", line 168, in _listen
for event in sse:
File "/usr/local/lib/python3.12/site-packages/homeconnect/sseclient.py", line 91, in next
self._connect()
File "/usr/local/lib/python3.12/site-packages/homeconnect/sseclient.py", line 56, in _connect
self.resp = requester.get(self.url, stream=True, **self.requests_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request
url, headers, data = self._client.add_token(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) `

home-assistant_2024-04-27T19-07-06.159Z.log

@pszafer
Copy link
Collaborator

pszafer commented Apr 27, 2024

You talking about different integration. It's not homeconnect integration .

@mcervar
Copy link
Author

mcervar commented Apr 28, 2024

ohhh, you are right, my bad, I thought filter was applied but somehow that log message was caught by it.
still nothing what can point out the problem in the logs, but I noticed that last 7 days it always stops working around 1am, earliest 00:35 am, latest around 01:10 am. I already checked my automations and nothing is triggered at that time.

image

Does integration maybe trigger something at that time? Maybe it tries to fetch energy metrics around 1am and something goes wrong there XD

@pszafer
Copy link
Collaborator

pszafer commented Apr 28, 2024

Can you try to turn on debug log of the integration and library in the evening and provide what is happening in the night.
As it's Easycontrol it just download last day at 1am.

@mcervar
Copy link
Author

mcervar commented Apr 28, 2024

I am already running debug mode, here are logs from last night

Debug mode set like this:

logger:
  default: warning
  logs:
    custom_components.bosch: debug
    bosch_thermostat_client: debug

Message at the end marked in bold only occurs in logs after devices stop working (verified the pattern in last few days), seems stats are fetched but not updated in HA:

024-04-28 01:02:01.708 DEBUG (MainThread) [bosch_thermostat_client.circuits.circuit] Current temp of LIVING ROOM is {'value': 24.5, 'minValue': 5.0, 'maxValue': 30.0, 'unitOfMeasure': 'C', 'writeable': 0, 'used': 'true', 'stepSize': 0.5}
2024-04-28 01:02:01.708 DEBUG (MainThread) [custom_components.bosch.climate] Update of climate Work room component called.
2024-04-28 01:02:01.708 DEBUG (MainThread) [bosch_thermostat_client.circuits.circuit] Current temp of WORK ROOM is {'value': 17.6, 'minValue': 5.0, 'maxValue': 30.0, 'unitOfMeasure': 'C', 'writeable': 0, 'used': 'true', 'stepSize': 0.5}
2024-04-28 01:02:01.709 DEBUG (MainThread) [custom_components.bosch.climate] Update of climate Bedroom component called.
2024-04-28 01:02:01.709 DEBUG (MainThread) [bosch_thermostat_client.circuits.circuit] Current temp of BEDROOM is {'value': 20.2, 'minValue': 5.0, 'maxValue': 30.0, 'unitOfMeasure': 'C', 'writeable': 0, 'used': 'true', 'stepSize': 0.5}
2024-04-28 01:02:01.709 DEBUG (MainThread) [custom_components.bosch.climate] Update of climate Bathroom component called.
2024-04-28 01:02:01.709 DEBUG (MainThread) [bosch_thermostat_client.circuits.circuit] Current temp of BATHROOM is {'value': 23.3, 'minValue': 5.0, 'maxValue': 30.0, 'unitOfMeasure': 'C', 'writeable': 0, 'used': 'true', 'stepSize': 0.5}

2024-04-28 01:02:01.712 DEBUG (MainThread) [custom_components.bosch] Update already in progress. Not updating.

@ChristophPech
Copy link

I do have the same issue since the last update. The debug log doesn't show anything out of the ordinary, the regular "Update of climate ... component called." still continue normally but all the values stop updating until I reload the integration. It happens at 4 o'clock every night, which is the same time my internet router reconnects and receives a new public IPv4.

@mcervar
Copy link
Author

mcervar commented May 8, 2024

My IP doesnt change at problematic time of the integration, only clue is this in the logs which starts showing after integration stops working properly:

2024-04-28 01:02:01.712 DEBUG (MainThread) [custom_components.bosch] Update already in progress. Not updating.

@ChristophPech can you check if the same occurs in your logs only after integration stops working? You need to enable debug logs if you havent already :D

@ChristophPech
Copy link

Yes, right. I too have this message, overlooked it before. I also forgot to enable debug logging for bosch_thermostat_client. I now get these after manually requesting a new DSL connection:

INFO (MainThread) [bosch_thermostat_client.connectors.xmpp] Msg exception for /dhwCircuits/dhw1/programs
DEBUG (MainThread) [bosch_thermostat_client.connectors.xmpp] Response to GET request /dhwCircuits/dhw1/programs: null

This means asyncio.TimeoutError. Maybe Bosch changed something or the new XMPP library behaves slightly different.

@pszafer
Copy link
Collaborator

pszafer commented May 8, 2024

I think new library doesn't reconnect properly. I'll fix that but HA changed too much in 2024.5; I have to rewrite a lot of code of component and don't have time for that.

@sergioras
Copy link

I have the same issue.
I temporarily solved it with an automation that reloads the integration every 24h:
service: homeassistant.reload_config_entry
target: {}
data:
entry_id: 06d7ca863dc3f075184f663ef0399e10

I found the correct entry_id in the core.config_entries file.

@ChristophPech
Copy link

I found the correct entry_id in the core.config_entries file.

You can find the ID in the URL when listing devices of the bosch integration:
image

@sergioras
Copy link

sergioras commented May 29, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants