Template with number shows incorrect format in frontend (with a comma)

is it since 118 that this template

{{state_attr('sensor.laundry_sensor_light_level','lightlevel')}}

which is a number with value ‘6551’:

now shows in the frontend with a comma ‘6,551’:

in entities card:


(sorry, new screenshot with different value but the issue remains clear…)

and more-info:

the comma is a true error, and shouldn’t be there. Is this a backend template issue, or a frontend bug. We simply need the actual value, not some formatting of that if that’s what’s happening)

using an template-entity-row card does show the correct format:

with code:

      include:
        - entity_id: '*_sensor_light_level'
          options:
            type: custom:template-entity-row
            name: >
              {{state_attr(config.entity,'friendly_name').split(' sensor light level')[0]}}
            state: >
              {{state_attr(config.entity,'lightlevel')}} lm.  # <-------

Why not? That’s how long numbers are supposed to look :man_shrugging:

well, no. 6000 should look like 6000. and not like 6,000.

A comma is used for the decimals not for indicating a thousand number. At least not in my language setting.

How would ‘6000,50’ look like using that notation. as in six thousand and a half

6,000.50 . Same as always. :man_shrugging:

If it’s the other way round in your locale, maybe your browser locale settings are incorrect?

Edit - just to clarify…

One million = 1,000,000

Four and a half = 4.5

Three thousand, four hundred and twenty-two and three-quarters = 3,422.75

When you look at how the last one is written in words, you can see where the comma comes from in the representation in numbers. The ‘.75’ would be said here as ‘point seven five’ (as in decimal point).

It’s the Profile Language setting that determines the decimal and thousands separators.

1 Like

if anything, this is new to 118? The numbers have always been displayed without this formatting.

at least not on this side, even though my profile language is in English and has always been like that.

(with ‘my language setting’ as referenced a few posts above I didn’t mean the HA setting (which is in English), but my native speaking/writing language (Dutch) …)

understand. apparently not system wide, given the screen I posted

So are you telling me the format of the more-info, which shows the actual values of the sensor, can’t be shown in the Frontend, as is?

I’m saying that decimal and thousand separators were introduced in 0.118, this setting is based on your language preference in your profile.

Apparently not all cards support it yet and there has been a bit of blowback that has so far been ignored.

Personally I like it. Makes numbers more readable.

1 Like

thanks, Ive added to that.

it was closed rather abruptly though, even while many users are responding.

in my specific setting, comparing light level with lx sensors, it doesnt make the comparison clearer at all.

hope we can get an option to format or not, at least for the separator

I agree, I find long numbers much easier to read when they’re ‘properly’ formatted.

I guess it shows my ignorance a little though that I didn’t realise other locales did format numbers differently. I suppose because when you program stuff the language is always done in American English, so it’s only really the spelling of colour that’s different, but a float or a double is always represented with a decimal point (full stop) so I never considered it past that point, and even then when your formatting things for display you do something like format(output, Locale.getLocale) and just presume that it will turn out right (like displaying right-to-left where appropriate, or putting mm/dd/yy for Americans and dd/mm/yy for normal people :wink: )

So yeah, I guess they didn’t quite get something right here, but it definitely looks better to me.

haha, yes we’re not normal :wink:

thank goodness we’re still living in the year 2020, and not 2.020…

1 Like

Interesting you should use this example, because it’s the exact issue I’m currently running in to…

(using Discogs integration, numbers showing up as ‘1,997’ for a currently playing album released in 1997, etc…) :rage: but yeah, let’s display years in this home automation system with commas in them, that makes perfect sense. :roll_eyes:

Please open an issue for that here: