Open bacco007 opened 1 year ago
At that point it is waiting for the complete state that will be send over from Home Assistant. For me this can take ~30s. How long did you wait?
My HA is on a Nuc and StreamDeck on RPI4.
I've just noticed that its come alive and has the icons I setup as a test - not sure how long it took, but happened since I logged the issue.
Rebooted and now its not working again:
Traceback (most recent call last):
File "/usr/local/bin/home-assistant-streamdeck-yaml", line 8, in <module>
sys.exit(main())
^^^^^^
File "/app/home_assistant_streamdeck_yaml.py", line 1176, in main
asyncio.run(
File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/app/home_assistant_streamdeck_yaml.py", line 1139, in run
complete_state = await get_states(websocket)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/home_assistant_streamdeck_yaml.py", line 683, in get_states
data = json.loads(await websocket.recv())
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 568, in recv
await self.ensure_open()
File "/usr/local/lib/python3.11/site-packages/websockets/legacy/protocol.py", line 953, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)
This error occurs when the WebSocket connection is closed with a status code of 1000 (OK) while your script is still trying to receive data from it.
Here's a breakdown of the error:
home_assistant_streamdeck_yaml.py
, the run()
function is calling get_states(websocket)
.get_states()
function tries to receive data from the WebSocket by calling await websocket.recv()
.websockets
library, the recv()
function checks if the WebSocket connection is still open by calling await self.ensure_open()
.ensure_open()
function raises a ConnectionClosedOK
exception because the connection was closed with a status code of 1000 (OK).It appears that the WebSocket connection is being closed normally (with status code 1000), but the script is still trying to receive data from it. This could be due to a timing issue, an issue with the remote server closing the connection, or a problem with the way the script is handling the WebSocket connection.
To resolve this issue, I could add error handling to catch the ConnectionClosedOK
exception and handle it gracefully, for example, by retrying the connection or logging an appropriate message. I might also want to somehow investigate why the connection is being closed and ensure that the script is managing the WebSocket connection correctly.
Will try to do this soon!
Hey, I wanted to let you know that I've recently released a new Home Assistant Supervisor add-on, which significantly simplifies the configuration process for the Stream Deck integration. It's designed to make your experience even more enjoyable and hassle-free. I invite you to check it out at https://github.com/basnijholt/home-assistant-streamdeck-yaml-addon and give it a try. Your feedback is always appreciated!
BTW when debugging I also ran into the 1000
error. It turned out my token didn't have the correct permissions.
It seems to detect the stream deck ok, but the device remains on the elgato logo screensaver - tried rebooting the Pi and restarting the docker container to no avail
I did wonder whether the Pi3 isnt powerful enough though