I too am experiencing the issue the addon fails to launch after restart of HA, both with and without watchdog service enabled. I think a similar error.
But it always works with manual start.
Perhaps something to do with the timing of addon launch? If the network is not yet up could cause failure. I’m no expert.
I do seem to have found a workaround, perhaps @NoFace you’d be interested.
I have the Portainer add-on installed, and if I use that to change the restart policy for the kodi2home container to “always”, it successfully launches after rebooting twice now.
I think it still throws the same error on first launch, but subsequently launches ok.
All logs below if it can be of use.
As ever thanks @DJJo14 for the fantastic add-on.
With watchdog enabled:
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2024-03-04 22:35:19,420 kodi settings: 10.0.1.11, 8080 9090, kodi, *
2024-03-04 22:35:19,422 Home assistant settings: ws://supervisor/core/api/websocket, False, *
2024-03-04 22:35:19,466 Kodi is connected {'name': 'Kodi', 'version': {'major': 21, 'minor': 0, 'revision': '87d2d6f84799224f5fe63a6bba3e973e84e18fef', 'tag': 'beta', 'tagversion': '2'}}
Traceback (most recent call last):
File "/kodi2home.py", line 178, in main
loop.run_until_complete( tasks )
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/kodi2home.py", line 112, in run_recv_home
await self.connect_to_home()
File "/kodi2home.py", line 66, in connect_to_home
self.websocket = await websockets.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
return await self.__await_impl__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 654, in __await_impl__
await protocol.handshake(
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 325, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 502
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/kodi2home.py", line 185, in <module>
main()
File "/kodi2home.py", line 180, in main
loop = asyncio.get_running_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
With no watchdog but “start on boot” enabled:
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2024-03-04 22:42:53,834 kodi settings: 10.0.1.11, 8080 9090, kodi, *
2024-03-04 22:42:53,836 Home assistant settings: ws://supervisor/core/api/websocket, False, *
2024-03-04 22:42:53,876 Kodi is connected {'name': 'Kodi', 'version': {'major': 21, 'minor': 0, 'revision': '87d2d6f84799224f5fe63a6bba3e973e84e18fef', 'tag': 'beta', 'tagversion': '2'}}
2024-03-04 22:42:53,888 Home Assistant: {"type":"auth_required","ha_version":"2024.2.5"}
2024-03-04 22:42:53,891 Home Assistant: {"type":"auth_ok","ha_version":"2024.2.5"}
2024-03-04 22:42:53,891 connected to home
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 963, in transfer_data
message = await self.read_message()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 1033, in read_message
frame = await self.read_data_frame(max_size=self.max_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 1108, in read_data_frame
frame = await self.read_frame(max_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 1165, in read_frame
frame = await Frame.read(
^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/framing.py", line 68, in read
data = await reader(2)
^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/streams.py", line 730, in readexactly
raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/kodi2home.py", line 178, in main
loop.run_until_complete( tasks )
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/kodi2home.py", line 117, in run_recv_home
home_data = await self.websocket.recv()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 568, in recv
await self.ensure_open()
File "/usr/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 939, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: no close frame received or sent
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/kodi2home.py", line 185, in <module>
main()
File "/kodi2home.py", line 180, in main
loop = asyncio.get_running_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
With restart policy modified via portainer:
2024-03-04 22:52:25,556 Kodi is connected {'name': 'Kodi', 'version': {'major': 21, 'minor': 0, 'revision': '87d2d6f84799224f5fe63a6bba3e973e84e18fef', 'tag': 'beta', 'tagversion': '2'}}
Traceback (most recent call last):
File "/kodi2home.py", line 178, in main
loop.run_until_complete( tasks )
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/kodi2home.py", line 112, in run_recv_home
await self.connect_to_home()
File "/kodi2home.py", line 66, in connect_to_home
self.websocket = await websockets.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
return await self.__await_impl__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 654, in __await_impl__
await protocol.handshake(
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 325, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 502
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/kodi2home.py", line 185, in <module>
main()
File "/kodi2home.py", line 180, in main
loop = asyncio.get_running_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2024-03-04 22:52:31,551 kodi settings: 10.0.1.11, 8080 9090, kodi, *
2024-03-04 22:52:31,554 Home assistant settings: ws://supervisor/core/api/websocket, False, *
2024-03-04 22:52:31,594 Kodi is connected {'name': 'Kodi', 'version': {'major': 21, 'minor': 0, 'revision': '87d2d6f84799224f5fe63a6bba3e973e84e18fef', 'tag': 'beta', 'tagversion': '2'}}
Traceback (most recent call last):
File "/kodi2home.py", line 178, in main
loop.run_until_complete( tasks )
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/kodi2home.py", line 112, in run_recv_home
await self.connect_to_home()
File "/kodi2home.py", line 66, in connect_to_home
self.websocket = await websockets.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 647, in __await_impl_timeout__
return await self.__await_impl__()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 654, in __await_impl__
await protocol.handshake(
File "/usr/lib/python3.11/site-packages/websockets/legacy/client.py", line 325, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 502
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/kodi2home.py", line 185, in <module>
main()
File "/kodi2home.py", line 180, in main
loop = asyncio.get_running_loop()
^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
2024-03-04 22:52:39,281 kodi settings: 10.0.1.11, 8080 9090, kodi, *
2024-03-04 22:52:39,283 Home assistant settings: ws://supervisor/core/api/websocket, False, *
2024-03-04 22:52:39,328 Kodi is connected {'name': 'Kodi', 'version': {'major': 21, 'minor': 0, 'revision': '87d2d6f84799224f5fe63a6bba3e973e84e18fef', 'tag': 'beta', 'tagversion': '2'}}
2024-03-04 22:52:39,354 Home Assistant: {"type":"auth_required","ha_version":"2024.2.5"}
2024-03-04 22:52:39,356 Home Assistant: {"type":"auth_ok","ha_version":"2024.2.5"}
2024-03-04 22:52:39,357 connected to home