Sending amcrest snapshot via telegram

Hi,

I’m facing the following error when the automation is triggered:

2018-09-24 13:57:58 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.notify_alarm, old_state=<state automation.notify_alarm=on; last_triggered=2018-09-24T15:51:17.822993+02:00, friendly_name=Notify Alarm @ 2018-09-23T23:19:13.574043+02:00>, new_state=<state automation.notify_alarm=on; last_triggered=2018-09-24T15:57:58.809991+02:00, friendly_name=Notify Alarm @ 2018-09-23T23:19:13.574043+02:00>>
2018-09-24 13:57:58 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Status code 401 (retry #1) loading http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0
2018-09-24 13:57:58 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Status code 401 (retry #2) loading http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0
2018-09-24 13:57:58 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Status code 401 (retry #3) loading http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0
2018-09-24 13:57:58 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Status code 401 (retry #4) loading http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0
2018-09-24 13:57:59 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Status code 401 (retry #5) loading http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0
2018-09-24 13:57:59 WARNING (SyncWorker_1) [homeassistant.components.telegram_bot] Can't load data in http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0 after 5 retries
2018-09-24 13:57:59 ERROR (SyncWorker_1) [homeassistant.components.telegram_bot] Can't send file with kwargs: {'message': 'Alarm Tripped', 'url': 'http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0'}

Thist is the config:

#####################
# motion pic telegram
#####################

- alias: Notify Alarm
  trigger:
    - platform: state
      entity_id: sensor.amcrest_camera_motion_detected
      to: 'True'
  action:
    - service: notify.telegram
      data:
        message: "Alarm Tripped"
        data:
          photo:
            - url: http://10.0.1.30/cgi-bin/snapshot.cgi?channel=0

Any advice?

Hi
I think you need to take a snapshot of the camera first (with camera.snapshot service), then send the photo using the service telegram_bot.send_photo. The directory where the snapshot is saved has to be whitelisted.

I have following automation / script setup for my Xiaofang Camera (incl 1 s delay)

'1528021640119':
  alias: Send Snapshot Xiaofang1 (1s delay)
  sequence:
  - delay: 00:00:01
  - data:
      entity_id: camera.xiaofang1
      filename: /home/homeassistant/xiaofang1.jpg
    service: camera.snapshot
  - data:
      file: /home/homeassistant/xiaofang1.jpg
    service: telegram_bot.send_photo
1 Like

Hi,
that’s working thanks.
Doing it directrly via url: would be nicer but I thing it takes to long to grep the screenshot from the camera.

br