SgtBatten / HA_blueprints

Somewhere to store automation blueprints
179 stars 68 forks source link

[Config Support]: Bounding box on Telegram notification snapshots #101

Closed honeyfairy closed 9 months ago

honeyfairy commented 11 months ago

Describe the problem you are having or the outcome you are trying to achieve.

How can I add bounding boxes of detected objects to the snapshots sent to Telegram?

I have set bounding boxes to True in the config, and the snapshots in Frigate>Snapshots does have the bounding boxes drawn on it, however the snapshots sent to Telegram does not.

Version

0.12.1-367d724

Automation config file

blueprint:
  name: Frigate Notifications (0.12.0.1h)
  description: "## Frigate Notifications\n\nThis 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.\n\nWith this blueprint,
    you may send the notification to multiple devices by leaving \"Device\" blank
    and instead use a [notification group][1].\n\n### Software Version Requirements\n
    \ - Minimum Home Assistant Version: 2022.2\n  - Minimum Frigate Version: 0.11.0\n
    \ - Minimum Frigate Integration Version: 3.0.0\n    - **Note:** “Enable the unauthenticated
    notification event proxy” must be ticked during setup\n  - An MQTT broker connected
    to home assistant and frigate.\n  - Minimum iOS Version: 15.0\n\n### Required
    entities:\n  - Frigate Camera Name\n  - Mobile App Device **or** the name of a
    Notification Group or TV\n\n### Features:\n  - Easily select the camera entity
    or mobile device using a drop down menu.\n  - Send notifications to an Android
    or IOS mobile device or a TV.\n    - or a group containing any combination of
    the above.\n  - Configure the title and message of the notification. \n  - Dynamically
    handle things like object type, zones and face detection from doubletake.\n  -
    Automatically handle some common errors like case matching and bad urls etc.\n
    \ - Optionally send the notification as a critical alert. (Critical)\n  - Optionally
    limit the playing of audio for secondary notification updates, and on IOS, customise
    the sound. (Alert Once)\n  - Choose whether or not to update the notification
    with new thumbnails as they become available.\n  - Customise the notification
    colour and icon.\n  - Optionally send a live view to IOS.\n  - Configure custom
    notification channels on Android.\n  - Specify which [zones][2] to be notified
    about. (Zone Filter)\n    - Choose between enforcing all required zones simultaneously
    or any one zone\n  - Specify what type of [objects][3] to be notified about. (Object
    Filter)\n  - Disable notifications if a presence entity or group is \"home\".
    (Presence Filter)\n  - Limit notifications based on the state of another entity.
    (State Filter)\n  - Limit notifications to certain hours of the day. (Time Filter)\n
    \ - Configure a cooldown for the camera to reduce the number of notifications
    when back-to-back events occur.\n  - 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.\n  - Set a loitering timer to notify you of stationary
    objects that remain for a set period of time.\n  - Configure what happens when
    you tap the notification (Tap Action)\n  - Configure 3 action buttons to open
    almost anything (defaults are: View Clip, View Snapshot and Silence New Notifications)\n
    \ - Configure the size, transparency, position and duration of TV notifications.\n
    \ - Debug option to help troubleshooting\n  - Support for multiple Frigate instances
    by specifying the ClientID and MQTT topic\n  - Optional delay to the initial notification
    to see if it resolves the no attached image issue.\n  - Live view on IOS\n  -
    Android option: Sticky as per https://community.home-assistant.io/t/frigate-mobile-app-notifications/311091/1043\n\n###
    Beta Changes:\n  - Add 10s delay to final notification update to ensure frigate
    has time to save snapshot edits (crop, bounding box etc) if update thumbnail is
    enabled. \n  - Add Video (gif) option to Android which will be sent 5 seconds
    after the event ends.\n  - Subtitle support\n  - Video for IOS sent 5 seconds
    after the event ends \n  - Set custom entity for IOS live view\n  - Set Icons
    for Action Buttons on IOS\n  - Strip _1 _2 and _3 from camera entities (trial
    feedback needed)\n\n[1]: https://companion.home-assistant.io/docs/notifications/notifications-basic#sending-notifications-to-multiple-devices\n[2]:
    https://blakeblackshear.github.io/frigate/configuration/cameras#zones\n[3]: https://blakeblackshear.github.io/frigate/configuration/objects\n\n##
    Support\nGo to https://github.com/SgtBatten/HA_blueprints to report bugs, request
    new features or get support with your configuration.\n"
  domain: automation
  source_url: https://github.com/SgtBatten/HA_blueprints/blob/telegram/Frigate%20Camera%20Notifications/Beta
  input:
    camera:
      name: Frigate Camera
      description: "Select the camera entity that will trigger notifications. \nIf
        you do not see cameras listed in the drop down, check you have the frigate
        integration installed.\n\nNote: The automation relies the frigate camera name
        matching the entity id in Home Assistant. It will automatically strip '_x'
        from the end of the entity id where x=1 , 2 or 3.\n"
      selector:
        entity:
          integration: frigate
          domain:
          - camera
          device_class:
          - camera
          multiple: false
    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
          multiple: false
    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: ''
    notify_telegram_chat_id:
      name: Telegram Chat ID (Optional)
      description: 'The chat ID to send telegram notifications to.

        If set, this will override individual devices and groups above. Note: TV (far
        below) must be set to false.

        '
      default: ''
    base_url:
      name: Base URL (Optional)
      description: "The external url for your Home Assistant instance. \nRecommended
        for IOS and required for Android/Fire TV.\n"
      default: ''
    mqtt_topic:
      name: MQTT Topic (Advanced)
      description: The MQTT topic frigate sends messages in.
      default: frigate/events
    client_id:
      name: Client ID (Optional-Advanced)
      description: Used to support multiple instances of Frigate. Leave blank if you
        don't know what to do.
      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: Short with a timestamp HH:MM
            value: '{{ label }} detected - {{ camera_name }} at {{event[''after''][''start_time'']|timestamp_custom(''%H:%M'')}}'
          - 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{% if entered_zones %} in the {{ entered_zones
              | join(', ') | replace('_',' ') }}{% endif %}.
          - label: Long with a timestamp HH:MM
            value: A {{ label }} {{ 'is loitering' if loitering else 'was detected'
              }} on the {{ camera_name }} camera{% if entered_zones %} in the {{ entered_zones
              | join(', ') | replace('_',' ') }}{% endif %} at {{event['after']['start_time']|timestamp_custom('%H:%M')}}.
          custom_value: true
          multiple: false
    subtitle:
      name: Subtitle
      description: A secondary heading you can use in your notifications.
      default: ''
    critical:
      name: Critical Notification (Optional)
      description: 'Send as a critical notification to the mobile device. This will
        ignore silent/vibrate modes.

        You can choose to limit crtical notifications to certain times using a template
        (some 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''
            }}'
          - '{{ event[''after''][''top_score''] |float(0) > 0.8 }}'
          custom_value: true
          multiple: false
    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: /api/frigate{{client_id}}/notifications/{{id}}/thumbnail.jpg
          - label: Snapshot
            value: /api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg
          custom_value: false
          multiple: false
    update_thumbnail:
      name: Update Image (Optional)
      description: Update the notification if a new "better" image is available.
      default: false
      selector:
        boolean: {}
    video:
      name: Video (Optional)
      description: You can optionally attach the clip to the notification which will
        replace the thumbnail/snapshot above if available.
      default: ''
      selector:
        select:
          options:
          - label: None
            value: ''
          - label: Clip
            value: /api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
          - label: Video for Telegram
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          custom_value: false
          multiple: false
    color:
      name: Notification Color - Android/TV only (Optional)
      description: Set the color of the notification on your Android mobile device
        or TV.
      default: '#03a9f4'
      selector:
        select:
          options:
          - label: Primary (Steelblue)
            value: '#03a9f4'
          - label: Red
            value: '#f44336'
          - label: Pink
            value: '#e91e63'
          - label: Purple
            value: '#926bc7'
          - label: Deep Purple
            value: '#6e41ab'
          - label: Indigo
            value: '#3f51b5'
          - label: Blue
            value: '#2196f3'
          - label: Light Blue
            value: '#03a9f4'
          - label: Cyan
            value: '#00bcd4'
          - label: Teal
            value: '#009688'
          - label: Green
            value: '#4caf50'
          - label: Light Green
            value: '#8bc34a'
          - label: Lime
            value: '#cddc39'
          - label: Yellow
            value: '#ffeb3b'
          - label: Amber
            value: '#ffc107'
          - label: Orange
            value: '#ff9800'
          - label: Deep Orange
            value: '#ff5722'
          - label: Brown
            value: '#795548'
          - label: Light Grey
            value: '#bdbdbd'
          - label: Grey
            value: '#9e9e9e'
          - label: Dark Grey
            value: '#606060'
          - label: Blue Grey
            value: '#607d8b'
          - label: Black
            value: '#000000'
          - label: White
            value: '#ffffff'
          custom_value: false
          multiple: false
    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
          multiple: false
    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
          multiple: false
    ios_live_view:
      name: Live View Entity - IOS only (Optional)
      description: Attach a live view from the selected entity to the notification
        for IOS devices.
      default: ''
      selector:
        entity:
          domain:
          - camera
          multiple: false
    sticky:
      name: Sticky - Android only (Optional)
      description: 'When enabled, the notification will stay active on the device
        after tapping it and remain there until cleared.

        '
      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.

        '
      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.

        '
      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
          multiple: false
    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'
          custom_value: false
    cooldown:
      name: Cooldown (Optional)
      description: Delay before sending another notification for this camera after
        the last event.
      default: 30
      selector:
        number:
          max: 300.0
          min: 0.0
          unit_of_measurement: seconds
          step: 1.0
          mode: slider
    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. \nNote: This only applies to new objects.
        Existing tracked objects will not be affected.\n"
      default: 30
      selector:
        number:
          max: 300.0
          min: 0.0
          unit_of_measurement: minutes
          step: 1.0
          mode: slider
    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.0
          min: 0.0
          unit_of_measurement: minutes
          step: 1.0
          mode: slider
    initial_delay:
      name: Delay initial notification (Optional)
      description: "How long to delay the first notification for each event. \n\nUse
        this if you DO NOT use \"update image\" and are experiencing notifications
        without attached images. Start with small numbers.\n"
      default: 0
      selector:
        number:
          max: 15.0
          min: 0.0
          unit_of_measurement: seconds
          step: 1.0
          mode: slider
    tap_action:
      name: Tap Action URL
      description: "# Action Buttons and URLs\n\nThe url to open when tapping on the
        notification. Some presets are provided, you can also set you own by typing
        in the box. \n\nThese options define the text and urls associated with the
        three action buttons at the bottom of the notification.\n"
      default: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
      selector:
        select:
          options:
          - label: View Clip
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          - label: View Snapshot
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
          - label: View Stream
            value: '{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json[''after''][''camera'']
              | lower | replace(''-'',''_'')}}?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
          multiple: false
    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{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
      selector:
        select:
          options:
          - label: View Clip
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          - label: View Snapshot
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
          - label: View Stream
            value: '{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json[''after''][''camera'']
              | lower | replace(''-'',''_'')}}?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
          multiple: false
    icon_1:
      name: Action Button 1 icon - IOS Only
      description: Customise the Icon on the first Action Button. Only the IOS SFSymbols
        library is supported, not mdi:icons. e.g sfsymbols:bell
      default: ''
    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{{client_id}}/notifications/{{id}}/snapshot.jpg'
      selector:
        select:
          options:
          - label: View Clip
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          - label: View Snapshot
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
          - label: View Stream
            value: '{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json[''after''][''camera'']
              | lower | replace(''-'',''_'')}}?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
          multiple: false
    icon_2:
      name: Action Button 2 icon - IOS Only
      description: Customise the Icon on the second Action Button. Only the IOS SFSymbols
        library is supported, not mdi:icons. e.g sfsymbols:bell
      default: ''
    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{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          - label: View Snapshot
            value: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
          - label: View Stream
            value: '{{base_url}}/api/camera_proxy_stream/camera.{{trigger.payload_json[''after''][''camera'']
              | lower | replace(''-'',''_'')}}?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
          multiple: false
    icon_3:
      name: Action Button 3 icon - IOS Only
      description: Customise the Icon on the third Action Button. Only the IOS SFSymbols
        library is supported, not mdi:icons. e.g sfsymbols:bell
      default: ''
    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
          custom_value: false
          multiple: false
    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
          custom_value: false
          multiple: false
    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.0
          min: 0.0
          unit_of_measurement: seconds
          step: 1.0
          mode: slider
    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%
          custom_value: false
          multiple: false
    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: {}
    max_updates:
      name: Max Updates
      description: 'Set the maximum number of times the automation will loop looking
        for updates. This is useful for cameras where you often get extended events
        or stationary objects and don''t want to recieve ongoing updates.

        Not every loop results in a notification so don''t set it to 3 expecting 3
        updates, you might get none.

        '
      default: 1000
      selector:
        number:
          min: 0.0
          max: 1000.0
          step: 1.0
          mode: slider
