Fixed content of FRIGATE- Person Detect Logic - Backyard Camera.yml. Copied wrong scripts text.
This commit is contained in:
parent
8e640c0acf
commit
84f530bfc4
@ -6,9 +6,14 @@ sequence:
|
|||||||
{% set user_id = context.user_id %} {{ states.person |
|
{% set user_id = context.user_id %} {{ states.person |
|
||||||
selectattr('attributes.user_id', '==', user_id) |
|
selectattr('attributes.user_id', '==', user_id) |
|
||||||
map(attribute='attributes.friendly_name') | first }}
|
map(attribute='attributes.friendly_name') | first }}
|
||||||
- condition: template
|
- condition: or
|
||||||
value_template: "{{ context_user == authorised_user }}"
|
conditions:
|
||||||
alias: is user excuting script the authorised_user?
|
- condition: template
|
||||||
|
value_template: "{{ context_user == authorised_user }}"
|
||||||
|
alias: is user excuting script the authorised_user?
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ context_user == 'Chris' }}"
|
||||||
|
alias: is user excuting script the admin user?
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
|
|||||||
@ -1,100 +1,124 @@
|
|||||||
alias: Action specified device for specified user
|
alias: "FRIGATE: Person Detect Logic - Backyard Camera"
|
||||||
description: ""
|
description: >-
|
||||||
sequence:
|
This automation is used to send a notification when a person is detected by
|
||||||
- variables:
|
Frigate. It uses the frigate MQTT event stream to trigger the notification and
|
||||||
context_user: >-
|
includes a snapshot of the detected object. The notification will be sent to
|
||||||
{% set user_id = context.user_id %} {{ states.person |
|
all devices with the specified group and will include a video clip of the
|
||||||
selectattr('attributes.user_id', '==', user_id) |
|
detection if available.
|
||||||
map(attribute='attributes.friendly_name') | first }}
|
triggers:
|
||||||
|
- topic: homeassistant/events
|
||||||
|
id: frigate-event
|
||||||
|
value_template: "{{ value_json[\"after\"][\"camera\"] }}"
|
||||||
|
variables:
|
||||||
|
after_zones: "{{ trigger.payload_json[\"after\"][\"entered_zones\"] }}"
|
||||||
|
before_zones: "{{ trigger.payload_json[\"before\"][\"entered_zones\"] }}"
|
||||||
|
camera: "{{ trigger.payload_json[\"after\"][\"camera\"] }}"
|
||||||
|
id: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
||||||
|
label: "{{ trigger.payload_json[\"after\"][\"label\"] }}"
|
||||||
|
score: "{{ trigger.payload_json[\"after\"][\"score\"] }}"
|
||||||
|
time_clip_start: "{{ trigger.payload_json[\"after\"][\"start_time\"] - 10.0 }}"
|
||||||
|
detect_time: "{{trigger.payload_json[\"after\"][\"start_time\"]|int}}"
|
||||||
|
trigger: mqtt
|
||||||
|
payload: Backyard
|
||||||
|
conditions:
|
||||||
- condition: or
|
- condition: or
|
||||||
conditions:
|
conditions:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ context_user == authorised_user }}"
|
value_template: "{{ trigger.payload_json['type'] == 'new' }}"
|
||||||
alias: is user excuting script the authorised_user?
|
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ context_user == 'Chris' }}"
|
value_template: "{{ before_zones | length == 0 }}"
|
||||||
alias: is user excuting script the admin user?
|
enabled: true
|
||||||
|
- alias: Object is in Back Yard
|
||||||
|
condition: template
|
||||||
|
value_template: "{{ [\"backyard_z1\"] | select(\"in\", after_zones) | list | length > 0 }}"
|
||||||
|
enabled: true
|
||||||
|
- alias: Person detected
|
||||||
|
condition: template
|
||||||
|
value_template: "{{ label == 'person' }}"
|
||||||
|
enabled: true
|
||||||
|
actions:
|
||||||
- choose:
|
- choose:
|
||||||
- conditions:
|
- conditions:
|
||||||
- condition: template
|
- condition: trigger
|
||||||
value_template: "{{ action_to_perform == 'toggle' }}"
|
id: frigate-event
|
||||||
alias: is toggle requested?
|
|
||||||
sequence:
|
sequence:
|
||||||
- choose:
|
- action: input_boolean.turn_on
|
||||||
- conditions:
|
metadata: {}
|
||||||
- condition: template
|
data: {}
|
||||||
value_template: "{{ device == 'sm_n986b' }}"
|
target:
|
||||||
alias: is device sm_n986b?
|
entity_id: input_boolean.backyard_motion_detected
|
||||||
sequence:
|
alias: Set Backyard motion detected
|
||||||
- action: input_boolean.toggle
|
- action: script.person_detect_actions
|
||||||
metadata: {}
|
alias: Trigger alarm and send critical priority event to devices
|
||||||
data: {}
|
data:
|
||||||
target:
|
id: "{{ id }}"
|
||||||
entity_id: input_boolean.notify_sm_n986b
|
title: >-
|
||||||
- conditions:
|
{{ label }} was detected on {{ camera | replace("_", " ") |
|
||||||
- condition: template
|
title }} camera
|
||||||
value_template: "{{ device == 'nokia_c20' }}"
|
message: >-
|
||||||
alias: is device nokia_c20?
|
"{{ label }} detected in the {{ after_zones[0] | replace("_", "
|
||||||
sequence:
|
") | title }} zone"
|
||||||
- action: input_boolean.toggle
|
notifTag: "{{ id }}"
|
||||||
metadata: {}
|
notifIcon: mdi:alarm-light
|
||||||
data: {}
|
group: frigate-notification-{{ camera }}
|
||||||
target:
|
channel: alarm
|
||||||
entity_id: input_boolean.notify_nokia_c20
|
importance: max
|
||||||
- conditions:
|
priority: critical
|
||||||
- condition: template
|
image: /api/frigate/notifications/{{ id }}/snapshot.jpg
|
||||||
value_template: "{{ device == 'sm_x115' }}"
|
video: null
|
||||||
alias: is device sm_x115?
|
base_url: https://home-assistant.sthome.org
|
||||||
sequence:
|
when: "{{ detect_time }}"
|
||||||
- action: input_boolean.toggle
|
camera: "{{ camera }}"
|
||||||
metadata: {}
|
- repeat:
|
||||||
data: {}
|
sequence:
|
||||||
target:
|
- wait_for_trigger:
|
||||||
entity_id: input_boolean.notify_sm_x115
|
- topic: homeassistant/events
|
||||||
- conditions:
|
payload: "{{ trigger.payload_json[\"after\"][\"id\"] }}"
|
||||||
- condition: template
|
value_template: "{{ value_json[\"after\"][\"id\"] }}"
|
||||||
value_template: "{{ device == 'sm_a032f' }}"
|
trigger: mqtt
|
||||||
alias: is device sm_a032f?
|
continue_on_timeout: false
|
||||||
sequence:
|
timeout: "00:02:00"
|
||||||
- action: input_boolean.toggle
|
alias: 2 min timeout
|
||||||
metadata: {}
|
- condition: template
|
||||||
data: {}
|
value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}"
|
||||||
target:
|
alias: Wait for end event
|
||||||
entity_id: input_boolean.notify_sm_a032f
|
- action: script.person_detect_actions
|
||||||
- conditions:
|
alias: Send high priority notification to devices
|
||||||
- condition: template
|
data:
|
||||||
value_template: "{{ device == 'sm_a245f' }}"
|
id: "{{ id }}"
|
||||||
alias: is device sm_a245f?
|
title: >
|
||||||
sequence:
|
{% if (wait.trigger.payload_json["after"]["sub_label"] !=
|
||||||
- action: input_boolean.toggle
|
None) -%} {{
|
||||||
metadata: {}
|
(wait.trigger.payload_json["after"]["sub_label"]) | title
|
||||||
data: {}
|
}} {%- else -%} {{ label | replace("_", " ") | title }}
|
||||||
target:
|
{%- endif %} was detected in the {{ after_zones[0] |
|
||||||
entity_id: input_boolean.notify_sm_a245f
|
replace("_", " ") | title }} zone
|
||||||
- conditions:
|
message: >-
|
||||||
- alias: is device sm_a042f?
|
Detected with {{ int(score | round(2) * 100) }}%
|
||||||
condition: template
|
confidence
|
||||||
value_template: "{{ device == 'sm_a042f' }}"
|
notifTag: "{{ id }}"
|
||||||
sequence:
|
notifIcon: mdi:cctv
|
||||||
- action: input_boolean.toggle
|
group: >
|
||||||
metadata: {}
|
frigate-notification-{{
|
||||||
data: {}
|
trigger.payload_json["after"]["camera"] }}
|
||||||
target:
|
channel: alarm
|
||||||
entity_id: input_boolean.notify_sm_a042f
|
priority: high
|
||||||
fields:
|
importance: default
|
||||||
authorised_user:
|
image: /api/frigate/notifications/{{ id }}/snapshot.jpg
|
||||||
selector:
|
video: /api/frigate/notifications/{{ id }}/{{ camera }}/clip.mp4
|
||||||
text: null
|
base_url: https://home-assistant.sthome.org
|
||||||
name: Authorised User
|
when: "{{ detect_time }}"
|
||||||
description: User who is allowed to execute script
|
camera: "{{ camera }}"
|
||||||
required: true
|
until:
|
||||||
action_to_perform:
|
- condition: template
|
||||||
selector:
|
value_template: "{{ wait.trigger.payload_json[\"type\"] == \"end\" }}"
|
||||||
text: null
|
alias: End event is detected
|
||||||
name: Action to Perform
|
- action: input_boolean.turn_off
|
||||||
required: true
|
metadata: {}
|
||||||
device:
|
data: {}
|
||||||
selector:
|
target:
|
||||||
text: null
|
entity_id: input_boolean.backyard_motion_detected
|
||||||
name: Device
|
alias: Reset Backyard motion detected
|
||||||
required: true
|
default: []
|
||||||
|
mode: parallel
|
||||||
|
max: 10
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user