thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

Formatting Numbers #115

Closed marcolino7 closed 7 months ago

marcolino7 commented 7 months ago

Hi, I use this plugin to templating some numbers. I am in Italy so we use comma as decimal separator and dot as thousand separator. image As you can see in screenshoot, the red rounded line is templated, comma separator il wrong and thousand separator missing. All other values that are not templated, are fine. Here is template I use: {{ state_attr('sensor.consumo_caldaia', 'last_period') | float }} Wh

Thanks in Advance Marco

ildar170975 commented 7 months ago

{{ state_attr('sensor.consumo_caldaia', 'last_period') | float }} Wh

Could you test this template in Dev tools -> Template? I observe SAME output for all defined number formats.

image

Seems this is a common issue with templates in HA. The number is stored in DB as a string with a "point" separator (seems to be); only Frontend shows converted values dependingly on user settings. But templates give us data "as is". Check the Markdown card too - it shows "raw" data too:

image In short - this is not a bug. This happens because we show data "as is" and do not apply a filter "convert_to_local_settings" (because there is no such a filter in Templating exposed to users).

marcolino7 commented 7 months ago

Hi, image you are right. I will ask to HA community.

Thanks

marcolino7 commented 7 months ago

Hi, for who have my issue, here is a fancy solution:

https://community.home-assistant.io/t/decimal-and-thousand-separator-are-not-honored-in-templating/640567