# Comparing payloads of MQTT-strings

**URL:** <https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538>\
**Category:** General\
**Created:** [13 August 2023 17:27 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538 "2023-08-13T17:27:15Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![Werner](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@Werner](https://discourse.nodered.org/u/Werner)\
**Post date:** [14 August 2023 14:57 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/21 "2023-08-14T14:57:05Z")

</div>

correct. I will see the payloads in the status node. but more important is to AND or OR the payloads.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [14 August 2023 20:18 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/22 "2023-08-14T20:18:54Z")

</div>

The only data you have actually shown us is

```auto
{
"topic":"innen/WZ_Luftmonitor",
"payload":25.65,
"battery":0,
"humidity":63.11,
"linkquality":126,
"temperature":25.65,
"voc":85,
"voltage":2800,
[plus some system generated properties]
}

```

It seems probable that there is no such msg property as msg.payload["innen/WZ\_Luftmonitor/temperature"] (hence it shows as undefined), nor indeed is there a msg.payload.temperature or msg.payload.Temperature.  
There is however a msg.temperature.

I think you may be confused about the way Node-red handles messages and the role of the Mqtt topic.

Most nodes only know about a single message at any one time.  
You can not refer back to the temperature from an earlier message with msg.payload["innen/WZ\_Luftmonitor/temperature"] (perhaps this construction comes from your attempt to use a join node?)

The links that @Steve-Mcl posted explain message structure and joining messages

If you show us examples of the data coming in on each mqtt node and the output that you want to generate from it, perhaps someone can show you how to achieve it.

---

<div class="post-metadata">

**Author:** ![Werner](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@Werner](https://discourse.nodered.org/u/Werner)\
**Post date:** [15 August 2023 10:48 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/23 "2023-08-15T10:48:12Z")

</div>

Hi jbudd, the 'temperature' was included in the 'mqtt json'-node's property. Now, I made it new, using standard mqtt-in nodes:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c6e76841c2ab6865aed1c4990101849b080faea9.png)

I am happy not having the change-nodes anymore. All three inputs have correct values (node.warn). There is no error message in the debug-node. But neither AND-function and the node.status are not working.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 August 2023 11:00 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/24 "2023-08-15T11:00:01Z")

</div>

In your `node.status` call, why are you using the variables with msg.payload?

You have already extracted the values from the payload into the v1 v2 and v3 variables.

Just use `v1` instead of `msg.payload[v1]`

---

<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:** [15 August 2023 11:09 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/25 "2023-08-15T11:09:13Z")

</div>

Also for the `if` statement. It should be  
`if ( v3 > 50000 && v2 >= 21 ... )`

---

<div class="post-metadata">

**Author:** ![Werner](https://avatars.discourse-cdn.com/v4/letter/w/f4b2a3/32.png) [@Werner](https://discourse.nodered.org/u/Werner)\
**Post date:** [15 August 2023 11:19 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/26 "2023-08-15T11:19:47Z")

</div>

Thanks to you all, my flow is now exactly perfect! Sorry for my stupid approach, but I learnt a lot yesterday and today! Final question: when editing the function node, I still have the 'old' JavaScript-editor. Where is Monaco?

---

<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:** [29 August 2023 11:20 UTC](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538/27 "2023-08-29T11:20:10Z")

</div>

Closed on 29 August 2023 11:20 UTC

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

[Previous page](https://discourse.nodered.org/t/comparing-payloads-of-mqtt-strings/80538.md?page=1)
