SgtBatten / HA_blueprints

Somewhere to store automation blueprints
178 stars 66 forks source link

[Issue]: {{ custom_action_auto |length > 0 }} never returns true #243

Closed rubin110 closed 1 month ago

rubin110 commented 1 month ago

Description

No matter what I stick into the custom_action_auto variable the condition {{ custom_action_auto |length > 0 }} always fails.

Version

0.12.0.4a

Automation Config

alias: Cat on counter notification snapshot
description: ""
trigger:
  - platform: mqtt
    topic: "{{mqtt_topic}}"
    payload: "{{ camera }}/new"
    value_template: >-
      {{ value_json['after']['camera'] | lower | replace('-','_') }}/{{
      value_json['type']}}
    id: frigate-event
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: silence-{{ camera }}
    id: silence
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: custom-{{ camera }}
    id: custom
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: 30
          - service: automation.turn_on
            target:
              entity_id: "{{ this.entity_id }}"
      - 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')
                }}
              enteredzones: "{{ trigger.payload_json['after']['entered_zones']}}"
              zone_multi_filter: >-
                {{zone_only and zone_multi and enteredzones|length and zones and
                zones |reject('in', enteredzones) |list |length == 0 }}
              loitering: false
              title: ""
              message: A cat was spotted on the kitchen counter
              subtitle: ""
              tap_action: /lovelace
              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 }}
              custom_filter: true
              icon: mdi:cat
              group: "{{camera}}-frigate-notification{{'-loitering' if loitering}}"
              channel: ""
              video: ""
              custom_action_auto:
                - choose:
                    - conditions:
                        - condition: time
                          after: "08:45:00"
                          before: "23:59:59"
                      sequence:
                        - repeat:
                            count: 4
                            sequence:
                              - service: light.toggle
                                metadata: {}
                                data:
                                  transition: 0.1
                                target:
                                  entity_id:
                                    - light.display_led
                                    - light.rubin_4
                                    - light.bath
                                    - light.dining_overhead
                                    - light.dining_1
                                    - light.living_overhead
                                    - light.living_flood_2
                                    - light.living_flood_1
                              - delay:
                                  hours: 0
                                  minutes: 0
                                  seconds: 0
                                  milliseconds: 500
          - alias: "Debug: write to Log"
            choose:
              - conditions:
                  - condition: template
                    value_template: "{{debug}}"
                sequence:
                  - service: logbook.log
                    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: {{base_url}}, 
                            critical: {{critical}}, 
                            alert once: {{alert_once}}, 
                            Update Thumbnails: {{update_thumbnail}}, 
                            Video: {{video}}, 
                            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}}, 
                            button 1 Text/URL/Icon: {{iif(button_1, button_1, 'unset')}} ({{url_1}}) {{icon_1}}, 
                            button 2 Text/URL/Icon: {{button_2}} ({{url_2}}) {{icon_2}}, 
                            button 3 Text/URL/Icon: {{button_3}} ({{url_3}}) {{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}}, 
                              Entered Zones: {{enteredzones}}, 
                              Zone Filter TEST: {{'PASS (Multi)' if zone_multi_filter else 'PASS' if ( not zone_only or not zone_multi and zones|select('in', enteredzones)|list|length ) else 'FAIL (Multi)' if zone_multi else 'FAIL' }}, 
                            Required objects TEST: 
                              Input: {{input_labels}}, 
                              TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}
                            presence entity (not home):
                              Entity: {{presence_entity}}
                              TEST:  {{'PASS' if not initial_home else 'FAIL'}}, 
                            disabled times: {{disable_times}}, 
                            State Filter: 
                              state filter toggle on: {{state_only}}, 
                              state filter entity: {{input_entity}}, 
                              required states: {{input_states}}, 
                              State Filter TEST: {{'PASS' if not state_only or states(input_entity) in states_filter else 'FAIL' }},
                            Custom Filter: {{custom_filter}}
          - 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: "{{  custom_action_auto != 0 }}"
                  - condition: template
                    value_template: >-
                      {{ not zone_only or (not zone_multi and zones|select('in',
                      enteredzones)|list|length > 0) or (zone_multi and
                      enteredzones|length > 0 and zones |reject('in',
                      enteredzones) |list |length == 0) }}
                  - condition: template
                    value_template: "{{ not initial_home }}"
                  - condition: template
                    value_template: >-
                      {{ not state_only or states(input_entity) in states_filter
                      }}
                sequence:
                  - choose:
                      - conditions:
                          - condition: time
                            after: "08:45:00"
                            before: "23:59:59"
                        sequence:
                          - repeat:
                              count: 4
                              sequence:
                                - service: light.toggle
                                  metadata: {}
                                  data:
                                    transition: 0.1
                                  target:
                                    entity_id:
                                      - light.display_led
                                      - light.rubin_4
                                      - light.bath
                                      - light.dining_overhead
                                      - light.dining_1
                                      - light.living_overhead
                                      - light.living_flood_2
                                      - light.living_flood_1
                                - delay:
                                    hours: 0
                                    minutes: 0
                                    seconds: 0
                                    milliseconds: 500
          - alias: Notify on new object
            choose:
              - conditions:
                  - condition: template
                    value_template: >-
                      {{ not zone_only or (not zone_multi and zones|select('in',
                      enteredzones)|list|length > 0) or (zone_multi and
                      enteredzones|length > 0 and zones |reject('in',
                      enteredzones) |list |length == 0) }}
                  - 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: 3dc2f3ab264c6554f32771af3b47a9cd
                            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:
                          - service: notify.{{ notify_group_target }}
                            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
                    default:
                      - service: notify.{{ notify_group_target }}
                        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
                            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
          - 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}}"
                    enteredzones: "{{ event['after']['entered_zones']|lower}}"
                    zone_filter: >-
                      {{ not zone_only or zones|select('in',
                      enteredzones)|list|length > 0 }}
                    zone_multi_filter: >-
                      {{not zone_only or not zone_multi or (
                      enteredzones|list|length > 0 and zones and
                      zones|reject('in', enteredzones)|list|length == 0 ) }}
                    stationary_moved: >-
                      {{ event['after']['position_changes'] >
                      event['before']['position_changes'] }}
                    zone_only_changed: >-
                      {{ zone_only and (enteredzones|length > 0 and not
                      last_zones|length) }}
                    entered_zones_changed: >-
                      {{ zones|length > 0 and (zones|select('in',
                      enteredzones)|list|length > zones|select('in',
                      last_zones)|list|length) }}
                    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 }}"
                    critical_input: "false"
                    critical: >-
                      {{ true if critical_input == 'true' else true if
                      critical_input == True else 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 cat was spotted on the kitchen counter
                    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:
                        - service: logbook.log
                          data_template:
                            name: Frigate Notification
                            message: |
                              DEBUG (in loop): 
                                Send Notification: {{ loitering or (custom_filter and 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)) }}
                                Info: 
                                  sublabel: {{sub_label}}, 
                                  image: "{{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: /api/frigate{{client_id}}/notifications/{{id}}/{{camera + '/clip.mp4' if video|length>0 and wait.trigger.payload_json['type'] == 'end' else attachment }}
                                  video: "{{video}}"
                                  critical: {{critical}}, 
                                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 Enabled: {{zone_only}}, 
                                      Multi Zone Enabled: {{zone_multi}}, 
                                      Required Zones: {{input_zones}}, 
                                      Last Zones: {{last_zones}}, 
                                      Entered zones: {{enteredzones|list|length}} - {{enteredzones}}, 
                                      TEST: {{'PASS' if not zone_only or (not zone_multi and zones|select('in', enteredzones)|list|length ) else 'PASS (Multi)' if zone_only and zone_multi and zone_multi_filter else 'FAIL (Multi)' if zone_only and zone_multi else 'FAIL' }}, 
                                    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'}},
                - 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 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: []
                - alias: Update Notification
                  choose:
                    - conditions:
                        - condition: template
                          value_template: >-
                            {{ loitering or (custom_filter and 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:
                                - condition: template
                                  value_template: "{{ not notify_group_target }}"
                              sequence:
                                - device_id: 3dc2f3ab264c6554f32771af3b47a9cd
                                  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:
                                - service: notify.{{ notify_group_target }}
                                  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
                          default:
                            - service: notify.{{ notify_group_target }}
                              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
              until:
                - condition: template
                  value_template: >-
                    {{ not wait.trigger or wait.trigger.payload_json['type'] ==
                    'end' }}
mode: parallel
trigger_variables:
  input_camera: camera.cam_04
  camera: "{{ input_camera | regex_replace('^camera\\.', '') }}"
  mqtt_topic: frigate/events
variables:
  input_camera: camera.cam_04
  camera: "{{ input_camera | regex_replace('^camera\\.', '') }}"
  camera_name: "{{ camera | replace('_', ' ') | title }}"
  input_base_url: https://xxxxxx: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&crop=1
  alert_once: false
  update_thumbnail: false
  ios_live_view: ""
  android_auto: false
  notify_group: all
  notify_group_target: >-
    {{ notify_group | lower | regex_replace('^notify\.', '') | replace(' ','_')
    }}
  zone_only: true
  input_zones:
    - kitchen_counter_zone
  zones: "{{ input_zones }}"
  zone_multi: false
  input_labels:
    - cat
  labels: "{{ input_labels | list | lower }}"
  presence_entity: ""
  disable_times:
    - "0"
    - "1"
    - "2"
    - "3"
    - "4"
    - "5"
    - "6"
    - "7"
  cooldown: 180
  loitering: false
  loiter_timer: 0
  initial_delay: 0
  fps: "{{ states('sensor.' + camera + '_camera_fps')|int(5) }}"
  state_only: false
  input_entity: input_boolean.actually_away
  input_states:
    - "off"
  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: false

Frigate Config

No response

Any other relevant information

No response

SgtBatten commented 1 month ago

I just did a very simple test, loaded up the stable and created an action that toggled my entry light when detecting a person.

Walking in front of the camera reliably triggered the custom action.

rubin110 commented 1 month ago

@SgtBatten thanks for the sanity check. Can you possibly send me that yaml to take a look at and compare? Thank you!

SgtBatten commented 1 month ago
    custom_action_auto:
      - type: toggle
        device_id: e1c64a....
        entity_id: 2d1dd.....
        domain: light

It may be that some custom actions are problematic. Is it definitely failing the condition test or was that an assumption?

rubin110 commented 1 month ago

I've given up trying to debug this. Just made a second automation to run the extra actions.