Different formatting of numbers

Why is the format of those two values different?

image

‘Gesamtdistanz’ uses a dot to separate the thousands, whereas ‘Arbeitszeit’ uses a comma. Additionally, the unit of ‘Gesamtdistanz’ is separated by a space, whereas the unit of ‘Arbeitszeit’ is not.

There doesn’t seem to be a setting for this in the entities popup:

Does anyone know how I can unify these numbers?

I would suggest the first thing you do is check the values. Are you sure that ‘Gesamtdistanz’ is actually 1,183km and not 1,183m?

Not sure as it lacks details, what I read is 1183 kilometer with a dot for the thousands and 1,232 hour so a bit more than 1 hour…seems all fine to me with data given

The thing is the precision is set to 3 decimal places which is where it appears to be putting the decimal place and makes me believe your unit of measurement is actually wrong.

What is the value of ‘sensor.mower_distance_driven’ if you put it into the developer tools → states?

Thank you for your replies!

I double checked it and i can safely say that it’s indeed 1232 hours, and not 1,2 hours. I verified this by entering both entities in the template editor:

states("sensor.mower_total_worktime") -> 1235.28
states("sensor.mower_distance_driven") -> 1185.977

I also have never reset the sensor that counts the working time. This is why over 1000 hours is more realistic than 1,2 hours.

You can also see this in the screenshots I added, in which both values are displayed with a dot separating the thousands. The display precision is set to zero decimal places for both values.

Seems to be a front-end issue?

:rofl: I missed the mower part and 1183km is a bit much even when having a castle. So reverse the same applies, what is your country setting as I would not expect the comma to be used as a thousands separator in DACH

1 Like

The format displayed by the entities card will depend on the device_class and unit_of_measurement used for that entity. You can determine what these are by finding the entity in developer tools → states and either looking at the attributes column or clicking on the entity’s hyperlink and then scrolling to the top of the page. If you don’t see one or both properties listed, know that it is acceptable to leave them undefined.

If you’d like to quickly see how any combination of choices will affect the display on the dashboard, go to settings → devices and services → integrations → helpers → template → template a sensor. For the template enter {{ 1234.567 }} and then choose the device class and unit of measurement you are interested in. You can then scroll down to see a preview of how the frontend will display it.

Keep in mind that both device_class and unit_of_measurement are optional, so be sure to see how the value is displayed when one or neither are chosen.

Note that when you choose a device class of duration, depending on the number you used in the template and the units of measurement, it might show only hours (1232h) or it might show hours and minutes (350h 24m) or it could show days, etc. When you see it in that context, not having a space between the number and the units makes sense. Because 350 h 24 m looks bad. So I don’t believe that the lack of a space is a bug, I believe it was an intentional design choice.

If you always want it to show hours and not minutes or other nicely-formatted units of time, and you also want a space between the number and the unit, then just remove device_class altogether. Or use a different card that gives you more options or allows templates.

Regarding the comma issue, I’m not sure what is happening there. Perhaps that is a bug. It will be interesting to see what you find when you play around with various options in the template sensor preview.