Comparing payloads of MQTT-strings

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

The only data you have actually shown us is

{
"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.

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

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.

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]

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

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?

1 Like

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