core: Timeout Errors with BSBLAN

The problem

Hello,

with #94315 I am now able to connect with my BSBLAN adapter. However, I get timeout error regularly. What can I do or configure to prevent the error?

I set the following parameters for logging in BSB-LAN: Bildschirmfoto 2023-08-07 um 06 55 35

What version of Home Assistant Core has the issue?

core-2023.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

bsblan

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.bsblan
Source: helpers/update_coordinator.py:242
Integration: BSB-Lan (documentation, issues)
First occurred: 6. August 2023 um 10:11:50 (96 occurrences)
Last logged: 04:53:54

Unexpected error fetching bsblan_192.168.178.191 data: Timeout occurred while connecting to BSBLAN device.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/bsblan/bsblan.py", line 119, in _request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 628, in sock_connect
    return await fut
           ^^^^^^^^^
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/bsblan/bsblan.py", line 118, in _request
    async with async_timeout.timeout(self.request_timeout):
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bsblan/bsblan.py", line 166, in state
    data = await self._request(params={"Parameter": f"{self._string_circuit1}"})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bsblan/bsblan.py", line 129, in _request
    raise BSBLANConnectionError(
bsblan.exceptions.BSBLANConnectionError: Timeout occurred while connecting to BSBLAN device.

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

I did some testing and tried to reproduce it. As I wrote, I can reproduce it by polling BSB-Lan when it is already busy. I think the same thing is happening to you, even if you have disabled sending via MQTT, the parameters are probably still being queried in the background.

I may have created a bugfix that randomizes the update interval a bit to probably hit these timeouts less often. This also fixes the flooding of the log with stack trace in case of a timeout. In my case, I haven’t had any new timeouts since then.

Thanks for the hint. I will try the newest master version during this week.