Saving last three camera snapshots & displaying info in a glance card on dashboard

Hi,

I have managed to create automations to save snapshots to a folder when my nest doorbell is pressed and also a person has been detected. I save these as a file with the type of detection (person or doorbell) and the datetime in the filename.
For example, to give a saved image with the filename front_door_doorbell20211120-135722.jpg for doorbell and front_door_person20211120-143441.jpg for person.

There is two things I would like to do with these snapshots that I can’t quite wrap my head around.

  1. Only save the last three snapshots: I have added the datetime to the filename for this reason. This would result in deleting the oldest file when a new image is created in order to only have three of each type of snapshot to be saved.

  2. Displaying information on a glance card: I would then like to have a glance card (or something with similar effect) on my dashboard, like in the mockup image below, which shows the last three events of either person or doorbell and how long ago this event occurred. I would then like to be able to press on an event to open the relevant screenshot.

mockup

Any help would be very much appreciated. Very new to home assistant so am not really sure what the right direction would be to implement these two ideas after a while of searching around. Cheers :slight_smile:

Take a look at the DELETE add-in. This may help you keep your saved files to a minimum, but requires an automation to do its thing. It wont keep just 3 files but you could use a several other methods to minimize the saved files to a usable quantity. Sorry, I cant help on getting the images into a glance card.

in configuration.yaml

#  ---------------------------------------------------------------------------
# Delete Files Service
delete:
#  https://github.com/chomupashchuk/delete-file-home-assistant
#  ---------------------------------------------------------------------------

In my automations

##########################################################
## Delete Old TTS Files from TTS Folder
##########################################################
- id: delete_old_tts_mp3_files
  alias: Delete Old TTS MP3 files
  initial_state: true
  mode: restart
  trigger:
    platform: time
    at: '02:30:00'
  action:
  - service: delete.files_in_folder
    data:
      folder: '/config/tts/'
      time: 259200
  - service: script.turn_on
    entity_id: script.notify_hass_delete_old_tts_mp3_files
    data:
      variables:
        var_folder_name: "tts"

Hope this helps a little.

2 Likes