Thanks for offering to take a look.
In TheFes’s global variable topic, it was identified that the errors didn’t match my assertion!
I’ve fixed the real issue in the code below, it is all working.
My issue all along was that I wrapped the variable in double curlies, inside an expression.
- alias: "Security: Object Detected"
id: "HD2f4Q5RbLgXv"
mode: parallel
triggers:
- trigger: mqtt
alias: "topic published to /reviews"
topic: "frigate/reviews"
id: frigate-event
payload: "alert"
value_template: "{{ value_json['after']['severity'] }}"
variables:
type: "{{ trigger.payload_json['type'] }}"
review_id: "{{ trigger.payload_json['after']['id'] }}"
camera: "{{ trigger.payload_json['after']['camera'] }}"
before_zones: "{{ trigger.payload_json['before']['data']['zones'] }}"
after_zones: "{{ trigger.payload_json['after']['data']['zones'] }}"
before_objects: "{{ trigger.payload_json['before']['data']['objects'] }}"
after_objects: "{{ trigger.payload_json['after']['data']['objects'] }}"
sub_labels: "{{ trigger.payload_json['after']['data']['sub_labels'] }}"
detections: "{{ trigger.payload_json['after']['data']['detections'] }}"
thumbnail: "https://ha.mydomain.com/api/frigate/notifications/{{detections[0]}}/thumbnail.jpg"
snapshot: "https://ha.mydomain.com/api/frigate/notifications/{{detections[0]}}/snapshot.jpg"
clip: "https://ha.mydomain.com/api/frigate/notifications/{{detections[0]}}/clip.mp4"
msg_description: "{{ after_objects|join(', ')|title }} detected"
msg_title: "{{ camera|title }} camera event"
actions:
- parallel:
- sequence:
- condition: template
alias: Object lifecycle has ended
value_template: '{{ type == "new" }}'
- wait_for_trigger:
- trigger: mqtt
topic: frigate/tracked_object_update
value_template: '{{ value_json["type"] == "description" and value_json["id"] in detections }}'
timeout:
seconds: "120"
- condition: template
alias: Object updated
value_template: "{{ wait.completed }}"
- event: set_variable
event_data:
key: "{{ review_id }}"
value: "{{ wait.trigger.payload_json['description'] }}"
set_timestamp: false
- sequence:
- action: notify.residents
data:
title: "{{ msg_title }}"
message: "{{ msg_description }}"
data:
subtitle: "{{ state_attr('sensor.variables', 'variables')[review_id] }}"
subject: "{{ state_attr('sensor.variables', 'variables')[review_id] }}"
group: "Security"
channel: "MEDIUM"
image: "{{ thumbnail }}"
tag: "{{ review_id }}"
entity_id: camera.{{ camera }}
color: "#FFFF00" # YELLOW
ledColor: "#FFFF00" # YELLOW
importance: high
priority: "high"
ttl: 0
persistent: "false"
sticky: "false"
actions:
- action: "URI"
title: "Thumbnail"
uri: "{{ thumbnail }}"
- action: "URI"
title: "Image"
uri: "{{ snapshot }}"
- action: "URI"
title: "Video"
uri: "{{ clip }}"
- condition: template
alias: Object lifecycle has ended
value_template: '{{ type == "end" }}'
- event: remove_variable
event_data:
key: "{{ review_id }}"