mode: parallel
trigger_variables:
  input_camera: !input camera
  camera: '{{ input_camera.rstrip(''_1'').rstrip(''_2'').rstrip(''_3'') | replace(''camera.'',
    '''') }}'
  mqtt_topic: !input mqtt_topic
trigger:
- platform: event
  event_type: mobile_app_notification_action
  event_data:
    action: silence-{{ camera }}
  id: silence
- platform: mqtt
  topic: '{{mqtt_topic}}'
  payload: '{{ camera }}/new'
  value_template: '{{ value_json[''after''][''camera''] | lower | replace(''-'',''_'')
    }}/{{ value_json[''type'']}}'
  id: frigate-event
variables:
  id: '{{ trigger.payload_json[''after''][''id''] }}'
  input_camera: !input camera
  camera: '{{ input_camera | replace(''camera.'', '''') }}'
  camera_name: '{{ camera | replace(''_'', '' '') | title }}'
  input_base_url: !input base_url
  base_url: '{{ input_base_url.rstrip(''/'')}}'
  input_client_id: !input client_id
  client_id: '{{input_client_id if not input_client_id else ''/'' + input_client_id
    if ''/'' not in input_client_id else input_client_id }}'
  attachment: !input attachment
  video: !input video
  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('' '',''_'')
    }}'
  telegram: !input notify_telegram_chat_id
  telegram_target: '{{ telegram | 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
  initial_delay: !input initial_delay
  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
  sticky: !input sticky
  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
  max_updates: !input max_updates
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:
        event: '{{ trigger.payload_json }}'
        object: '{{ trigger.payload_json[''after''][''label''] }}'
        label: '{{ object | title }}'
        initial_home: '{{ presence_entity != '''' and is_state(presence_entity, ''home'')
          }}'
        entered_zones: '{{ trigger.payload_json[''after''][''entered_zones''] |lower}}'
        zone_multi_filter: '{{zone_only and zone_multi and entered_zones|length and
          zones and zones |reject(''in'', entered_zones) |list |length == 0 }}'
        title: !input title
        message: !input message
        subtitle: !input subtitle
        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_1: !input icon_1
        icon_2: !input icon_2
        icon_3: !input icon_3
        critical_input: !input critical
        critical: '{{ true if critical_input == ''true'' else true if critical_input
          == True else false }}'
        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: \n  Info:\n    fps: {{fps}}, \n    frigate event id:
              {{id}}{{', Frigate client ID: ' + client_id if client_id else ''}},
              \n    object (formatted): {{object}} ({{label}}),\n  Config: \n    camera(formatted):
              {{camera}}({{camera_name}}), \n    Base URL: {{base_url}}, \n    critical:
              {{critical}}, \n    alert once: {{alert_once}}, \n    Update Thumbnails:
              {{update_thumbnail}}, \n    attachment: {{attachment}}\n    Video: {{video}},
              \n    Target: {{'Telegram,  ' if telegram else 'group (input/formatted):
              ' + group + '/' + group_target + ', ' if group else 'Mobile Device,
              '}}\n    cooldown: {{cooldown}}s, \n    loiter timer: {{loiter_timer}}s,
              \n    initial delay: {{initial_delay}}s, \n    color: {{color}}, \n
              \   sound: {{sound}}, \n    Channel: {{channel}}, \n    Sticky: {{sticky}},
              \n    Title: {{title}}, \n    Message: {{message}},\n    Subtitle: {{subtitle}},
              \n    tap_action: {{tap_action}}, \n    button 1 Text/URL/Icon: {{iif(button_1,
              button_1, 'unset')}} ({{url_1}}) {{icon_1}}, \n    button 2 Text/URL/Icon:
              {{button_2}} ({{url_2}}) {{icon_2}}, \n    button 3 Text/URL/Icon: {{button_3}}
              ({{url_3}}) {{icon_3}}, \n    icon: {{icon}}\n    tv: {{tv}}, \n    tv_position:
              {{tv_position}}, \n    tv_size: {{tv_size}}, \n    tv_duration: {{tv_duration}},
              \n    tv_transparency: {{tv_transparency}}, \n    tv_interrupt: {{tv_interrupt}},
              \n    Max updates: {{max_updates}}\n  Filters: \n    Zones: \n      zone
              filter toggle on: {{zone_only}}, \n      Multi Zone toggle on: {{zone_multi}},
              \n      Required zones: {{input_zones}}, \n      Entered Zones: {{entered_zones}},
              \n      Zone Filter TEST: {{'PASS (Multi)' if zone_multi_filter else
              'PASS' if ( not zone_only or not zone_multi and zones|select('in', entered_zones)|list|length
              ) else 'FAIL (Multi)' if zone_multi else 'FAIL' }}, \n    Required objects
              TEST: \n      Input: {{input_labels}}, \n      TEST: {{'PASS' if not
              labels|length or object in labels else 'FAIL'}}\n    presence entity
              (not home):\n      Entity: {{presence_entity}}\n      TEST:  {{'PASS'
              if not initial_home else 'FAIL'}}, \n    disabled times: {{disable_times}},
              \n    State Filter: \n      state filter toggle on: {{state_only}},
              \n      state filter entity: {{input_entity}}, \n      required states:
              {{input_states}}, \n      State Filter TEST: {{'PASS' if not state_only
              or states(input_entity) in states_filter else 'FAIL' }},\n"
    - alias: Notifications enabled for object label
      condition: template
      value_template: '{{ not labels|length or object in labels }}'
    - alias: Delay for image
      choose:
      - conditions:
        - '{{initial_delay > 0}}'
        sequence:
        - delay:
            seconds: '{{initial_delay}}'
    - alias: Notify on new object
      choose:
      - conditions:
        - '{{ not zone_only or (not zone_multi and zones|select(''in'', entered_zones)|list|length
          > 0) or (zone_multi and entered_zones|length > 0 and zones |reject(''in'',
          entered_zones) |list |length == 0) }}'
        - '{{ not initial_home }}'
        - '{{ not state_only or states(input_entity) in states_filter }}'
        sequence:
        - choose:
          - conditions: '{{ not group and not telegram}}'
            sequence:
            - device_id: !input notify_device
              domain: mobile_app
              type: notify
              title: '{{title}}'
              message: '{{message}}'
              data:
                tag: '{{ id }}'
                group: '{{ camera }}-frigate-notification'
                color: '{{color}}'
                subject: '{{subtitle}}'
                image: '{{attachment}}?format=android'
                video: '{{video}}'
                clickAction: '{{tap_action}}'
                ttl: 0
                priority: high
                notification_icon: '{{icon}}'
                sticky: '{{sticky}}'
                channel: '{{''alarm_stream'' if critical else channel}}'
                subtitle: '{{subtitle}}'
                url: '{{tap_action}}'
                attachment:
                  url: '{{attachment}}'
                push:
                  sound: '{{sound}}'
                  interruption-level: '{{ iif(critical, ''critical'', ''active'')
                    }}'
                entity_id: '{{ios_live_view}}'
                actions:
                - action: URI
                  title: '{{button_1}}'
                  uri: '{{url_1}}'
                  icon: '{{icon_1}}'
                - action: URI
                  title: '{{button_2}}'
                  uri: '{{url_2}}'
                  icon: '{{icon_2}}'
                - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                  title: '{{button_3}}'
                  uri: '{{url_3}}'
                  icon: '{{icon_3}}'
                  destructive: true
          - conditions: '{{ tv }}'
            sequence:
            - service: notify.{{ group_target }}
              data:
                title: '{{title}}'
                message: '{{message}}'
                data:
                  tag: '{{ id }}'
                  group: '{{ camera }}-frigate-notification'
                  color: '{{color}}'
                  subject: '{{subtitle}}'
                  clickAction: '{{tap_action}}'
                  ttl: 0
                  priority: high
                  notification_icon: '{{icon}}'
                  sticky: '{{sticky}}'
                  channel: '{{''alarm_stream'' if critical else channel}}'
                  image:
                    url: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
                  fontsize: '{{tv_size}}'
                  position: '{{tv_position}}'
                  duration: '{{tv_duration}}'
                  transparency: '{{tv_transparency}}'
                  interrupt: '{{tv_interrupt}}'
                  timeout: 30
                  subtitle: '{{subtitle}}'
                  url: '{{tap_action}}'
                  attachment:
                    url: '{{attachment}}'
                  push:
                    sound: '{{sound}}'
                    interruption-level: '{{ iif(critical, ''critical'', ''active'')
                      }}'
                  entity_id: '{{ios_live_view}}'
                  actions:
                  - action: URI
                    title: '{{button_1}}'
                    uri: '{{url_1}}'
                    icon: '{{icon_1}}'
                  - action: URI
                    title: '{{button_2}}'
                    uri: '{{url_2}}'
                    icon: '{{icon_2}}'
                  - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                    title: '{{button_3}}'
                    uri: '{{url_3}}'
                    icon: '{{icon_3}}'
                    destructive: true
          - conditions: '{{ telegram | length > 0 }}'
            sequence:
            - service: telegram_bot.send_photo
              data:
                target: '{{telegram}}'
                caption: '{{message}}'
                url: '{{base_url + attachment }}'
          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}}'
                subject: '{{subtitle}}'
                image: '{{attachment}}?format=android'
                video: '{{video}}'
                clickAction: '{{tap_action}}'
                ttl: 0
                priority: high
                notification_icon: '{{icon}}'
                sticky: '{{sticky}}'
                channel: '{{''alarm_stream'' if critical else channel}}'
                subtitle: '{{subtitle}}'
                fontsize: '{{tv_size}}'
                position: '{{tv_position}}'
                duration: '{{tv_duration}}'
                transparency: '{{tv_transparency}}'
                interrupt: '{{tv_interrupt}}'
                url: '{{tap_action}}'
                attachment:
                  url: '{{attachment}}'
                push:
                  sound: '{{sound}}'
                  interruption-level: '{{ iif(critical, ''critical'', ''active'')
                    }}'
                entity_id: '{{ios_live_view}}'
                actions:
                - action: URI
                  title: '{{button_1}}'
                  uri: '{{url_1}}'
                  icon: '{{icon_1}}'
                - action: URI
                  title: '{{button_2}}'
                  uri: '{{url_2}}'
                  icon: '{{icon_2}}'
                - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                  title: '{{button_3}}'
                  uri: '{{url_3}}'
                  icon: '{{icon_3}}'
                  destructive: true
    - repeat:
        sequence:
        - wait_for_trigger:
          - platform: mqtt
            topic: '{{mqtt_topic}}'
            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)
              }}'
            critical_input: !input critical
            critical: '{{ true if critical_input == ''true'' else true if critical_input
              == True else false }}'
            title: "{% if sub_label %} \n  {{title | replace('A Person', sub_label|title)
              | replace('Person', sub_label|title)}}\n{%else%}\n  {{title}}\n{%endif%}\n"
            message: "{% if sub_label %} \n  {{message | replace('A Person', sub_label|title)
              | replace('Person', sub_label|title)}}\n{%else%}\n  {{message}}\n{%endif%}\n"
            subtitle: "{% if sub_label %} \n  {{subtitle | replace('A Person', sub_label|title)
              | replace('Person', sub_label|title)}}\n{%else%}\n  {{subtitle}}\n{%endif%}\n"
        - alias: Update thumbnail at end of event
          choose:
          - conditions:
            - '{{event[''type''] == ''end'' or repeat.index == max_updates}}'
            - '{{update_thumbnail or video|length > 0}}'
            sequence:
            - delay:
                seconds: 5
            - variables:
                new_snapshot: true
        - alias: 'Debug: write to Log'
          choose:
          - conditions:
            - '{{debug}}'
            sequence:
            - service: logbook.log
              data_template:
                name: Frigate Notification
                message: "DEBUG (in loop): \n  Info: \n    Last Zones: {{last_zones}},
                  \n    Current zones: {{entered_zones}}, \n    sublabel: {{sub_label}},
                  \n    IOS sound: {{update if not critical else 'yes due critical
                  notifications'}}, \n    Android Sound: {{'disabled by alert once'
                  if alert_once else 'enabled'}}, \n    image: \"{{attachment}}\"\n
                  \   video: \"{{video}}\"\n    critical: {{critical}}, \n  Triggers:
                  \n    New Snapshot: {{new_snapshot}}, \n    Presence Changed: {{presence_changed}},
                  \n    stationary moved: {{stationary_moved}}, \n    entered zones
                  changed: {{entered_zones_changed}}, \n    sublabel changed: {{sub_label_changed}},
                  \n  Conditions: \n    Loitering: {{loitering}}\n      or \n    Presence
                  Entity not home: {{'ON' if presence_entity != '' else 'OFF'}} -
                  {{'PASS' if not home else 'FAIL'}}, \n    zone filter TEST: {{'ON'
                  if zone_only else 'OFF'}} - {{'PASS' if zone_filter else 'FAIL'}},
                  \n    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'}}, \n    state filter TEST: {{'ON' if state_only
                  else 'OFF'}} - {{'PASS' if state_true else 'FAIL'}}\n"
        - 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 and not telegram}}'
                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}}'
                    subject: '{{subtitle}}'
                    image: '{{attachment}}?format=android'
                    video: '{{video}}'
                    clickAction: '{{tap_action}}'
                    ttl: 0
                    priority: high
                    alert_once: '{{ alert_once }}'
                    notification_icon: '{{icon}}'
                    sticky: '{{sticky}}'
                    channel: '{{''alarm_stream'' if critical else channel}}'
                    subtitle: '{{subtitle}}'
                    url: '{{tap_action}}'
                    attachment:
                      url: '{{video if video|length>0 and ( event[''type''] == ''end''
                        or repeat.index == max_updates) else attachment}}'
                    push:
                      sound: '{{ iif(update, ''none'', sound) }}'
                      interruption-level: '{{ iif(critical, ''critical'', ''active'')
                        }}'
                    entity_id: '{{ios_live_view}}'
                    actions:
                    - action: URI
                      title: '{{button_1}}'
                      uri: '{{url_1}}'
                      icon: '{{icon_1}}'
                    - action: URI
                      title: '{{button_2}}'
                      uri: '{{url_2}}'
                      icon: '{{icon_2}}'
                    - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                      title: '{{button_3}}'
                      uri: '{{url_3}}'
                      icon: '{{icon_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}}'
                      subject: '{{subtitle}}'
                      clickAction: '{{tap_action}}'
                      ttl: 0
                      priority: high
                      alert_once: '{{ alert_once }}'
                      notification_icon: '{{icon}}'
                      sticky: '{{sticky}}'
                      channel: '{{''alarm_stream'' if critical else channel}}'
                      image:
                        url: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg'
                      video: '{{video}}'
                      fontsize: '{{tv_size}}'
                      position: '{{tv_position}}'
                      duration: '{{tv_duration}}'
                      transparency: '{{tv_transparency}}'
                      interrupt: '{{tv_interrupt}}'
                      timeout: 30
                      subtitle: '{{subtitle}}'
                      url: '{{tap_action}}'
                      attachment:
                        url: '{{video if video|length>0 and ( event[''type''] == ''end''
                          or repeat.index == max_updates ) else attachment}}'
                      push:
                        sound: '{{ iif(update, ''none'', sound) }}'
                        interruption-level: '{{ iif(critical, ''critical'', ''active'')
                          }}'
                      entity_id: '{{ios_live_view}}'
                      actions:
                      - action: URI
                        title: '{{button_1}}'
                        uri: '{{url_1}}'
                        icon: '{{icon_1}}'
                      - action: URI
                        title: '{{button_2}}'
                        uri: '{{url_2}}'
                        icon: '{{icon_2}}'
                      - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                        title: '{{button_3}}'
                        uri: '{{url_3}}'
                        icon: '{{icon_3}}'
                        destructive: true
              - conditions: '{{ telegram | length > 0 }}'
                sequence:
                - choose:
                  - conditions:
                    - '{{ event[''type''] == ''end'' or repeat.index == max_updates
                      }}'
                    - '{{ video | length > 0 }}'
                    sequence:
                    - service: telegram_bot.send_video
                      data:
                        target: '{{telegram}}'
                        caption: '{{message}}'
                        url: '{{base_url + video if video else ''''}}'
                  default:
                  - service: telegram_bot.send_photo
                    data:
                      target: '{{telegram}}'
                      caption: '{{message}}'
                      url: '{{base_url + attachment }}'
              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}}'
                    subject: '{{subtitle}}'
                    image: '{{attachment}}?format=android'
                    video: '{{video}}'
                    clickAction: '{{tap_action}}'
                    ttl: 0
                    priority: high
                    alert_once: '{{ alert_once }}'
                    notification_icon: '{{icon}}'
                    sticky: '{{sticky}}'
                    channel: '{{''alarm_stream'' if critical else channel}}'
                    fontsize: '{{tv_size}}'
                    position: '{{tv_position}}'
                    duration: '{{tv_duration}}'
                    transparency: '{{tv_transparency}}'
                    interrupt: '{{tv_interrupt}}'
                    subtitle: '{{subtitle}}'
                    url: '{{tap_action}}'
                    attachment:
                      url: '{{video if video|length>0 and ( event[''type''] == ''end''
                        or repeat.index == max_updates ) else attachment}}'
                    push:
                      sound: '{{ iif(update, ''none'', sound) }}'
                      interruption-level: '{{ iif(critical, ''critical'', ''active'')
                        }}'
                    entity_id: '{{ios_live_view}}'
                    actions:
                    - action: URI
                      title: '{{button_1}}'
                      uri: '{{url_1}}'
                      icon: '{{icon_1}}'
                    - action: URI
                      title: '{{button_2}}'
                      uri: '{{url_2}}'
                      icon: '{{icon_2}}'
                    - action: '{{ ''URI'' if ''/'' in url_3 else url_3 }}'
                      title: '{{button_3}}'
                      uri: '{{url_3}}'
                      icon: '{{icon_3}}'
                      destructive: true
        until: '{{ not wait.trigger or event[''type''] == ''end'' or repeat.index
          == max_updates }}'

