Closed musapinar closed 2 months ago
Your should use WebRTC Camera integration.
@AlexxIT Isn't that a "custom component"/card integration ? How is that related to my request ? 😕
I already do have Go2rtc and Frigate set up an running fine. It does stream great through both Frigate and as a "Generic camera" as well, with subsecond latency, externally (outside the LAN).
I need an URL. How does the "WebRTC Camera integration" achieve this ?
Anyways, I went the long route and ended up implementing webtorrent.
I copied your html/js at https://alexxit.github.io/go2rtc/#share=redacted&pwd=redacted&media=video+audio
and put it locally within a folder /homeassistant/www/player/
as an index.html, that I now reach at https://hass.redacted.com/local/player/index.html#share=porche_sub&pwd=redacted&media=video+audio
Here is how it looks like in frigate.yaml
[...]
go2rtc:
streams:
Garage:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/401
- ffmpeg:Garage#audio=opus
Garage_sub:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/402
- ffmpeg:Garage_sub#audio=opus
Porche:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/301
- ffmpeg:Porche#audio=opus
Porche_sub:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/302
- ffmpeg:Porche_sub#audio=opus
Terrasse:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/101
- ffmpeg:Terrasse#audio=opus
Terrasse_sub:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/102
- ffmpeg:Terrasse_sub#audio=opus
Allee:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/201
- ffmpeg:Allee#audio=opus
Allee_sub:
- rtsp://redacted:redacted@192.168.1.28:554/Streaming/channels/202
- ffmpeg:Allee_sub#audio=opus
webtorrent: # https://github.com/AlexxIT/go2rtc?tab=readme-ov-file#module-webtorrent
shares:
# /homeassistant/www/player/index.html => https://hass.redacted.com/local/player/index.html#share=porche_sub&pwd=redacted&media=video+audio
porche_sub: # share name, should be unique among all go2rtc users!
pwd: redacted
src: Porche_sub # stream name from streams section
garage_sub:
pwd: redacted
src: Garage_sub
terrasse_sub:
pwd: redacted
src: Terrasse_sub
allee_sub:
pwd: redacted
src: Allee_sub
[...]
pwd
is identical for all 4 streams (32 chars).
So now I can set my tap_action such as :
tap_action: '{{base_url}}/local/player/index.html#share={{trigger.payload_json[''after''][''camera'']
| lower | replace(''-'',''_'')}}_sub&pwd=redacted&media=video+audio'
which does work as I expected.
How safe is torrenting ? I wish I did not have to rely on openwebtorrent. Can you elaborate about "WebRTC Camera integration" ?
This component can "generate URL to WebRTC stream". You also can use WebTorrent technology. It have static URL, if you setup it via go2rtc config.
OK. Found it : https://github.com/AlexxIT/WebRTC/wiki/Cast-or-share-camera-stream#html-page Thanks.
"Frigate Notification" integration (https://github.com/SgtBatten/HA_blueprints) allows you to send notifications on your mobile phone when a person is detected. Clicking on the notification can redirect you to the player. yaml configuration of such an automation looks like this :
which will generate a link like :
https://hass.redacted.com/api/camera_proxy_stream/camera.porche?token=6943b3017636a1d83527e238423ea55acbafa2c610970f6f7e7b087c23d313dc
Problem : the "stream" it returns is actually just a jpeg image (a snapshot, not even an mjpeg) ? if I pull-to-refresh on my phone or press F5 on my desktop browser, it does refresh the image with a more recent snapshot.
Question : Having only the "token" as a relevant camera entity (which seems safe enough to me as it appears to be a "rolling" code refreshed every x minutes), how can I return the webrtc video player ?
Thank you.