Is it possible to use a flow variable as a value in a JSON string?

Oh god, worked it out, phew!

For any other poor soul reading this in the future, I ended up with this:

A template node containing {"data" : { "value" : {{flow.MinCool}} } } which feeds directing into the call service node and populates the Data field automatically.

OK I need to go to sleep now haha. Thanks everyone for your help and suggestions as always!

1 Like

Hi i have the same issue but i havent quite got it to work what are the settings you are using on the template node

This is what i have so far

[{"id":"540aef05.e9bfb","type":"api-call-service","z":"a1c0be48.ec3b9","name":"Snapshot full","server":"9c52e9c6.678398","version":1,"debugenabled":true,"service_domain":"hassio","service":"snapshot_full","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":550,"y":100,"wires":[["1620aef0.314851"]]},{"id":"ea93648c.8440a8","type":"inject","z":"a1c0be48.ec3b9","name":"Backup","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"00 02 * * 0","once":false,"onceDelay":0.1,"x":100,"y":100,"wires":[["b6100085.089dd"]]},{"id":"1620aef0.314851","type":"debug","z":"a1c0be48.ec3b9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":100,"wires":[]},{"id":"b6100085.089dd","type":"function","z":"a1c0be48.ec3b9","name":"","func":"msg.name = \"Backup \" + Date().toString();\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":100,"wires":[["f02a7c41.4c626"]]},{"id":"f02a7c41.4c626","type":"template","z":"a1c0be48.ec3b9","name":"name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"data\" : { \"name\" : {{msg.name}} } }","output":"str","x":390,"y":100,"wires":[["540aef05.e9bfb"]]},{"id":"9c52e9c6.678398","type":"server","z":"","name":"Home Assistant"}]

So if anyone is interested i got to work like this

[{"id":"540aef05.e9bfb","type":"api-call-service","z":"a1c0be48.ec3b9","name":"Snapshot full","server":"9c52e9c6.678398","version":1,"debugenabled":true,"service_domain":"hassio","service":"snapshot_full","entityId":"","data":"{}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":true,"x":550,"y":100,"wires":[[]]},{"id":"ea93648c.8440a8","type":"inject","z":"a1c0be48.ec3b9","name":"Backup","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"00 02 * * 0","once":false,"onceDelay":0.1,"x":100,"y":100,"wires":[["b6100085.089dd"]]},{"id":"b6100085.089dd","type":"function","z":"a1c0be48.ec3b9","name":"","func":"msg.payload = \"Backup \" + Date().toString();\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":100,"wires":[["72a98633.54c208"]]},{"id":"72a98633.54c208","type":"template","z":"a1c0be48.ec3b9","name":"name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"data\":{\"name\" : \"{{{payload}}}\" }\n }","output":"json","x":390,"y":100,"wires":[["540aef05.e9bfb"]]},{"id":"9c52e9c6.678398","type":"server","z":"","name":"Home Assistant"}]
3 Likes

Thanks a lot, this worked for me!

no porb have a great day

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