Set Switch: Easy Question

but not for me :slight_smile:

Hi there,

i would like a build a Switch Node with the Payload Data from mqtt input.

grafik

If payload Data AAA4178400C8XXXXXX then Switch output 1.

Thanks for help!

Your payload is still a JSON string, make sure you convert it to an object using either the JSON node or by setting the MQTT input node to parse JSON.

Hi,
thanks for reply..

something like that?

grafik

grafik

But this node is not function:

what did i do wrong?

Yes although in your switch you will need msg.payload.RfRaw.Data

this not function :frowning:

The debug node (msg) is empty...

Try payload.RfRaw.Data

Yup typo on my end.

You should use the copy button in the debug window - no more typos.

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

https://nodered.org/docs/user-guide/messages

Typo was on my side not his (in my reply)

grafik

I had already tried. does not work either :frowning:

is this right???

grafik

Sorry. My mistake. Still true for the OP though :slight_smile:

That does look ok

Is it possible there's a newline at the end of your incoming string ? Can you try to replace == by contains ?

no :frowning:

I do not understand that...

I thought I understood that :slight_smile:

Lol - I'll summarise...

Just hover the debug item and use the copy path button - helps you get the path to the item of interest without any mistakes. Then you just paste it into the change or switch node. No fuss no muss.

Alternatively to the approach of adding a JSON node behind an MQTT-in, you could also edit in the MQTT node that it should give output as parsed JSON, if you do that you can skip the json node.

Do I have. the path is correct :frowning:

there is a good tip, thanks. you don't need an additional JSON node. But unfortunately the result is the same :frowning: