I am trying to combine two output topic, payload pairs into an object made up of the payloads.
the two msg's come out of node-red-ramp-thermostat as topic = current / payload = value & topic = target / payload = value
I have tried using If statement approach on the topics but this seems a complicated / messy way of doing things. Is there a simple way to do this in a function. i need the output object to be msg,value = current payload, msg threshold=target payload.
maybe there is a node that already does this ? I have tried "join node" but cant get it to work, i would rather use a function if possable.
Chris
From your description, the Join node should be able to do what you want - or at least, it can do the work to get the two separate messages joined into one message. You would then need a Change node to get the different properties into exactly the form you want.
[{"id":"2436f695.a2901a","type":"inject","z":"6a4f2112.f1006","name":"","topic":"current","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":1420,"wires":[["cde37530.1fedb8"]]},{"id":"cde37530.1fedb8","type":"join","z":"6a4f2112.f1006","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":460,"y":1440,"wires":[["82d73490.519b88"]]},{"id":"d7a80a7d.245228","type":"inject","z":"6a4f2112.f1006","name":"","topic":"target","payload":"123","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":1480,"wires":[["cde37530.1fedb8"]]},{"id":"1f25dbb9.d46164","type":"debug","z":"6a4f2112.f1006","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":1440,"wires":[]},{"id":"82d73490.519b88","type":"change","z":"6a4f2112.f1006","name":"","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.current","tot":"msg"},{"t":"set","p":"threshold","pt":"msg","to":"payload.target","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1440,"wires":[["1f25dbb9.d46164"]]}]
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.