Setup: RPi4 running Hassos. Both Hassos and Frigate are the latest versions.
Use case: when I receive an alert from a Frigate camera I would like to send the resultant video clip to my devices via the Telegram Bot. I can do this for the thumbnail picture but I have spent hours trying to make it work with video. Both the Home Assistant Telegram and Frigate documentation refer to this use case, but neither shows how it is done.
alias: Frigate alerts
description: Person/car detection in cameras from Frigate
trigger:
- platform: mqtt
topic: frigate/events
condition: []
action:
- service: notify.camera_alert_telegram
data:
message: >-
A {{trigger.payload_json["after"]["label"]}} was detected on
{{trigger.payload_json["after"]["camera"]}}
data:
video:
- url: >-
'http://ccab4aaf-frigate:5000/api/events/{{trigger.payload_json["after"]["id"]}}/{{trigger.payload_json["after"]["camera"]}}/clip.mp4'
caption: >-
'Video of {{trigger.payload_json["after"]["label"]}} detected on
{{ trigger.payload_json["after"]["camera"] }}'
mode: single
And here are the error messages I receive.
Can't load data into ByteIO: No connection adapters were found for "'http://ccab4aaf-frigate:5000/api/events/1614904741.504328-knf1ic/Camera1/clip.mp4'"
and
Can't send file with kwargs: {'message': "'Video from person detected on Camera1'", 'url': "'http://ccab4aaf-frigate:5000/api/events/1614904741.504328-knf1ic/Camera1/clip.mp4'", 'caption': "'Video caption for person detected on Camera1'"}
I am guessing I have made a syntax error but I can’t see where. Please help!
Hi I presume that you have checked that you can see the video in the Media Browser (under Frigate/Clips)?
If so, this is how I got sending via Telegram working:
Set a delay after the end of the detection (it seems like it needs to be at least 30 seconds but I found 45 seconds more reliable) before attempting to send the video;
Set the timeout to 1000 in the video attachment YAML files. (add a line with timeout: 1000 after the video URL).
I hope this helps
Hi, just testing Telegram with Frigate for the first time, and have this running on my dev-nuc. Do I need to give access from internet (port forwarding) to my dev-nuc for this to work, ref the URL or should it still work by just using:
I use the access from the Internet. My port is open already so that I can access and control HA from outside my home. I am using DuckDNS to set up a SSL connection
Hi I can still receive photos notification, but I’m still not getting videos on telegram @allenrong88 is it working for you?
Logs
Can't send file with kwargs: {'message': 'Video of alert', 'url': 'http://ccab4aaf-frigate:5000/api/events/1621081093.316226-dwpaga/kitchen/clip.mp4', 'timeout': 1000, 'caption': 'A person was detected on kitchen camera'}
Can't send file with kwargs: {'message': 'Video of alert', 'url': 'http://ccab4aaf-frigate:5000/api/events/1621081367.345592-yaoo5l/kitchen/clip.mp4', 'timeout': 1000, 'caption': 'A person was detected on kitchen camera'}
Can't send file with kwargs: {'message': 'Video of alert', 'url': 'http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4', 'timeout': 1000, 'caption': 'A person was detected on kitchen camera'}
Status code 404 (retry #1) loading http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4
Status code 404 (retry #2) loading http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4
Status code 404 (retry #3) loading http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4
Status code 404 (retry #4) loading http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4
Status code 404 (retry #5) loading http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4
Can't load data in http://ccab4aaf-frigate:5000/api/events/1621081093.316226-dwpaga/kitchen/clip.mp4 after 5 retries
Can't load data in http://ccab4aaf-frigate:5000/api/events/1621081367.345592-yaoo5l/kitchen/clip.mp4 after 5 retries
Can't load data in http://ccab4aaf-frigate:5000/api/events/1621083291.687607-6zy6t7/kitchen/clip.mp4 after 5 retries
My automation
- alias: Notify of events
trigger:
platform: mqtt
topic: frigate/events
action:
- service: notify.telegram
data_template:
message: 'A {{trigger.payload_json["after"]["label"]}} was detected.'
data:
photo:
# this url should work for addon users
- url: 'http://ccab4aaf-frigate:5000/api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg'
caption: 'A {{trigger.payload_json["after"]["label"]}} was detected on {{ trigger.payload_json["after"]["camera"] }} camera'
- delay:
hours: 0
minutes: 0
seconds: 53
milliseconds: 0
- service: notify.telegram
data_template:
message: Video of alert
data:
video:
- url: 'http://ccab4aaf-frigate:5000/api/events/{{trigger.payload_json["after"]["id"]}}/{{trigger.payload_json["after"]["camera"]}}/clip.mp4'
timeout: 1000
caption: 'A {{trigger.payload_json["after"]["label"]}} was detected on {{ trigger.payload_json["after"]["camera"] }} camera'
mode: single