Frigate Config

mqtt:
  host: [REDACTED]
  user: [REDACTED]
  password: [REDACTED]

database:
  path: /config/frigate.db

detectors:
  cpu1:
    type: cpu
    num_threads: 3

  cpu2:
    type: cpu
    num_threads: 3

cameras:

  camera1:
    ffmpeg:
      inputs:
        - path: [REDACTED]
          roles:
            - detect
            - rtmp
            - record
            - clips
    detect:
      width: 1920
      height: 1080
      fps: 5

      stationary:
         interval: 0
         threshold: 50

    record:
      enabled: true

      events:
        retain:
          default: 14
          mode: active_objects

    objects:
      track:
        - person
        - car

  camera2:
    ffmpeg:

      inputs:
        - path: [REDACTED]
          roles:
            - detect
            - rtmp
            - record
            - clips

    detect:

      width: 1920
      height: 1080
      fps: 5
      stationary:
         interval: 0
         threshold: 50

    zones:
      entrance:
        coordinates: [REDACTED]
        objects:
          - car
          - person
      yard:
        coordinates: [REDACTED]
        objects:
          - person

    record:
      enabled: true

      retain:
        days: 7
        mode: all

      events:
         required_zones:
           - entrance
           - yard

         retain:
           default: 14
           mode: active_objects
    snapshots:
       required_zones:
         - entrance
         - yard
    objects:
      track:
        - person
        - car

  camera3:
    ffmpeg:     
      output_args:
        record: preset-record-generic-audio-aac

      inputs:
        - path: [REDACTED]
          roles:
            - detect
            - rtmp
            - record
            - clips
    snapshots:
     bounding_box: true

    detect:
      width: 1920
      height: 1080
      fps: 5

    record:
      enabled:  true

      events:
         retain:
           default: 1

  camera4:
    ffmpeg:

      inputs:
        - path: [REDACTED]
          roles:
            - detect
            - rtmp
            - record
            - clips

    detect:
      width: 1920
      height: 1080
      fps: 5

    record:
      enabled: true

      events:
        retain:
          default: 3
          mode: active_objects

    objects:
      track:
        - person
        - car
        - bus
        - motorcycle 

