id: "automation_frigate_person_from_street" alias: Frigate Person From Street description: "Fire a notification if a person is detected by Frigate coming towards the house from the street" mode: single max_exceeded: silent trigger: platform: mqtt topic: frigate/events payload: new value_template: "{{ value_json.type }}" variables: id: "{{ trigger.payload_json['after']['id'] }}" camera: "{{ trigger.payload_json['after']['camera'] }}" camera_name: "{{ camera | replace('_', ' ') | title }}" object: "{{ trigger.payload_json['after']['label'] }}" label: "{{ object | title }}" entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}" type: "{{ trigger.payload_json['type'] }}" stationary: "{{ trigger.payload_json['after']['stationary'] }}" base_url: https://automation.clintweaver.com group_target: "" zone_only: true before_zones: - from_street after_zones: - driveway_center - driveway_east_side - parking_spot input_zones: - from_street zones: "{{ input_zones | list }}" input_labels: - person labels: "{{ input_labels | list }}" presence_entity: person.clint condition: - "{{ type != 'end' }}" - "{{ not zone_only or entered_zones|length > 0 }}" - "{{ not stationary }}" - "{{ not zones|length or zones|select('in', entered_zones)|list|length > 0 }}" - "{{ not labels|length or object in labels }}" #- "{{ not presence_entity or not is_state(presence_entity, 'home') }}" #- "{{ not garage_door or not is_state(garage_door, 'on') }}" action: - choose: - conditions: "{{ not group_target }}" sequence: - device_id: 70c62eb366d6ed914b0ccc6bf41c32fd domain: mobile_app type: notify message: A {{ label }} was detected on the {{ camera_name }} camera. data: tag: "{{ id }}" group: frigate-notification-{{ camera }} image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android attachment: url: /api/frigate/notifications/{{id}}/thumbnail.jpg - service: persistent_notification.create data: title: A {{ label }} was detected on the {{ camera_name }} camera. message: 'A {{ label }} was detected on the {{ camera_name }} camera. ![image](https://automation.clintweaver.com/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg)' notification_id: "{{ id }}" default: - service: notify.{{ group_target }} data: message: A {{ label }} was detected on the {{ camera_name }} camera. data: tag: "{{ id }}" group: frigate-notification-{{ camera }} image: /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android attachment: url: /api/frigate/notifications/{{id}}/thumbnail.jpg - repeat: sequence: - wait_for_trigger: - platform: mqtt topic: frigate/events payload: "{{ id }}" value_template: "{{ value_json['after']['id'] }}" timeout: minutes: 2 continue_on_timeout: false - condition: template value_template: "{{ wait.trigger.payload_json['type'] == 'end' }}" - choose: - conditions: "{{ not group_target }}" sequence: - device_id: 70c62eb366d6ed914b0ccc6bf41c32fd domain: mobile_app type: notify message: A {{ label }} was detected on the {{ camera_name }} camera. data: tag: "{{ id }}" group: frigate-notification-{{ camera }} url: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 clickAction: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 image: >- /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android sound: none attachment: url: /api/frigate/notifications/{{id}}/thumbnail.jpg actions: - action: URI title: View Clip uri: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 - action: URI title: View Snapshot uri: >- {{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg - action: silence-{{ camera }} title: Silence Notifications destructive: true default: - service: notify.{{ group_target }} data: message: A {{ label }} was detected on the {{ camera_name }} camera. data: tag: "{{ id }}" group: frigate-notification-{{ camera }} url: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 clickAction: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 image: >- /api/frigate/notifications/{{id}}/thumbnail.jpg?format=android sound: none attachment: url: /api/frigate/notifications/{{id}}/thumbnail.jpg actions: - action: URI title: View Clip uri: >- {{base_url}}/api/frigate/notifications/{{id}}/{{camera}}/clip.mp4 - action: URI title: View Snapshot uri: >- {{base_url}}/api/frigate/notifications/{{id}}/snapshot.jpg - action: silence-{{ camera }} title: Silence Notifications destructive: true until: "{{ wait.trigger.payload_json['type'] == 'end' }}" - wait_for_trigger: - platform: event event_type: mobile_app_notification_action event_data: action: silence-{{ camera }} timeout: seconds: 30 continue_on_timeout: false - delay: minutes: 30