From 374880992ca977af873763f22db8755f2de155da Mon Sep 17 00:00:00 2001 From: Tony Peng <4816327+t0ny-peng@users.noreply.github.com> Date: Wed, 23 Jun 2021 00:44:44 -0400 Subject: [PATCH] Add note about clip not being immediately available after the end event. Add automation example with a delay. --- docs/docs/usage/home-assistant.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/docs/usage/home-assistant.md b/docs/docs/usage/home-assistant.md index 45764e01a..000889f55 100644 --- a/docs/docs/usage/home-assistant.md +++ b/docs/docs/usage/home-assistant.md @@ -42,6 +42,10 @@ To load a video clip taken by frigate from Home Assistants API : https://HA_URL/api/frigate/notifications///clip.mp4 ``` +:::caution +The clip video is not immediately available after the `end` event arrives. +::: + Here is a simple example of a notification automation of events which will update the existing notification for each change. This means the image you see in the notification will update as frigate finds a "better" image. ```yaml @@ -113,6 +117,29 @@ automation: tag: "{{trigger.payload_json['after']['id']}}" ``` +```yaml +# Tested on iOS +- alias: Play the clip video in the notification dropdown when the last event arrives + trigger: + platform: mqtt + topic: frigate/events + condition: + - "{{ trigger.payload_json['after']['label'] == 'person' }}" + - "{{ 'yard' in trigger.payload_json['before']['current_zones'] }}" + - "{{ trigger.payload_json['type'] == 'end'}}" + action: + # A delay is needed here because frigate needs some time to store the clip video, + # otherwise HA companion app will show 404 in the notification. + - delay: "00:00:15" + - service: notify.mobile_app_jojo + data_template: + title: "Motion detected" + message: "A {{trigger.payload_json['after']['label']}} has entered the yard." + data: + video: "https://HA_URL/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/{{trigger.payload_json['after']['camera']}}/clip.mp4" + tag: "{{trigger.payload_json['after']['id']}}" +``` + If you are using telegram, you can fetch the image directly from Frigate: ```yaml