Hi
Question in a nutshell is the following: When using required_zones in frigate, how do I send notifications (to the phone, WhatsApp or Telegram) with the same image that Frigate has in it’s event, that is when you look at the events in the Frigate GUI.
The way I solved it is the following with some drawback. I have a Frigate integration inside the HASS that is using MQTT for events. This is a standard frigate integration.
In Frigate I have required_zones configured for clips and recordings. Therefore the events are created in Frigate only when the object detection is positive inside the required_zones.
Then i Have an automation that is triggered on ALL events and have a condition that checks if the occupancy inside the zone has been satisfied. If so then the message via telegram is being pushed out. That image URL is being built using
The drawback with this approach is that EVERY event (of type: new, end) will be processed by the automation. That is all objects OUTSIDE of the required_zones. Thats a lot of events during the day when cars and people are passing by.
What I instead want is to be able to send notification with the image but only when the objects is inside the required_zone.
I have tried to use the occupancy as a trigger without using events but then I have no access to the image URL or dont know how to retrieve it since there is no payload data containing it.
Here is my automation which works but with unnecessary overhead
alias: Frigate Notification
description: ""
trigger:
- platform: mqtt
topic: frigate/events
value_template: "{{ value_json.type }}"
payload: new
- platform: mqtt
topic: frigate/events
value_template: "{{ value_json.type }}"
payload: end
condition:
- or:
- condition: state
entity_id: binary_sensor.zone_driveway_all_occupancy
state: "on"
- condition: state
entity_id: binary_sensor.zone_frontside_all_occupancy
state: "on"
action:
- service: notify.telegram_notify
data:
message: MSG
title: Tittle
data:
photo:
- url: >-
http://192.168.2.194:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg?box=1
caption: >-
A {{trigger.payload_json["after"]["label"]}} was detected by
{{trigger.payload_json["after"]["camera"]}} camera.
mode: single