Full disclosure, I have stumbled my way through HA leaning heavily on the community. I have no idea how to properly code or format my automation, but I am trying. Sorry this is so long winded…
I have a Foscam Floodlight camera. It is set up to record a 20 second clip once it detects motion and it records it via ftp connection to my rpi running HA. I have been trying to set up automations based on that recording and here’s where I am currently at.
I can get HA to send me the video file via Telegram every time a new one gets recorded but I don’t necessarily want all of those video files. So what I want to do is have HA create a snapshot once motion is detected and send me the snapshot via Telegram with an inline callback to request the video. There are a few challenges here.
I had to create a manual CGI sensor that HA needs to manually check every few seconds to detect the motion. Since that was unreliable I got turned on to Folder Watcher so that I can monitor the FTP location and as a soon as a new video file gets created, I can trigger an automation.
The part I simply could not figure out was the automation that gets triggered during the Telegram callback to request the location of the video file. I thought it was “{{ trigger.event.data.path }}” but I think that only works when it’s part of the same automation where that event was actually triggered (which would be the initial creation of the video file.)
I then thought that if there was a way to make the file path info part of the message sent during the callback request that could solve the problem but here’s where I ran into a roadblock with Telegram & Folder Watcher and testing out this concept.
I made an automation to simply send me a telegram msg with the file path location once a new file is created.
alias: telegram folder watcher location test
description: ""
trigger:
- platform: event
event_type: folder_watcher
id: created
event_data:
event_type: created
condition: []
action:
- service: telegram_bot.send_message
data:
title: blah
message: "{{ trigger.event.data.path }}"
mode: single
BUT, this only works sometimes. If I create a new file in the Folder Watcher folder it will not work. It WILL work if I change the message to just some random text, not the code for the file path. Now remember I was talking about also creating a snapshot using the same Folder Watcher trigger. If that automation is running, it will successfully create a snapshot as soon as the new, test file is created. Now that new snapshot that gets created WILL trigger the code pasted above and successfully send me the file path via Telegram. I don’t understand why the test file won’t trigger it but the test file will trigger a new snapshot and that snapshot will trigger the above automation.
I am not even 100% sure that bringing the file location into the Telegram callback will solve my problem (since I don’t know how to take that input and make it the file path in the callback automation) but the fact that this test step won’t work as designed is making me crazy.