Files
fresh-home/automations/frigate/frigate_person_front_porch.yaml
T
2024-04-14 14:08:56 -04:00

155 lines
6.4 KiB
YAML

id: "1642041485222"
alias: Frigate Person Front Porch
description: "Fire a notification if a person is detected by Frigate in the front yard"
mode: single
max_exceeded: silent
trigger:
platform: mqtt
topic: frigate/events
payload: frigate_cam19
value_template: "{{ value_json['after']['camera'] }}"
variables:
id: "{{ trigger.payload_json['after']['id'] }}"
camera: "{{ trigger.payload_json['after']['camera'] }}"
camera_name: "{{ camera | replace('_', ' ') | title }}"
object: "{{ trigger.payload_json['after']['label'] }}"
label: "{{ object | title }}"
entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
type: "{{ trigger.payload_json['type'] }}"
base_url: https://automation.clintweaver.com
group_target: ""
zone_only: true
input_zones:
- front_porch
- driveway
zones: "{{ input_zones | list }}"
input_labels:
- person
labels: "{{ input_labels | list }}"
presence_entity: person.clint
condition:
- "{{ type != 'end' }}"
- "{{ not zone_only or entered_zones|length > 0 }}"
- "{{ not zones|length or zones|select('in', entered_zones)|list|length > 0 }}"
- "{{ not labels|length or object in labels }}"
#- "{{ not presence_entity or not is_state(presence_entity, 'home') }}"
- '{{ is_state("binary_sensor.garage_door","off") }}'
- '{{ is_state("binary_sensor.outer_garage_door","off") }}'
- '{{ is_state("binary_sensor.front_door_contact","off") }}'
- '{{ is_state("binary_sensor.patio_door_contact","off") }}'
- '{{ is_state("binary_sensor.front_porch_motion","off") }}'
- '{{ is_state("binary_sensor.garage_motion_switch_home_security_motion_detection","off") }}'
action:
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: 70c62eb366d6ed914b0ccc6bf41c32fd
domain: mobile_app
type: notify
message: A {{ label }} was detected on the {{ camera_name }} camera.
data:
tag: "{{ id }}"
group: frigate-notification-{{ camera }}
image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
attachment:
url: /api/frigate/notifications/{{id}}/thumbnail.jpg
- service: persistent_notification.create
data:
title: A {{ label }} was detected on the {{ camera_name }} camera.
message: 'A {{ label }} was detected on the {{ camera_name }} camera. ![image](https://automation.clintweaver.com/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg)'
notification_id: "{{ id }}"
default:
- service: notify.{{ group_target }}
data:
message: A {{ label }} was detected on the {{ camera_name }} camera.
data:
tag: "{{ id }}"
group: frigate-notification-{{ camera }}
image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
attachment:
url: /api/frigate/notifications/{{id}}/thumbnail.jpg
- repeat:
sequence:
- wait_for_trigger:
- platform: mqtt
topic: frigate/events
payload: "{{ id }}"
value_template: "{{ value_json['after']['id'] }}"
timeout:
minutes: 2
continue_on_timeout: false
- condition: template
value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: 70c62eb366d6ed914b0ccc6bf41c32fd
domain: mobile_app
type: notify
message: A {{ label }} was detected on the {{ camera_name }} camera.
data:
tag: "{{ id }}"
group: frigate-notification-{{ camera }}
url: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
clickAction: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
image: >-
/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
sound: none
attachment:
url: /api/frigate/notifications/{{id}}/thumbnail.jpg
actions:
- action: URI
title: View Clip
uri: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
- action: URI
title: View Snapshot
uri: >-
{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg
- action: silence-{{ camera }}
title: Silence Notifications
destructive: true
default:
- service: notify.{{ group_target }}
data:
message: A {{ label }} was detected on the {{ camera_name }} camera.
data:
tag: "{{ id }}"
group: frigate-notification-{{ camera }}
url: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
clickAction: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
image: >-
/api/frigate/notifications/{{id}}/thumbnail.jpg?format=android
sound: none
attachment:
url: /api/frigate/notifications/{{id}}/thumbnail.jpg
actions:
- action: URI
title: View Clip
uri: >-
{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4
- action: URI
title: View Snapshot
uri: >-
{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg
- action: silence-{{ camera }}
title: Silence Notifications
destructive: true
until: "{{ wait.trigger.payload_json['type'] == 'end' }}"
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: silence-{{ camera }}
timeout:
seconds: 30
continue_on_timeout: false
- delay:
minutes: 30