I have never tried it, but maybe this helps: https://www.home-assistant.io/developers/websocket_api/
If you don’t require authentication the JavaScript/HTML code that’s linked might already show what you need. Can’t test that though because I have authentication enabled and haven’t looked into adding authentication.
Resurrecting this topic. This looks like just what I need.
@danielperna84, should the version with authentication work using a long-lived access token instead of the old password authentication method? I tried simply pasting in a long-lived access token for api_password in line 25 without success. I’m unsure if/how to change the headers otherwise.
The old password has been deprecated for ages. So only the token should work (and maybe other authenticatoin methods).
But I’m no expert. I just pointed at the documentation of which I know exists.