Websocket client sensor

It would be great if it was possible to have a websocket (client) sensor.
Binding to websockets allows instant actions, witch will come in handy for motion sensors and switches for example.

I would use it for my Xiaomi sensors connected to Deconz. Deconz offers a rest-api and websockets for specific events.

When my motion sensors detects presence this will be sent to the websocket client:

{"e":"changed","id":"2","r":"sensors","state":{"lastupdated":"2017-08-31T09:17:09","presence":false},"t":"event"} {"e":"changed","id":"2","r":"sensors","state":{"lastupdated":"2017-08-31T09:23:52","presence":true},"t":"event"}

I don’t know if it’s hard to implement, but I can imagine websockets are getting more common these days so other systems could also benefit.

It should probably be implemented using aiohttp, since that’s what already used for other stuff in HASS and no external dependency would be required. aiohttp also has support for being a websocket client.

The problem I mainly see is what is going to happen with the data. Some devices may send JSON, some others maybe something else. So there must be some mechanism to define how to parse and evaluate the data.

By any change anyone working on this ? WS sensor will be really great alternative to mqtt that does not pass over webproxy.

1 Like

Hi there
I would also like to see a websocket sensor/switch in HA
would come in very handy for my Unipi Neuron’s with EVOK.