Websocket get camera HLS stream

I’m trying to retrieve an HLS access token or stream URL like the one on the front-end/loveplace. My camera does not have any rtsp or other video streaming locally, but with the use of Tuya integration I am able to get the stream. But I would like to access camera stream outside of Home Assistant. So far I am able to get thumbnail but I want stream or HLS access token:

from websocket import create_connection
import json
ws = create_connection("ws://ip:8123/api/websocket")
result =  ws.recv()
print("Received '%s'" % result)
ws.send(json.dumps(
{
  "type": "auth",
  "access_token": "eyJ0eXAiOiJKV1QiL(...)Awu7cxLodelRXCOZFtXABMQ7fReEXLbvxtUHY1c"
}))
result =  ws.recv()
print("Received '%s'" % result)

ws.send(json.dumps(
{
  "id": 19,
  "type": "camera_thumbnail",
  "entity_id": "camera.videokamera"
}))

print("Received '%s'" % result)

ws.close()

in the second call, can you change type to camera/stream rather than camera_thumbnail?

1 Like

It works! Thank you so much! :slight_smile:

Happy to hear that enjoy

Is there a way to get the HLS access token with a HTTP request rather than a websocket connection?