Replace decimal point with comma not working

Hi,

I wanted to replace a decimal point with a comma because the values are shown with a decimal-comma instead of a point.

18,20°C instead of 18.20°C

I tried:
{{(states("sensor.temperatur_vorrat"))| regex_replace(find=".", replace=",")}}

but all the digits are replaced with the “,” , the output is “,” instead of “18,2”

any ideas?

Spartacus

If this is a global issue, instead of changing it per entity there is a setting in your profile for this:

If it is only one sensor with the wrong radix format then try this:

{{ (states("sensor.temperatur_vorrat"))|replace('.',',') }}
2 Likes

That literally means “replace every character” as . means “any character”.

To use this function, you need to use \. to represent a dot.

Note that decimal commas will not work in template calculations: they will not be recognised as numbers.

Hi,

thanks for reply. The Global settings are ok, but if I use a markdown card, the values are shown with the ." insead of the comma.

An I guess I have to replace it for all my values…but your solution works fine!
{{ (states("sensor.temperatur_hobby"))|float|replace('.',',') }}

Ok, thanks, I understand! I’m not very familiar with regex! :grinning:

You could open a new frontend issue for that:

The card should respect your profile setting.

Hi,

thanks for the hint, I will do this, but if you can see, it is ignored in the card.

Moin,

it seems to be not a bug in the markdown and I have to correct it manually!

Markdown Card doesn´t support global settings for country-specific number format · Issue #19795 · home-assistant/frontend (github.com)

Does your browser / PC regional setting affect it?

Browser is ok. Values are correct in different cards, as you can see attached, only markdown has an issue. But I can replace it, with the regex and then it is ok!