Save file using date in the name[SOLVED]


I am trying to pass a record service command to one of my cameras using following yaml command line:

service: camera.record
filename: /tmp/snapshot_{{ }}.mp4

however in addition to the entity_id, I would like to include the date and time of record in the file name how can I go about this?

Many thanks.

After little bit of thinking and playing around here is how it has to be done:

data: { 
        filename:"/config/storage/recordings/{{now().day}}-{{now().month}}-{{now().year}}/{{}}"+" {{ now().hour}}:{{now().minute}}:{{now().second}}.mp4",
        duration: 10

now() function can give the complete date and time or you can use individual components of time as I did in above example.

1 Like