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

OpenTherm/config: blocking call to sleep inside the event loop #117599

Open
andriej opened this issue May 16, 2024 · 10 comments
Open

OpenTherm/config: blocking call to sleep inside the event loop #117599

andriej opened this issue May 16, 2024 · 10 comments

Comments

@andriej
Copy link
Contributor

andriej commented May 16, 2024

The problem

I have issue with OpenTherm (OTGW) integration.
It uses socket:// to connect to gateway and I see warning in logfile:

2024-05-16 15:30:33.962 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to sleep inside the event loop by integration 'config' at homeassistant/components/config/config_entries.py, line 120: await hass.config_entries.async_reload(entry_id) (offender: /usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py, line 104: time.sleep(0.3)), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+config%22

I do not see any other errors regarding OpenTherm.
Only informational that it can't connect to socket:// in UI (when I hover on the error, I see `Could not connect to gateway at socket://ip:port <Errno 111>)

It was working all releases before 2024.5.

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

core-2024.4.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OpenTherm Gateway

Link to integration documentation on our website

https://www.home-assistant.io/integrations/opentherm_gw/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Turning debug and reloading integration doesn't provide much info, as it seems it's issue with config/HA interpretation of 'socket://' connection?
2024-05-17 01:16:38.208 DEBUG (MainThread) [pyotgw.status] Starting reporting routine 2024-05-17 01:16:38.225 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to sleep inside the event loop by integration 'config' at homeassistant/components/config/config_entries.py, line 120: await hass.config_entries.async_reload(entry_id) (offender: /usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py, line 104: time.sleep(0.3)), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+config%22

Additional information

Could be connected with #116635

@home-assistant
Copy link

Hey there @mvn23, mind taking a look at this issue as it has been labeled with an integration (opentherm_gw) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of opentherm_gw can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign opentherm_gw Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


opentherm_gw documentation
opentherm_gw source
(message by IssueLinks)

@andriej andriej changed the title OpenTherm: blocking call to sleep with socket OpenTherm/config: blocking call to sleep inside the event loop May 16, 2024
@mvn23
Copy link
Contributor

mvn23 commented May 17, 2024

Thank you for the report. Unfortunately I have not been able to reproduce the issue so far. We had a similar issue in the past (see #67430 for example) but it was supposed to be fixed with the change to pyserial-asyncio-fast in #116527
When does the message show up in the logs? Do you have a reliable way to reproduce the issue? The log message hints on an integration reload, but that doesn't trigger any errors for me...

@andriej
Copy link
Contributor Author

andriej commented May 17, 2024

Any hints on how can I reproduce?
Everytime I restarts HA it ends up the same - integration says it can't connect.
Connection is there as direct connection with client shows the data messages flowing.

@mvn23
Copy link
Contributor

mvn23 commented May 20, 2024

What do you mean by "direct connection with client"? If there is a successful connection from Home Assistant to the gateway then the debug logging should show all messages as well. If they don't show then there is no data being received by Home Assistant.

For the reproduction, do I understand correctly that the log message shows up on a restart of Home Assistant?
Can you trigger it by reloading the integration? Or by disconnecting the gateway after the connection has been established? If we can find a way to reliably trigger the error then it will be easier to debug and fix.

@andriej
Copy link
Contributor Author

andriej commented May 20, 2024

HA cannot make successful connection even once.

I am testing connection on putty to make sure it's not OTGW gateway fault.

I've turned on "debug" on OpenTherm integration but messages I pasted are the only ones I have in my log file

Restart of OS or HA does not solve the situation, HA still can't connect to OTGW even once (so no debug messages in logfile).
How can I further help it debug?

I guess problem is with how HA interprets "socket://" in URI to the OTGW and that's the issue, but I'm not sure on this - I just interpret the error.

@mvn23
Copy link
Contributor

mvn23 commented May 20, 2024

If you have the Terminal & SSH addon you can use nc <ip> <port> (that's separated by spaces) to test basic connectivity. If the messages don't show up there then it's likely a networking issue. It's still not great that the blocking call message shows up and I'll keep looking for the issue there, but it may help you find out why the integration is not working.

@andriej
Copy link
Contributor Author

andriej commented May 20, 2024

nc works from my machine and from HA OS too:
➜ ~ nc 192.168.x.x 2222
T00110000
BC0110000
T80190000
BC0192C00
T00090000
BC0090000
T00630000
BC0630000
^Cpunt!

➜ ~

@andriej
Copy link
Contributor Author

andriej commented May 21, 2024

If it changes anything - updating to 2024.5.4 ddin't solve the problem.

@mvn23
Copy link
Contributor

mvn23 commented May 21, 2024

Only informational that it can't connect to socket:// in UI (when I hover on the error, I see `Could not connect to gateway at socket://ip:port <Errno 111>)

Error 111 means 'Connection Refused'. Since you seem to be able to connect with nc I don't see why this would happen.
Can you post a debug log from start until this message and the 'blocking call' message have both shown up? If there's anything related to opentherm_gw or pyotgw shortly after that then please include that as well.

@andriej
Copy link
Contributor Author

andriej commented May 29, 2024

Unfortunately I do not have more debug logs, as it seems that OTGW is not even "used" in this connection.
Integration is loaded but not throwing errors in logs because there's Errno 111, which is irrelevant as I can access the data directly and have been restarting the gateway multiple times.

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

No branches or pull requests

3 participants