Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Thumbnails/Snapshots/etc not showing up when sent to a notification group and multiple false positive with a single zone specified #77

Open
NonaSuomy opened this issue Aug 16, 2023 · 21 comments
Assignees
Labels
Awaiting Response Further information is requested bug Something isn't working

Comments

@NonaSuomy
Copy link

NonaSuomy commented Aug 16, 2023

Description

I was having issues, when I first set this up using the beta, iOS was working fine with a thumbnail shown. After that, I added a notification group to HA YAML.

- name: ALL_DEVICES
  platform: group
  services:
    - service: mobile_app_unknown
    - service: mobile_app_iphone
    - service: mobile_app_android
    - service: mobile_app_iphone2
    - service: alexa_media_robot_s_vector
    - service: desktop_host1
    - service: desktop_host2
    - service: desktop_host3
    - service: desktop_host4
    - service: desktop_host5

For some reason, only the android device was getting an image.

It showed in the Hass.Agent it was getting a bad url (complained about non http uri) /api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?format=android

I then did a test with the developer tools in HA to send this to the hass.agent service. It still didn't show an image on the notification. I then added http://HASSIP:Port in front and boom the image worked on the notification.

Then I looked at the blueprint and noticed there were multiple occurrences missing {{base_url}} throughout it. I modified the blueprint pasted below to add all missing {{base_url}} lines

I'm not sure if auto-set this somehow on something I selected wrong or if it's supposed to be this way but works for others?

Maybe this should be looked at to be prevented or let me know what I did wrong during the setup to cause this.

I noticed in these Blueprint settings it shows that it is missing {{base_url}} in that video string. Not sure if this is the default but that may be one issues?

Blueprint settings

id: '123456789876543'
alias: Frigate Notifications (0.12.0.1g)
description: ''
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera: camera.hqfrontyardcam
    zone_filter: true
    zones:
      - zone_0_front_door
    zone_multi: false
    ios_live_view: camera.hqfrontyardcam
    video: /api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    notify_group: ALL_DEVICES
    icon: mdi:cctv
    debug: true
    attachment: snapshot

Seems also weird that only the notification group switch made it not work properly.

Let me know if what I did broke anything else or if it actually should be this way with {{base_url}} in front of ever /api line.

Another issue I was having was with a lot of false positives happening even though I only set it to notify me if someone walked in one zone. Seemed to send me notifications on everything until I did this:

    - alias: Notify on new object
      choose:
      - conditions:
        - '{{ not zone_only or (not zone_multi and zones|select(''in'', entered_zones)|list|length
          > 2) or (zone_multi and entered_zones|length > 0 and zones |reject(''in'',
          entered_zones) |list |length == 0) }}'

Setting this

entered_zones)|list|length > 2

to 2 seems to have made it quieter and now only triggers on that one zone I specified.

Thank you.

Version

0.12.0.1g

Automation Config

