SgtBatten / HA_blueprints

Somewhere to store automation blueprints
207 stars 80 forks source link

Wrapper object is not callable #288

Closed blueharford closed 1 month ago

blueharford commented 1 month ago

Description

Notifications stopped working

Version

0.14.0.1a

Automation Config

alias: Frigate Backyard Notifications
description: ""
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera: camera.backyard
    notify_device: 0fce7692dbc619c242f66452044447da
    attachment: snapshot.jpg?bbox=1&crop=1
    update_thumbnail: true
    video: ""
    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'}}
    zone_filter: true
    zones:
      - back-steps
      - yard
      - patio
    labels: []
    notify_group: seidels
    base_url: https://**.*****.com
    alert_once: true
    cooldown: 45
    debug: true
    disable_times:
      - "23"
      - "22"
    tts: false
    redacted: true
    mqtt_topic: frigate/reviews
    tts_helper: input_text.frigate_notifications_tts
    message: A {{ label }} was detected in the {{ zones(0) | title }}.
    sound: News_Flash.caf
    tap_action: /ccab4aaf_frigate-proxy/dashboard
    button_1: Open Frigate
    url_1: /ccab4aaf_frigate-proxy/dashboard

Frigate Config

No response

Any other relevant information

No response

blueharford commented 1 month ago

IMG_3795

