# Display two payloads in one Text

**URL:** <https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208>\
**Category:** Dashboard\
**Created:** [6 August 2020 08:10 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208 "2020-08-06T08:10:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![zimb86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zimb86/32/26925_2.png) [@zimb86](https://discourse.nodered.org/u/zimb86)\
**Post date:** [6 August 2020 08:10 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/1 "2020-08-06T08:10:01Z")

</div>

Hi,  
i´m completely new to node-red and this may be a stupid question but I cant get it work:  
Got 2 values from a CCU node: Temperature and Humidity  
I want to display these two values in one line Text on the Dashboard (xx °C / yy %)  
I created a function to store the payload in msg.temp and msg.hum.  
Value format for the "Text" is {{msg.temp}} °C / {{msg.hum}} %  
That basically works, but just for one value at a time.  
CCU sends the correspondig value when it changes, so for example the temp is send every 10 minutes, the humidity once in a hour - so I cant use a join.  
Whats the simples way to achieve this?

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9458307c8a204fad9016c481428868e68e32459.png) ![2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/a/4ac29ac46d158aa9e4515de28a43371ae7cdd6f4.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 August 2020 08:17 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/2 "2020-08-06T08:17:56Z")

</div>

Hi.

We all have to start somewhere. There is nothing wrong with not knowing.

The node you need to look at is the `join` node.

Set it to `manual` and set it to accept `2` messages.

That will get that part of it better.

Then look at the `template` node... There are two. The one you want is the one with a `{` icon in its node symbol.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 August 2020 08:33 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/3 "2020-08-06T08:33:14Z")

</div>

@zimb86 The way I would do this is to have each sensor store it's values in a flow variable. You could use a change node to do this:  
 ![Screen Shot 2020-08-06 at 4.22.38 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/6627ff8bef959c410888c4fbe76f16dfdc84f388.png)  
This way flow.temperature and flow.humidity will always have the latest value. Then connect the outputs of both `change` nodes to another 'change' node and use the 'replace' option to move in the values

 ![Screen Shot 2020-08-06 at 4.30.22 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/f/cf1803956d774f633199d80b011fe9b31b96bf2c.png)  
and feed that to your `ui-text` node.

Here is a sample flow using `inject` nodes in-place of the `mqtt-in` nodes and a `debug` in-place of the ui-text`

```auto
[{"id":"1cc4dda7.44b11a","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"humidity","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":80,"wires":[["1788d09e.f95897"]]},{"id":"6d010fab.b62d28","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"temperature","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":160,"wires":[["1788d09e.f95897"]]},{"id":"1788d09e.f95897","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"temp °C / humi %","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"temp","fromt":"str","to":"temperature","tot":"flow"},{"t":"change","p":"payload","pt":"msg","from":"humi","fromt":"str","to":"humidity","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":120,"wires":[["e8d8301b.957a78"]]},{"id":"2bb527d5.911e38","type":"inject","z":"3e1ce002.535ce8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"56","payloadType":"num","x":90,"y":80,"wires":[["1cc4dda7.44b11a"]]},{"id":"eb2f94c2.4e8178","type":"inject","z":"3e1ce002.535ce8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"45","payloadType":"num","x":90,"y":160,"wires":[["6d010fab.b62d28"]]},{"id":"e8d8301b.957a78","type":"debug","z":"3e1ce002.535ce8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":120,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![zimb86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zimb86/32/26925_2.png) [@zimb86](https://discourse.nodered.org/u/zimb86)\
**Post date:** [6 August 2020 08:43 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/4 "2020-08-06T08:43:43Z")

</div>

> [@zenofmud](#):
>
> ```auto
> [{"id":"1cc4dda7.44b11a","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"humidity","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":80,"wires":[["1788d09e.f95897"]]},{"id":"6d010fab.b62d28","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"temperature","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":160,"wires":[["1788d09e.f95897"]]},{"id":"1788d09e.f95897","type":"change","z":"3e1ce002.535ce8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"temp °C / humi %","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"temp","fromt":"str","to":"temperature","tot":"flow"},{"t":"change","p":"payload","pt":"msg","from":"humi","fromt":"str","to":"humidity","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":120,"wires":[["e8d8301b.957a78"]]},{"id":"2bb527d5.911e38","type":"inject","z":"3e1ce002.535ce8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"56","payloadType":"num","x":90,"y":80,"wires":[["1cc4dda7.44b11a"]]},{"id":"eb2f94c2.4e8178","type":"inject","z":"3e1ce002.535ce8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"45","payloadType":"num","x":90,"y":160,"wires":[["6d010fab.b62d28"]]},{"id":"e8d8301b.957a78","type":"debug","z":"3e1ce002.535ce8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":120,"wires":[]}]
> 
> ```

Thanks @zenofmud, That works like expected!  
So if I got multiple sensors on one flow i have to use unique variables for each, right?

@Trying_to_learn In my understanding the problem using join is, that the values are only updated if both (temp/hum) are submitted. Giving the case that temp is updated just now and hum in about 2 hours the current received temp is not displayed on the dashboard until hum is submitted in 2h.  
Is that correct?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [6 August 2020 08:45 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/5 "2020-08-06T08:45:42Z")

</div>

> [@zimb86](#):
>
> So if I got multiple sensors on one flow i have to use unique variables for each, right?

Can you expand on this?

As for the `join` you are correct, both msgs would have to arrive before it was sent on. That is why I gave my suggestion to use to flow variables.

---

<div class="post-metadata">

**Author:** ![zimb86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zimb86/32/26925_2.png) [@zimb86](https://discourse.nodered.org/u/zimb86)\
**Post date:** [6 August 2020 08:51 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/6 "2020-08-06T08:51:13Z")

</div>

Sure, I want to create a dashboard of all my room temperature sensors.  
So I have to modify flow.humidity to flow.humidity.werkstatt  
otherwise the incoming temperature values would all use the same variable?

![3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14f5f6d4c9b12339273d2060a0ee991eefffd18b.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 08:52 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/7 "2020-08-06T08:52:56Z")

</div>

> [@zimb86](#):
>
> In my understanding the problem using join is, that the values are only updated if both (temp/hum) are submitted.

If you set the message parts count in the Join node to 1 then you will get a message every time either of them arrives (but it will include the latest values of both. Alternatively if you want to wait initially for both but then get a message every time either of them appears again then set the parts count to 2 and select `and every subsequent message`.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 08:54 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/8 "2020-08-06T08:54:09Z")

</div>

> [@zimb86](#):
>
> I want to display these two values in one line Text on the Dashboard (xx °C / yy %)

It might be easier to use two text nodes side by side, or does that not work for you?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 August 2020 09:11 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/9 "2020-08-06T09:11:25Z")

</div>

Using a join you can do this, which copes with the differing sample rates.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d0cf07136bfa1c09f7f0e491769e5d9a8be0b917.png)

```auto
[{"id":"25720941.ac4676","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"temp","payload":"56","payloadType":"num","x":100,"y":1080,"wires":[["27050894.921978"]]},{"id":"ceb4d080.f0bd4","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"hum","payload":"45","payloadType":"num","x":100,"y":1160,"wires":[["27050894.921978"]]},{"id":"4951d89f.89625","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":1220,"wires":[]},{"id":"27050894.921978","type":"join","z":"bdd7be38.d3b55","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":350,"y":1140,"wires":[["d659d4f3.25077"]]},{"id":"d659d4f3.25077","type":"function","z":"bdd7be38.d3b55","name":"","func":"let temp = msg.payload.temp === undefined ? \"\" : msg.payload.temp\nlet hum = msg.payload.hum === undefined ? \"\" : msg.payload.hum\nmsg.payload = `${temp} C / ${hum} %`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":300,"y":1220,"wires":[["4951d89f.89625"]]}]

```

---

<div class="post-metadata">

**Author:** ![zimb86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zimb86/32/26925_2.png) [@zimb86](https://discourse.nodered.org/u/zimb86)\
**Post date:** [10 August 2020 07:24 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/10 "2020-08-10T07:24:04Z")

</div>

Thanks everyone, finally I used @Colin s example to get it work.

 ![5](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/3/83271e027a93276a1b97bcf6afecc4866f0733f2.png)  
 ![6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/4/34c03481d9933dcadf480ed11528daa8a6afb454.png)

---

<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:** [24 August 2020 07:24 UTC](https://discourse.nodered.org/t/display-two-payloads-in-one-text/31208/11 "2020-08-24T07:24:06Z")

</div>

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