Quick one and deffo suffering a brain freeze.
I need this line to limit the number of digits after the decimal point.
var mph = parseFloat (wind) * 0.44704;
I've used the syntax somewhere else in my flows, but after 10 mins still can't find it...
I will one day tidy up my many many tabs of flows...
TIA
var mph = parseFloat (wind) * 0.44704;
mph = Math.round(mph*100)/100; // number
or use
mph = mph.toFixed(2); // string
What are you doing that requires you to throw away accuracy like this? Usually it is best to delay rounding until you are, for example, displaying it. Many dashboard nodes allow you to do that at the moment of display.
Hi, it's being fed into Home Assistant. It comes in as a M/S wind speed without decimal places, using the multiplication results in 8 digits after the decimal where two will be enough for what it's used for
I used this one, seems easier to understand.
Many thanks.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.