blueharford commented 1 month ago
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: 30
      - 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
    sequence:
      - variables:
          event: '{{ trigger.payload_json }}'
          detections: '{{ event[''after''][''data''][''detections''] }}'
          review_id: '{{event[''after''][''id'']}}'
          id: '{{ detections[0] }}'
          objects: '{{ event[''after''][''data''][''objects''] }}'
          sub_labels: '{{ event[''after''][''data''][''sub_labels''] }}'
          label: >-
            {% set data = namespace(labels=[]) %}  {% for obj in objects %}
              {% if "-verified" in obj %}
              {% else %}
                {% set data.labels = data.labels + [obj] %}
              {% endif %}
            {% endfor %} {% set data.labels = data.labels + sub_labels %}  {{
            data.labels | unique | list | sort | join(", ") | title }}
          initial_home: '{{ presence_entity != '''' and is_state(presence_entity, ''home'') }}'
          after_zones: '{{ event[''after''][''data''][''zones''] }}'
          zone_multi_filter: >-
            {{zone_only and zone_multi and after_zones|length and zones and
            zones |reject('in', after_zones) |list |length == 0 }}
          title: ''
          message: A {{ label }} was detected in the {{ zones(0) | title }}.
          subtitle: ''
          tap_action: /ccab4aaf_frigate-proxy/dashboard
          button_1: Open Frigate
          button_2: View Snapshot
          button_3: Silence New Notifications
          url_1: /ccab4aaf_frigate-proxy/dashboard
          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:{{'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'
          channel: ''
          video: ''
          custom_action: []
      - alias: 'Debug: write to Log'
        choose:
          - conditions:
              - '{{debug}}'
            sequence:
              - data_template:
                  name: Frigate Notification
                  message: |
                    DEBUG: 
                      Info:
                        fps: {{fps}}, 
                        Frigate Review id: {{review_id}}{{', Frigate client ID: ' + client_id if client_id else ''}}, 
                        Frigate Detections: {{detections}}
                        Objects: {{label}},
                        Sub Labels: {{sub_labels | join(', ')}}
                      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, 
                        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: {{after_zones}}, 
                          Zone Filter TEST: {{'PASS (Multi)' if zone_multi_filter else 'PASS' if ( not zone_only or not zone_multi and zones|select('in', after_zones)|list|length ) else 'FAIL (Multi)' if zone_multi else 'FAIL' }}, 
                        Required objects TEST: 
                          Input: {{input_labels}}, 
                          TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}
                        presence entity (not home):
                          Entity: {{presence_entity}}
                          TEST:  {{'PASS' if not initial_home else 'FAIL'}}, 
                        disabled times: {{disable_times}}, 
                        State Filter: 
                          state filter toggle on: {{state_only}}, 
                          state filter entity: {{input_entity}}, 
                          required states: {{input_states}}, 
                          State Filter TEST: {{'PASS' if not state_only or states(input_entity) in states_filter else 'FAIL' }},
                        Custom Filter: {{custom_filter}}
                action: logbook.log
      - alias: Delay for image
        choose:
          - conditions:
              - '{{initial_delay > 0}}'
              - '{{trigger.payload_json[''type''] == ''new'' }}'
            sequence:
              - delay:
                  seconds: '{{initial_delay}}'
      - alias: Custom Action Auto
        choose:
          - conditions:
              - '{{ custom_action |length > 0 }}'
              - >-
                {{ not zone_only or (not zone_multi and zones|select('in',
                after_zones)|list|length > 0) or (zone_multi and
                after_zones|length > 0 and zones |reject('in', after_zones)
                |list |length == 0) }}
              - '{{ not initial_home }}'
              - '{{ not state_only or states(input_entity) in states_filter }}'
            sequence: []
      - alias: Notify on new object
        choose:
          - conditions:
              - >-
                {{ not zone_only or (not zone_multi and zones|select('in',
                after_zones)|list|length > 0) or (zone_multi and
                after_zones|length > 0 and zones |reject('in', after_zones)
                |list |length == 0) }}
              - '{{ not initial_home }}'
              - '{{ not state_only or states(input_entity) in states_filter }}'
              - '{{ custom_filter }}'
            sequence:
              - choose:
                  - conditions: '{{ not notify_group_target }}'
                    sequence:
                      - device_id: 0fce7692dbc619c242f66452044447da
                        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: '{{ 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 }}
SgtBatten commented 1 month ago

Your second post is the blueprint, there is zero information in it so I will delete it

Is it to do with the TTS stuff? I need more information

blueharford commented 1 month ago
alias: Frigate Backyard Notifications
description: ""
use_blueprint:
  path: SgtBatten/Beta.yaml
  input:
    camera: camera.backyard
    notify_device: 0fce7692dbc619c242f66452044447da
    attachment: snapshot.jpg?bbox=1&crop=1
    update_thumbnail: true
    video: ""
    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'}}
    zone_filter: true
    zones:
      - back-steps
      - yard
      - patio
    labels: []
    notify_group: seidels
    base_url: https://ha.fffffff.com
    alert_once: true
    cooldown: 45
    debug: true
    disable_times:
      - "23"
      - "22"
    tts: false
    redacted: true
    mqtt_topic: frigate/reviews
    tts_helper: input_text.frigate_notifications_tts
    message: A {{ label }} was detected in the {{ zones(0) | title }}.
    sound: News_Flash.caf
    tap_action: /ccab4aaf_frigate-proxy/dashboard
    button_1: Open Frigate
    url_1: /ccab4aaf_frigate-proxy/dashboard
SgtBatten commented 1 month ago

I cannot do anything without logs and relevant debug information.

blueharford commented 1 month ago

This is all that's in the logbook.


{
  "trace": {
    "last_step": "action/0/choose/2/sequence/0",
    "run_id": "4a9b0b914a9251aaab453f29a10e8f47",
    "state": "stopped",
    "script_execution": "error",
    "timestamp": {
      "start": "2024-10-01T01:14:44.960234+00:00",
      "finish": "2024-10-01T01:14:44.967736+00:00"
    },
    "domain": "automation",
    "item_id": "1727049704652",
    "error": "TypeError: 'Wrapper' object is not callable",
    "trigger": "mqtt topic frigate/reviews",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-10-01T01:14:44.962982+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.frigate_backyard_notifications",
              "state": "on",
              "attributes": {
                "id": "1727049704652",
                "last_triggered": "2024-10-01T01:13:01.262889+00:00",
                "mode": "parallel",
                "current": 0,
                "max": 10,
                "friendly_name": "Frigate Backyard Notifications"
              },
              "last_changed": "2024-09-29T12:31:55.717603+00:00",
              "last_reported": "2024-10-01T01:13:01.271373+00:00",
              "last_updated": "2024-10-01T01:13:01.271373+00:00",
              "context": {
                "id": "01J92T6HJ9X9MG9SSCXSZ8H88T",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "frigate-event",
              "idx": "0",
              "alias": null,
              "platform": "mqtt",
              "topic": "frigate/reviews",
              "payload": "{\"type\": \"end\", \"before\": {\"id\": \"1727745180.867291-mvob2p\", \"camera\": \"backyard\", \"start_time\": 1727745180.867291, \"end_time\": null, \"severity\": \"alert\", \"thumb_path\": \"/media/frigate/clips/review/thumb-backyard-1727745180.867291-mvob2p.webp\", \"data\": {\"detections\": [\"1727745180.305523-ub60sg\"], \"objects\": [\"person\"], \"sub_labels\": [], \"zones\": [\"yard\", \"patio\"], \"audio\": []}}, \"after\": {\"id\": \"1727745180.867291-mvob2p\", \"camera\": \"backyard\", \"start_time\": 1727745180.867291, \"end_time\": 1727745254.618261, \"severity\": \"alert\", \"thumb_path\": \"/media/frigate/clips/review/thumb-backyard-1727745180.867291-mvob2p.webp\", \"data\": {\"detections\": [\"1727745180.305523-ub60sg\"], \"objects\": [\"person\"], \"sub_labels\": [], \"zones\": [\"yard\", \"patio\"], \"audio\": []}}}",
              "qos": 0,
              "description": "mqtt topic frigate/reviews",
              "payload_json": {
                "type": "end",
                "before": {
                  "id": "1727745180.867291-mvob2p",
                  "camera": "backyard",
                  "start_time": 1727745180.867291,
                  "end_time": null,
                  "severity": "alert",
                  "thumb_path": "/media/frigate/clips/review/thumb-backyard-1727745180.867291-mvob2p.webp",
                  "data": {
                    "detections": [
                      "1727745180.305523-ub60sg"
                    ],
                    "objects": [
                      "person"
                    ],
                    "sub_labels": [],
                    "zones": [
                      "yard",
                      "patio"
                    ],
                    "audio": []
                  }
                },
                "after": {
                  "id": "1727745180.867291-mvob2p",
                  "camera": "backyard",
                  "start_time": 1727745180.867291,
                  "end_time": 1727745254.618261,
                  "severity": "alert",
                  "thumb_path": "/media/frigate/clips/review/thumb-backyard-1727745180.867291-mvob2p.webp",
                  "data": {
                    "detections": [
                      "1727745180.305523-ub60sg"
                    ],
                    "objects": [
                      "person"
                    ],
                    "sub_labels": [],
                    "zones": [
                      "yard",
                      "patio"
                    ],
                    "audio": []
                  }
                }
              }
            },
            "input_camera": "camera.backyard",
            "camera": "backyard",
            "type": "alert",
            "mqtt_topic": "frigate/reviews",
            "camera_name": "Backyard",
            "input_base_url": "https://ha.joshuaseidel.com",
            "base_url": "https://ha.joshuaseidel.com",
            "input_client_id": "",
            "client_id": "",
            "attachment": "snapshot.jpg?bbox=1&crop=1",
            "alert_once": true,
            "update_thumbnail": true,
            "ios_live_view": "",
            "android_auto": false,
            "notify_group": "seidels",
            "notify_group_target": "seidels",
            "zone_only": true,
            "input_zones": [
              "back-steps",
              "yard",
              "patio"
            ],
            "zones": [
              "back-steps",
              "yard",
              "patio"
            ],
            "zone_multi": false,
            "input_labels": [],
            "labels": [],
            "presence_entity": "",
            "disable_times": [
              "23",
              "22"
            ],
            "cooldown": 45,
            "initial_delay": 0,
            "fps": 5,
            "state_only": false,
            "input_entity": "",
            "input_states": [],
            "states_filter": [],
            "custom_filter": true,
            "color": "#03a9f4",
            "sound": "News_Flash.caf",
            "input_volume": 100,
            "volume": 1,
            "sticky": false,
            "tv": false,
            "tv_position": "center",
            "tv_size": "large",
            "tv_duration": 10,
            "tv_transparency": "0%",
            "tv_interrupt": false,
            "debug": true,
            "objects": [
              "person"
            ],
            "initial_home": false,
            "after_zones": [
              "yard",
              "patio"
            ],
            "zone_multi_filter": false
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-10-01T01:14:44.963092+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/0": [
        {
          "path": "condition/0/conditions/0",
          "timestamp": "2024-10-01T01:14:44.963179+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/1": [
        {
          "path": "condition/0/conditions/1",
          "timestamp": "2024-10-01T01:14:44.963283+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "condition/0/conditions/2": [
        {
          "path": "condition/0/conditions/2",
          "timestamp": "2024-10-01T01:14:44.963363+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/2/conditions/0": [
        {
          "path": "condition/0/conditions/2/conditions/0",
          "timestamp": "2024-10-01T01:14:44.963422+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "condition/0/conditions/2/conditions/1": [
        {
          "path": "condition/0/conditions/2/conditions/1",
          "timestamp": "2024-10-01T01:14:44.963501+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/2": [
        {
          "path": "condition/0/conditions/2/conditions/2",
          "timestamp": "2024-10-01T01:14:44.963789+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/3": [
        {
          "path": "condition/0/conditions/2/conditions/3",
          "timestamp": "2024-10-01T01:14:44.964220+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/4": [
        {
          "path": "condition/0/conditions/2/conditions/4",
          "timestamp": "2024-10-01T01:14:44.964426+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/5": [
        {
          "path": "condition/0/conditions/2/conditions/5",
          "timestamp": "2024-10-01T01:14:44.964558+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/6": [
        {
          "path": "condition/0/conditions/2/conditions/6",
          "timestamp": "2024-10-01T01:14:44.964655+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/7": [
        {
          "path": "condition/0/conditions/2/conditions/7",
          "timestamp": "2024-10-01T01:14:44.964748+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "condition/0/conditions/2/conditions/8": [
        {
          "path": "condition/0/conditions/2/conditions/8",
          "timestamp": "2024-10-01T01:14:44.964837+00:00",
          "result": {
            "result": true,
            "entities": []
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-10-01T01:14:44.965163+00:00",
          "changed_variables": {
            "context": {
              "id": "01J92T9PV0HT6E7AK2GED84TTB",
              "parent_id": null,
              "user_id": null
            }
          },
          "error": "TypeError: 'Wrapper' object is not callable",
          "result": {
            "choice": 2
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-10-01T01:14:44.965235+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-10-01T01:14:44.965269+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2024-10-01T01:14:44.965326+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2024-10-01T01:14:44.965353+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/2": [
        {
          "path": "action/0/choose/2",
          "timestamp": "2024-10-01T01:14:44.965400+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/2/conditions/0": [
        {
          "path": "action/0/choose/2/conditions/0",
          "timestamp": "2024-10-01T01:14:44.965428+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/2/sequence/0": [
        {
          "path": "action/0/choose/2/sequence/0",
          "timestamp": "2024-10-01T01:14:44.965559+00:00",
          "error": "TypeError: 'Wrapper' object is not callable"
        }
      ]
    },
    "config": {
      "mode": "parallel",
      "trigger_variables": {
        "input_camera": "camera.backyard",
        "camera": "{{ input_camera | regex_replace('^camera\\.|_\\d+$', '') }}",
        "type": "alert",
        "mqtt_topic": "frigate/reviews"
      },
      "trigger": [
        {
          "platform": "mqtt",
          "topic": "{{mqtt_topic}}",
          "payload": "{{ camera }}/{{type}}",
          "value_template": "{{ value_json['after']['camera'] | lower | replace('-','_') }}/{{ value_json['after']['severity']}}",
          "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"
        }
      ],
      "variables": {
        "input_camera": "camera.backyard",
        "camera": "{{ state_attr(input_camera, 'camera_name') }}",
        "camera_name": "{{ state_attr(input_camera, 'friendly_name') }}",
        "type": "alert",
        "input_base_url": "https://ha.joshuaseidel.com",
        "base_url": "{{ input_base_url.rstrip('/')}}",
        "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": true,
        "update_thumbnail": true,
        "ios_live_view": "",
        "android_auto": false,
        "notify_group": "seidels",
        "notify_group_target": "{{ notify_group | lower | regex_replace('^notify\\.', '') | replace(' ','_') }}",
        "zone_only": true,
        "input_zones": [
          "back-steps",
          "yard",
          "patio"
        ],
        "zones": "{{ input_zones }}",
        "zone_multi": false,
        "input_labels": [],
        "labels": "{{ input_labels | list | lower }}",
        "presence_entity": "",
        "disable_times": [
          "23",
          "22"
        ],
        "cooldown": 45,
        "initial_delay": 0,
        "fps": "{{ states('sensor.' + camera + '_camera_fps')|int(5) }}",
        "state_only": false,
        "input_entity": "",
        "input_states": [],
        "states_filter": "{{ input_states | list | lower }}",
        "custom_filter": true,
        "color": "#03a9f4",
        "sound": "News_Flash.caf",
        "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,
        "objects": "{{ trigger.payload_json['after']['data']['objects'] }}",
        "initial_home": "{{ presence_entity != '' and is_state(presence_entity, 'home') }}",
        "after_zones": "{{ trigger.payload_json['after']['data']['zones'] }}",
        "zone_multi_filter": "{{zone_only and zone_multi and after_zones|length and zones and zones |reject('in', after_zones) |list |length == 0 }}"
      },
      "condition": {
        "condition": "or",
        "conditions": [
          {
            "condition": "trigger",
            "id": "silence"
          },
          {
            "condition": "trigger",
            "id": "custom"
          },
          {
            "condition": "and",
            "conditions": [
              {
                "condition": "trigger",
                "id": "frigate-event"
              },
              {
                "alias": "Notifications enabled for object",
                "condition": "template",
                "value_template": "{{ not labels|length or labels|select('in', objects)|list|length > 0 }}"
              },
              "{{ not this.attributes.last_triggered or (now() - this.attributes.last_triggered).seconds > cooldown }}",
              "{{ not disable_times|length or not now().hour in disable_times|map('int')|list }}",
              "{{ not zone_only or (not zone_multi and zones|select('in', after_zones)|list|length > 0) or (zone_multi and after_zones|length > 0 and zones |reject('in', after_zones) |list |length == 0) }}",
              "{{ not initial_home }}",
              "{{ not state_only or states(input_entity) in states_filter }}",
              "{{ custom_filter }}",
              "{{ trigger.payload_json['type'] == 'new' or trigger.payload_json['type']  == 'end' or update_thumbnail }}"
            ]
          }
        ]
      },
      "action": [
        {
          "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": 30
                  }
                },
                {
                  "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"
                }
              ],
              "sequence": [
                {
                  "variables": {
                    "event": "{{ trigger.payload_json }}",
                    "detections": "{{ event['after']['data']['detections'] }}",
                    "review_id": "{{event['after']['id']}}",
                    "id": "{{ detections[0] }}",
                    "objects": "{{ event['after']['data']['objects'] }}",
                    "sub_labels": "{{ event['after']['data']['sub_labels'] }}",
                    "label": "{% set data = namespace(labels=[]) %}  {% for obj in objects %}\n  {% if \"-verified\" in obj %}\n  {% else %}\n    {% set data.labels = data.labels + [obj] %}\n  {% endif %}\n{% endfor %} {% set data.labels = data.labels + sub_labels %}  {{ data.labels | unique | list | sort | join(\", \") | title }}",
                    "initial_home": "{{ presence_entity != '' and is_state(presence_entity, 'home') }}",
                    "after_zones": "{{ event['after']['data']['zones'] }}",
                    "zone_multi_filter": "{{zone_only and zone_multi and after_zones|length and zones and zones |reject('in', after_zones) |list |length == 0 }}",
                    "title": "",
                    "message": "A {{ label }} was detected in the {{ zones(0) | title }}.",
                    "subtitle": "",
                    "tap_action": "/ccab4aaf_frigate-proxy/dashboard",
                    "button_1": "Open Frigate",
                    "button_2": "View Snapshot",
                    "button_3": "Silence New Notifications",
                    "url_1": "/ccab4aaf_frigate-proxy/dashboard",
                    "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:{{'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",
                    "channel": "",
                    "video": "",
                    "custom_action": []
                  }
                },
                {
                  "alias": "Debug: write to Log",
                  "choose": [
                    {
                      "conditions": [
                        "{{debug}}"
                      ],
                      "sequence": [
                        {
                          "data_template": {
                            "name": "Frigate Notification",
                            "message": "DEBUG: \n  Info:\n    fps: {{fps}}, \n    Frigate Review id: {{review_id}}{{', Frigate client ID: ' + client_id if client_id else ''}}, \n    Frigate Detections: {{detections}}\n    Objects: {{label}},\n    Sub Labels: {{sub_labels | join(', ')}}\n  Config: \n    camera(formatted): {{camera}}({{camera_name}}), \n    Base URL: {{base_url}}, \n    critical: {{critical}}, \n    alert once: {{alert_once}}, \n    Update Thumbnails: {{update_thumbnail}}, \n    Video: {{video}}, \n    Target: {{'group (input/formatted): ' + notify_group + '/' + notify_group_target + ', ' if notify_group else 'Mobile Device'}}\n    cooldown: {{cooldown}}s, \n    initial delay: {{initial_delay}}s, \n    color: {{color}}, \n    sound: {{sound}}, \n    android_auto: {{android_auto}}, \n    Group: {{group}}, \n    Channel: {{channel}}, \n    Sticky: {{sticky}}, \n    Title: {{title}}, \n    Message: {{message}},\n    Subtitle: {{subtitle}}, \n    tap_action: {{tap_action}}, \n    button 1 Text/URL/Icon: {{iif(button_1, button_1, 'unset')}} ({{url_1}}) {{icon_1}}, \n    button 2 Text/URL/Icon: {{button_2}} ({{url_2}}) {{icon_2}}, \n    button 3 Text/URL/Icon: {{button_3}} ({{url_3}}) {{icon_3}}, \n    icon: {{icon}}\n    tv: {{ tv }}, \n    tv_position: {{tv_position}}, \n    tv_size: {{tv_size}}, \n    tv_duration: {{tv_duration}}, \n    tv_transparency: {{tv_transparency}}, \n    tv_interrupt: {{tv_interrupt}}, \n  Filters: \n    Zones: \n      zone filter toggle on: {{zone_only}}, \n      Multi-Zone toggle on: {{zone_multi}}, \n      Required zones: {{input_zones}}, \n      Entered Zones: {{after_zones}}, \n      Zone Filter TEST: {{'PASS (Multi)' if zone_multi_filter else 'PASS' if ( not zone_only or not zone_multi and zones|select('in', after_zones)|list|length ) else 'FAIL (Multi)' if zone_multi else 'FAIL' }}, \n    Required objects TEST: \n      Input: {{input_labels}}, \n      TEST: {{'PASS' if not labels|length or object in labels else 'FAIL'}}\n    presence entity (not home):\n      Entity: {{presence_entity}}\n      TEST:  {{'PASS' if not initial_home else 'FAIL'}}, \n    disabled times: {{disable_times}}, \n    State Filter: \n      state filter toggle on: {{state_only}}, \n      state filter entity: {{input_entity}}, \n      required states: {{input_states}}, \n      State Filter TEST: {{'PASS' if not state_only or states(input_entity) in states_filter else 'FAIL' }},\n    Custom Filter: {{custom_filter}}\n"
                          },
                          "action": "logbook.log"
                        }
                      ]
                    }
                  ]
                },
                {
                  "alias": "Delay for image",
                  "choose": [
                    {
                      "conditions": [
                        "{{initial_delay > 0}}",
                        "{{trigger.payload_json['type'] == 'new' }}"
                      ],
                      "sequence": [
                        {
                          "delay": {
                            "seconds": "{{initial_delay}}"
                          }
                        }
                      ]
                    }
                  ]
                },
                {
                  "alias": "Custom Action Auto",
                  "choose": [
                    {
                      "conditions": [
                        "{{ custom_action |length > 0 }}",
                        "{{ not zone_only or (not zone_multi and zones|select('in', after_zones)|list|length > 0) or (zone_multi and after_zones|length > 0 and zones |reject('in', after_zones) |list |length == 0) }}",
                        "{{ not initial_home }}",
                        "{{ not state_only or states(input_entity) in states_filter }}"
                      ],
                      "sequence": []
                    }
                  ]
                },
                {
                  "alias": "Notify on new object",
                  "choose": [
                    {
                      "conditions": [
                        "{{ not zone_only or (not zone_multi and zones|select('in', after_zones)|list|length > 0) or (zone_multi and after_zones|length > 0 and zones |reject('in', after_zones) |list |length == 0) }}",
                        "{{ not initial_home }}",
                        "{{ not state_only or states(input_entity) in states_filter }}",
                        "{{ custom_filter }}"
                      ],
                      "sequence": [
                        {
                          "choose": [
                            {
                              "conditions": "{{ not notify_group_target }}",
                              "sequence": [
                                {
                                  "device_id": "0fce7692dbc619c242f66452044447da",
                                  "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": "{{ 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 }}"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "id": "1727049704652",
      "alias": "Frigate Backyard Notifications",
      "description": ""
    },
    "blueprint_inputs": {
      "id": "1727049704652",
      "alias": "Frigate Backyard Notifications",
      "description": "",
      "use_blueprint": {
        "path": "SgtBatten/Beta.yaml",
        "input": {
          "camera": "camera.backyard",
          "notify_device": "0fce7692dbc619c242f66452044447da",
          "attachment": "snapshot.jpg?bbox=1&crop=1",
          "update_thumbnail": true,
          "video": "",
          "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'}}",
          "zone_filter": true,
          "zones": [
            "back-steps",
            "yard",
            "patio"
          ],
          "labels": [],
          "notify_group": "seidels",
          "base_url": "https://ha.joshuaseidel.com",
          "alert_once": true,
          "cooldown": 45,
          "debug": true,
          "disable_times": [
            "23",
            "22"
          ],
          "tts": false,
          "redacted": true,
          "mqtt_topic": "frigate/reviews",
          "tts_helper": "input_text.frigate_notifications_tts",
          "message": "A {{ label }} was detected in the {{ zones(0) | title }}.",
          "sound": "News_Flash.caf",
          "tap_action": "/ccab4aaf_frigate-proxy/dashboard",
          "button_1": "Open Frigate",
          "url_1": "/ccab4aaf_frigate-proxy/dashboard"
        }
      }
    },
    "context": {
      "id": "01J92T9PV0HT6E7AK2GED84TTB",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Frigate Backyard Notifications",
      "message": "triggered by mqtt topic frigate/reviews",
      "source": "mqtt topic frigate/reviews",
      "entity_id": "automation.frigate_backyard_notifications",
      "context_id": "01J92T9PV0HT6E7AK2GED84TTB",
      "domain": "automation",
      "when": 1727745284.9650002
    }
  ]
}
blueharford commented 1 month ago

@SgtBatten thoughts?

SgtBatten commented 1 month ago

Nothing so far.

Did you try removing the tts stuff as previously mentioned?

blueharford commented 1 month ago

I figured it out in the middle of the night it was zones(0) and needed to be zones[0]. Now just need to change it to get the last reported zone name from the json payload instead of the blueprint variable. That's on the books for today.

SgtBatten commented 1 month ago

ohh yeah i see it in the message now. good find