Rounding temperature values

The math or the Jinja2?
In Jinja2,

{% is surrounding regular code
{{ is the return of the code
| float will ensure that you convert the state into a float number
| round(0) will remove everything after the decimal point

In HA
states.sensor is all sensors states, then it is yours that we pick.

The math behind is up-to-you but think about it with your exemples and one of mine

23.3 -> 46.6 -> 46 -> 23
4.69 -> 9.38 -> 9 -> 4.5
12.2 -> 24.4 -> 24 -> 12
1.6 -> 3.2 -> 3 -> 1.5

In the last exemple, 1.6 multiplied by 2 will get over 3 that will lead to 1.5 as the final result
On the other hand, 1.4 doesn’t, it will be 2.8 that will later become 2 and then 1. You got the idea, right?

1 Like