record:
  enabled: True
  retain:
    days: 1
    mode: motion
  events:
    retain:
      default: 7
      mode: motion

snapshots:
  # Optional: Enable writing jpg snapshot to /media/frigate/clips (default: shown below)
  enabled: True
  # Optional: save a clean PNG copy of the snapshot image (default: shown below)
  clean_copy: True
  # Optional: print a timestamp on the snapshots (default: shown below)
  timestamp: False
  # Optional: draw bounding box on the snapshots (default: shown below)
  bounding_box: True
  # Optional: crop the snapshot (default: shown below)
  crop: False
  # Optional: height to resize the snapshot to (default: original size)
  #height: 175
  # Optional: Restrict snapshots to objects that entered any of the listed zones (default: no required zones)
  required_zones: []
  # Optional: Camera override for retention settings (default: global values)
  retain:
    # Required: Default retention days (default: shown below)
    default: 10
    # Optional: Per object retention days
    objects:
      person: 15

Any other information that may be helpful

No response

honeyfairy commented 11 months ago

I noted the following in the changelog:

Beta Changes: Add 10s delay to final notification update to ensure frigate has time to save snapshot edits (crop, bounding box etc) if update thumbnail is enabled.

I enabled the Update image feature, still does not work

SgtBatten commented 11 months ago

