Open o0Zz opened 2 weeks ago
We can totally use the web socket API!
We can just add a WebSocketClient
that follows a similar protocol to other clients. I would expect most of the existing endpoints to be supported with websockets too but I haven't looked into it much yet. I think it'd be epic to wrap the websocket api. I wish I could do it myself but frankly I'm swamped this semester 😅
I'll work on it here and there on a branch.
Hi,
It seems that Home Assistant is moving away from maintaining the REST API in favor of the WebSocket API, as indicated by discussions on various forums. Due to this shift, the REST API has limited support for certain features, such as retrieving forecast data. Specifically, calling a service like get_forecasts does not work properly via the REST API, as it doesn't support returning data responses (even when using return_response=True).
For example, the following code:
results in a 500 error.
Related issues are tracked here:
Issue #106379 Issue #99820 Currently, the only reliable way to call this service and receive a response is through the WebSocket API, which complicates things if this library doesn't natively support WebSocket connections.
Here's a reference on how to interact with the WebSocket API in Python: https://jeroenboumans.medium.com/listening-to-the-home-assistent-websocket-api-with-python-7a074f8c81ea
Would you be open to supporting WebSocket integration in this library? It would make it much easier to interact with Home Assistant services moving forward.
Thanks for your time and consideration!