Send telegram video

I have set up this automation to send video notification to telegram which it works but not very well, it seems to send the video taken a few detections before, sometimes it will send the video that has captured the video at that moment but not often, i’ve cleared cache / reset devices etc and it seems to work then reverts back to its strange behaviour.

i do have four cameras set up this way so i was wondering if that is too many cameras sending notification’s interfering with the automations (to test i do walk around activating the motion for the cams), i just cant work it out trying a few ways in combination to no avail, so just checking if this is a know thing ? too much traffic or just the incorrect automation…any help would be greatly accepted.

- alias: back garden Kitchen record video
  trigger:
    platform: state
    entity_id: binary_sensor.blueiris_back_garden_kitchen_motion
    to: 'on'
  action:
    - service: camera.record
      data:
        entity_id: camera.blueiris_back_garden_kitchen
        filename: '/config/www/temp/kitchen/kitchen.mp4'
        duration: 30
        lookback: 0
    # - delay: 00:00:05    
    - service: notify.telegram
      data:
        title: "Back Garden Kitchen Motion"
        message: Motion detected in back test garden
        data:
          video:
            - file: '/config/www/temp/kitchen/kitchen.mp4'
              caption: Back Garden Kitchen Motion Video   

The problem looks like race condition. Sometimes video sent before it’s actually saved on disk.
You can use folder_watcher to catch file closure event.

folder_watcher:
- folder: /config/video

automation:
- alias: Send recorded video
  trigger:
    platform: event
    event_type: folder_watcher
    event_data:
      event_type: closed 
      path: /config/video/camera1.mp4
  action:
  - service: notify.notify
    data_template:
      message: New video recorded
      data:
        video:
          timeout: 180
          file: "/config/video/camera1.mp4"
          caption: "{{now().strftime('%Y-%m-%d %H:%M:%S')}}"

2 Likes

updated for newer version:

folder_watcher:
- folder: /config/video

automation:
- alias: Send recorded video 1
  trigger:
    platform: event
    event_type: folder_watcher
    event_data:
      event_type: moved
      dest_path: /config/video/camera1.mp4
  action:
  - service: notify.someone
    data_template:
      message: New video recorded
      data:
        video:
          timeout: 180
          file: "/config/video/camera1.mp4"
          caption: "{{now().strftime('%Y-%m-%d %H:%M:%S')}}"

After upgrading to HA 2022.10 the “moved” event type does not seem to work. Do you have the same problem?
Github issue Folder watcher don’t firing “moved” Event type. #79795

Here we go again. Now previous example seems to work.
Use:

 event_type: closed
 path: /your/path

:+1: Yes, this is my line now.

event_type: closed #moved

Ping pong between closed and moved :rofl: :rofl: