Question about the camera record service

Hello, So I am using the JSONata Expression editor to record my video from my camera to my nvr with the following.

{"filename":'/media/frigate/{{ computer_camera }}_{{now().strftime("%Y%m%d-%H%M%S")}}.mp4'}

How do I add duration values for the camera? This is for the camera.record service to be specific.

Welcome to the forum.

I assumed since I have never heard of the camera.record service that it's a HA thing.

Sure enough a quick google of camera.record service took me directly to the relevant information -

https://www.home-assistant.io/integrations/camera/

Where you can see in Service data attributes

duration Target recording length (in seconds). Default: 30

1 Like

That does not look like JSONata, it looks more like a Mustache template.

So what I'm asking is how would I implement the duration into this?
{"filename":'/media/frigate/{{ computer_camera }}_{{now().strftime("%Y%m%d-%H%M%S")}}.mp4'}

Sorry for the confusion, you're right it is. I brought up the JSONata editor because that's where I was adding this. I tried to be specific as I've asked this question on other forums that weren't Node Red specific.

You would most likely find the correct answer on the HA forum, node-red section.

At a guess (as not many here use HA) you would add a property to the json string.
e.g.

{"filename":'/media/frigate/{{ computer_camera }}_{{now().strftime("%Y%m%d-%H%M%S")}}.mp4',"duration":{{path_to_duration_vale}}}

presuming duration is a integer
you would need to add the property path.

1 Like

So can you elaborate on the property path? I'm really new to all of this so forgive my ignorance. Also, I've tried the HA forums with no response so I've been forced to try asking elsewhere. So here I am.

The path to the message variable holding the duration value you wish to add
e.g. msg.something.something

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

1 Like

Interesting. Okay, let me look at this for a bit and see if I can get this to work. Thank you for your time.

Your question is difficult for those who dont use HA (most here do not use HA, only Node-RED)

But perhaps a demo using core built-in Node-RED nodes will help you?

JSONata used:

{
    "filename": "/media/frigate/" & computer_camera & "_" & $moment().format("YYYYMDD-HHmmss") & ".mp4",
    "duration": duration
}

The demo flow (use CTRL-I to import)

[{"id":"70be9c28a7f55a87","type":"inject","z":"73b44920080e0db3","name":"server3_camera5, 1234","props":[{"p":"payload"},{"p":"computer_camera","v":"server3_camera5","vt":"str"},{"p":"duration","v":"1234","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1440,"y":80,"wires":[["154b1d6156823171"]]},{"id":"154b1d6156823171","type":"change","z":"73b44920080e0db3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"filename\": \"/media/frigate/\" & computer_camera & \"_\" & $moment().format(\"YYYYMDD-HHmmss\") & \".mp4\",\t    \"duration\": duration\t}\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1470,"y":140,"wires":[["384554834ef7097d"]]},{"id":"384554834ef7097d","type":"debug","z":"73b44920080e0db3","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1500,"y":200,"wires":[]}]

I have no idea if this is what you want but at least, as a working demo, it might lead you down the right path.

1 Like

Yea I know. I'm in a weird in-between because a lot of people here don't use HA, and on the HA forums a lot of people don't use Node Red. But this helps as really I just need help with the syntax. I'll try what you posted.

Okay, so this works.

{
    "filename": "/media/frigate/" & computer_camera & "_" & $moment().format("YYYYMDD-HHmmss") & ".mp4",
    "duration": duration
}

I appreciate the help.

1 Like

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