WTH can't sensor values be rounded without templates?

Yeah I’ve came across the need to round values recently, on the dashboard though, as I’m a fan of precision.

Should maybe have an option in the card config as well as at entity level

2 Likes

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.

Unfortunately this is not going to happen. KNX sensor value_template by farmio · Pull Request #47734 · home-assistant/core · GitHub

For information, here the link to the same topic of WTH2020, 11th most voted topic:

2 Likes

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.

@aruffell … wondering if you can help me accomplish this

It’s coming :slight_smile: see State of the Open Home 2022 - YouTube at 1:00:00

3 Likes

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 :slight_smile:

Bild

Seconds year this has to come now.

The first PR appeared :slight_smile: Thank you Home Assistant Developers :partying_face:

6 Likes

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?

1 Like

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.

The same here. The digit rounding setting should be tied to the UI only to be useful.

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…

4 Likes

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?

It was announced on the 2023-2 release party that sensor precision was was pulled at the last minute and is being adjusted for next month…

3 Likes

Thank you. It can be heard by Franck here https://www.youtube.com/live/S3XRVsqRX9k?feature=share&t=6650

Looking forward to see it in action and see if it will affect Utility Meters. I don’t want daily costs like 0.88919999999954500 € or Gauge Cards like:
image

Ya, here’s a new sensor group entity. Not Ideal. I would have pulled that into a template sensor to ‘fix’ it, but I’ll deal for a month…


(And yes, my humidifer is not keeping up… :persevere: }

2 Likes

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.

1 Like

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.

1 Like