Beginner: String(INT) global variable convert to number?

Hi!

First time trying Node-Red with the Weidmuller program.

I have a temperature sensor and I'm trying to get this to convert to $number but I don't understand at all how to go further. Checked forums, youtube etc.

My variable is currently a "Int" (string). I'm new with JavaScript aswell. Have MQTT Explorer connected.
Any good and easy explanation for a beginner?


gragr

Hi @r4sby, welcome to the forum.

At the right hand side of ther debug window are a couple of buttons "Copy path" and "Copy value"
image

If you click Copy path on the line containing your value [and paste it somewhere] you see that the value is at msg.payload.MEASURED_TEMP.value.

I'm not sure what your change node Jsonata expression is trying to do but it needs to work with the path just shown. This seems to work:

You could also convert it using a function node. This would be my approach because I dislike Jsonata syntax.

msg.payload = Number(msg.payload.MEASURED_TEMP.value);
return msg;
1 Like

Thank you for a quick reply and good information.

I found out that my variable had 2 outputs, first is "Array of process data",
Other output "Map of process data". First I used Map of process data, by misstake and figured it out :grinning:

I also did what you posted. Worked! :smile:

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