Most likely there are arguments for both the backend and the frontend. I have for example various light and humidity sensors (eg. 45553.56lx or 54.54%) where backend would make more sense, as the decimals are absolutely useless.
Sidenote:
In my case allowing value templates for knx and modbus would do the backend job as well.
I have lots of battery sensors and it drives me up the wall that some have a decimal and some don’t. I’d love to get rid of all decimals as it really doesn’t add any value on a battery percentage. There is at least one card that allows changing the “precision” (as it is called in the card) - meaning the number of decimals, but I believe it should be native functionality.
That’s great news. That will hopefully finally make my GUI more readable. Too much useless precision kills readability sometimes. Played around with CSS a lot, no chance. Looking forward to see this arriving
That’s nice, but it looks like that’s happening at the sensor level, so you’ll have to toss away the extra digits when the data comes in (if I understand the code correctly).
I really want to keep the extra precision on the backend for later analysis and calculations.
It must just be a difference in style or something but personally as a developer, I would never have even thought of rounding the numbers anywhere but within the frontend at the time of display. Not sure why the HA devs seem opposed to rounding on the frontend?
I just found this. It seems like it’s going to be a pretty good workaround, at least for the entities card. Hopefully I can find something similar for gauges.
Rounding will be supported with 2023.2. Thank you very much, I already did beta testing and it works perfectly. It can be defined on both integration and entitiy level, but I think this approach is fine. All my templates could be removed!
Edit: It had been removed in the last second, what a pity… Hopefully next month…
Sorry for the maybe “dumb” question, but how can I do the check in an integration code if HA 2023.2 is installed and hence do not round the value only in that case?
EDIT: I mean, how to check that HA is newer enough to support the native_precision property, otherwise return the custom-rounded string?
I hope this makes is to 2023.3 because I have a few current sensors monitoring power consumption of big appliances like heatpump, oven, stoves and such, and while on stand by the decimal point is fluctuating (say, between 6.2 and 6.5w).
That causes an unnecessary stress on the log and the database, saving a new value every few seconds, while for me that level of precession on an appliance that over the course of a day consumes 8kwh makes no difference. I believe this will help reduce database stress significantly.
It’s in the 2023.3 beta if you want to try it (very stable). Please keep discussion of the beta release to the beta channel of the Home Assistant Discord though.