Use case: Have access to jpg and mp4 files via api links. The urls for each require templates based on a mqtt topic’s payload. I’d like to send the jpg file via telegram with an inline keyboard access to the video file. Reason being I don’t always want the video on my phone but could decide based on the jpg file.
Issue: Both the link to the jpg and the mp4 require templated trigger.payload_json in the urls. Works fine for the snapshot automation (that automation has the mqtt topic in the trigger) but not in the telegram callback video automation as the mqtt topic is not in that automation.
Question: is it possible to extract the payload_json info from an mqtt topic without having that mqtt topic as the trigger? Basically can I pull that payload info into the 2nd automation below without using the mqtt topic in the trigger? The first automation below works fine; the second obviously doesn’t. If I replaced the jpg url in the first automation with the mp4 url, the format of the mp4 url is correct.
Lots going on here; I know. Thanks in advance for any thoughts/suggestions.
- id: Presence Snapshot
alias: Presence Snapshot
trigger:
- platform: mqtt
topic: "frigate/events"
action:
- service: notify.home
data_template:
message: 'A {{trigger.payload_json["after"]["label"]}} was detected.'
data:
photo:
- url: 'http://X.X.X.X:XXXX/api/events/{{trigger.payload_json["after"]["id"]}}/thumbnail.jpg?format=android'
caption: 'A {{trigger.payload_json["after"]["label"]}} was detected on {{ trigger.payload_json["after"]["camera"] }} camera at {{ now().strftime("%a %m/%d/%y at %I:%M:%S %p")}}'
inline_keyboard:
- 'SHOW VIDEO CLIP:/clip'
- id: Presence Video
alias: Presence Video
trigger:
- platform: event
event_type: telegram_callback
event_data:
data: '/clip'
action:
- service: notify.home
data:
video:
- url: 'http://X.X.X.X:XXXX/clips/{{trigger.payload_json["after"]["camera"]}}-{{trigger.payload_json["after"]["id"]}}.mp4'