Get number from output mysql

I am creating the clock part for my roomthermostat. I have a database with times and temp's.
I have a flow where a mysql query gives back one row with the temp that should be sent to the thermostat at a certain time. This comes out of the mysql block:

array[1]
0: object
tk_temp: "19.8"

I fed that through a json node as proposed in an other thread but then I have this:

"[{"tk_temp":"19.8"}]"

How do I get the 19.8 out there so I can feed that value in a mqtt-out that sets my roomthermostat (I know how to do that).
Java is not my strongest point... :blush:
-Warner-

Hi.

You have fed an object into JSON node and it has turned it into a string.

Delete that and simply access the properties of the array mysql returns.

Read the documentation on working with messages, it shows you how to inspect objects in the debug window (even tells you if the payload is a string or object etc). Better still, it tells you how to select an item of interest and copy it's path.

I promise if you absorb that info, you won't find yourself asking questions like this.

Nor mine. Luckily this is JavaScript (huge difference :slight_smile: )

I found the solution.
With a Change node: set msg.payload to msg.payload[0].tk_temp
Now for the next challenge... (graphs...)

1 Like

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