Telegram send video file (Ring)

Hello,

i’m trying to let ha. send a video to my telegram channel but i’m always greeted with an error:


Can't send file with kwargs: {'message': 'Last Ring Video', 'file': 'test.mp4'}

2:41 PM components/telegram_bot/__init__.py (ERROR)

'test.mp4' are not secure to load data from!

2:41 PM components/telegram_bot/__init__.py (WARNING

this is my config:

- id: ring_video_download
  alias: Ring Video Download
  hide_entity: true
  trigger:
  - entity_id: binary_sensor.ring_front_door_motion
    from: 'off'
    to: 'on'
    platform: state
  condition: []
  action:
  - service: downloader.download_file
    data_template:
      url: '{{ states.camera.front_door.attributes.video_url }}'
      filename: test.mp4
      overwrite: true
  - service: notify.oneplus
    data:
      message: Last Ring Video
      data:
        video:
        - file: test.mp4

i also added this to my configuration:

  download_dir: /share
python_script:

  whitelist_external_dirs:
    - /share

can anyone spot an error ?!?

Did you come right with this? @jeroen.nijssen I’m trying to do the same, just wondering if I need to carry on searching. :slight_smile:

Howdy!

So got this all working nicely. :slight_smile: Just trying to figure out how long it takes for my doorbell to upload to ring, then making it accessible to home assistant. 1 minute seems too short, but for you it may be perfect. YMMV. Just a case of fiddling with the delay in these automation scripts.

In your config yaml file, don’t forget to add two things.
First, inside your main homeassistant setup :

homeassistant:
  auth_providers: []
  allowlist_external_dirs:
    - /config/www/images/ 
    - /downloads/    
  whitelist_external_dirs:
    - /config/www/images/ 
    - /downloads/ 

Then anywhere you like in your config file, allow the downloader component and specify where this downloads to. [Pro-tip: map it to somehting that isn’t your SD card]

downloader:
  download_dir: /downloads

First one is a motion detection script:

- alias: Telegram notification -Front door motion
  id: telegram_front_door_motion
  trigger:
  - entity_id: binary_sensor.front_door_motion
    from: 'off'
    platform: state
    to: 'on'
  action:
  - service: notify.Bergen_telegram
    data_template:
      message: "Movement detected at the Front Door. I'll send a photo in a bit. You know how slow Ring is."
  - delay: 00:02:00
  - service: camera.snapshot
    data:
      entity_id: camera.front_door_2
      filename: /downloads/ring/fdoor-snapshot.jpg #/config/www/images/fdoor-snapshot.jpg  
  - service: telegram_bot.send_photo
    data_template:
      file: /downloads/ring/fdoor-snapshot.jpg #/config/www/images/fdoor-snapshot.jpg
      caption: The perp
      target: []
      disable_notification: true
      timeout: 1000
  - service: downloader.download_file
    data_template:
      url: "{{ states.camera.front_door_2.attributes.video_url }}"
      subdir: ring
      filename: fdoor_latest.mp4
      overwrite: true
  - delay: 00:00:05  
  - service: telegram_bot.send_video
    data:      
      file: /downloads/ring/fdoor_latest.mp4
      caption: Here's the video from Ring
      target: []
      disable_notification: true
      timeout: 1000
      inline_keyboard:
      - Show options:/options

This second one is is a call & command request script - type in /frontdoor_vid in telegram (or add to your options menu) and back comes the last video that was recorded by ring for that device:

- alias: Request Ring Video Download
  id: ring_video_download_request  
  trigger:
  - event_type: telegram_callback
    event_data:
      data: /frontdoor_vid
    platform: event
  - event_type: telegram_command
    event_data:
      command: /frontdoor_vid
    platform: event
  condition: []
  action:
  - service: downloader.download_file
    data_template:
      url: "{{ states.camera.front_door_2.attributes.video_url }}"
      subdir: ring
      filename: fdoor_latest.mp4
      overwrite: true
  - delay: 00:00:05  
  - service: telegram_bot.send_video
    data:      
      target: []
      callback_query_id: '{{ trigger.event.data.id }}'
      file: /downloads/ring/fdoor_latest.mp4
      caption: Latest front door video from Ring
      disable_notification: true
      timeout: 1000
      inline_keyboard:
      - Show options:/options

Hopefully that helps someone other than me. :slight_smile:

Hi there,

following your example, however seems can’t save jpg on the path, only the mp4.

homeassistant.log error

configuration.yaml

  auth_providers: []
   
  allowlist_external_dirs:
    - /config/www/images
    - /config/downloads
    - /config/downloads/ring
  whitelist_external_dirs:
    - /config/www/images
    - /config/downloads
    - /config/downloads/ring

automation.yaml

- id: '1608067011823'
  alias: Telegram notification -Front door motion
  trigger:
  - entity_id: binary_sensor.front_door_exterior_ding
    from: 'off'
    platform: state
    to: 'on'
  action:
  - service: notify.telegram
    data_template:
      message: "Movement detected at the Front Door. I'll send a photo in a bit. You know how slow Ring is."
  - delay: 00:02:00
  - service: camera.snapshot
    data:
      entity_id: camera.front_door_exterior
      filename: /config/downloads/ring/fdoor-snapshot.jpg  
  - service: telegram_bot.send_photo
    data_template:
      file: /config/downloads/ring/fdoor-snapshot.jpg
      caption: The perp
      target: []
      disable_notification: true
      timeout: 1000
  - service: downloader.download_file
    data_template:
      url: "{{ states.camera.front_door_exterior.attributes.video_url }}"
      subdir: ring
      filename: fdoor_latest.mp4
      overwrite: true
  - delay: 00:00:05  
  - service: telegram_bot.send_video
    data:      
      file: /config/downloads/ring/fdoor_latest.mp4
      caption: Here's the video from Ring
      target: []
      disable_notification: true
      timeout: 1000
      inline_keyboard:
      - Show options:/options

image

any ideas on what’s missing?

Thanks

Any suggestion how to sort this out?

This stuff is not accepted in configuration.yaml and I am not able to make it work.
Anyone who fixed this?

I have a code which works now:

alias: "Sicherheit: Türklingel Video speichern"
trigger:
  - platform: state
    entity_id:
      - binary_sensor.haustur_ding
    to: "on"
    from: "off"
action:
  - service: telegram_bot.send_message
    data:
      message: Bewegung an der Haustür detektiert! Bild folgt...
  - delay: "00:02:00"
    enabled: true
  - service: camera.snapshot
    data:
      filename: www/downloads/ring/haustuer_snapshot.jpg
    target:
      entity_id: camera.haustur
  - service: telegram_bot.send_photo
    data:
      file: www/downloads/ring/haustuer_snapshot.jpg
      caption: Ring
  - service: downloader.download_file
    data_template:
      url: "{{ states.camera.haustur.attributes.video_url }}"
      subdir: ring
      filename: haustuer_video.mp4
      overwrite: true
  - delay: "00:00:05"
    enabled: true
  - service: telegram_bot.send_video
    data:
      file: www/downloads/ring/haustuer_video.mp4
      caption: Hier ist das Video dazu.

The only problem I have is the video format which is square and not 16:9 like the video source.

2 Likes

I have the same problem, were you able to resolve it? Actually, I solved it, it was the spacing that was the issue!

Thanks for responding.
No, I did not fix this yet.
So, which spacing are you referring to?