I am trying to create a custom component for my Securifi Almond. It has a websocket api. I am not able to get a simple websocket client up.
This just starts off a separate thread and connects to websocket
import homeassistant.loader as loader
import logging
import asyncio
import json
import websockets
import json
# The domain of your component. Should be equal to the name of your component.
DOMAIN = 'pyalmond'
# List of component names (string) your component depends upon.
def setup(hass, config):
async with websockets.connect('ws://<URL>') as websocket:
name = str('{ "MobileInternalIndex":"garage_door_hass", "CommandType":"GetDeviceIndex", "ID":"16" "Index":"1" }')
greeting = await websocket.recv()
await websocket.send(name)
almond_garage_door= await websocket.recv()
hass.states.set('sensor.almond_garage_door', 'Open')
return True