RegEx in function-node

@Ropper I think you will also have to replace the comma in order for parseFloat to work correctly

var payload = msg.payload.toString();
payload = payload.split("=")[1];
msg.payload = parseFloat(payload.replace(",", "."));
return msg;

You could change your remote command from
vcgencmd measure_temp
to
vcgencmd measure_temp | cut -d "=" -f 2
which hopefully returns 53.0'C
or
vcgencmd measure_temp | cut -d "=" -f 2 | cut -d "'" -f 1 # -d doublequote singlequote doublequote
53.0

Not sure how you would pass those quotes over though, might need to escape them.
Edit - you don't need to wrap -d = in quotes but you do need the quotes for -d "'"

Thanks Steve - Probably not a topic question but anyhows - how do I remove the decimal in the temp (send the msg as 2-digit value?

you can use parseInt() instead of parseFloat() .. that will return an integer without the decimal
and rounded down so 51.7 would become 51.

If you want more "accuracy" you can also use Math.round() which rounds to the closest whole number
Math.round(51.7) will result to 52

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