SgtBatten / HA_blueprints

Somewhere to store automation blueprints
184 stars 72 forks source link

[Config Support]: Not receiving notifications (iOS + NAS Hosted Frigate) #289

Open dfly112 opened 1 day ago

dfly112 commented 1 day ago

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

I initially had Frigate installed via addon + integration within HA and was previously receiving notifications using the stable version (0.12.0.4d), but decided to get fancy and change storage from container to NAS. I used the official methods (add database to frigate config, added NAS storage to HA) and everything broke resulting in no notifications. Prior to posting here, I tried rolling back to previous settings in HA, removing database from frigate config, seeing if notifications worked with fresh 0.12.0.4d and fresh beta 0.12.0.4k with and without customized settings, and installing frigate on the NAS via docker. None of these have worked. It seems that I am unable to get traces due to triggers not firing and can only manually trigger the automation. Reolink app is sending notifications. Assuming this issue is with MQTT since when I go to configure and listen to "frigate/events" I haven't seen anything publish for the topic...

Capture

Questions:

Version

Frigate vers 0.14.1, Automation vers 0.12.0.4k

Automation config

mode: parallel
trigger_variables:
  input_camera: camera.reolink
  camera: "{{ input_camera | regex_replace('^camera\\.|_\\d+$', '') }}"
  mqtt_topic: frigate/events
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: camera.reolink
  camera: "{{ input_camera | regex_replace('^camera\\.', '') }}"
  camera_name: "{{ camera | replace('_', ' ') | title }}"
  input_base_url: 192.168.x.x:8123
  base_url: "{{ input_base_url.rstrip('/')}}"
  update_sub_label: false
  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: snapshot.jpg?bbox=1
  alert_once: true
  update_thumbnail: true
  ios_live_view: camera.reolink
  android_auto: false
  notify_group: ""
  notify_group_target: >-
    {{ notify_group | lower | regex_replace('^notify\.', '') | replace(' ','_')
    }}
  zone_only: true
  input_zones:
    - doorway
  zones: "{{ input_zones }}"
  zone_multi: false
  zone_order_enforced: false
  input_labels:
    - person
    - car
    - dog
  labels: "{{ input_labels | list | lower }}"
  presence_entity: ""
  disable_times: []
  cooldown: 30
  loitering: false
  loiter_timer: 0
  initial_delay: 0
  fps: "{{ states('sensor.' + camera + '_camera_fps')|int(5) }}"
  state_only: false
  input_entity: ""
  input_states: []
  states_filter: "{{ input_states | list | lower }}"
  color: "#03a9f4"
  sound: default
  input_volume: 100
  volume: "{{ (1 * input_volume|int(100))/100 }}"
  sticky: false
  tv: false
  tv_position: center
  tv_size: large
  tv_duration: 10
  tv_transparency: 0%
  tv_interrupt: false
  debug: true
  redacted: true
  master_condition: []
