Variable payload syntax

Hi there,
to control a thermostat (tuya) I generate the following payload with an inject-node (see photo). That works fine. Now I would like to hand over control to a slider node. Unfortunately I don't know the syntax. The payload should remain the same, only the value behind set: should be changed using the slider (currently 150). The rest of the payload should stay the same. Does anyone have any suggestion?

Many Thanks

Thoralf
inject_node

There are many ways to do this. Here is a simple one using a template node set to output a parse json object.

[{"id":"9123be75.86ad7","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"100","payloadType":"num","x":90,"y":920,"wires":[["a15b33f3.e423c"]]},{"id":"a15b33f3.e423c","type":"ui_slider","z":"c791cbc0.84f648","name":"","label":"slider","tooltip":"","group":"8b5cde76.edd58","order":9,"width":0,"height":0,"passthru":true,"outs":"end","topic":"topic","topicType":"msg","min":0,"max":"150","step":"5","x":220,"y":880,"wires":[["408e47d1.1dad8"]]},{"id":"408e47d1.1dad8","type":"template","z":"c791cbc0.84f648","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n\"set\": {{payload}},\n\"dps\": 2\n}","output":"json","x":384.00001525878906,"y":863,"wires":[["8501df36.31a7e8"]]},{"id":"d226cbf4.abb8d8","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"150","payloadType":"num","x":90,"y":820,"wires":[["a15b33f3.e423c"]]},{"id":"8501df36.31a7e8","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":644.0000152587891,"y":783,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

plenty of other useful examples here https://cookbook.nodered.org/

Hi there,

Thanks very much. I tried a lot, unfortunately without success.
It works immediately with your template.

Many greetings, Thoralf

1 Like

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