Posts: 11
Joined: Sat Dec 06, 2014 3:59 pm

Node Red Function for Array (Javascript)

Tue Jul 25, 2017 3:57 pm


I'm experimenting around in node-red (graphical interface for IoT) and I am trying to use an SQL select statement inside of a function to return the maximum temperature present in a MySQL db table. The select function is working correct as my msg.payload debug node is displaying the result.
However, what I want to do is just display the number reset and not the whole object. I assume I need another function node but not exactly sure what to do.

Example: My debug node which is using msg.payload is displaying {"MAX":"99"}. What I really want the msg.payload to contain is just 99.

node-red.JPG (17.68 KiB) Viewed 3148 times
label.JPG (9.61 KiB) Viewed 3148 times
debug.JPG (23.03 KiB) Viewed 3148 times

User avatar
Posts: 4567
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Node Red Function for Array (Javascript)

Wed Jul 26, 2017 10:47 am

Change the "Value format" of the "text" node to

Code: Select all

{{ msg.payload["MIN"] }}

Return to “Java”

Who is online

Users browsing this forum: No registered users and 3 guests