I have a sensor which returns a NUMBER (not string). How can I ensure that is displayed with e.g. 2 fixed decimals in a gauge card?
Example:
template:
- sensor:
- name: "Solar Accounting Total Daily"
unique_id: solar_accounting_total_daily
device_class: monetary
unit_of_measurement: "EUR"
state: >
{{ ( ... | float(0)) | round(2) }}
Alternative:
state: >
{{ '%0.2f' | format( ... | float(0)) }}
With both ways the sensor apparently returns a NUMBER (not string) - which is actually what I want. But with that, 1.00 becomes 1 and 1.20 becomes 1.2. Only 1.23 stays the same. In consequence, when I put this sensor into a gauge card the trailing 0s are also gone. What I am actually after is a way to tell the gauge card that it should always display the monetary number with 2 fixed decimals, e.g. 1,00 €.
If this is not possible, what other options do I have?