i am able to get snapshots from my ONVIF cameras to my mobile via Telegram whenever Frigate detects human. unfortunately 1 onvif cam, named Alley, refuses to do so… so my next option is to get the photo through Frigate’s event.
this is the generic yml that i got from the Frigate’s website but does not work. could you please advise what the syntax should be?
alias: auto send photo from alley camera human detect 2
description: ''
trigger:
- platform: mqtt
topic: frigate/events
action:
- service: telegram_bot.send_photo
data_template:
message: A {{trigger.payload_json["after"]["alley"]}} was detected.
data:
image: >-
http://192.168.1.229/api/frigate/notifications/{{trigger.payload_json["after"]["alley"]}}/thumbnail.jpg?format=android
tag: '{{trigger.payload_json["after"]["alley"]}}'
when: '{{trigger.payload_json["after"]["start_time"]|int}}'
mode: single
i dont need the whole picture. bonus if i just get the cropped section of the person as seen here:
The following works, “south_side” is the camera name, but can be a zone name as well.
If you just want the cropped image, replace “snapshot.jpg” with “thumbnail.jpg”
alias: Frigate - Notify Detected Object On South Side
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: template
value_template: >-
{{
(as_timestamp(now())-as_timestamp(state_attr('automation.frigate_notify_detected_object_on_south_side','last_triggered')
| default(0)) | int > 60) }}
- condition: template
value_template: '{{ ''south_side'' in trigger.payload_json[''after''][''camera''] }}'
action:
- service: script.turn_on
target:
entity_id: script.1620211106675
data:
variables:
where: living_room
what: >-
'A {{trigger.payload_json["after"]["label"]}} was detected on the
South Side Camera.'
- service: notify.group
data_template:
message: Some Message.
data:
photo:
- url: >-
http://ha_lan_ip:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
caption: >-
'A {{trigger.payload_json["after"]["label"]}} was detected on the
South Side Camera. Event ID
{{trigger.payload_json["after"]["id"]}}'
mode: single
- delay:
seconds: 30
- service: notify.group
data_template:
message: Some Message.
data:
video:
- url: >-
http://192.168.200.211:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/clip.mp4
timeout: 5000
caption: >-
'Video of {{trigger.payload_json["after"]["label"]}}" detected on
the South Side Camera.'
thanks for the reminder. i dont have that automation so i added it in.
so this is what it looks like:
alias: auto send photo to telegram Detected human in alley camera frigate
description: ''
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: template
value_template: >-
{{
(as_timestamp(now())-as_timestamp(state_attr('automation.auto_send_photo_from_alley_camera_human_detect_in_alley','last_triggered')
| default(0)) | int > 60) }}
- condition: template
value_template: '{{ ''alley'' in trigger.payload_json[''after''][''camera''] }}'
action:
- service: telegram_bot.send_photo
data_template:
message: Someone spotted in the alley2.
data:
photo:
- url: >-
http://192.168.1.229:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
caption: >-
'A {{trigger.payload_json["after"]["label"]}} was detected in the
alley. Event ID {{trigger.payload_json["after"]["id"]}}'
mode: single
so for automation.auto_send_photo_from_alley_camera_human_detect_in_alley’ it looks like this:
alias: alert alley camera human detect
description: ''
trigger:
- platform: state
entity_id: binary_sensor.alley_person_motion
to: 'on'
action:
- service: notify.telegram
data:
message: someone in the alley
mode: single
That’s not the automation you should be using for the condition, you can omitt the condition altogether if you want to test, but the condition is so that the automation don’t run multiple times within 60 seconds, and should be the same automation you’re using to send the message.
i am sorry i still cannot get anything to work.
could you please share all the yaml code? including this " automation.frigate_notify_detected_object_on_south_side"
alias: auto send photo to telegram Detected human in alley camera frigate
description: ''
trigger:
- platform: mqtt
topic: frigate/events
condition:
- condition: template
value_template: >-
{{ (as_timestamp(now())-as_timestamp(state_attr('automation.auto_send_photo_to_telegram_detected_human_in_alley_camera_frigate','last_triggered') | default(0)) | int > 60) }}
- condition: template
value_template: '{{ ''alley'' in trigger.payload_json[''after''][''camera''] }}'
action:
- service: telegram_bot.send_photo
data_template:
message: Someone spotted in the alley2.
data:
photo:
- url: >-
http://192.168.1.229:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
caption: >-
'A {{trigger.payload_json["after"]["label"]}} was detected in the
alley. Event ID {{trigger.payload_json["after"]["id"]}}'
mode: single
initial_state: true
You probably need to change “service: telegram_bot.send_photo” to "service: notify.(whatever your notifier name is), go to “Developer Tools > SERVICES” and type “notify.” and see what your notifier name is configured as, or post your telegram notify configuration.
BUT got nothing in Telegram. i use the same “service: telegram_bot.send_photo” service for other alerts so i know that service is working with my phone.
i really appreciate your time and help in this!
i just installed API into my config file as recommended.
i access HA via http with my desktop to do all changes, such as this automation now.
using your latest code provided on July 1st, i do get the text "
Someone spotted in the alley2.
"
Can anyone confirm that it is possible to send telegram message with snapshot, video with Telegram( Polling or broadcast) without external access to the HA instance?
Everything works with telegram_bot to send a message without attached image or video.
Hello friends! Please help with the problem. I use Frigate for motion detection and recording. Also telegram for receiving notifications. But for some reason it doesn’t work as it should. There is automation:
service: telegram_bot.send_photo
data_template:
message: ‘A {{trigger.payload_json[“after”][“label”]}} was detected.’
data:
photo:
# this url should work for addon users
- url: ‘http://192.168.1.134: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’
if you change the telegram_bot.send_message, the tex message comes. And telegram_bot.send_photo does not send anything.
After two weeks of torment, I found a solution for myself. Maybe it will be useful to someone. The only thing I don’t understand is why my strange code works. And others don’t:
'alias: Telegram sent snapshot
trigger:
platform: mqtt
topic: frigate/events
action:
- service: notify.telegram
data_template:
message: 'A {{trigger.payload_json["after"]["label"]}} was detected.'
data:
photo:
- url: >-
http://192.168.1.134:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg
caption: >-
'A {{trigger.payload_json["after"]["label"]}} was detected at the
Front {{trigger.payload_json["after"]["entered_zones"]}}'.'