basnijholt / home-assistant-streamdeck-yaml

Control Home Assistant on Stream Deck with support on all operating systems and configuration via YAML
Apache License 2.0
251 stars 15 forks source link

Connection Issue with Home Assistant WebSockets #145

Open trolleur124 opened 1 year ago

trolleur124 commented 1 year ago

Hello,

I'm trying to use Home Assistant Stream Deck YAML to control my Home Assistant system using my Stream Deck. However, I'm encountering issues when trying to connect to Home Assistant's WebSockets.

Steps to Reproduce:

I followed the instructions to set up Home Assistant Stream Deck YAML using the configuration.yaml configuration file.

I specified the correct WebSocket connection URL in the .env file.

When I run the Docker command to execute Home Assistant Stream Deck YAML, I get an error related to the WebSocket connection.

Expected Behavior:

I expect Home Assistant Stream Deck YAML to successfully connect to Home Assistant's WebSockets and allow me to control my devices and scenes via my Stream Deck.

Additional Information:

URL of my Home Assistant instance: http://raspberrypi:8123/
Configuration in .env file:

HASS_HOST=raspberrypi:8123 HASS_TOKEN=TOKEN STREAMDECK_CONFIG=configuration.yaml WEBSOCKET_PROTOCOL=ws

My error :

antoine@raspberrypi:~/home-assistant-streamdeck-yaml $ docker run --rm -it --privileged --env-file=$(pwd)/.env -v $(pwd)/:/app/ basnijholt/home-assistant-streamdeck-yaml:latest
[22:00:12] Using version 2023.8.6.dev1+gb47cdb3.d20230812 of the Home Assistant Stream Deck.        home_assistant_streamdeck_yaml.py:1923
           Starting Stream Deck integration with args.host='raspberrypi:8123',                      home_assistant_streamdeck_yaml.py:1924
           args.config=PosixPath('configuration.yaml'), args.protocol='ws # or "ws" if you don\'t
           have SSL, by default it\'s wss'
           Found 6 keys, deck=<StreamDeck.Devices.StreamDeckMini.StreamDeckMini object at           home_assistant_streamdeck_yaml.py:1489
           0xf4fc6e70>
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 1928, 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 1836, in run
    async with setup_ws(host, token, protocol) as websocket:
  File "/usr/local/lib/python3.11/contextlib.py", line 204, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/home_assistant_streamdeck_yaml.py", line 1012, in setup_ws
    async with websockets.connect(uri, max_size=10485760) as websocket:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/websockets/legacy/client.py", line 483, in __init__
    wsuri = parse_uri(uri)
            ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/websockets/uri.py", line 77, in parse_uri
    raise exceptions.InvalidURI(uri, "scheme isn't ws or wss")
websockets.exceptions.InvalidURI: ws # or "ws" if you don't have SSL, by default it's wss://raspberrypi:8123/api/websocket isn't a valid URI: scheme isn't ws or wss

I dont have SSL

Any assistance in resolving this issue would be greatly appreciated. Thank you! Antoine Jutras Canada, Québec

StonyManager commented 9 months ago

I'm no expert, but it looks to me like you have a typo in your .env file. The fourth log line where it says args.protocol= seems to have copied the whole line from .env. In my case, all it says in my log is args.protocol='ws' That # in the line should make the rest a comment and be ignored. Maybe helpful?