Automation for camera.snapshot for Amcrest IP camera

Hi everyone,

I am just starting my journey with Home Assistant so I am sorry if the question is noobish/obvious.

I own an Amcrest IP camera (IP2M-841W) and I would like to add some automation with its motion detection.

I have successfully connected it to HA, enabled motion detection, and named it camera1.
I was able to create simple automation for sending notification (persistant_notification) once motion is detected.

I would like to create an automation for taking a snapshot (image) once motion is detected. When I try to add the action: camera.snapshot service for the automation nothing works. I added the filename configuration under /tmp and added /tmp to whitelist_external_dirs.
From reading the services available for Amcrest (https://www.home-assistant.io/integrations/amcrest/#services) I see that snapshot is not there.

My question is, is it really the case that snapshots are not available? am I doing something wrong?

Thanks is advance.

Can we see your automation… snapshot is a service of any camera that’s already being fed into HA as far as I know. I use Amcrest cameras and receive snapshots daily…

Sure. This is the output of “automations.yaml”

- id: '1574371315309'
  alias: Send image on movement
  description: ''
  trigger:
  - entity_id: binary_sensor.amcrest_camera_motion_detected
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: camera.camera1
      filename: /tmp/aaaa.jpg
    service: camera.snapshot

On my “configuration.yaml” I have the following configuration:

homeassistant:
    whitelist_external_dirs:
    - /tmp

Nothing really standing out as wrong… for mine I had to list the entire path… but I’m pretty sure that that is not normal, and something is not right with my setup that I have to do that… but maybe you want to try it anyway. (also have entire path in whitelist)

- alias: Front Yard Camera Motion Snapshot
  trigger:
  - entity_id: binary_sensor.front_yard_motion
    platform: state
    from: 'off'
    to: 'on'
  action:
  - service: camera.snapshot
    data:
      entity_id: camera.front_yard
      filename: "/home/homeassistant/.homeassistant/www/cam_captures/front/{{ as_timestamp(states.automation.front_yard_camera_motion_snapshot.attributes.last_triggered)|timestamp_custom('%Y_%m_%d__%H_%M_%S') }}.jpg"

And here is whitelist

  whitelist_external_dirs: 
   - /home/homeassistant/.homeassistant/www/cam_captures
   - /home/homeassistant/.homeassistant/www/cam_captures/front

My installation is under /usr/share/hassio/homeassistant
and I do not have a homeassistant user like you have. Could it be the problem?

No it shouldn’t be but maybe worth trying to actual full path… like I said I don’t know that it’s normal that I have to do that… as many docs just show the path under the config dir… but maybe you have a similar issue… without it my snapshots never saved and I believe the error log was giving me a message about not being able to save (it was awhile ago now)… did you check for errors after triggering the automation?

@Bartem Thank you very much for your help, appreciate it!
Eventually I changed the path to be under /share and rebooted the machine and I was able to take a screenshot!