WTH can't sensor values be rounded without templates?

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

Yup, I saw that. But it was in 2023.2 beta too and it was removed last minute, so I hope this time it has been nailed.

1 Like

Finally implemented in 2023.3, thank you Home Assistant. Values are no more rounded in the core.

With custom cards I’ve found that I need to use a template to apply the rounding, but otherwise works great - e.g.

'{{ states("sensor.name", rounded=True) }}'

This is awesome progress. Would be great if it could be expanded to move the decimal place too.

Currently, every Tuya device I have requires a template as the raw power data is right but overstated, HA sees it as watts. So I need to do the following for each device.

bedroom_powerpoint_north:
        friendly_name: 'Bedroom - Powerpoint_power_north_w'
        unit_of_measurement: 'W'
        device_class: 'power'
        value_template: '{{(states.sensor.bedroom_north_power_point_power.state | float / 10 | round(1) )}}'

The Tuya API is garbage. Avoid their devices.

1 Like

The rounding feature in HA does not work when showing the sensor as a layer in the custom button card, just saying… it still shows decimals

That’s because custom button card hasn’t implemented that functionality, just saying.

1 Like

Really? This cannot be inherited? Interesting. Thanks for saving me time dealing with the problem.

It can be inherited, custom button card hasn’t done that. Custom button card hasn’t had a maintainer for almost 2 years now.

Thanks for this; I’m going to try it out. Completely with you—as a developer, there’s no way I’m rounding a number’s stored value on the backend, unless for some reason rounded ones are desired for calculations.

Edit: Actually it’s now supported to do just on the presentation layer? Not much usage information available from what I’ve found so far. The number of decimals used when displaying a sensor state is now configurable | Home Assistant Developer Docs