Yaml Syntax wrong?

I’ve added frigate to my home
and the next step is to add some smart notifications.

I’ve created simple automation to alert when a person is passing:

alias: 'Camera: Telegram notification for persons'
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
    payload: person
    value_template: '{{ "person" if value_json["after"]["camera"] == "front_balcony" }}'
condition: []
action:
  - service: notify.telegram_me
    data_template:
      message: A {{trigger.payload_json["after"]["label"]}} been spotted.
mode: parallel
max: 5

So that work OK (it does flood me with many messages but this I will try to solve later)

My next step was to add a snapshot to my telegram message,
I’ve all the snapshots from frigate going into the local media directory of HA so they are accessible from the internet (not great, and this I also need to think on how to secure).

But this didn’t worked at all

alias: 'Camera: Telegram notification for persons (Duplicate) (Duplicate)'
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
    payload: person
    value_template: '{{ "person" if value_json["after"]["camera"] == "front_balcony" }}'
condition: []
action:
  - service: notify.telegram_me
    data_template: >
      message: A {{trigger.payload_json["after"]["label"]}} been spotted.
      photo:
        - url: https://some_domain/local/clips/{{trigger.payload_json["after"]["camera"]}}-{{trigger.payload_json["after"]["id"]}}.jpg
mode: parallel
max: 10

I have also tried to just send the components that compose my URL as a debugging step but that failed too, as it seems that my syntax is wrong as HA add >_ or just > to my automation:

alias: 'Camera: Telegram notification for persons (Duplicate) (Duplicate)'
description: ''
trigger:
  - platform: mqtt
    topic: frigate/events
    payload: person
    value_template: '{{ "person" if value_json["after"]["camera"] == "front_balcony" }}'
condition: []
action:
  - service: notify.telegram_me
    data_template: >
      message: >_ 
     A {{trigger.payload_json["after"]["label"]}} been spotted,
     {{trigger.payload_json["after"]["camera"]}},
     {{trigger.payload_json["after"]["id"]}}
mode: parallel
max: 10

I have lots of conditions and if, then’s but the following is the stripped out sections that may be relevant or may help you:

I use this to trigger - send photo to telegram:

  trigger:
  - platform: mqtt
    topic: frigate/events
    payload: garden_cam
    value_template: '{{ value_json.after.camera }}'
  condition:
  - condition: template
    value_template: '{{ trigger.payload_json[''after''][''has_snapshot''] == true
      }}'
  - condition: template
    value_template: '{{ trigger.payload_json[''after''][''label''] == ''person'' }}'

Then this action:

      - service: telegram_bot.send_photo
        data:
          target:
          - #########
          - #########
          url: http://192.168.1.28:5000/api/events/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg?bbox=1&crop=1
          caption: Person Detected In Garden (Picture)

Hopefully this helps to get you started, I have several conditions that help prevent spamming with multiple phots while events are taking place and have additional automations that send video to telegram once event has finished, happy to help if you need it, but lets start with getting a basic photo sent i guess.

2 Likes

Going to try that :slight_smile:
Will report back

Working fantastic,
thanks a lot

1 Like