Web socket Sensor

Hello All, i hope you Can help me, i have a custom system for My domo house (no brand) how Can i create a custom sensor with a custom websocket client? I’m interested only a First part, i Will connect to My URL ws://myhardwaredevice/ws and capture All message received to My new custom sensor. Thanks,for me this Is important, this Is First step for My experience with home assistant

Please help me

You will need to provide a more thorough explanation of what you need and what you have tried.

The documentation is here https://developers.home-assistant.io/docs/en/external_api_websocket.html

@vingar
Have a look at the development documentation.

@zarthan
I think he actually want’s to do it the other way around. A component that connects to an external websocket, and then uses the events it receives to update the entity. Somewhat similar to subscribing to a MQTT broker, listening to everything that gets published, and make that data accessible for Home Assistant to use.

2 Likes

All I know is I can’t be of much help. Glad you could do a better job of pointing.

Exact! My websocket Is from another device.
I would connect to this websocket, and when There are changes, My custom sensor of HA, It will have to change!
If websocket receive message: 000000;00001;000001 (example), the value of State it will have to be the same!

can anyone recommend a built-in HA library to manage an external websocket client? thanks

Home Assistant is using aiohttp. Here’s an example of how WebSockets are used with that library.

1 Like

Thanks Daniel for your interest, you have been a great help, would you be able to help me realize an example of a sensor that only contains the string received from the socket? thank you, I will be grateful

Unfortunately not. But the resources I have posted pluf looking at existing sensor-implementations should be all that’s needed to get this done. :wink:

Hello, Vingar, did you found solution for it? I am looking for somthing similar.

I am also in process to write a custom component which connects to an external websocket server to get information to HA. So, i need to use HA as a websocket client. I can use python tornado(async) or websocket-client(sync) modules in the custom component for that but i was also wondering if there is a way to use native HA methods?

I, too, am looking for a simple websocket client sensor. I have an interface on my pool that has a websocket available for me to get real time updates as JSON. I am surprised that I haven’t been able to find one. It sounds like I’m not the only one searching for this feature.

2 Likes

I am running the signal api in json mode and would like to receive messages through ws and use these to instruct home assistant - any luck with any of the above searches?

Did you get this working?

Via node red, i connected node red to the signal api. This allows for some interaction, however everything needs to be defined so not perfect

was trying to do the same, it’s odd we have a websocket server but not a client, Ended up in using Nodered as well and it work.