frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Value 0 shown as 0.0 or as 0.00

Open iz8mbw opened this issue 10 months ago • 5 comments

Checklist

  • [X] I have updated to the latest available Home Assistant version.
  • [X] I have cleared the cache of my browser.
  • [X] I have tried a different browser to see if it is related to my browser.
  • [ ] I have tried reproducing the issue in safe mode to rule out problems with unsupported custom resources.

Describe the issue you are experiencing

Hello. I have noticed that a value of 0 (zero) can be returned as 0 or 0.0 or 0.00 depending on the entity. So, depending on the entity, the quantity of zero decimals are shown.

image

Well, a 0 (zero) value should not have others 0 decimals, so shown 0.0 or 0.00 as 0.

Thanks.

Describe the behavior you expected

If/when a value is 0 I expect to see 0 without any decimals.

Steps to reproduce the issue

...

What version of Home Assistant Core has the issue?

2024.3.3

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Chrome 123

Which operating system are you using to run this browser?

Windows 10

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

iz8mbw avatar Apr 02 '24 13:04 iz8mbw

I would not use a custom card to demonstrate a possible issue. Suggest to post screenshots from Dev tools & with stack Entities card or more-info windows.

ildar170975 avatar Apr 02 '24 13:04 ildar170975

Here other screenshots, as we can see "0" or "0.0" is taken from the Entity value from Home Assistant itself.

0.0: image

image

0: image

image

Here I have created this below as TEST, as you can see some Entities show 0 and onther Entities show 0.0: image

iz8mbw avatar Apr 02 '24 14:04 iz8mbw

This is the intended behavior for numbers on the front end. If the raw entity state has zeros after the decimal, those are displayed in Lovelace cards,etc.

joshmcrty avatar Apr 17 '24 23:04 joshmcrty

What I can tell is if I reboot Home Assistant, when it starts I can read "0.0": image

Then I power-on this switch and I can read the Power: image

Then I power-off this switch and Power is now "0" and not more "0.0": image

I don't think the "intended behavior" is to show a different quantity of 0 as decimals when the value is simply 0.

iz8mbw avatar Apr 18 '24 09:04 iz8mbw

I should have clarified, this is the intended behavior for the frontend code. It doesn't make assumptions about how the raw data should be formatted or truncated, beyond user preference for decimal and thousands separator. Currency is a good example where dropping a trailing zero from $3.20 to $3.2 isn't a great default behavior. This issue of trailing zeroes has been brought up before and "fixed" to the current behavior.

See https://github.com/home-assistant/frontend/issues/7787. In the example you have provided with the Shelly switch, I think the integration itself may need to be updated so it is consistent with how it returns the raw state value when it is "zero." Or maybe a precision option needs to be added to the integration in core? https://www.home-assistant.io/blog/2023/03/01/release-20233/#sensor-display-precision

joshmcrty avatar Apr 18 '24 19:04 joshmcrty

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 17 '24 21:07 github-actions[bot]