Rounding in Template - sometimes wrong

Hi,

i have a problem with my template (sensor.yaml).
There is a calculatet value with “0.196” and i wanted to see “0.20 €” in my Dashboard.
So i make a rounding with 2 but if it is a zero in there its only be shown 0.2 € instead of 0.20 €.

{% set JP_Euro = { "cost": 12.196, "unit": "€" } %}
{{ JP_Euro.cost | round(2) }} €
{{ JP_Euro.cost | round(3) }} €

I tried also the format command:

{{ "%.2f" | format (states('sensor.bad_verbrauch_monat') | float * states('sensor.energy_cost') | float) }}

The same problem, but only in the dashboard. In the template Editor it works !
Can someone help ?


{% set b = 0.20 %}
{{'%0.2f'| format(b|float(0))}}€

computes 0.20€ (at least in a Markdown Card). Maybe you give it a try.