Show last 5 edited images from a folder

I have my doorbell cam capturing images in motion and the Deepstack to tell if there is a person detected, if so, an image is saved with a timestamp, as well as a latest image.

I’m showing the latest image in HA, which is simple as I know the file name remains the same. However, how would I show the last 5 images captured by the camera?

They would be the last 5 files modified in a folder but I can’t work out how to get this information to display them dynamically?

Thanks for any assistance

Do you need more than 5 images to be saved?

If not save them in sequence as image_name_1.jpg, image_name_2.jpg ... image_name_5.jpg.

Then overwrite these images with the same names as new images come in.

That way you know the five image names to display.

e.g.

- id: drive_camera_motion
  alias: 'Drive Camera Motion'
  initial_state: true
  trigger:
    platform: state
    entity_id:
    - binary_sensor.pir_drive
    from: 'off'
    to: 'on'
  condition:
  - condition: template # only every 5 minutes at most
    value_template:  "{{ (( as_timestamp(now()) - as_timestamp(state_attr('automation.drive_camera_motion', 'last_triggered')) | int(0) ) / 60 ) > 5 }}"
  action:
  - service: camera.snapshot
    data:
      entity_id: camera.front
      filename: '/config/www/snapshots/drive1.jpg'
  - delay: 00:00:01
  - service: camera.snapshot
    data:
      entity_id: camera.front
      filename: '/config/www/snapshots/drive2.jpg'
  - delay: 00:00:01
  - service: camera.snapshot
    data:
      entity_id: camera.front
      filename: '/config/www/snapshots/drive3.jpg'
  - service: notify.email
    data:
      title: 'Drive Movement'
      message: 'Drive movement detected'
      data:
        images:
          - /config/www/snapshots/drive1.jpg
          - /config/www/snapshots/drive2.jpg
          - /config/www/snapshots/drive3.jpg

Hi Tom

Thank you for the suggestion. I had toyed with that idea but didn’t really want to go editing the source of the custom component, Deepstack, that I was using.

Late last night I stumbled across https://github.com/robmarkcole/HASS-Photo-browser/ by @robmarkcole which I think is exactly what I’m after so will have a play with that later on today.

1 Like

Nice. I hadn’t seen that before. Might give it a go myself.

I just started using this… Gallery Panel for images/videos

Thank you. I gave Photo browser a go but it has issues (see the bottom of the github page).

I’ll try Gallery Panel instead.

Thank you

I’ve got Photo Browser working just as I want it after making a few css changes and haven’t experienced any of the issues of images not rendering yet so it’s good to have this as a backup incase that doesn’t work the way I hope in future.