action:
  - if:
      - condition: []
    then:
      - choose:
          - alias: Silence New Object Notifications
            conditions:
              - condition: trigger
                id: silence
            sequence:
              - target:
                  entity_id: "{{ this.entity_id }}"
                data:
                  stop_actions: false
                action: automation.turn_off
              - delay:
                  minutes: 5
              - target:
                  entity_id: "{{ this.entity_id }}"
                action: automation.turn_on
          - alias: Custom Action Manual
            conditions:
              - condition: trigger
                id: custom
            sequence: []
          - alias: Frigate Event
            conditions:
              - condition: trigger
                id: frigate-event
              - condition: template
                value_template: "{{ is_state(this.entity_id, 'on') }}"
              - condition: template
                value_template: >-
                  {{ not this.attributes.last_triggered or (now() -
                  this.attributes.last_triggered).seconds > cooldown }}
              - condition: template
                value_template: >-
                  {{ 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'] |
                    default([]) }}
                  any_zones_entered: >-
                    {{ zones | length == 0 or ((zones | select('in',
                    entered_zones) | list | length) > 0) }}
                  zone_single_satisfied: "{{ any_zones_entered if zone_only else true}}"
                  all_zones_entered: >-
                    {{ zones | length == 0 or ((zones | reject('in',
                    entered_zones) | list | length) == 0) }}
                  zone_multi_satisfied: "{{ all_zones_entered if zone_only and zone_multi else true}}"
                  ordered_zones: "{{ zones | join('|') }}"
                  ordered_entered_zones: "{{ entered_zones | join('|') }}"
                  ordered_zones_match: "{{ ordered_zones == ordered_entered_zones }}"
                  zone_order_satisfied: >-
                    {{ (zone_only and zone_multi and ordered_zones_match) if
                    zone_order_enforced else true }}
                  zones_satisfied: >-
                    {{zone_single_satisfied and zone_multi_satisfied and
                    zone_order_satisfied}}
                  loitering: false
                  title: Front Door Alert
                  message: >-
                    A {{ label }} {{ 'is loitering' if loitering else 'was
                    detected' }} on the {{ camera_name }} camera.
                  subtitle: ""
                  tap_action: >-
                    {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
                  button_1: View Clip
                  button_2: View Snapshot
                  button_3: Silence New Notifications
                  url_1: >-
                    {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera}}/clip.mp4
                  url_2: >-
                    {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/snapshot.jpg
                  url_3: silence-{{ camera }}
                  icon_1: ""
                  icon_2: ""
                  icon_3: ""
                  critical_input: "false"
                  critical: >-
                    {{ true if critical_input == 'true' else true if
                    critical_input == True else false }}
                  tts: false
                  tts_helper: ""
                  custom_filter: true
                  icon: >-
                    mdi:{{'account-outline' if label == 'Person' else 'dog' if
                    label == 'Dog' else 'cat' if label == 'Cat' else 'car' if
                    label == 'Car' else 'home-assistant'}}
                  group: "{{camera}}-frigate-notification{{'-loitering' if loitering}}"
                  channel: ""
                  video: ""
                  custom_action_auto: []
              - alias: "Debug: write to Log"
                choose:
                  - conditions:
                      - condition: template
                        value_template: "{{debug}}"
                    sequence:
                      - data_template:
                          name: Frigate Notification
                          message: |
                            DEBUG: 
                              Info:
                                fps: {{fps}}, 
                                frigate event id: {{id}}{{', Frigate client ID: ' + client_id if client_id else ''}}, 
                                object (formatted): {{object}} ({{label}}),
                              Config: 
                                camera(formatted): {{camera}}({{camera_name}}), 
                                Base URL: {{'REDACTED' if base_url and redacted else base_url}}, 
                                critical: {{critical}}, 
                                tts: {{tts}} 
                                helper: {{tts_helper if tts else 'N/A'}},
                                alert once: {{alert_once}}, 
                                Update Thumbnails: {{update_thumbnail}}, 
                                Video: {{video if not redacted else video |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}, 
                                Target: {{'group (input/formatted): ' + notify_group + '/' + notify_group_target + ', ' if notify_group else 'Mobile Device'}}
                                cooldown: {{cooldown}}s, 
                                loiter timer: {{loiter_timer}}s, 
                                initial delay: {{initial_delay}}s, 
                                color: {{color}}, 
                                sound: {{sound}}, 
                                android_auto: {{android_auto}}, 
                                Group: {{group}}, 
                                Channel: {{channel}}, 
                                Sticky: {{sticky}}, 
                                Title: {{title}}, 
                                Message: {{message}},
                                Subtitle: {{subtitle}}, 
                                tap_action: {{tap_action if not redacted else tap_action |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}, 
                                button 1 Text/URL/Icon: {{iif(button_1, button_1, 'unset')}} ({{url_1 if not redacted else url_1 |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}) {{icon_1}}, 
                                button 2 Text/URL/Icon: {{button_2}} ({{url_2 if not redacted else url_2 |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}) {{icon_2}}, 
                                button 3 Text/URL/Icon: {{button_3}} ({{url_3 if not redacted else url_3 |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}) {{icon_3}}, 
                                icon: {{icon}}
                                tv: {{ tv }}, 
                                tv_position: {{tv_position}}, 
                                tv_size: {{tv_size}}, 
                                tv_duration: {{tv_duration}}, 
                                tv_transparency: {{tv_transparency}}, 
                                tv_interrupt: {{tv_interrupt}}, 
                              Filters: 
                                Zones: 
                                  Zone Filter toggle on: {{zone_only}}, 
                                  Multi-Zone toggle on: {{zone_multi}}, 
                                  Required zones: {{input_zones}}, 
                                  Zone Order toggle on: {{zone_order_enforced}}
                                  Entered Zones: {{entered_zones}},
                                  TEST: {{'PASS' if zones_satisfied else 'FAIL' }} {{'(Multi)' if zone_only and zone_multi}} {{'(Order-Enforced)' if zone_only and zone_multi and zone_order_enforced}}, 
                                Required objects TEST: 
                                  Input: {{input_labels}}, 
                                  TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}
                                presence entity (not home):
                                  Entity: {{presence_entity}}
                                  TEST:  {{'PASS' if not initial_home else 'FAIL'}}, 
                                disabled times: {{disable_times}}, 
                                State Filter: 
                                  State Filter toggle on: {{state_only}}, 
                                  State Filter Entity: {{input_entity}}, 
                                  Required States: {{input_states}}, 
                                  TEST: {{'PASS' if not state_only or states(input_entity) in states_filter else 'FAIL' }},
                                Custom Filter: {{custom_filter}}
                        action: logbook.log
              - alias: Notifications enabled for object label
                condition: template
                value_template: "{{ not labels|length or object in labels }}"
              - alias: Delay for image
                choose:
                  - conditions:
                      - condition: template
                        value_template: "{{initial_delay > 0}}"
                    sequence:
                      - delay:
                          seconds: "{{initial_delay}}"
              - alias: Custom Action Auto
                choose:
                  - conditions:
                      - condition: template
                        value_template: "{{ custom_action_auto |length > 0 }}"
                      - condition: template
                        value_template: "{{ zones_satisfied }}"
                      - condition: template
                        value_template: "{{ not initial_home }}"
                      - condition: template
                        value_template: >-
                          {{ not state_only or states(input_entity) in
                          states_filter }}
                    sequence: []
              - alias: Notify on new object
                choose:
                  - conditions:
                      - condition: template
                        value_template: "{{ zones_satisfied }}"
                      - condition: template
                        value_template: "{{ not initial_home }}"
                      - condition: template
                        value_template: >-
                          {{ not state_only or states(input_entity) in
                          states_filter }}
                      - condition: template
                        value_template: "{{ custom_filter }}"
                    sequence:
                      - choose:
                          - conditions:
                              - condition: template
                                value_template: "{{ not notify_group_target }}"
                            sequence:
                              - device_id: 53dacfe93fae0bf2931c7cd715adeed0
                                domain: mobile_app
                                type: notify
                                title: "{{title}}"
                                message: "{{message}}"
                                data:
                                  tag: "{{ id }}"
                                  group: "{{ group }}"
                                  color: "{{color}}"
                                  subject: "{{subtitle}}"
                                  image: >-
                                    {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}{{'&'
                                    if '?' in attachment else
                                    '?'}}format=android
                                  video: "{{video}}"
                                  clickAction: "{{tap_action}}"
                                  ttl: 0
                                  priority: high
                                  notification_icon: "{{icon}}"
                                  sticky: "{{sticky}}"
                                  channel: "{{'alarm_stream' if critical else channel}}"
                                  car_ui: "{{android_auto}}"
                                  subtitle: "{{subtitle}}"
                                  url: "{{tap_action}}"
                                  attachment:
                                    url: >-
                                      {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}
                                  push:
                                    sound:
                                      name: "{{sound}}"
                                      volume: "{{ iif(sound == 'none', 0, volume) }}"
                                      critical: "{{ iif(critical, 1, 0) }}"
                                  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:
                              - condition: template
                                value_template: "{{ tv }}"
                            sequence:
                              - data:
                                  title: "{{title}}"
                                  message: "{{message}}"
                                  data:
                                    tag: "{{ id }}"
                                    group: "{{ group }}"
                                    color: "{{color}}"
                                    subject: "{{subtitle}}"
                                    clickAction: "{{tap_action}}"
                                    ttl: 0
                                    priority: high
                                    notification_icon: "{{icon}}"
                                    sticky: "{{sticky}}"
                                    channel: >-
                                      {{'alarm_stream' if critical else
                                      channel}}
                                    car_ui: "{{android_auto}}"
                                    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: >-
                                        {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}
                                    push:
                                      sound:
                                        name: "{{sound}}"
                                        volume: "{{ iif(sound == 'none', 0, volume) }}"
                                        critical: "{{ iif(critical, 1, 0) }}"
                                    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
                                action: notify.{{ notify_group_target }}
                        default:
                          - data:
                              title: "{{title}}"
                              message: "{{message}}"
                              data:
                                tag: "{{ id }}"
                                group: "{{ group }}"
                                color: "{{color}}"
                                subject: "{{subtitle}}"
                                image: >-
                                  {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}{{'&'
                                  if '?' in attachment else '?'}}format=android
                                video: "{{video}}"
                                clickAction: "{{tap_action}}"
                                ttl: 0
                                priority: high
                                notification_icon: "{{icon}}"
                                sticky: "{{sticky}}"
                                channel: "{{'alarm_stream' if critical else channel}}"
                                car_ui: "{{android_auto}}"
                                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}}
                                push:
                                  sound:
                                    name: "{{sound}}"
                                    volume: "{{ iif(sound == 'none', 0, volume) }}"
                                    critical: "{{ iif(critical, 1, 0) }}"
                                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
                            action: notify.{{ notify_group_target }}
                      - if:
                          - condition: template
                            value_template: >-
                              {{tts and (not tts_helper or not alert_once or
                              (tts_helper and id not in states(tts_helper)))}}
                        then:
                          sequence:
                            - choose:
                                - conditions: "{{ not notify_group_target }}"
                                  sequence:
                                    - device_id: 53dacfe93fae0bf2931c7cd715adeed0
                                      domain: mobile_app
                                      type: notify
                                      message: "{{'TTS'}}"
                                      data:
                                        tag: "{{ id }}{{'-tts'}}"
                                        channel: >-
                                          {{'alarm_stream' if critical else
                                          channel}}
                                        alert_once: "{{ alert_once }}"
                                        tts_text: "{{message}}"
                              default:
                                - data:
                                    message: "{{'TTS'}}"
                                    data:
                                      tag: "{{ id }}{{'-tts'}}"
                                      channel: >-
                                        {{'alarm_stream' if critical else
                                        channel}}
                                      alert_once: "{{ alert_once }}"
                                      tts_text: "{{message}}"
                                  action: notify.{{ notify_group_target }}
                            - data:
                                value: >
                                  {% set newIds = id + '|' + states(tts_helper)
                                  %}

                                  {{ newIds[:250] }}
                              target:
                                entity_id: input_text.tts_notifications
                              action: input_text.set_value
              - 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']['frame_time'] !=
                          event['after']['snapshot']['frame_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 |
                          default([]) }}
                        any_zones_entered: >-
                          {{ zones | length == 0 or ((zones | select('in',
                          entered_zones) | list | length) > 0) }}
                        zone_single_satisfied: "{{ any_zones_entered if zone_only else true}}"
                        all_zones_entered: >-
                          {{ zones | length == 0 or ((zones | reject('in',
                          entered_zones) | list | length) == 0) }}
                        zone_multi_satisfied: >-
                          {{ all_zones_entered if zone_only and zone_multi else
                          true}}
                        ordered_zones: "{{ zones | join('|') }}"
                        ordered_entered_zones: "{{ entered_zones | join('|') }}"
                        ordered_zones_match: "{{ ordered_zones == ordered_entered_zones }}"
                        zone_order_satisfied: >-
                          {{ (zone_only and zone_multi and ordered_zones_match)
                          if zone_order_enforced else true }}
                        zones_satisfied: >-
                          {{zone_single_satisfied and zone_multi_satisfied and
                          zone_order_satisfied}}
                        new_entered_zones: "{{ zones | select('in', entered_zones) | list }}"
                        last_entered_zones: "{{ zones | select('in', last_zones) | list }}"
                        entered_new_zones: >-
                          {{ zone_only and (entered_zones | length > last_zones
                          | length) }}
                        entered_new_filter_zones: >-
                          {{ zone_only and zones | length > 0 and
                          (new_entered_zones | length > last_entered_zones |
                          length) }}
                        stationary_moved: >-
                          {{ event['after']['position_changes'] >
                          event['before']['position_changes'] }}
                        state_true: >-
                          {{ not state_only or states(input_entity) in
                          states_filter }}
                        sub_label: |
                          {% if event['after']['sub_label'] %} 
                            {{event['after']['sub_label'][0]}}
                          {%else%}
                            {{event['after']['sub_label']}}
                          {%endif%}
                        sub_label_before: |
                          {% if event['before']['sub_label'] %} 
                            {{event['before']['sub_label'][0]}}
                          {%else%}
                            {{event['before']['sub_label']}}
                          {%endif%}
                        sub_label_changed: >-
                          {{ update_sub_label and sub_label != sub_label_before
                          }}
                        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: "false"
                        critical: >-
                          {{ true if critical_input == 'true' else true if
                          critical_input == True else false }}
                        tts: false
                        title: |
                          {% if sub_label and update_sub_label %} 
                            {{title | replace('A Person', sub_label|title) | replace('Person', sub_label|title)}}
                          {%else%}
                            {{title}}
                          {%endif%}
                        input_message: >-
                          A {{ label }} {{ 'is loitering' if loitering else 'was
                          detected' }} on the {{ camera_name }} camera.
                        message: |
                          {% if sub_label and update_sub_label %} 
                            {{input_message | replace('A Person', sub_label|title) | replace('Person', sub_label|title)}}
                          {%else%}
                            {{input_message}}
                          {%endif%}
                        custom_action_auto_multi: []
                    - alias: Update thumbnail at end of event
                      choose:
                        - conditions:
                            - condition: template
                              value_template: "{{wait.trigger.payload_json['type'] == 'end' }}"
                            - condition: template
                              value_template: >-
                                {{('snapshot' in attachment and
                                update_thumbnail) or video|length > 0}}
                          sequence:
                            - delay:
                                seconds: 5
                            - variables:
                                new_snapshot: "{{update_thumbnail}}"
                    - alias: "Debug: write to Log"
                      choose:
                        - conditions:
                            - condition: template
                              value_template: "{{debug}}"
                          sequence:
                            - data_template:
                                name: Frigate Notification
                                message: |
                                  DEBUG (in loop): 
                                    Send Notification: {{ loitering or (custom_filter and not home and zones_satisfied and state_true and (new_snapshot or presence_changed or stationary_moved or entered_new_zones or entered_new_filter_zones or sub_label_changed)) }}
                                    Info: 
                                      sublabel: {{sub_label}}, 
                                      image: "{{'REDACTED' if base_url and redacted else base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}"
                                      Title: {{title}}
                                      message: {{message}}
                                      iOS sound: {{'Critical' if critical else 'disabled by alert once' if alert_once else 'enabled'}}, 
                                      Android Sound: {{'disabled by alert once' if alert_once else 'enabled'}}, 
                                      iOS url: {{'REDACTED' if base_url and redacted else base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type'] == 'end' else attachment }}
                                      video: "{{video if not redacted else video |regex_replace(find='^[^\/].+?[^\/:](?=[?\/]|$)', replace='REDACTED', ignorecase=False)}}"

                                      critical: {{critical}},
                                      tts: {{tts}} 
                                    Triggers: 
                                      New Snapshot: {{'True' if event['before']['snapshot']['frame_time'] != event['after']['snapshot']['frame_time'] else 'False'}}{{' - Disabled' if not update_thumbnail}} 
                                      Presence Changed: {{presence_changed}}, 
                                      Stationary Moved: {{stationary_moved}}, 
                                      Entered Zones Changed: {{'True' if event['before']['entered_zones'] != event['after']['entered_zones'] else 'False'}}{{' - Disabled' if not zone_only}}, 
                                      sublabel changed: {{ sub_label != sub_label_before }}{{' - Disabled' if not update_sub_label}}, 
                                    Conditions: 
                                      Loitering: {{loitering}}
                                        or
                                      Filters: 
                                        Zones: 
                                          Zone Filter toggle on: {{zone_only}}, 
                                          Multi-Zone toggle on: {{zone_multi}}, 
                                          Required zones: {{input_zones}}, 
                                          Zone Order toggle on: {{zone_order_enforced}}
                                          Last Zones: {{last_zones}}, 
                                          Entered Zones: {{ entered_zones | list | length }} - {{entered_zones}},
                                          TEST: {{'PASS' if zones_satisfied else 'FAIL' }} {{'(Multi)' if zone_only and zone_multi}} {{'(Order-Enforced)' if zone_only and zone_multi and zone_order_enforced}},         
                                        Object Filter: 
                                          Input: {{input_labels}}, 
                                          TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}, 
                                        Presence entity (not home):
                                          Entity: {{presence_entity}}, 
                                          TEST:  {{'PASS' if not home else 'FAIL'}}, 
                                        Time Filter:
                                          Disabled times: {{disable_times}}, 
                                          TEST: {{'PASS' if now().hour not in disable_times else 'FAIL'}}
                                        State Filter: 
                                          State Filter toggle on: {{state_only}}, 
                                          State Filter Entity: {{input_entity}}, 
                                          Required States: {{input_states}}, 
                                          TEST: {{'PASS' if state_true else 'FAIL'}}, 
                                        Custom Filter: {{'PASS' if custom_filter else 'FAIL'}},
                              action: logbook.log
                    - alias: Custom Action Auto Multi
                      choose:
                        - conditions:
                            - condition: template
                              value_template: "{{ custom_action_auto_multi | length > 0 }}"
                            - condition: template
                              value_template: >-
                                {{ loitering or (not home and zones_satisfied
                                and state_true and (new_snapshot or
                                presence_changed or stationary_moved or
                                entered_new_zones or entered_new_filter_zones or
                                sub_label_changed)) }}
                          sequence: []
                    - alias: Update Notification
                      choose:
                        - conditions:
                            - condition: template
                              value_template: >-
                                {{ loitering or (custom_filter and not home and
                                zones_satisfied and state_true and (new_snapshot
                                or presence_changed or stationary_moved or
                                entered_new_zones or entered_new_filter_zones or
                                sub_label_changed)) }}
                          sequence:
                            - choose:
                                - conditions:
                                    - condition: template
                                      value_template: "{{ not notify_group_target }}"
                                  sequence:
                                    - device_id: 53dacfe93fae0bf2931c7cd715adeed0
                                      domain: mobile_app
                                      type: notify
                                      title: "{{title}}"
                                      message: "{{message}}"
                                      data:
                                        tag: "{{ id }}{{'-loitering' if loitering}}"
                                        group: "{{ group }}"
                                        color: "{{color}}"
                                        subject: "{{subtitle}}"
                                        image: >-
                                          {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}{{'&'
                                          if '?' in attachment else
                                          '?'}}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}}
                                        car_ui: "{{android_auto}}"
                                        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 }}
                                        push:
                                          sound:
                                            name: "{{ iif(update, 'none', sound) }}"
                                            volume: >-
                                              {{ iif((update or sound == 'none'), 0,
                                              volume) }}
                                            critical: "{{ iif(critical, 1, 0) }}"
                                        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:
                                    - condition: template
                                      value_template: "{{ tv }}"
                                  sequence:
                                    - data:
                                        title: "{{title}}"
                                        message: "{{message}}"
                                        data:
                                          tag: "{{ id }}{{'-loitering' if loitering}}"
                                          group: "{{ group }}"
                                          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}}
                                          car_ui: "{{android_auto}}"
                                          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: >-
                                              {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{camera
                                              + '/clip.mp4' if video|length>0 and
                                              wait.trigger.payload_json['type'] ==
                                              'end' else attachment }}
                                          push:
                                            sound:
                                              name: "{{ iif(update, 'none', sound) }}"
                                              volume: >-
                                                {{ iif((update or sound == 'none'), 0,
                                                volume) }}
                                              critical: "{{ iif(critical, 1, 0) }}"
                                          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
                                      action: notify.{{ notify_group_target }}
                              default:
                                - data:
                                    title: "{{title}}"
                                    message: "{{message}}"
                                    data:
                                      tag: "{{ id }}{{'-loitering' if loitering}}"
                                      group: "{{ group }}"
                                      color: "{{color}}"
                                      subject: "{{subtitle}}"
                                      image: >-
                                        {{base_url}}/api/frigate{{client_id}}/notifications/{{id}}/{{attachment}}{{'&'
                                        if '?' in attachment else
                                        '?'}}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}}
                                      car_ui: "{{android_auto}}"
                                      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 }}
                                      push:
                                        sound:
                                          name: "{{ iif(update, 'none', sound) }}"
                                          volume: >-
                                            {{ iif((update or sound == 'none'), 0,
                                            volume) }}
                                          critical: "{{ iif(critical, 1, 0) }}"
                                      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
                                  action: notify.{{ notify_group_target }}
                            - if:
                                - condition: template
                                  value_template: >-
                                    {{tts and (not tts_helper or not alert_once
                                    or (tts_helper and id not in
                                    states(tts_helper)))}}
                              then:
                                sequence:
                                  - choose:
                                      - conditions: "{{ not notify_group_target }}"
                                        sequence:
                                          - device_id: 53dacfe93fae0bf2931c7cd715adeed0
                                            domain: mobile_app
                                            type: notify
                                            message: "{{'TTS'}}"
                                            data:
                                              tag: >-
                                                {{ id }}{{'-loitering-tts' if
                                                loitering}}
                                              channel: >-
                                                {{'alarm_stream' if critical else
                                                channel}}
                                              alert_once: "{{ alert_once }}"
                                              tts_text: "{{message}}"
                                    default:
                                      - data:
                                          message: "{{'TTS'}}"
                                          data:
                                            tag: >-
                                              {{ id }}{{'-loitering-tts' if
                                              loitering}}
                                            channel: >-
                                              {{'alarm_stream' if critical else
                                              channel}}
                                            alert_once: "{{ alert_once }}"
                                            tts_text: "{{message}}"
                                        action: notify.{{ notify_group_target }}
                                  - data:
                                      value: >
                                        {% set newIds = id + '|' +
                                        states(tts_helper) %}

                                        {{ newIds[:250] }}
                                    target:
                                      entity_id: input_text.tts_notifications
                                    action: input_text.set_value
                  until:
                    - condition: template
                      value_template: >-
                        {{ not wait.trigger or wait.trigger.payload_json['type']
                        == 'end' }}
