#can someone please help me changing this automation to the new notify.send_message (telegram)

1 messages · Page 1 of 1 (latest)

wet yarrow
#

Hey,
can someone please help me changing this automation to the new notify.send_message (telegram)
my old code:

alias: werkend ingezoomd backup oude telegram notify
description: ""
triggers:
  - topic: frigate/reviews
    payload: alert
    value_template: "{{ value_json['after']['severity'] }}"
    trigger: mqtt
conditions: []
actions:
  - data_template:
      message: >-
        A {{trigger.payload_json["after"]["data"]["objects"] | sort | join(", ")
        | title}} was detected.
      data:
        photo:
          - url: >-
              http://mylocalip:5000/api/events/{{trigger.payload_json["after"]["data"]["detections"][0]}}/thumbnail.jpg            
            caption: >-
              A {{trigger.payload_json["after"]["label"]}} was detected on {{
              trigger.payload_json["after"]["camera"] }} camera
    action: notify.telegram_alex
mode: single

I asked it to AI to help me , they gave me this but it has errors:

description: "new ingezoomd notify"
mode: single
triggers:
  - topic: frigate/reviews
    payload: alert
    value_template: "{{ value_json['after']['severity'] }}"
    trigger: mqtt
conditions: []
actions:
  - service: notify.telegram_alex
    data:
      message: >-
        A {{trigger.payload_json["after"]["data"]["objects"] | sort | join(", ") | title}} was detected on {{ trigger.payload_json["after"]["camera"] }} camera
      data:
        photo:
          - url: >-
              http://myip:5000/api/events/{{trigger.payload_json["after"]["data"]["detections"][0]}}/thumbnail.jpg

i have error:
Error while executing automation automation.new_ingezoomd_notify: extra keys not allowed @ data['photo']
new ingezoomd notify: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data['photo']
Thanks for your time

lament yew
#

You can't send a photo with notify.send_message action

#

You need to use the telegram_bot actions

wet yarrow
#

stupid of me that i didn't think about the telegram_botsend_photo part

#

i have it working now thanks

#
alias: ingezoomd - Telegram Bot Photo
description: Sends Frigate snapshots via telegram_bot.send_photo
triggers:
  - topic: frigate/reviews
    payload: alert
    value_template: "{{ value_json['after']['severity'] }}"
    trigger: mqtt
conditions: []
actions:
  - action: telegram_bot.send_photo
    data:
      target: mytelegramchatid
      url: >-
        http://myip:5000/api/events/{{trigger.payload_json["after"]["data"]["detections"][0]}}/thumbnail.jpg
      caption: >-
        A {{trigger.payload_json["after"]["data"]["objects"] | sort | join(", ")
        | title}}  was detected on the {{
        trigger.payload_json["after"]["camera"] }} camera.
mode: single