Save Camera Image (when motion detected)

I think it should be owner homeassistant. Check the owner of the other files?

I run HASS with pi so it should be OK I guess, I´m not in virtual env either.

Well, it is not working, so something is not right :wink:

In my experience, HA does not behave well if permissions are not set properly.

I agree, I´ll wait for someone else to try it :slight_smile:

Appears that on my pi images are saved in the folder /home/pi/Desktop/hass-cam. However whenever I create a folder tmp and assign write permissions to it I still get the error:

2017-11-05 07:04:16 ERROR (MainThread) [homeassistant.components.camera] Can't write /tmp/test.jpg, no access to path!

Have raised an issue

Try tmp/test.jpg

Here’s the solution:

https://github.com/home-assistant/home-assistant/issues/10356#issuecomment-341982006

The docs have also been updated.
cheers

for those who use newer versions from foscam my foscam app also has the option to take a snapshot and save it in a predefined directory.

I believe this could be closed now

Yes, it works great.

Is it possible to do this feature also for capture a movie for x seconds?

1 Like

If there isn’t a feature request for that then I would add one :slight_smile: For the raspberry pi camera this is feasible, not sure about all other cameras.
Cheers

I use an rtsp stream, with ffmpeg I could capture now, but full integration would be nicer

1 Like

I created my config according to @mikenolet’s answer: ffmpeg_motion binary sensor as trigger with automation taking 3 snapshots and then sending it via Telegram. This is using a Reolink IP cam.

binary_sensor:

- name: cam01
  platform: ffmpeg_motion
  input: rtsp://[user]:[password]@[ip]:554/h264Preview_01_sub
  reset: 120

shell_command (to take the snapshots):

camera_take_snapshot: >
  /usr/bin/wget http://[ip]/cgi-bin/api.cgi?cm[user]&channel=0&rs=1234567890&user=[user]&password=[password] -O {{filename}}

And finally
automation:

- alias: 'Motion Notify'
  hide_entity: True
  trigger:
    - platform: state
      entity_id: binary_sensor.cam01
      to: 'on'
  action:
    - service: shell_command.camera_take_snapshot
      data:
        filename: /home/user/.homeassistant/data/camera_snapshots/snap1.jpg
    - delay:
         seconds: 5
    - service: shell_command.camera_take_snapshot
      data:
        filename: /home/user/.homeassistant/data/camera_snapshots/snap2.jpg
    - delay:
         seconds: 5
    - service: shell_command.camera_take_snapshot
      data:
        filename: /home/user/.homeassistant/data/camera_snapshots/snap3.jpg
    - delay:
         seconds: 1
    - service: notify.telegram
      data:
        message: 'cam01 Motion!'
        data:
          photo:
            - file: /home/user/.homeassistant/data/camera_snapshots/snap1.jpg
              caption: cam01
            - file: /home/user/.homeassistant/data/camera_snapshots/snap2.jpg
            - file: /home/user/.homeassistant/data/camera_snapshots/snap3.jpg
1 Like

I create my own proyect, if you want ideas, and before notification, you can see all motions, not only three.

I do similar but rather than have a script to capture the cam image, I do it like this:

notifyalarm:
  alias: Notify Alarm Trip
  sequence:
    - service: telegram_bot.send_message
      data:
        message: "Alarm Tripped"
        target: [xxxxxxxxx, yyyyyyyyy]
#send cam
    - service: telegram_bot.send_photo
      data:
        url: 'http://<ip>:8123/api/camera_proxy/<entityname>?token=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
        target: [xxxxxxxxxx, yyyyyyyyy]

You can grab the image url from the HASS interface, but you’ll need to change it to camera_proxy rather than the stream and then it’ll grab a still straight from HASS.

1 Like

I couldn’t get yours to work and gave up.

The automation or the gallery viewer? … try this one Gallery Panel for images/videos

That’s not working for me either. I’ve worked something else out for now.

sorry , I have very abandoned the project

If I pick it up again, I’ll let you know

regards