In the widget code you have access to the js Math object and Number object. This gives you several different choices here. The easiest is probably just to parse the state string directly into an integer:
That will always just truncate the string at the the decimal point (i.e., even 3.999 will become 3). If you would prefer actual up and down rounding of the number then you can use:
I am struggling with the same issue. I have a temperature setpoint widget in which I would like to set setpoint with one decimal precision. The following code tend to generate large decimal numbers. Could you please help me to round it to one decimal precision?
It is not a full JS implementation. It is just an js-like expression parser. This means there are a lot of things you can’t do, but many of the base js methods are available to you.