OpenVoiceOS / ovos-PHAL-plugin-homeassistant

HomeAssistant PHAL Plugin for OpenVoice OS
Apache License 2.0
11 stars 3 forks source link

[BUG] Normalize user-inputted URL for HomeAssistant #30

Closed mikejgray closed 1 year ago

mikejgray commented 1 year ago
2023-06-15 22:58:27.673 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:_connect:64 - ERROR - Http://10.0.1.141:8123/api/websocket isn't a valid URI: scheme isn't ws or wss
Traceback (most recent call last):
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 48, in _connect
   self.websocket = await websockets.connect(uri)
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/legacy/client.py", line 490, in __init__
   wsuri = parse_uri(uri)
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/uri.py", line 77, in parse_uri
   raise exceptions.InvalidURI(uri, "scheme isn't ws or wss")
websockets.exceptions.InvalidURI: Http://10.0.1.141:8123/api/websocket isn't a valid URI: scheme isn't ws or wss
2023-06-15 22:58:27.677 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:run:246 - INFO - self.loop.is_running=False
2023-06-15 22:59:33.639 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:_connect:64 - ERROR - sent 1000 (OK); then received 1000 (OK)
Traceback (most recent call last):
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 58, in _connect
   await self.authenticate()
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 39, in authenticate
   await self.listen()
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 75, in listen
   message = await self.websocket.recv()
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 568, in recv
   await self.ensure_open()
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 953, in ensure_open
   raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: sent 1000 (OK); then received 1000 (OK)
2023-06-15 22:59:33.643 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:run:246 - INFO - self.loop.is_running=False
2023-06-15 22:59:33.869 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:_connect:64 - ERROR - sent 1000 (OK); then received 1000 (OK)
Traceback (most recent call last):
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 58, in _connect
   await self.authenticate()
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 39, in authenticate
   await self.listen()
 File "/home/neon/venv/lib/python3.7/site-packages/ovos_PHAL_plugin_homeassistant/logic/socketclient.py", line 75, in listen
   message = await self.websocket.recv()
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 568, in recv
   await self.ensure_open()
 File "/home/neon/venv/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 953, in ensure_open
   raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedOK: sent 1000 (OK); then received 1000 (OK)
2023-06-15 22:59:33.873 - enclosure - ovos_PHAL_plugin_homeassistant.logic.socketclient:run:246 - INFO - self.loop.is_running=False

I think the plugin replaces http with wss, but we might want to lowercase the whole URL first