hass-gardena-smart-system icon indicating copy to clipboard operation
hass-gardena-smart-system copied to clipboard

Not reconnecting after temporary loss of internet connection

Open hazzit1 opened this issue 2 years ago • 7 comments
trafficstars

I've recently had two internet DSL reconnects which resulted in the "Gardena Smart System connection" to stay as "disconnected".

A HA reboot fixed the problem until the next internet connection loss.

Maybe #136 is related?

hazzit1 avatar Jun 01 '23 15:06 hazzit1

I have the same issue. The integration looses connection after a while (Not sure if this is related to the automatic DSL reconnect) I have to restart home assistant to connect again. Any idea how to fix this. Unfortunately it’s also not possible to reload the integration via e.g. automation.

knallt avatar Jun 24 '23 06:06 knallt

The problem exist for a longer time. Every time I update my devices and my HomeAssistant system loose internet connectivity for a few minutes the APi connection is lost till you restart HA core. It seems to me that no re-authentication takes place in such a case. I generated a monitor and an alert to be able to restart HA core. But it would be great to have the restart method for integrations integrated.

Bildschirmfoto 2023-07-25 um 13 11 39

martinw72 avatar Jul 25 '23 11:07 martinw72

I have the same problem. Problem has been in existence from the issue of this version. Would be happy to be part of a test group when allocated for fixing

mash727 avatar Jul 30 '23 23:07 mash727

I also face this problem that the device stays disconnected after an internet loss. As the internet router performs a daily re-connection this results in regular connection losses (probably once a week). I would be happy to get a solution for this and if I can help in any way just let me know.

Nevertheless: Thanks for your efforts for providing this integration. I like it.

Stoffl17 avatar Aug 08 '23 09:08 Stoffl17

Same problem

GLehnhoff avatar Sep 25 '23 05:09 GLehnhoff

I have a similar issue. In my case, during startup of Home Assistant, it cannot connect, and will never reconnect afterward. That is with Gardena plugin v1.0.0 installed via HACS.

Logs:

Logger: homeassistant.config_entries
Source: config_entries.py:399
First occurred: 1:44:09 PM (1 occurrences)
Last logged: 1:44:09 PM

Error setting up entry for gardena_smart_system
Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/anyio/streams/tls.py", line 131, in _call_sslobject_method
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/ssl.py", line 979, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:1006)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 69, in start_tls
    ssl_stream = await anyio.streams.tls.TLSStream.wrap(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/anyio/streams/tls.py", line 123, in wrap
    await wrapper._call_sslobject_method(ssl_object.do_handshake)
  File "/lsiopy/lib/python3.11/site-packages/anyio/streams/tls.py", line 138, in _call_sslobject_method
    data = await self.transport_stream.receive()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1203, in receive
    await self._protocol.read_event.wait()
  File "/usr/lib/python3.11/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_exceptions.py", line 10, in map_exceptions
    yield
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 78, in start_tls
    raise exc
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 68, in start_tls
    with anyio.fail_after(timeout):
  File "/lsiopy/lib/python3.11/site-packages/anyio/_core/_tasks.py", line 119, in __exit__
    raise TimeoutError
TimeoutError

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

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
    yield
  File "/lsiopy/lib/python3.11/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
    raise exc
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
    response = await connection.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_async/connection.py", line 92, in handle_async_request
    raise exc
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_async/connection.py", line 69, in handle_async_request
    stream = await self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_async/connection.py", line 149, in _connect
    stream = await stream.start_tls(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 66, in start_tls
    with map_exceptions(exc_map):
  File "/usr/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/lsiopy/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectTimeout

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

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/config_entries.py", line 399, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gardena_smart_system/__init__.py", line 49, in async_setup_entry
    await gardena_system.start()
  File "/config/custom_components/gardena_smart_system/__init__.py", line 85, in start
    await self.smart_system.authenticate()
  File "/config/lsiopy/lib/python3.11/site-packages/gardena/smart_system.py", line 80, in authenticate
    self.token_manager.load_from_oauth2_token(await self.client.fetch_token(
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 125, in _fetch_token
    resp = await self.post(
           ^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1848, in post
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 90, in request
    return await super(AsyncOAuth2Client, self).request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/lsiopy/lib/python3.11/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectTimeout

debackerl avatar Oct 23 '23 11:10 debackerl

same issue here, any solution yet?

@martinw72 how did you implement the monitoring?

tob1234567 avatar Feb 15 '24 14:02 tob1234567