Extract values from a mqtt payload (json) object

1,916 views
Skip to first unread message

Bert Tammer

unread,
Mar 4, 2018, 2:35:18 PM3/4/18
to Node-RED
Hi all,
I am trying to get myselve familair with node-RED. I have several sensors which i would like to present on my dashboard.
This is the flow i am trying:


This is the output fron the JSON node.

The Switch node looks like this:
can help me
But unfortunately it does not work. I see no debug info in the next step or on the dashboard.
These sensors are part of Sonoff TH16 switches. The switch part is working perfectly.

Unfortunately i am not a programmer... But i hope someone can help me.
Kind regards, Bert

Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3

Colin Law

unread,
Mar 4, 2018, 3:22:30 PM3/4/18
to node...@googlegroups.com
Instead of a Switch node I think you need two Change nodes both looking at the output from mqtt. One of which Moves msg.payload.SI1721.Temperature to msg.payload and the other the same but Humidity.

Colin



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/d664f1ab-7e54-41f2-90e1-727be92cdb61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bert Tammer

unread,
Mar 5, 2018, 2:54:41 AM3/5/18
to Node-RED
Hi Colin,
Thank you for your reaction.
I am trying to us the change node now. But unfortunately not succesful.
This is the flow right now:

But lets concentrate on Temperature alone.
Here are the cfgs of the change nodes:
  



Op zondag 4 maart 2018 21:22:30 UTC+1 schreef Colin Law:
Instead of a Switch node I think you need two Change nodes both looking at the output from mqtt. One of which Moves msg.payload.SI1721.Temperature to msg.payload and the other the same but Humidity.

Colin
On 4 March 2018 at 19:35, Bert Tammer <btam...@gmail.com> wrote:
Hi all,
I am trying to get myselve familair with node-RED. I have several sensors which i would like to present on my dashboard.
This is the flow i am trying:


This is the output fron the JSON node.

The Switch node looks like this:
can help me
But unfortunately it does not work. I see no debug info in the next step or on the dashboard.
These sensors are part of Sonoff TH16 switches. The switch part is working perfectly.

Unfortunately i am not a programmer... But i hope someone can help me.
Kind regards, Bert


--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3

Bert Tammer

unread,
Mar 5, 2018, 3:09:54 AM3/5/18
to Node-RED
Unfortunately i do not see anything in the debug after the change nodes...
I try to get the right info from: https://nodered.org/docs/user-guide/messages#understanding-the-structure-of-a-message
Not sure what i do wrong, but it must be something silly...

Op maandag 5 maart 2018 08:54:41 UTC+1 schreef Bert Tammer:

Colin Law

unread,
Mar 5, 2018, 3:34:34 AM3/5/18
to node...@googlegroups.com
If you look back at my suggestion you will see I said "Move msg.payload.SI1721.Temperature to msg.payload". You have done Set msg.payload.SI1721.Temperature to msg.payload which is Set instead of Move and it is the wrong way round, you want the contents of msg.payload.S..Temperature moved into msg.payload, from where the dashboard node will pick it up.  The search doesn't work because it searches for values in attributes, not attribute names.

Colin

To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Bert Tammer

unread,
Mar 5, 2018, 4:07:05 AM3/5/18
to Node-RED
This is the Debug outpot  i get from the Change nodes for temperature:

As you see, it is the same as the output from the json node...

Op zondag 4 maart 2018 20:35:18 UTC+1 schreef Bert Tammer:
Auto Generated Inline Image 1

Colin Law

unread,
Mar 5, 2018, 4:14:30 AM3/5/18
to node...@googlegroups.com
I that with the change node as I have suggested?  Show us the config for that.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages