How to add timestamp to Snapshot file?

I do try to add an timestamp to an snapshot file using the snapshot service.
I do use:

{    
        "entity_id": "camera.garageachter",    
        "filename": "/config/www/snapshots/snapshot_camera_{{now().strftime('%H:%M %d-%m-%Y')}}.jpg"
    
}

But it is only making a filename without the date stamp


What am I doing wrong

_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg

Thanks for the answer, but stil no time stamp
Do I need to activate the now() stamp?

Thanks again.
This is working, but in NodeRED It is not

Maybe it will work after restart

I really don’t understand.
This is the way I do, there is a file created, but without timestamp:


where data is:

{     
    "filename": "/config/www/snapshots/snapshot_camera_test_{{ now().strftime("%Y%m%d-%H%M%S") }}.jpg",    
    "entity_id": "camera.garageachter"

}

If I try your way at the services part in HA it is creating the right file

timestamp: this is a variable value
Unfortunately, I don’t use NordRed :slightly_frowning_face:

Thanks any how for the help :+1:

by default NR using mustache templates not jinja2 like HA. If you want to be able to a jinja template to HA you’ll need to check the Use alternative template tags for the Data field

or you can do it directly in NR with the data type of the data field set to J: Expression

{    
        "entity_id": "camera.garageachter",    
        "filename": "/config/www/snapshots/snapshot_camera_" & $moment().format("YYYMMDD-hhmmss") &".jpg"
}

Thanks. I did find a solution by adding time stamp to the payload with an date/time formatter node:

and added at the data part:

{
    "filename": "/config/www/snapshots/snapshot_camera_{{payload}}.jpg",
    "entity_id": "camera.garageachter"
}

I will try your solution also
because it is one node less :sunglasses:

EDIT: I tried your J: Expression solution. Thats working
I didn’t get it running with “alternative template tags” activated.
Thanks for the answer

1 Like

Can someone share the full node? Try to make it work but I get snapshot_.jpg :smiley: