I have a sensor that displays correctly as a plain number (e.g. 2312) when I check it in Developer Tools → States.
But when I use it in a card (specifically custom:gauge-card-pro, custom:modern-circular-gauge), it shows up as 2,312 with a comma as the thousands separator.
I already tried the following without any effect:
Converting the value to a string in various ways
Creating a second template sensor without device_class: power and without unit_of_measurement (so it should be treated as plain text)
Setting thousands_separator: “” (empty string) directly in the gauge-card-pro configuration
decimals: 0 is already set
The only thing that removes the comma is changing the number format manually in my user profile: Profile → General → Number format → (switch away from the locale that uses comma as thousands separator)
Is there any other solution that applies only to this sensor/card — without forcing me to change the number format globally for my entire user profile?
I would prefer not to affect how all other numbers (like energy totals, temperatures, etc.) are displayed across the dashboard.
It shows a RAW presentation - not formatted according to your settings and this entity’s accuracy settings.
Not using these cards, but some custom cards may not use standard HA functions to compose a properly formatted value, instead these cards use own formatting.
Usually it is supposed to have SAME presentation of a value in all cards. None of stock cards have a way to customize a presentation for this particular card only. Only some custom cards support this - but they may not support showing a default presentation as was said above.
In case of using a stock card - perhaps creating a template sensor with a different precision settings could be a way. As for different format settings like “use comma instead of dot” - similar, you will have to create a template sensor with altered content (keep in mind that states are always strings). As for custom cards - it’s a different story since all custom cards are different.
Converting to int will cause removing a possible fractional part (without rounding). Result will be a string.
Rounding and removing a fractional part, then unneeded conversion to int, then unneeded conversion to string.
What is your final goal? If you need to create a value equal to a difference of other sensors - you need to create a template sensor, this is correct.
If you need to get rid of fractional part - round(0) will be enough.