Saving Camera Images to a Folder

Currently I’m saving images to a folder in “www” for when someone rings my door bell. What I would like to do is save the most resent image as “latest_doorbell_image” and rename the one that was saved before that as a different name. Just like the Deepstack intergration does. That way I can display the latest image in the UI.

Example:
image

Is this possible to do with Node Red?

No idea about node red. but this is how I do it in HA itself.
I save 2 images: one with “latest” one with timestamp:

      - "/config/tensorflow/storagemotion/doorbell_latest.jpg"
      - "/config/tensorflow/storagemotion/doorbell_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"

Then I have a script that deletes anything older than 5 days:
'find /config/tensorflow/storagemotion/ -maxdepth 2 -type f -mtime +5 -exec rm {} -f \;'
The script runs once a day…

2 Likes

Thanks. I never thought of saving two images. Got it working using HA. I will play around to see if Node Red can do it.

May i ask you how looks the full script of deletes the files and where did you put it?

This is the full script.
This one liner searches (find) for files (-type f) in /config/tensorflow/storagemotion/ and subfolders up to 2 levels down (-maxdepth 2) that are older than 5 days (-mtime +5) and force deletes them (-exec rm {} -f \;)

Where are you inputting these? Can you provide the full code to save 2 images?

- "/config/tensorflow/storagemotion/doorbell_latest.jpg"
- "/config/tensorflow/storagemotion/doorbell_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"

I don’t use tensorflow anymore but the below will give you what you need

    - service: camera.snapshot
      data:
        entity_id: camera.doorbell
        filename: '/config/www/CCTV_Snapshots/Doorbell.jpg'

ok. I knew about this one, but I thought we can combine them to save to 2 different locations with one service.

Something like this?

    - service: camera.snapshot
      data:
        - entity_id: camera.doorbell
          filename: '/config/www/CCTV_Snapshots/Doorbell.jpg'
        - entity_id: camera.doorbell
          filename: '/config/www/Some_Other_Location/Doorbell.jpg'

I get this error.

Automation with alias ‘Security Balcony Camera Snapshot’ could not be validated and has been disabled: template value should be a string for dictionary value @ data[‘action’][0][‘data’]. Got [OrderedDict([(‘entity_id’, ‘camera.security_balcony’), (‘filename’, ‘/config/www/img/security/balcony/security_balcony_camera_last.jpg’)]), OrderedDict([(‘entity_id’, ‘camera.security_balcony’), (‘filename’, ‘/config/www/img/security/balcony/{{ now().strftime(“%Y%m%d_%H%M%S”) }}security_balcony_camera.jpg’)])]

Looks like you need 2 separate services, Diane make much difference to be honest