Please share your automation config

honeyfairy commented 11 months ago

Please share your automation config

Here is my automation config:


alias: Yard Notifications to Telegram group
description: ""
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera: camera.mpcam_fullview
    notify_device: f8480a01ed1c29d3ca2af2d781feea53
    notify_telegram_chat_id: "-123123"
    base_url: http://ip:8123
    message: >-
      {{ label }} detected - {{ camera_name }} at
      {{event['after']['start_time']|timestamp_custom('%H:%M')}}
    attachment: /api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg
    video: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    zones:
      - yard
    zone_filter: true
    labels:
      - person
      - cat
SgtBatten commented 10 months ago

Can you try setting the attachment url to one with bounding box in the dropdown?

image

Menz01 commented 9 months ago

Can you try setting the attachment url to one with bounding box in the dropdown?

image

Is this something that can be set in the ui editor of the blueprint? I am not seeing it. I am not getting bounding boxes in the notifications sent to my Google pixel phone. I think it would help me tune my settings better and reduce false positives

SgtBatten commented 9 months ago

You may need to update to a newer version of the beta, but yes

Menz01 commented 9 months ago

You may need to update to a newer version of the beta, but yes

I am on 0.12.0.2 of your card, I am on the 0.13 beta Frigate and the beta 5 of the Frigate HA integration and I do not see it. The OP says that is the current version. So what am I missing?