alias: Distillers Front Door
description: ""

Frigate Config

mqtt:
  host: 192.168.x.x #(Home Assistant IP)
  port: 1883
  user: USERNAME
  password: PASS
  stats_interval: 60

cameras:
  reolink:
    ffmpeg:
      inputs:
        - path: rtsp://127.0.0.1:8554/reolink?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - record
            - audio
        - path: rtsp://127.0.0.1:8554/reolink_sub?video=copy&audio=aac
          input_args: preset-rtsp-restream
          roles:
            - detect
      output_args:
        record: preset-record-generic-audio-aac
    mqtt:
      enabled: true
      bounding_box: true
      timestamp: false
      crop: false
    audio:
      enabled: true
    objects:
      track:
        - person
        - dog
      filters:
        person:
          min_score: 0.65
    motion:
      threshold: 30
      contour_area: 15
      improve_contrast: 'true'
      lightning_threshold: 0.8
      mask: 0.671,0.015,0.98,0.012,0.979,0.049,0.673,0.052
    zones:
      Doorway:
        coordinates: 0.194,0.081,0.974,0.077,0.981,0.984,0.201,0.99
        objects:
          - person
        loitering_time: 1
        inertia: 3

go2rtc:
  streams:
    reolink:
      - ffmpeg:http://CAMERA-IP/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=USERNAME&password=PASS!#audio=aac#async
      - rtsp://USERNAME:PASS@CAMERA-IP:554/h264Preview_01_main
    reolink_sub:
      - rtsp://USERNAME:PASS@CAMERA-IP:554/h264Preview_01_sub
  webrtc:
    candidates:
      - SYNOLOGYNAS-IP:8555
      - stun:8555

