I would like to adjust the decimal places of a value from a temperature sensor. The sensor delivers a payload with e.g. 22.68, the last digit should be omitted and rounded, so in this case a new payload of 22.7 should be output. This should be feasible via a function node, unfortunately everything I have found and tried so far has not worked. Unfortunately I do not know anything about programming. What should I put in the function?
You can do that with either a function node or a change node (with JSONata). Usually the output will be a string rather than a number however. Probably fine if you are simply displaying it.
have found a workarround with the calculate node:
multiply wirh 1 and round with one decimals
msg.payload = Math.round(msg.payload *10)/10
Presuming msg.payload is a number.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.