# Combine node outputs

**URL:** <https://discourse.nodered.org/t/combine-node-outputs/46570>\
**Category:** General\
**Created:** [1 June 2021 18:06 UTC](https://discourse.nodered.org/t/combine-node-outputs/46570 "2021-06-01T18:06:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lorccan](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@lorccan](https://discourse.nodered.org/u/lorccan)\
**Post date:** [1 June 2021 18:06 UTC](https://discourse.nodered.org/t/combine-node-outputs/46570/1 "2021-06-01T18:06:43Z")

</div>

This is really simple, but I haven’t touched node-RED for ages and I’m stuck:

Two nodes generate slightly different payloads (of objects containing key:value pairs) but they do have the key “Rain” in common. This can have a value of 1 or 0.

I want to get the value of Rain from each payload, sum them, and then feed the result to another node where: if Rain = 1 then do nothing, else turn on watering system.

I’ve tried a Join, followed by Change node with Jsonata $sum to modify the output but I’m getting tangled up. Any help would be much appreciated.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [1 June 2021 18:13 UTC](https://discourse.nodered.org/t/combine-node-outputs/46570/2 "2021-06-01T18:13:24Z")

</div>

Here is an example

```auto
[{"id":"12cf7965.5ab35f","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"one","payload":"{\"one\":1,\"rain\":1}","payloadType":"json","x":170,"y":4720,"wires":[["18501f64.763a81"]]},{"id":"18501f64.763a81","type":"join","z":"c74669a0.6a34f8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":380,"y":4740,"wires":[["24f8b497.851794"]]},{"id":"7d9e3470.082b1c","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"{\"two\":1,\"rain\":1}","payloadType":"json","x":170,"y":4760,"wires":[["18501f64.763a81"]]},{"id":"24f8b497.851794","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sum(payload.*.rain)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":4740,"wires":[["df2cf978.75a28"]]},{"id":"df2cf978.75a28","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":4840,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![lorccan](https://avatars.discourse-cdn.com/v4/letter/l/278dde/32.png) [@lorccan](https://discourse.nodered.org/u/lorccan)\
**Post date:** [1 June 2021 18:17 UTC](https://discourse.nodered.org/t/combine-node-outputs/46570/3 "2021-06-01T18:17:40Z")

</div>

Thank you. I should have asked earlier instead of going around in circles. I was almost there. I was just missing the asterisk in the Change: "payload.\*."

---

<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:** [31 July 2021 18:17 UTC](https://discourse.nodered.org/t/combine-node-outputs/46570/4 "2021-07-31T18:17:53Z")

</div>

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