SgtBatten commented 9 months ago

The beta blueprint.

Menz01 commented 9 months ago

The beta blueprint.

Thank you. So I updated to the beta blueprint and found in the ui the setting and I enabled it. Unfortunately I am still not getting any bounding boxes on my snapshots in my notifications

SgtBatten commented 9 months ago

Unless frigate changed the urls it should work. I'm not using latest frigate as I've had no time to check anything out.

Can you please share your automation config from yaml mode into he UI, not from automations.yaml like you have initially.

Menz01 commented 9 months ago

Unless frigate changed the urls it should work. I'm not using latest frigate as I've had no time to check anything out.

Can you please share your automation config from yaml mode into he UI, not from automations.yaml like you have initially.

alias: Frigate Notifications description: "" use_blueprint: path: SgtBatten/Beta.yaml input: camera: camera.front_doorbell_cam notify_group: Frigate Notifications base_url: https://homeassistant.(domain).duckdns.org/ title: Person was detected message: Person was detected on the Front Doorbell Cam update_thumbnail: true attachment: snapshot.jpg?bbox=1 tv: true notify_device: fddac319b1405d2cb9ae95a8bf7766c7

SgtBatten commented 9 months ago

I just did a very basic new blueprint with just my device camera and snapshot with bounding box set. It worked.

