I think understand your question. I think you want to round up and not use standard rounding.
To make this easier for others to understand: use “</>” button to format your code.
Change the ‘will’ to ‘want’ if that is what you mean, it took me awhile to interpret what I think you meant.
Filter round(x) will convert the input to a number and round it to x decimals. Round has four modes and the default mode (with no mode specified) will round-to-even.
round(x, "floor") will always round down to x decimals
round(x, "ceil") will always round up to x decimals
round(1, "half") will always round to the nearest .5 value. x should be 1 for this mode
FWIW, it’s effectively koying’s suggested formula but also employs the format statement to ensure the result always has two decimal places (like 12.40 instead of 12.4).
Sorry I’m not a programmer… but I didn’t understand why on template editor is correct with result 1.30 and the same “value_template” applied to the sensor template show me 1.3.
I think this may be caused by Home Assistant’s ‘native typing’ feature. In brief, it examined the value 1.30 and determined it looks like a floating point number so it stored it as 1.3 because that’s the equivalent of 1.30 or even 1.300, etc.
Unfortunately, in this case, the conversion ruins our effort to present the value in the desired format. The conversion to 1.3 wouldn’t be a problem if there was a way for a Lovelace card, such as the Entities Card, to present the value as 1.30 but, as explained by koying, this is not currently possible.
There’s one workaround that you might consider to be acceptable: use a Markdown Card because it supports the use of a template and displays the template’s result verbatim.
Here’s an example where the sensor’s value is 22 but the Markdown Card allows me to display it as 22.00.
HI @123 thanks a lot for the explanation and thanks for the help.
I hope in the future will be created “device_class” with currency option, just to show 2 decimal in home hassistant.
If you found the workaround useful (Markdown Card), please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. It will also place a link below your first post that leads to the solution post. All of this helps users find answers to similar questions.