How do I reference last modified file?

I’ve setup my camera to record video and take snapshot when triggerd by person. Snapshots are set as overwrite, so I have no issue referencing it. However, mp4s are named by time of recording, how do I reference it so I can view the clip without downloading the file or finding out the exact file name? Is there a way to reference last modified file?

  - service: camera.record
      entity_id: camera.living_room
      filename: >-
        now().strftime("%Y%m%d-%H%M%S") }}.mp4
      duration: 20
  - service: camera.snapshot
      filename: /config/www/nest/living_room/living_person.jpg
      entity_id: camera.living_room
camera_view: auto
type: picture-glance
entities: []
title: Living
  action: url
  action: url
  url_path: >-{{    
    now().strftime("%Y%m%d-%H%M%S") }}.mp4 **Doesn't work**

My clips are short, so when I make a new timestamped recording, I make a copy of the last one with a fixed name using a shell command.

copy_last_recording: "cp `ls -t /tmp/camera.security_camera_*.mp4 | head -n1` /home/homeassistant/.homeassistant/www/camera.security_camera_last.mp4"


Thanks for your tip! Did you find a new solution or are you still using this method? However thanks for share it! It was helpful

Still using it. :slight_smile: If I were to change it I’d skip the use of /tmp, but that’s minor.

1 Like

Only for your info there are other maybe solution using folder_watcher. Just to know that there is also this tool… maybe it could be helpful to do other stuff :wink:

1 Like

Yup, aware of it and using for some other stuff. I just tend to leave working things alone. :slight_smile:

1 Like