WTH can't sensor values be rounded without templates?

I have so many templates only for rounding sensor values. Why do sensor entities have no option to set decimals? Advantages:

  • no annoying doublicates
  • less templates ( i do not like templates)
  • less recorder storage ( less decimals, less changes)

If we had limited votes, this would definitely get one from me.

Templates are powerful - but IMO, also over-relied on in HA. There must be a better way if the goal is to improve usability.

4 Likes

Lets keep the original idea simple so it has a chance of being actioned. If you can come up with specific examples please create your own WTH.

Dashboard entities could definitely do with a precision option. +1

5 Likes

This one feature would remove the need for around half of my templates :slight_smile: so a+1 from me

2 Likes

Thanks for this WTH. Now I don’t have to submit this one myself :smiley:

Definitely a vote

1 Like

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…

3 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?