home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.55k stars 29.91k forks source link

Velux component preventing Home Assistant to restart from GUI #38391

Closed HAjerry closed 3 years ago

HAjerry commented 4 years ago

The problem

I am using Velux KLF200 with firmware 0.2.0.0.71.0, already installed on delivery. If I restart the Velux box before starting Home Assistant, everything works fine. I can control the two covers connected to the KLF200. However, if I later try to restart Home Assistant from the GUI (Configuration | Server controls | Restart) then Home Assistant never starts again. Also, the homeassistant.log file is not updated. I have noticed that it DOES work to restart Home Assistant from the CLI: $ sudo systemctl restart home-assistant@homeassistant.service. I then get the below error message in homeassistant.log.

Environment

Problem-relevant configuration.yaml

velux:
  host: "<ip>"
  password: "<pwd>"

Traceback/Error logs

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/setup.py", line 193, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
    return fut.result()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/velux/__init__.py", line 31, in async_setup
    await hass.data[DATA_VELUX].async_start()
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/velux/__init__.py", line 69, in async_start
    await self.pyvlx.load_scenes()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/pyvlx.py", line 89, in load_scenes
    await self.scenes.load()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/scenes.py", line 51, in load
    await get_scene_list.do_api_call()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/api_event.py", line 21, in do_api_call
    await self.send_frame()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/api_event.py", line 33, in send_frame
    await self.pyvlx.send_frame(self.request_frame())
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/pyvlx.py", line 72, in send_frame
    await self.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/pyvlx.py", line 45, in connect
    await self.connection.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyvlx/connection.py", line 85, in connect
    self.transport, _ = await self.loop.create_connection(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1046, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1076, in _create_connection_transport
    await waiter
ConnectionAbortedError: SSL handshake is taking longer than 60.0 seconds: aborting the connection

Additional information

This is probably similar to issue #21946.

mtdcr commented 4 years ago

@HAjerry Can you please verify whether Home Assistant restarts reliably after you disabled the velux component completely?

The connection issue is already covered by https://github.com/home-assistant/core/issues/34844. In my experience, it does not prevent Home Assistant from starting. Only the velux component would usually fail to initialize under that condition.

Therefore, please make sure there's no other component responsible for your failed shutdown and startup sequence. Do you have any custom components installed? Because the aborted shutdown (SIGKILL sent by systemd) is the reason for the velux component not being able to reconnect to the KLF200 later.

This backtrace showing up in the log may be a reason for people to believe that the velux component might be responsible for totally unrelated problems during startup.

HAjerry commented 4 years ago

Sorry for late reply. I have tried in the past to disable the velux component which made restart work again. However, I would like to confirm this with some more testing including the work around covered by #34844. I will get back once I have looked more into this.

HAjerry commented 4 years ago

@mtdcr - I can confirm that the problem only occurs when I am using the Velux component. If I comment out the Velux component, restart from the GUI works perfectly fine. Do you need any additional logs? Just let me know. FYI, I am using the Miele component which is a custom component.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.