Spartacus
(Spartacus)
February 13, 2024, 10:01pm
1
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
tom_l
February 13, 2024, 10:06pm
2
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
Troon
(Troon)
February 13, 2024, 10:28pm
3
Spartacus:
regex_replace(find="."
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.
Spartacus
(Spartacus)
February 13, 2024, 10:39pm
4
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('.',',') }}
Spartacus
(Spartacus)
February 13, 2024, 10:40pm
5
Ok, thanks, I understand! I’m not very familiar with regex!
tom_l
February 13, 2024, 10:43pm
6
You could open a new frontend issue for that:
The card should respect your profile setting.
Spartacus
(Spartacus)
February 14, 2024, 7:27am
7
Hi,
thanks for the hint, I will do this, but if you can see, it is ignored in the card.
Spartacus
(Spartacus)
February 14, 2024, 4:02pm
8
tom_l
February 14, 2024, 8:22pm
9
Does your browser / PC regional setting affect it?
Spartacus
(Spartacus)
February 14, 2024, 10:13pm
10
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!