Closed medhathaddad closed 10 months ago
Interesting. I was seeing this error suddenly on my beta builds a few days ago. I fixed it by changing some code which I thought had worked previously. Stable has not been changed in months and yet suddenly someone gets the same error. Could have been a HA update perhaps. ...
I can fix it but before I do, Can you please screenshot the trace tree from the automation page.
Is this what you're asking for?
Yes but that seems to have zero going on. Is there an earlier one which has some activity?
no, i only started setting it up today
I understand, but the error says it ran twice at 708 and 724 and I would expect traces at those times.
The automation has never been triggered although events were triggered by Frigate and I received alerts via Telegram. It says it ran twice because I tried running it manually using the "run" button.
More logs
"false_positive": false, "start_time": 1692999172.87784, "end_time": null, "score": 0.53515625, "box": [886, 322, 1096, 539], "area": 45570, "ratio": 0.967741935483871, "region": [838, 271, 1158, 591], "stationary": true, "motionless_count": 1052, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "after": {"id": "1692999172.87784-gwj9kw", "camera": "3", "frame_time": 1692999307.665939, "snapshot_time": 1692999177.941411, "label": "car", "sub_label": null, "top_score": 0.736328125, "false_positive": false, "start_time": 1692999172.87784, "end_time": null, "score": 0.53515625, "box": [886, 322, 1096, 539], "area": 45570, "ratio": 0.967741935483871, "region": [838, 271, 1158, 591], "stationary": true, "motionless_count": 1954, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "type": "update"}' 2023-08-25 21:35:07.747 DEBUG (MainThread) [homeassistant.components.mqtt.models] Rendering incoming payload '{"before": {"id": "1692999172.87784-gwj9kw", "camera": "3", "frame_time": 1692999247.566839, "snapshot_time": 1692999177.941411, "label": "car", "sub_label": null, "top_score": 0.736328125, "false_positive": false, "start_time": 1692999172.87784, "end_time": null, "score": 0.53515625, "box": [886, 322, 1096, 539], "area": 45570, "ratio": 0.967741935483871, "region": [838, 271, 1158, 591], "stationary": true, "motionless_count": 1052, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "after": {"id": "1692999172.87784-gwj9kw", "camera": "3", "frame_time": 1692999307.665939, "snapshot_time": 1692999177.941411, "label": "car", "sub_label": null, "top_score": 0.736328125, "false_positive": false, "start_time": 1692999172.87784, "end_time": null, "score": 0.53515625, "box": [886, 322, 1096, 539], "area": 45570, "ratio": 0.967741935483871, "region": [838, 271, 1158, 591], "stationary": true, "motionless_count": 1954, "position_changes": 1, "current_zones": [], "entered_zones": [], "has_clip": true, "has_snapshot": true}, "type": "update"}' with variables {} with default value 'default' and Template<template=({{ value_json['after']['camera'] | lower | replace('-','_') }}/{{ value_json['type']}}) renders=321> 2023-08-25 21:35:09.463 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 3.217 seconds (success: True) 2023-08-25 21:35:17.439 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 3.206 seconds (success: True) 2023-08-25 21:35:25.437 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 3.203 seconds (success: True) 2023-08-25 21:35:33.449 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 3.208 seconds (success: True) 2023-08-25 21:35:36.340 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/2/motion (qos=0): b'OFF' 2023-08-25 21:35:41.458 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 3.212 seconds (success: True)
Oh, you cant run it manually.
So should it have triggered on it's own? i spend most afternoons walking out to my cams to set them off :)
I have my cars parked so it triggers on its own every time I restart Frigate. I have enabled my Telegram notifications, restarted Frigate and I got an alert right away that a car was detected but for some odd reason, I am not receiving any using your blueprint
More logs
And you didn't trigger anything at 9:38 other than restarting HA?
Frigate restarted at 9:38 and was able to send an alert via Telegram since it detected the cars. I didn't have to run your blueprint manually this time.
I just cleared the logs and restarted it and the error appeared on it own
Ahh i know what it is. your camera name is just a number and it's being treated as a number not text
Well, that was embarrassing. I appreciate your help
Oh you changed it in frigate?
I was going to try and fix it. Not sure if it would have worked but this was my first attempt
blueprint:
name: Frigate Notifications (0.12.0.1)
description: |
## Frigate Notifications
This blueprint will send a notification to your device when a Frigate event for the selected camera is fired. The notification will initially include the thumbnail of the detection, but include an actionable notification allowing you to view the clip and snapshot.
With this blueprint, you may send the notification to multiple devices by leaving "Device" blank and instead use a [notification group][1].
### Software Version Requirements
- Minimum Home Assistant Version: 2022.2
- Minimum Frigate Version: 0.11.0
- Minimum Frigate Integration Version: 3.0.0
- **Note:** “Enable the unauthenticated notification event proxy” must be ticked during setup
- An MQTT broker connected to home assistant and frigate.
- Minimum iOS Version: 15.0
### Required entities:
- Frigate Camera Name
- Mobile App Device **or** the name of a Notification Group or TV
### Features:
- Easily select the camera entity or mobile device using a drop down menu.
- Send notifications to an Android or iOS mobile device or a TV.
- or a group containing any combination of the above.
- Configure the title and message of the notification.
- Dynamically handle things like object type, zones and face detection from doubletake.
- Automatically handle some common errors like case matching and bad urls etc.
- Optionally send the notification as a critical alert. (Critical)
- Optionally limit the playing of audio for secondary notification updates, and on iOS, customise the sound. (Alert Once)
- Choose whether or not to update the notification with new thumbnails as they become available.
- Customise the notification colour and icon.
- Optionally send a live view to iOS.
- Configure custom notification channels on Android.
- Specify which [zones][2] to be notified about. (Zone Filter)
- Choose between enforcing all required zones simultaneously or any one zone
- Specify what type of [objects][3] to be notified about. (Object Filter)
- Disable notifications if a presence entity or group is "home". (Presence Filter)
- Limit notifications based on the state of another entity. (State Filter)
- Limit notifications to certain hours of the day. (Time Filter)
- Configure a cooldown for the camera to reduce the number of notifications when back-to-back events occur.
- Silence future notifications for a defined amount of time through actionable notifications. This is helpful in situations where you know you will be triggering detections for an extended period of time. i.e. kids playing outside.
- Set a loitering timer to notify you of stationary objects that remain for a set period of time.
- Configure what happens when you tap the notification (Tap Action)
- Configure 3 action buttons to open almost anything (defaults are: View Clip, View Snapshot and Silence New Notifications)
- Configure the size, transparency, position and duration of TV notifications.
- Debug option to help troubleshooting
[1]: https://companion.home-assistant.io/docs/notifications/notifications-basic#sending-notifications-to-multiple-devices
[2]: https://blakeblackshear.github.io/frigate/configuration/cameras#zones
[3]: https://blakeblackshear.github.io/frigate/configuration/objects
## Support
Go to https://github.com/SgtBatten/HA_blueprints to report bugs, request new features or get support with your configuration.
domain: automation
source_url: https://github.com/SgtBatten/HA_blueprints/blob/main/Frigate%20Camera%20Notifications/Stable
input:
camera:
name: Frigate Camera
description: |
Select the camera entity that will trigger notifications.
If you do not see cameras listed in the drop down, check you have the frigate integration installed.
Note: The automation relies on this matching your frigate config (by default it does).
selector:
entity:
integration: frigate
domain: camera
device_class: camera
notify_device:
name: Mobile Device
description: Select a device that runs the official Home Assistant app to receive notifications. If you wish to notify a group of devices or and Android/Fire TV use the field below to override this selection. This can be left blank in that case
default: false
selector:
device:
integration: mobile_app
notify_group:
name: Notification Group or Android/Fire TV (Optional)
description: |
The name of the group or individual TV to send notifications to.
If set, this will override individual devices above.
Note: If the group contains both mobile devices and TVs, the TV will not display the snapshot unless 'TV notifications' to true, however this will stop android phones recieving thumbnails.
default: ""
base_url:
name: Base URL (Optional)
description: |
The external url for your Home Assistant instance.
Recommended for iOS and required for Android/Fire TV.
default: ""
title:
name: Notification Title (Optional)
description: |
# Notification Customisations
The title of the notification.
default: ""
message:
name: Notification Message
description: |
The message of the notification.
You can use variables such as {{camera_name}} and {{label}}
e.g A {{ label }} {{ 'is loitering' if loitering else 'was detected' }} on the {{ camera_name }} camera.
default: A {{ label }} {{ 'is loitering' if loitering else 'was detected' }} on the {{ camera_name }} camera.
selector:
select:
options:
- label: "Default: e.g A Person was detected on the Side camera."
value: "A {{ label }} {{ 'is loitering' if loitering else 'was detected' }} on the {{ camera_name }} camera."
- label: "Short: e.g Person detected - Side"
value: "{{ label }} detected - {{ camera_name }}"
- label: "Long: e.g A Person was detected on the Side camera in the driveway."
value: "A {{ label }} {{ 'is loitering' if loitering else 'was detected' }} on the {{ camera_name }} camera{{ ' in the ' + entered_zones if entered_zones else '.'}}"
custom_value: true
critical:
name: Critical Notification (Optional)
description: |
Send as a critical notification to the mobile device.
Sometimes notifications (particularly on android) are delayed, this will resolve this.
You can choose to limit crtical notifications to certain times using a template (two examples provided but you can enter your own as long as it outputs true or false)
default: "false"
selector:
select:
options:
- "false"
- "true"
- "{{'false' if now().hour in [8,9,10,11,12,13,14,15,16,17,18] else 'true'}}"
- "{{'true' if is_state('sun.sun', 'above_horizon') else 'false' }}"
custom_value: true
alert_once:
name: Alert Once (Optional)
description: Only the first notification for each event will play a sound. Updates, including new thumbnails will be silent. iOS users who use Critical Notifications above will still hear default critical sounds for updates.
default: false
selector:
boolean:
attachment:
name: Attachment
description: |
Choose which image to attach to the notification.
Note: TVs will always get sent the snapshot if TV is true
default: thumbnail
selector:
select:
options:
- label: Thumbnail
value: thumbnail
- label: Snapshot
value: snapshot
update_thumbnail:
name: Update Attachment (Optional)
description: Update the notification if a new "better" image is available.
default: false
selector:
boolean:
color:
name: Notification Color (Optional)
description: Set the color of the notification on your mobile device or TV.
default: steelblue
selector:
select:
options:
- steelblue
- grey
- black
- indigo
- green
- red
- cyan
- teal
- amber
- pink
icon:
name: Notification Icon (Optional)
description: Change the icon that displays on the notification. You can enter a single icon or create a template like the example given in the dropdown. You must include 'mdi:' in the icon name.
default: mdi:home-assistant
selector:
select:
options:
- mdi:home-assistant
- mdi:cctv
- "mdi:{{'account-outline' if label == 'Person' else 'dog' if label == 'Dog' else 'cat' if label == 'Cat' else 'car' if label == 'Car' else 'home-assistant'}}"
custom_value: true
sound:
name: Notification Sound - iOS only (Optional)
description: You can specify a soud file on your device that will play for the notifications. You will need to import the sound file into home assistant.
default: default
selector:
select:
options:
- default
- none
custom_value: true
ios_live_view:
name: Live View - iOS only (Optional)
description: Attach a live view to the notification for iOS devices
default: false
selector:
boolean:
channel:
name: Notification Channel - Android only (Optional)
description: Create a new channel for notifications to allow custom notification sounds, vibration patterns and overide of Do Not Disturb mode. Configured directly on the device.
default: ""
zone_filter:
name: Zone Filter on/off (Optional)
description: |
# Filters
Enable to only notify if object has entered a zone listed below.
default: false
selector:
boolean:
zones:
name: Required Zones (Optional - Enabled Above)
description: |
Enter the name of one zone at a time. Include underscores as per your frigate config.
By default any zone is acceptable. if you desire ALL listed zones to be entered before getting a notification, enable the multi toggle below.
Note: If the text entry is glitching (dissapearing every few seconds) select one of the examples, then edit in yaml mode.
default: []
selector:
select:
options:
- examples
- porch
- front_door
- side
- garden
multiple: true
custom_value: true
zone_multi:
name: Multi Zone (Optional)
description: Require all zones specified above to be entered, instead of any listed zone. Zone Filter must be enabled also.
default: false
selector:
boolean:
labels:
name: Object Filter (Optional)
description: |
Enter or select one object at a time.
Note: If the text entry is glitching (dissapearing every few seconds) select one of the examples, then edit in yaml mode.
default: ""
selector:
select:
options:
- person
- dog
- cat
- car
- package
- bird
multiple: true
custom_value: true
presence_filter:
name: Presence Filter (Optional)
description: Only notify if selected presence entity is not "home".
default: ""
selector:
entity:
domain:
- device_tracker
- person
- group
state_filter:
name: State Filter on/off (Optional)
description: Enable the two State Filter settings below. Only notify if selected entity is in the specified states.
default: false
selector:
boolean:
state_entity:
name: State Filter Entity (Optional)
description: Only notify if selected entity is in the below state. You must enable State Filter above to use this.
default: ""
selector:
entity:
state_filter_states:
name: State Filter States (Optional)
description: Enter the states that the above entity must be in, one at a time.
default: []
selector:
select:
options: []
multiple: true
custom_value: true
disable_times:
name: Time Filter (Optional)
description: Prevent notifications from being sent during the specified hours
default: []
selector:
select:
multiple: true
options:
- label: 00:00 - 00:59
value: "0"
- label: 01:00 - 01:59
value: "1"
- label: 02:00 - 02:59
value: "2"
- label: 03:00 - 03:59
value: "3"
- label: 04:00 - 04:59
value: "4"
- label: 05:00 - 05:59
value: "5"
- label: 06:00 - 06:59
value: "6"
- label: 07:00 - 07:59
value: "7"
- label: 08:00 - 08:59
value: "8"
- label: 09:00 - 09:59
value: "9"
- label: 10:00 - 10:59
value: "10"
- label: 11:00 - 11:59
value: "11"
- label: 12:00 - 12:59
value: "12"
- label: 13:00 - 13:59
value: "13"
- label: 14:00 - 14:59
value: "14"
- label: 15:00 - 15:59
value: "15"
- label: 16:00 - 16:59
value: "16"
- label: 17:00 - 17:59
value: "17"
- label: 18:00 - 18:59
value: "18"
- label: 19:00 - 19:59
value: "19"
- label: 20:00 - 20:59
value: "20"
- label: 21:00 - 21:59
value: "21"
- label: 22:00 - 22:59
value: "22"
- label: 23:00 - 23:59
value: "23"
cooldown:
name: Cooldown (Optional)
description: Delay before sending another notification for this camera after the last event.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: seconds
silence_timer:
name: Silence New Object Notifications (Optional)
description: |
How long to silence notifications for this camera when requested as part of the actionable notification.
Note: This only applies to new objects. Existing tracked objects will not be affected.
default: 30
selector:
number:
max: 300
min: 0
unit_of_measurement: minutes
loiter_timer:
name: Loitering Notifications (Optional)
description: >
Sends new loitering notification if a stationary object is detected for longer
than the specified time. 0 is off and will not send notifications.
default: 0
selector:
number:
max: 300
min: 0
unit_of_measurement: minutes
tap_action:
name: Tap Action URL
description: |
# Action Buttons and URLs
The url to open when tapping on the notification. Some presets are provided, you can also set you own.
These 7 options define the text and urls associated with the three action buttons at the bottom of the notification.
default: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
selector:
select:
options:
- label: View Clip
value: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
- label: View Snapshot
value: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
- label: View Stream
value: "{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera'].lower()}}?token={{state_attr( 'camera.' ~ camera, 'access_token')}}"
- label: Open Home Assistant (web)
value: "{{base_url}}/lovelace"
- label: Open Home Assistant (app)
value: /lovelace
- label: Open Frigate
value: /ccab4aaf_frigate/dashboard
- label: Open Frigate (Full Access)
value: /ccab4aaf_frigate-fa/dashboard
- label: Open Frigate (proxy)
value: /ccab4aaf_frigate-proxy/dashboard
- label: Open Reolink App (Android)
value: app://com.mcu.reolink
custom_value: true
button_1:
name: Action Button 1 Text
description: "The text used on the first Action button at the bottom of the notification. Set the URL below. Default is View Clip"
default: "View Clip"
url_1:
name: Action Button 1 URL
description: Customise what happens when you press the first Action Button. Select from one of the preconfigured options or enter your own custom URL.
default: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
selector:
select:
options:
- label: View Clip
value: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
- label: View Snapshot
value: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
- label: View Stream
value: "{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera'].lower()}}?token={{state_attr( 'camera.' ~ camera, 'access_token')}}"
- label: Open Home Assistant
value: "{{base_url}}/lovelace"
custom_value: true
button_2:
name: Action Button 2 Text
description: "The text used on the second Action button at the bottom of the notification. Set the URL below."
default: "View Snapshot"
url_2:
name: Action Button 2 URL
description: Customise what happens when you press the second Action Button. Select from one of the preconfigured options or enter your own custom URL.
default: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
selector:
select:
options:
- label: View Clip
value: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
- label: View Snapshot
value: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
- label: View Stream
value: "{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera'].lower()}}?token={{state_attr( 'camera.' ~ camera, 'access_token')}}"
- label: Open Home Assistant
value: "{{base_url}}/lovelace"
custom_value: true
button_3:
name: Action Button 3 Text
description: "The text used on the third Action button at the bottom of the notification. Set the URL below."
default: "Silence New Notifications"
url_3:
name: Action Button 3 URL
description: Customise what happens when you press the third Action Button. Select from one of the preconfigured options or enter your own custom URL."
default: silence-{{ camera }}
selector:
select:
options:
- label: Silence New Notifications
value: silence-{{ camera }}
- label: View Clip
value: "{{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4"
- label: View Snapshot
value: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
- label: View Stream
value: "{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera'].lower()}}?token={{state_attr( 'camera.' ~ camera, 'access_token')}}"
- label: Open Home Assistant
value: "{{base_url}}/lovelace"
custom_value: true
tv:
name: TV Notification (Optional)
description: |
# TV Notifications
Set to true if you are notifying an Android/Fire TV
Can also be used to prioritise snapshots on the TV over android mobile apps when notifying a mixed device group.
Base URL must be set
The below settings are for TV notifications only
default: false
selector:
boolean:
tv_position:
name: TV Notification Position (Optional)
description: Set the position of the notification on your TV
default: center
selector:
select:
mode: dropdown
options:
- bottom-right
- bottom-left
- top-right
- top-left
- center
tv_size:
name: TV Notification Size (Optional)
description: Set the size of the notification on your TV.
default: large
selector:
select:
mode: dropdown
options:
- small
- medium
- large
- max
tv_duration:
name: TV Notification Duration (Optional)
description: The duration (in seconds) the notification will display on your TV.
default: 10
selector:
number:
max: 300
min: 0
unit_of_measurement: seconds
tv_transparency:
name: TV notification Transaparency (Optional)
description: Set the transparency of the notification on your TV.
default: 0%
selector:
select:
mode: dropdown
options:
- 0%
- 25%
- 50%
- 75%
- 100%
tv_interrupt:
name: TV Notification Interrupt (Optional)
description: "If set to true the notification is interactive and can be dismissed or selected to display more details. Depending on the running app (e.g., Netflix), this may stop playback."
default: false
selector:
boolean:
debug:
name: Debug
description: |
# DEBUG
Enable to send debug messsages to the home assistant logbook.
default: false
selector:
boolean:
mode: parallel
trigger_variables:
input_camera: !input camera
camera: "{{ input_camera | replace('camera.', '') |string }}"
trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "silence-{{ camera }}"
id: silence
- platform: mqtt
topic: frigate/events
payload: "{{ camera }}/new"
value_template: "{{ value_json['after']['camera'] | string | lower | replace('-','_') }}/{{ value_json['type']}}"
id: frigate-event
variables:
input_camera: !input camera
camera: "{{ input_camera | replace('camera.', '') |string }}"
camera_name: "{{ camera | string | replace('_', ' ') | title }}"
input_base_url: !input base_url
base_url: "{{ input_base_url.rstrip('/')}}"
attachment: !input attachment
critical_input: !input critical
critical: "{{ true if critical_input == 'true' else false }}"
alert_once: !input alert_once
update_thumbnail: !input update_thumbnail
ios_live_view: !input ios_live_view
group: !input notify_group
group_target: "{{ group | lower | replace('notify.', '') | replace(' ','_') }}"
zone_only: !input zone_filter
input_zones: !input zones
zones: "{{ input_zones | list | lower }}"
zone_multi: !input zone_multi
input_labels: !input labels
labels: "{{ input_labels | list | lower }}"
presence_entity: !input presence_filter
disable_times: !input disable_times
cooldown: !input cooldown
loitering: false
loiter_timer: !input loiter_timer
fps: "{{ states('sensor.' + camera + '_camera_fps')|int(5) }}"
state_only: !input state_filter
input_entity: !input state_entity
input_states: !input state_filter_states
states_filter: "{{ input_states | list | lower }}"
color: !input color
sound: !input sound
tv: !input tv
tv_position: !input tv_position
tv_size: !input tv_size
tv_duration: !input tv_duration
tv_transparency: !input tv_transparency
tv_interrupt: !input tv_interrupt
debug: !input debug
action:
- choose:
- alias: "Silence New Object Notifications"
conditions:
- condition: trigger
id: silence
sequence:
- service: automation.turn_off
target:
entity_id: "{{ this.entity_id }}"
data:
stop_actions: false
- delay:
minutes: !input silence_timer
- service: automation.turn_on
target:
entity_id: "{{ this.entity_id }}"
- alias: "Frigate Event"
conditions:
- condition: trigger
id: "frigate-event"
- "{{ is_state(this.entity_id, 'on') }}"
- "{{ not this.attributes.last_triggered or (now() - this.attributes.last_triggered).seconds > cooldown }}"
- "{{ not disable_times|length or not now().hour in disable_times|map('int')|list }}"
sequence:
- variables:
id: "{{ trigger.payload_json['after']['id'] }}"
object: "{{ trigger.payload_json['after']['label'] }}"
label: "{{ object | title }}"
# Dynamic Variables per event
initial_home: "{{ presence_entity != '' and is_state(presence_entity, 'home') }}"
initial_entered_zones: "{{ trigger.payload_json['after']['entered_zones'] |lower}}"
zone_multi_filter: "{{zone_only and zone_multi and initial_entered_zones|length and zones and zones |reject('in', initial_entered_zones) |list |length == 0 }}"
# Customisation of text
title: !input title
message: !input message
tap_action: !input tap_action
button_1: !input button_1
button_2: !input button_2
button_3: !input button_3
url_1: !input url_1
url_2: !input url_2
url_3: !input url_3
icon: !input icon
channel: !input channel
- alias: "Debug: write to Log"
choose:
- conditions:
- "{{debug}}"
sequence:
- service: logbook.log
data_template:
name: Frigate Notification
message: |
DEBUG:
Info:
fps: {{fps}},
frigate event id: {{id}},
object (formatted): {{object}} ({{label}}),
Config:
camera(formatted): {{camera}}({{camera_name}}),
Base URL: {{base_url}},
critical: {{critical}},
alert once: {{alert_once}},
Update Thumbnails: {{update_thumbnail}},
Target: {{'group (input/formatted): ' + group + '/' + group_target + ', ' if group else 'Mobile Device'}}
cooldown: {{cooldown}}s,
loiter timer: {{loiter_timer}}s,
color: {{color}},
sound: {{sound}},
Title: {{title}},
Message: {{message}},
tap_action: {{tap_action}},
button 1 Text/URL: {{iif(button_1, button_1, 'unset')}} ({{url_1}}),
button 2 Text/URL: {{button_2}} ({{url_2}}),
button 3 Text/URL: {{button_3}} ({{url_3}}),
icon: {{icon}}
tv: {{tv}},
tv_position: {{tv_position}},
tv_size: {{tv_size}},
tv_duration: {{tv_duration}},
tv_transparency: {{tv_transparency}},
tv_interrupt: {{tv_interrupt}},
Filters:
Zones:
zone filter toggle on: {{zone_only}},
Multi Zone toggle on: {{zone_multi}},
Required zones: {{input_zones}},
Entered Zones: {{initial_entered_zones}},
Zone Filter TEST: {{'PASS (Multi)' if zone_multi_filter else 'PASS' if ( not zone_only or not zone_multi and zones|select('in', initial_entered_zones)|list|length ) else 'FAIL (Multi)' if zone_multi else 'FAIL' }},
Required objects TEST:
Input: {{input_labels}},
TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}
presence entity (not home):
Entity: {{presence_entity}}
TEST: {{'PASS' if not initial_home else 'FAIL'}},
disabled times: {{disable_times}},
State Filter:
state filter toggle on: {{state_only}},
state filter entity: {{input_entity}},
required states: {{input_states}},
State Filter TEST: {{'PASS' if not state_only or states(input_entity) in states_filter else 'FAIL' }},
- alias: "Notifications enabled for object label"
condition: template
value_template: "{{ not labels|length or object in labels }}"
- alias: "Notify on new object"
choose:
- conditions:
- "{{ not zone_only or (not zone_multi and zones|select('in', initial_entered_zones)|list|length > 0) or (zone_multi and initial_entered_zones|length > 0 and zones |reject('in', initial_entered_zones) |list |length == 0) }}"
- "{{ not initial_home }}"
- "{{ not state_only or states(input_entity) in states_filter }}"
sequence:
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}"
group: "{{ camera }}-frigate-notification"
color: "{{color}}"
# Android Specific
image: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg?format=android"
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{sound}}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
- conditions: "{{ tv }}"
sequence:
- service: "notify.{{ group_target }}"
data:
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}"
group: "{{ camera }}-frigate-notification"
color: "{{color}}"
# Android Specific
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# Android/Fire TV
image:
url: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
fontsize: "{{tv_size}}"
position: "{{tv_position}}"
duration: "{{tv_duration}}"
transparency: "{{tv_transparency}}"
interrupt: "{{tv_interrupt}}"
timeout: 30
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{sound}}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
default:
- service: "notify.{{ group_target }}"
data:
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}{{'-loitering' if loitering}}"
group: "{{ camera }}-frigate-notification{{'-loitering' if loitering}}"
color: "{{color}}"
# Android Specific
image: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg?format=android"
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# Android/Fire TV
fontsize: "{{tv_size}}"
position: "{{tv_position}}"
duration: "{{tv_duration}}"
transparency: "{{tv_transparency}}"
interrupt: "{{tv_interrupt}}"
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{sound}}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
- 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
- variables:
event: "{{ wait.trigger.payload_json }}"
loitering: "{{ loiter_timer and event['before']['motionless_count']/fps/60 < loiter_timer and event['after']['motionless_count']/fps/60 >= loiter_timer }}"
new_snapshot: "{{ update_thumbnail and event['before']['snapshot_time'] != event['after']['snapshot_time'] }}"
home: "{{ presence_entity != '' and is_state(presence_entity, 'home') }}"
presence_changed: "{{ presence_entity != '' and as_datetime(event['before']['frame_time']) < states[presence_entity].last_changed }}"
last_zones: "{{ event['before']['entered_zones'] |lower}}"
entered_zones: "{{ event['after']['entered_zones'] |lower}}"
zone_filter: "{{ not zone_only or zones|select('in', entered_zones)|list|length > 0 }}"
zone_multi_filter: "{{not zone_only or not zone_multi or ( entered_zones|list|length > 0 and zones and zones|reject('in', entered_zones)|list|length == 0 ) }}"
stationary_moved: "{{ event['after']['position_changes'] > event['before']['position_changes'] }}"
zone_only_changed: "{{ zone_only and (entered_zones|length > 0 and not last_zones|length) }}"
entered_zones_changed: "{{ zones|length > 0 and (zones|select('in', entered_zones)|list|length > 0 and not zones|select('in', last_zones)|list|length) }}"
state_true: "{{ not state_only or states(input_entity) in states_filter }}"
sub_label: "{{ event['after']['sub_label']}}"
sub_label_changed: "{{ sub_label != event['before']['sub_label'] }}"
update: "{{ alert_once or (new_snapshot and not loitering and not presence_changed and not zone_only_changed and not entered_zones_changed and not sub_label_changed) }}"
title: >
{% if sub_label %}
{{title | replace('A Person', sub_label|title) | replace('Person', sub_label|title)}}
{%else%}
{{title}}
{%endif%}
message: >
{% if sub_label %}
{{message | replace('A Person', sub_label|title) | replace('Person', sub_label|title)}}
{%else%}
{{message}}
{%endif%}
- alias: "Debug: write to Log"
choose:
- conditions:
- "{{debug}}"
sequence:
- service: logbook.log
data_template:
name: Frigate Notification
message: |
DEBUG (in loop):
Info:
Last Zones: {{last_zones}},
Current zones: {{entered_zones}},
sublabel: {{sub_label}},
iOS sound: {{update if not critical else 'yes due critical notifications'}},
Android Sound: {{'disabled by alert once' if alert_once else 'enabled'}},
Triggers:
New Snapshot: {{new_snapshot}},
Presence Changed: {{presence_changed}},
stationary moved: {{stationary_moved}},
entered zones changed: {{entered_zones_changed}},
sublabel changed: {{sub_label_changed}},
Conditions:
Loitering: {{loitering}}
or
Presence Entity not home: {{'ON' if presence_entity != '' else 'OFF'}} - {{'PASS' if not home else 'FAIL'}},
zone filter TEST: {{'ON' if zone_only else 'OFF'}} - {{'PASS' if zone_filter else 'FAIL'}},
multi-zone filter: {{'OFF' if not zone_only or not zone_multi else 'ON'}} - {{'PASS' if not zone_only or not zone_multi or ( entered_zones|length and zones and zones |reject('in', entered_zones) |list |length == 0 ) else 'FAIL'}},
state filter TEST: {{'ON' if state_only else 'OFF'}} - {{'PASS' if state_true else 'FAIL'}}
image: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
- alias: "Notify on loitering or significant change"
choose:
- conditions: "{{ loitering or (not home and zone_filter and zone_multi_filter and state_true and (new_snapshot or presence_changed or stationary_moved or zone_only_changed or entered_zones_changed or sub_label_changed)) }}"
sequence:
- choose:
- conditions: "{{ not group_target }}"
sequence:
- device_id: !input notify_device
domain: mobile_app
type: notify
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}{{'-loitering' if loitering}}"
group: "{{ camera }}-frigate-notification{{'-loitering' if loitering}}"
color: "{{color}}"
# Android Specific
image: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg?format=android"
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
alert_once: "{{ alert_once }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{ iif(update, 'none', sound) }}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
- conditions: "{{ tv }}"
sequence:
- service: "notify.{{ group_target }}"
data:
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}{{'-loitering' if loitering}}"
group: "{{ camera }}-frigate-notification{{'-loitering' if loitering}}"
color: "{{color}}"
# Android Specific
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
alert_once: "{{ alert_once }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# Android/Fire TV
image:
url: "{{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg"
fontsize: "{{tv_size}}"
position: "{{tv_position}}"
duration: "{{tv_duration}}"
transparency: "{{tv_transparency}}"
interrupt: "{{tv_interrupt}}"
timeout: 30
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{ iif(update, 'none', sound) }}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
default:
- service: "notify.{{ group_target }}"
data:
title: "{{title}}"
message: "{{message}}"
data:
tag: "{{ id }}{{'-loitering' if loitering}}"
group: "{{ camera }}-frigate-notification{{'-loitering' if loitering}}"
color: "{{color}}"
# Android Specific
image: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg?format=android"
clickAction: "{{tap_action}}"
ttl: "{{ iif(critical, 0, 3600000) }}"
priority: "{{ iif(critical, 'high', 'normal') }}"
alert_once: "{{ alert_once }}"
notification_icon: "{{icon}}"
channel: "{{channel}}"
# Android/Fire TV
fontsize: "{{tv_size}}"
position: "{{tv_position}}"
duration: "{{tv_duration}}"
transparency: "{{tv_transparency}}"
interrupt: "{{tv_interrupt}}"
# iOS Specific
url: "{{tap_action}}"
attachment:
url: "/api/frigate/notifications/{{id}}/{{attachment}}.jpg"
push:
sound: "{{ iif(update, 'none', sound) }}"
interruption-level: "{{ iif(critical, 'critical', 'active') }}"
entity_id: "{{ iif(ios_live_view, input_camera, '' ) }}"
# Actions
actions:
- action: URI
title: "{{button_1}}"
uri: "{{url_1}}"
- action: URI
title: "{{button_2}}"
uri: "{{url_2}}"
- action: "{{ 'URI' if '/' in url_3 else url_3 }}"
title: "{{button_3}}"
uri: "{{url_3}}"
destructive: true
until: "{{ not wait.trigger or wait.trigger.payload_json['type'] == 'end' }}"
Yes, all I had to do was change the camera name and it's working fine, thanks once again :)
Describe the problem you are having or the outcome you are trying to achieve.
I keep getting this error every time I try running the automation. The integration seems to be set up fine as I am able to receive notifications via Telegram.
Logger: homeassistant.components.automation.frigate_notifications_0_12_0_1 Source: components/automation/init.py:269 Integration: Automation (documentation, issues) First occurred: 7:08:22 PM (2 occurrences) Last logged: 7:24:35 PM
Error rendering variables: TypeError: can only concatenate str (not "int") to str
Version
(0.12.0.1)
Automation config file
Frigate Config
Any other information that may be helpful
No response