Passing message to next node using template syntax

hi all forum members,

Not sure if the topic makes sense .. but I'll ask anyway :wink:

This is the value I wanted to pass on to next node:
image

.. could not get this working on the next node (EXEC node)
image

I don't know if that's correct way to pass value, I've googled it but could not find similar example of it.
Is it possible/proper to pass value like that?

I believe the exec node does not allow mustache template.
You could create the command prior and append it with msg.payload.
there are many ways to do this of course.

Here is one example using the template node.

[{"id":"1194e34726faa84f","type":"inject","z":"e1ef5728e9206b4a","name":"","props":[{"p":"payload"},{"p":"topic","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"str","x":210,"y":620,"wires":[["8c67ed5a9667154f"]]},{"id":"8c67ed5a9667154f","type":"template","z":"e1ef5728e9206b4a","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"set_power {{{payload}}} -s powered {{#topic}}1{{/topic}}{{^topic}}0{{/topic}}","output":"str","x":380,"y":640,"wires":[["74ee6f08590cce85","0d37b44178b16b05"]]},{"id":"daf93507509ec81f","type":"inject","z":"e1ef5728e9206b4a","name":"","props":[{"p":"payload"},{"p":"topic","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"str","x":210,"y":680,"wires":[["8c67ed5a9667154f"]]},{"id":"74ee6f08590cce85","type":"debug","z":"e1ef5728e9206b4a","name":"debug 2472","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":620,"wires":[]},{"id":"0d37b44178b16b05","type":"exec","z":"e1ef5728e9206b4a","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":550,"y":660,"wires":[[],[],[]]}]

You would not need the change node to convert the booleans doing it this way.

1 Like

thank you @E1cid

I've never used template node before, your example looks simple but took me sometime to understand. At least I know how to use the template node and mustache now :slight_smile:

Anyway .. I've used function node to make the flow works ..

Cheers!!

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