JSON Expression Blink save.video timestamp

I am trying to move over some of my automations from home assistant to node red. in HA, I had an automation that wrote a filename to storage when motion was detected on my blink cameras.

/media/blink/backalley_blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4

and this filename worked fine. All saved videos had a timestamp in them. When I moved over the code in node red for a json expression, it saves fine but does not timestamp it.

{ "name":"back_alley_street", "filename":"/media/blink/backalley_blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4" }

It just shows as backalley_blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4 in my storage.

What is the proper way to get each new file to save with the write timestamp, also I am mountain time.

You would need to use a JSONata expression in a change node.
e.g.

[{"id":"4b89a6392a059f18","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":3640,"wires":[["4dfbe838e3a6b816"]]},{"id":"4dfbe838e3a6b816","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t   \"name\": \"back_alley_street\",\t   \"filename\": \"/media/blink/backalley_blink_video_\" &\t     $moment().tz(\"America/Edmonton\").format(\"YYYYMMDDHHmmss\") & \t     \".mp4\" \t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":3640,"wires":[["f6e8ac13a798492d"]]},{"id":"f6e8ac13a798492d","type":"debug","z":"452103ea51141731","name":"debug 109","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":3600,"wires":[]}]

Expression

{
   "name": "back_alley_street",
   "filename": "/media/blink/backalley_blink_video_" &
     $moment().tz("America/Edmonton").format("YYYYMMDDHHmmss") & 
     ".mp4" 
}

https://momentjs.com/docs/#/displaying/format/

That worked, thank you!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.