blueprint:
  name: Frigate Notifications (0.12.0.1g)
  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/main/Frigate Camera
    Notifications/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: ''
    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{{ ' in the ' + entered_zones if entered_zones
              else '.'}}
          - label: Long with a timestamp HH:MM
            value: A {{ label }} {{ 'is loitering' if loitering else 'was detected'
              }} on the {{ camera_name }} camera{{ ' in the ' + entered_zones if entered_zones
              else '.'}} 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: thumbnail
          - label: Snapshot
            value: snapshot
          multiple: false
          custom_value: 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: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4'
          multiple: false
          custom_value: 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'
          multiple: false
          custom_value: 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?bbox=1'
          - 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
          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?bbox=1'
          - 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
          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?bbox=1'
      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?bbox=1'
          - 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
          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?bbox=1'
          - 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
          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
          multiple: false
          custom_value: 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
          multiple: false
          custom_value: 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%
          multiple: false
          custom_value: 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: {}
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:
  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
  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
  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
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 }}'
        id: '{{ trigger.payload_json[''after''][''id''] }}'
        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
        video: !input video
    - 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    Video: {{video}}, \n    Target: {{'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  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
          > 2) 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_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}}'
                subject: '{{subtitle}}'
                image: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?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: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg'
                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?bbox=1'
                  fontsize: '{{tv_size}}'
                  position: '{{tv_position}}'
                  duration: '{{tv_duration}}'
                  transparency: '{{tv_transparency}}'
                  interrupt: '{{tv_interrupt}}'
                  timeout: 30
                  subtitle: '{{subtitle}}'
                  url: '{{tap_action}}'
                  attachment:
                    url: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg'
                  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
          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: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?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: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg'
                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"
        - alias: Update thumbnail at end of event
          choose:
          - conditions:
            - '{{wait.trigger.payload_json[''type''] == ''end'' }}'
            - '{{(attachment == ''snapshot'' and update_thumbnail) or video|length
              > 0}}'
            sequence:
            - delay:
                seconds: 5
            - variables:
                new_snapshot: '{{update_thumbnail}}'
        - 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    IOS url: {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera
                  + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type']
                  == 'end' else attachment + '.jpg'}}\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    image:
                  \"{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg\"\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_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}}'
                    subject: '{{subtitle}}'
                    image: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?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: >-
                        {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/
                        {{
                          camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type'] == 'end'
                          else attachment + ".jpg"
                        }}
                    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?bbox=1'
                      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: >-
                          {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/
                          {{
                            camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type']== 'end'
                            else attachment + ".jpg"
                          }}
                      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
              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: '{{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?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: >-
                        {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/
                        {{
                          camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type'] == 'end'
                          else attachment + ".jpg"
                        }}
                    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 wait.trigger.payload_json[''type''] == ''end''
          }}'

Frigate Config

ui:
  use_experimental: false
  live_mode: mse

mqtt:
  host: MQTTIP
  port: 1883
  topic_prefix: frigate
  client_id: frigate
  user: user
  password: pass

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

rtmp:
  # Optional: Enable the RTMP stream (default: True)
  enabled: False

go2rtc:
  streams:
    HQFrontYardCam:
      - rtsp://user:pass@CAMIP:554/Streaming/Channels/101/
    HQFrontYardCam_sub:
      - rtsp://name:pass@CAMIP:554/Streaming/Channels/102/

detectors:
  cpu1:
    type: cpu
    num_threads: 2
  cpu2:
    type: cpu
    num_threads: 2

#Global Object Settings
objects:
  track:
    - person
    - dog
    - cat
    - mouse
    - bird
    - car
    - bicycle
    - motorcycle
    - bus

cameras:
  HQFrontYardCam:
    ffmpeg:
      inputs:
        # High Resolution Stream
        - path: rtsp://127.0.0.1:8554/HQFrontYardCam
          input_args: preset-rtsp-restream
          roles:
            - record
        # Low Resolution Stream
        - path: rtsp://127.0.0.1:8554/HQFrontYardCam_sub
          input_args: preset-rtsp-restream
          roles:
            - detect
    detect:
      width: 640
      height: 480
      fps: 5
    snapshots:
      enabled: True
      bounding_box: True
    record:
      enabled: True
      retain:
        days: 7
        mode: all
      events:
        retain:
          default: 10
          mode: active_objects
    motion:
      improve_contrast: True
      mask:
        - 214,15,214,31,25,31,25,15
    zones:
      zone_0_front_door:
        coordinates: 463,239,360,238,285,206,292,150,369,62,394,33,476,33
      zone_0_Driveway:
        coordinates: 385,228,79,147,204,77,396,64

birdseye:
  enabled: True
  restream: False
  width: 1280
  height: 720
  quality: 1
  mode: objects

live:
  height: 640
  quality: 1

Any other relevant information

No errors in the log.
@NonaSuomy NonaSuomy added the bug Something isn't working label Aug 16, 2023
@SgtBatten
Copy link
Owner

Thanks for doing the digging on this one. It's probably the solution to #45 .

I don't know why it it broken with groups. As you saw yourself, it works for non groups and it works for android regardless of groups.

It's not meant to need the base url. In fact ideally we wouldn't use it because we can get the images locally instead of via the internet.

The additional oddity it is it isn't broken for everyone. Again see the issue linked above.

Historically the base url was only needed for things like accessing the clips and snapshots from the action buttons.

entered_zones)|list|length > 2

I don't really understand this change. How did you pick 2? By my analysis, you are essentially saying it needs to be in 3 matching zones by doing that.

Besides the fact it should not work I'm curious to the logic.

I'd like to see some debug outputs if you can enable it and past them here. Instructions are available here https://github.com/SgtBatten/HA_blueprints/blob/main/Frigate%20Camera%20Notifications/Guide%3A%20Debug%20Option.md

@SgtBatten
Copy link
Owner

I may have a solution.

Please test with the beta version in the pull request above.

@SgtBatten SgtBatten added the Awaiting Response Further information is requested label Aug 17, 2023
@NonaSuomy
Copy link
Author

NonaSuomy commented Aug 18, 2023

Updated will report back on how it goes. So far the thumbnail on iOS disappeared again. Takes a while for someone to drive by the right way for the camera to trigger the false positive. Will report back.

Noticed there still are some missing {{base_url}}

image: "/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg?format=android"

And it says {{base_ur}} here instead of {{base_url}}
url: "{{base_ur}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}.jpg"

@SgtBatten
Copy link
Owner

@NonaSuomy thanks fixed the missing l

The first one should only be used for android so I've left it

@NonaSuomy
Copy link
Author

No false positives yet.
Added {{base_url}} back to all the other /api lines didn't fix the missing thumbnail this time.

@SgtBatten
Copy link
Owner

No false positives yet. Added {{base_url}} back to all the other /api lines didn't fix the missing thumbnail this time.

So to confirm. You used the latest version from the pull request which fixed the zoning issue.

You also added base urls everywhere in addition to one I added but still don't get thumbnails on iOS?

@NonaSuomy
Copy link
Author

NonaSuomy commented Aug 19, 2023

Correct on both accounts. I'm going to switch back to what I had before and see if the thumbnail comes back for iOS.

I was talking to Amadeo who was able to add to their PR to make the buttons work in HASS.Agent notifications. What this project transmits for buttons at the bottom of the popup. Hopefully, I can test that as well if I can get it to compile.

Edit it's working! Yay!

https://github.com/amadeo-alex/HASS.Agent.Staging/tree/feature-app-sdk

https://github.com/amadeo-alex/HASS.Agent.Staging/commits/feature-app-sdk

added option to treat URI elements of notification action like androi…

@NonaSuomy
Copy link
Author

I went back to the previous code and the notification image shows back up.

@SgtBatten
Copy link
Owner

I assume you've been replacing yaml and then reloading automations?

There is potentially a cache issue still (within HA generally) that I reported months ago. Please create a new automation from scratch and see how it goes.

@NonaSuomy
Copy link
Author

I smashed your false positives fixes with my old thumbnail working version and seems to be working well now. Thumbnails and no false positives.

I was just replacing the Beta.yaml then restarting HA then clicking save on the settings page again. I'll try the new automation thing you said.

@SgtBatten
Copy link
Owner

my old thumbnail working version and seems to be working well now.

What are the noteworthy differences between your version and the current beta?

@NonaSuomy
Copy link
Author

Okay got a chance to test it and the thumbnails still don't work.

Seems to be a lot of change between G and L beta.

I was trying to slowly copy pasta stuff from L to G but takes forever as I don't want to quickly copy everything and then break it and not know what exact line broke it.

@SgtBatten
Copy link
Owner

SgtBatten commented Aug 22, 2023

Seems to be a lot of change between G and L beta.

Don't really need to compare those. (Yet)

Sound alike you were on beta g and thumbnails weren't working. Then you made some changes and they were were working. So all I need is those changes to begin with.

@NonaSuomy
Copy link
Author

NonaSuomy commented Aug 24, 2023

The only changes made were {{ base_url }} on every /api/ line and ?bbox=1 on the image lines. Which I tried on L beta and it didn’t work unfortunately. My modification to G beta was pasted above in that yaml maybe you can notice better than I if there was anything else changed between G and L that may be the culprit?
Not only iOS but HASS.Agent as well looses its thumb nail when I switch to L beta.

@SgtBatten
Copy link
Owner

I notice in your automation yaml you don't have a base url actually set?

@SgtBatten SgtBatten added Awaiting Response Further information is requested and removed Awaiting Response Further information is requested labels Aug 24, 2023
@SgtBatten
Copy link
Owner

Also did you at any point actually do a clean install of the latest beta?

@NonaSuomy
Copy link
Author

Yes sorry fresh install as my comment before that was “I’ll try what you said with the fresh install” then next was “I finally got to try it”

You can see the base url is set below

id: '#############'
alias: Frigate Notifications (0.12.0.1l)
description: ''
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera: camera.hqfrontyardcam
    zone_filter: true
    zones:
      - zone_0_front_door
    zone_multi: false
    ios_live_view: camera.hqfrontyardcam
    video: >-
      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
    notify_group: ALL_DEVICES
    icon: mdi:cctv
    debug: true
    attachment: snapshot
    base_url: http://HAIP:8123
    message: A {{ label }} was detected at the front door.

@NonaSuomy
Copy link
Author

Tried Beta "O" still same issues no thumb on iOS and false positives with only one zone enabled.

@SgtBatten
Copy link
Owner

SgtBatten commented Aug 30, 2023

Well I'm probably going to revert all the baseurl changes then. I thought you said it was working?

Is it all iOS devices? Have you tried rearranging the devices or temporarily using a smaller list.

@SgtBatten

This comment was marked as outdated.

@SgtBatten
Copy link
Owner

no thumb on iOS

Can you please use this file and see if both issues are resolved

https://github.com/SgtBatten/HA_blueprints/blob/beta/Frigate%20Camera%20Notifications/Beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Response Further information is requested bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants