Include payload text to file name in camera snapshot service

Hello,

New here, I have tried looking on the forum without finding answer to my problem.
I would like to dynamically create a file name based on content from msg.payload and current date/time using the camera snapshot service.

Payload is name of the camera, can vary from "garage", "driveway" or "backyard"

I manage to include the date but cannot find a way to include the payload in my file name.
Tried this but it does't work, {{payload}} is just not replaced with the actual payload text, it is just left empty.

{"filename": "/config/www/snapshots/snapshot_{{payload}}_" & $moment().format("YYYY_MM_DD_HH_mm_ss") &".jpg" }

Any ideas how to solve this?

Can you provide screenshots showing the debug output and your flow?

Of course, sorry I forgot.

Can you also show where you are trying to generate a file name and the full debug message coming out of that?

I am trying to create a file using the camera snapshot service. However I am not sure how to find the debug message of that node:

I see. Unfortunately, like the many of folk here, I don't use HA

Therefore I would suggest using a change node or a function node before that service node to build your filename. Then you can reference the filename msg property that you generate using JSONata in that service node

You can also very easily check this change node or functional using a debug node to ensure it is doing what you expect.

Understood, I gave it a tried but still cannot find a way to include the payload text inside a file name. I guess I am using the wrong syntax:

Hi instead of posting screenshots of your flow & values could you please export the flow/values and paste them as text into a reply. that way I don't have to rebuild everything you've done to show you what the problem is.

your JSONATA should be:

{"filename": "/config/www/snapshots/snapshot_" & payload & "_" & $moment().format("YYYY_MM_DD_HH_mm_ss") &".jpg" }

Hi instead of posting screenshots of your flow & values could you please export the flow/values and paste them as text into a reply. that way I don't have to rebuild everything you've done to show you what the problem is.

Sorry about that, new here. Will do that!

1 Like

{"filename": "/config/www/snapshots/snapshot_" & payload & "_" & $moment().format("YYYY_MM_DD_HH_mm_ss") &".jpg" }

YES!!! Thanks a lot, that was what I was looking for.
Learning the correct syntax is not easy.

Which is why I suggested putting that logic in a separate node where you can attaching a debug node to see what's happening. :man_shrugging:

1 Like

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