Menz01 commented 9 months ago

I just did a very basic new blueprint with just my device camera and snapshot with bounding box set. It worked.

that is awesome for you but how do i troubleshoot why mine is not working?

SgtBatten commented 9 months ago

It only works for in progress events. So you are going to have to go stand in front of your camera and trigger an event and manually go to the url for that event (use the blueprint to give you the snapshot url) and add the bbox query parameter to it. See if it works like that.

SgtBatten commented 9 months ago

Maybe it doesn't work on groups. Try a single device also. If I find time I'll try a group.

Menz01 commented 9 months ago

Maybe it doesn't work on groups. Try a single device also. If I find time I'll try a group.

That must be it. I removed the notification group and left a single device and I have the bounding boxes in snapshots. Thanks for the suggestion. Would be nice if I could send to my group that way but this will work for now

SgtBatten commented 9 months ago

Honestly I can't explain why it would be different. But thanks for letting me know that was the issue.

Menz01 commented 9 months ago

Just another interesting discovery...from the pull down menu on my notification I see the bounding box but if I click the view snapshot button it is gone from that view

SgtBatten commented 9 months ago

That's expected as they aren't the same image. The notification thumbnail bounding box is generated in real time when the message is sent. the other one is the stored snapshot that frigate will show in it's UI. You can configure the latter within the frigate config independently.

Menz01 commented 9 months ago

You can configure the latter within the frigate config independently.

Where in the config is this? i am looking the config example and not seeing it (i am sure i am not looking at the right spot)

SgtBatten commented 9 months ago

https://docs.frigate.video/configuration/

Under the snapshot section midway down.