detectors:
  coral:
    type: edgetpu
    device: usb

audio:
  enabled: true
  listen:
    - bark
    - scream
    - speech
    - yell

review:
  alerts:
    labels:
      - person
      - dog
  detections:
    labels:
      - person
      - dog

record:
  enabled: true
  retain:
    days: 3
    mode: motion
  events:
    objects:
      - person
      - dog
    retain:
      default: 30
      mode: motion
      objects:
        person: 14

detect:
  enabled: true
  width: 640
  height: 480
  fps: 5
  min_initialized: 2
  max_disappeared: 25
  stationary:
    interval: 50
    threshold: 50

birdseye:
  enabled: true
  mode: continuous

snapshots:
  enabled: true
  timestamp: false
  bounding_box: true
  retain:
    default: 30

objects:
  track:
    - person
    - dog
  filters:
    dog:
      min_score: .7
      threshold: .9
    person:
      min_score: .65
      threshold: .85

version: 0.14

Any other information that may be helpful

Specifics:

Things broken:

SgtBatten commented 22 hours ago
  • With a Docker Container in Synology NAS, I had to change the MQTT IP to the HA IP. Does this have to get changed in MQTT itself as well or can I keep mosquitto MQTT's default of core.mosquitto?

The only thing you would change is the mqtt up and port if necessary int he frigate config and in your mqtt broker. Mqtt itself should just be default regardless of how it's installed.

  • I am currently using Frigate Proxy... Is there any specific settings I need to change to have the automation work?

No, this just brings frigate into HA so if you have frigate showing in the HA side menu and frigate entities in HA it's working.

  • Do I have to modify clip.mp4/snapshot.jpg paths to direct it to my NAS folder?

No.

Seems like you have issues with your frigate talking to HA via mqtt which is a prerequisite for the blueprint rather than something the blueprint or I can fix.