Send camera snapshot to Telegram

Hi all

I have a question regarding Telegram. I don’t get it working. It’s really strange.

What do I want: I want a motion image to be send through Telegram to my phone. This is my flow

alias: Send Telegram Motion Screenshot (test)
description: Source Dahua Camera 
trigger:
  - type: motion
    platform: device
    device_id: aaaaaaaaaaaaaaaaaaaaaaaa
    entity_id: binary_sensor.00000_motion_alarm
    domain: binary_sensor
condition: []
action:
  - service: camera.snapshot
    data:
      filename: /screenshot/dahua_snapshot.jpg
    target:
      entity_id: camera.dahua_mediaprofile_channel1_mainstream
  - service: notify.telegram_aaa
    data:
      message: test
      data:
        photo:
          - file: /screenshot/dahua_snapshot.jpg
            caption: Movement
mode: single

I also tried this:

action:
  - service: notify.telegram_aaa
    data:
      title: Send an image
      message: ''
      data:
        photo:
          - url: http://192.168.168.168/cgi-bin/snapshot.cgi
            username: username
            password: password
            authentication: digest
            caption: Movement

The normal part:

  • If I start the flows manually, the snapshot will be send. Even if I click it every 5 seconds. ALL THE TIME
  • If in developer tools I change the state from the binary_sensor.00000_motion_alarm to on: The flow triggers and works. ALL THE TIME
  • If I make a flow with only text to be send. This works always, also when the motion sensor has been triggered by onvif.

Now the strange part:

  • Bot actions are NEVER working when the motion sensor has been triggered by a real event. Truly NEVER.
  • When the sensor has been triggered by a real event, the snapshot in /screenshot/dahua_snapshot.jpg is ALWAYS updated to the new image.

I want to focus on the first option (saving the file to /screenshot/dahua_snapshot.jpg). If I look in the logging, I get these messages all the time if it fails.

2022-02-17 16:40:54 ERROR (SyncWorker_11) [homeassistant.components.telegram_bot] Error sending photo: Image_process_failed. Args: (), kwargs:{'chat_id': 1111111, 'photo': <_io.BufferedReader name='/screenshot/dahua_snapshot.jpg'>, 'caption': 'Movement', 'disable_notification': False, 'reply_markup': None, 'timeout': None, 'parse_mode': 'Markdown'}

Can anyone point me in a direction where I can solve this? I am just new with Home Assistant, but I can’t wrap my head around what I am doing wrong here.

1 Like

I haven’t been able to solve this. I moved on to Signal, which is working fine for me.

Use the telegram_bot.send_photo service

1 Like

I just saw this thread.
Using the OP configuration waht needs to be changed.
I am unsure of where to put the telegram_bot.send_photo
Thanks

I have it placed in automation

  - service: telegram_bot.send_photo
    data:
      file: /config/www/kamerafoto/xxxxxxx.jpg
      caption: xxxxxxxxx
2 Likes

Thanks now I understand

how can I handle, that the actual picture will be send.
My picture get there name from date and time.
Like
20221205-173525.jpg
20221205-173528.jpg

any idea ? thx

1 Like

I use on my automation

  - service: camera.snapshot
    data:
      entity_id: camera.cam2
      filename: >-
        /config/www/camera_snapshots/mysnap_{{ now ().year }}_{{ now ().month
        }}_{{ now ().day }}_{{ now ().hour }}_{{ now ().minute }}.jpg
    entity_id: camera.cam1
    enabled: true

scusate qualcuno ha risolto? come?

Can someone share the full config on how to sent a camera motion snapshot image to a telegram group?

1 Like

Looking for the same… :wink: