2025.7: That's the question

Just add unique_id (restart not reload) and manage the precision in the frontend. It’ll default to 2.

You don’t need to round in the template.

1 Like

Thanks!
Now i do get one decimal precision, but, interestingly now all is kind of “odd”: default is still with zero decimals, it’s just that value is displayed with one decimal.
Just to eliminate old manual settings i created a new sensor (baterija_6) which shows:


which is correct, but this shows a different situation:

but exactly that can be a problem with big count of sensors… on each one i have to

  • find it
  • click on it
  • click gear icon
  • change decimals
  • click save
    This will take weeks…

You only need to do that if the default 2 isn’t want you want. IIRC, the default is based on device class too. So in many cases, you don’t need to alter anything.

The looks like its working right ? You’ve added 1 decimal place to the template and then changed to 0 decimal places in the UI ?

which is exactly my problem… most of my template sensors are temperatures, voltages… at all of them one decimal is enough… that’s why i’d like to set that inside template sensor.

How about trying it and seeing what the default is before passing judgement.

Nope, that was by default. I didn’t change anyting except parentheses, as you suggested.

Change it to 1 decimal place in the UI

As you suggested i created another sensor, same as others, but without round(1). I restarted HA and this came up:


so again not correct. It’s not on two decimals, but zero.

that’s the same as i’d have 12 decimals. As i said i’d like to avoid to do that on hundreds of sensors one-by-one and solve it the way it should be - at the source.

You’re still looking at the under the hood value…

Look at the state in the UI.

Also, I have no idea what field is precision on that page.

I.e. here’s the under the hood for temperature:

But in the UI, it defaults to 1 sig fig without altering anything.

same there, this is shown without any changes made in UI:

Ok, then change it to whatever you want. It appears as if the default for V device_class is 0 sig figs.

Indeed, I just created a template sensor and as soon as I added the voltage device class it went to 0 decimal places, but you can change it in the UI to 1

Correct! If i remove device_class and leave empty then it reverts to 12 decimals. I did have to change aaaal my batteries from zero to 1 decimal not long ago, yes.

So, basically, what you’re saying is that there is no way to solve this but changing one-by-one ? Which will, as said, take hours… It’s very odd that there’s no general solution to this? I’d say that round in base config (which, in this case is template) is the main fact, but obviously it isn’t?

EDIT: is there any device class list with default decimals?

How many volt device classe entities do you have?

well… i have around 30 battery-based devices (a bunch of thermometers, some battery-based esp’s, some tuya battery sensors…), three UPS devices (3-4 batteries each) where i monitor batteries, then a bunch (20+) of temperature sensors where i also need only one decimal… it come up to hundred to correct, i’d say.
Sure, it’s not a problem from now on, i know what to do, the problem are old entities…

i was too late above with my question… is there any device class list with default decimals? perhaps i could “trick” ha with set appropriate class?

Temp sensors default to 1, so no you wont’ have to modify those.

Again, I suggest you add unique_id to the template entities that need (restart, not reload) them and then see how many you actually have to alter. I’d wager the actual number is low.

1 Like

OK, thank god for that. I didn’t come to those yet…
so, to sum up: there’s no other way than manual correction. Or, should we say: since unitl now HA wasn’t “as it should be” regardin gdecimals we were making our sensors “wrong” (or sloppy) and now we’re paying the price… correct?

(btw…many thanks for your patience and help!)

The entity_registry is the only way to update display_precision, but if you’re comfortable with a little javascript you can batch update entity_registry for multiple entities in the browser console, if you really have hundreds of entities that need to update.

I posted an example here: https://github.com/home-assistant/core/issues/146873#issuecomment-2981139609