I ended up getting videos sending to telegram working for anyone else that might be interested.
TL;DR - On alert, send a video to an FTP server that HA has access to (could use HA FTP add-on), use HA folder_watcher
add-on to watch when the file has been modified, then use telegram_bot to send the video.
BI supports sending a video file via FTP on alert. The bummer is BI doesn’t support SFTP (although they do support FTPS). I didn’t love the idea of sending the video over plain text FTP (and couldn’t get FTPS working with the BI FTP add-on), so I spun up an FTP server on the BI host, and configure BI to use that local FTP server. Then I network share the FTP directory (on the BI host), and mount that share on my HA host at /bialerts
.
Folder Watcher Config
Then I configured HA folder_watcher
add-on (configuration.yml
) to watch that directory:
folder_watcher:
- folder: /bialerts
patterns:
- "*.mp4"
You will also need to add this to configuration.yml
as well:
homeassistant:
allowlist_external_dirs:
- "/media"
Camera Alert Config
Then in BI i setup the alert like this:
this will create an mp4 file in the directory with the short name of the camera.
Automation Config
Then I setup my automation like this:
- wait_for_trigger:
- platform: event
event_type: folder_watcher
event_data:
event_type: modified
path: /bialerts/{{ trigger.payload_json.camera }}.mp4
- platform: event
event_type: folder_watcher
event_data:
event_type: created
path: /bialerts/{{ trigger.payload_json.camera }}.mp4
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: telegram_bot.send_video
data:
file: /bialerts/{{ trigger.payload_json.camera }}.mp4
This will watch for if an mp4 file is created or modified with the camera short name, with a timeout of 60 seconds, in my testing it takes my setup around 10 seconds to complete, but you might have to adjust this timeout as needed.
Thoughts
I dont have a lot of cameras, and dont get a lot of alerts, but so far correct video has been attached.
This could be simplified IF BI supported SFTP, OR if you dont care about sending video files over FTP, or setup FTPS server/got HA FTP addon working with FTPS, to be fair I didn’t spend much time on getting FTPS working.