MyHOME icon indicating copy to clipboard operation
MyHOME copied to clipboard

myHome does not handle properly connection failures

Open f18m opened this issue 1 year ago • 0 comments

Hi, I noticed this problem several times. To reproduce it: 0) start from a working myHome setup

  1. disconnect the myHomeServer from the network (or just shut down the switch it's connected to)
  2. restart HomeAssistant

With these 2 steps the myHome integration does not work and I find this message in the logs:

Registratore: homeassistant.config_entries
Fonte: config_entries.py:551
Prima occorrenza: 15 aprile 2024 alle ore 20:42:13 (1 occorrenze)
Ultima registrazione: 15 aprile 2024 alle ore 20:42:13

Error setting up entry MyHomeServer1 Gateway for myhome

Traceback (most recent call last):
  File "/config/custom_components/myhome/__init__.py", line 87, in async_setup_entry
    tests_results = await hass.data[DOMAIN][mac][CONF_ENTITY].test()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/myhome/gateway.py", line 131, in test
    return await OWNSession(gateway=self.gateway, logger=LOGGER).test_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/OWNd/connection.py", line 240, in test_connection
    ) = await asyncio.open_connection(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1120, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1102, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1005, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.6', 20000)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/myhome/__init__.py", line 89, in async_setup_entry
    _gateway_handler = hass.data[DOMAIN].pop(CONF_GATEWAY)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'gateway'

f18m avatar Apr 16 '24 05:04 f18m