I need help converting load average statistics (which are available as attributes on a sensor) to percentages.
those 3 load averages are:
1 minute load
5 minute load
15 minute load
which return different CPU values every second.
a 1 load means a load of 25 percent of the system.
a 2 load 50%, 3 load 75% and 4 load 100%.
What I want to achieve is that it gives the precise percentage and not just 25, 50, 75 or 100%.
so when the load number is 0,84 it must give me a percentage of 14% for instance.
You can also set this up via the UI: just put the {{ ... }} bit in the template field.
Notes:
Attributes can be numbers, whereas states are always strings. If you were using a state value in a template like this, you’d need to convert it with |float.
I’ve not included any rounding in this. You can do that in the front end; or you could do it in the template using |int for integers or |round(2) for two decimal places. So {{ (...)|int }} with the brackets so you’re not just doing it to the 25.