# Include payload text to file name in camera snapshot service

**URL:** <https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336>\
**Category:** General\
**Created:** [27 January 2022 12:59 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336 "2022-01-27T12:59:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 12:59 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/1 "2022-01-27T12:59:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 13:13 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/2 "2022-01-27T13:13:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 13:18 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/3 "2022-01-27T13:18:20Z")

</div>

Of course, sorry I forgot.

 ![Node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/635fd3725b4e44847a6ddf25ef3882213854d08b.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 13:21 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/4 "2022-01-27T13:21:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 13:24 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/5 "2022-01-27T13:24:10Z")

</div>

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:

 ![Capture02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/7/f713473ceebe66a4cc7a24e23b7ed57ec9abaa55.png)

 ![Capture03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/58b64b0995ff7ec7dfa8fc86e026d4d0e56d21d0.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 13:28 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/6 "2022-01-27T13:28:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 13:37 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/7 "2022-01-27T13:37:29Z")

</div>

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:

 ![Capture 04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4dd91e1df790cbc585d864b3430b8da9a07211b.png)

 ![Capture05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8a9abd4e9d3890ef971e4544d63ac71d2129eb1e.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 13:42 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/8 "2022-01-27T13:42:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)\
**Post date:** [27 January 2022 13:42 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/9 "2022-01-27T13:42:55Z")

</div>

> [@gulli1986](#):
>
> {"filename": "/config/www/snapshots/snapshot\_{{payload}}\_" & $moment().format("YYYY\_MM\_DD\_HH\_mm\_ss") &".jpg" }

your JSONATA should be:

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

---

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 13:44 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/10 "2022-01-27T13:44:37Z")

</div>

> 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!

---

<div class="post-metadata">

**Author:** ![gulli1986](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gulli1986/32/55098_2.png) [@gulli1986](https://discourse.nodered.org/u/gulli1986)\
**Post date:** [27 January 2022 13:45 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/11 "2022-01-27T13:45:41Z")

</div>

> {"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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 January 2022 13:53 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/12 "2022-01-27T13:53:40Z")

</div>

> [@gulli1986](#):
>
> 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. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 February 2022 13:53 UTC](https://discourse.nodered.org/t/include-payload-text-to-file-name-in-camera-snapshot-service/57336/13 "2022-02-10T13:53:57Z")

</div>

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