Re-send telgram notification on failure

Hey, guys!

I have an automation that sends frigate videos to telegram. Everything is going fine except sometimes I’m experiencing connection problems or timeouts like this:

2023-11-05 10:42:03.095 ERROR (SyncWorker_3) [homeassistant.components.telegram_bot] Can't send file with kwargs: {'caption': 'Видео события', 'url': 'https://example.com/api/frigate/notifications/1699169829.147553-i7ucl4/clip.mp4', 'timeout': 240}

I already have timeout of 4 mins, so I’m not sure if it is good idea to increase it further, also connection problems may occur from time to time, since this is a not a small file.

My idea: since telegram integration does not allow re-sending itself, is it possible to detect failure on HA automation level and retry it? Ideally it would be cool if I could set max retry attempts. Thanks

Here is my setup:

service: telegram_bot.send_video
data:
  caption: Video
  url: >-
    https://example.com/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/clip.mp4
  target:
    - chat_id
  timeout: 240
alias: Send video
1 Like