frontend icon indicating copy to clipboard operation
frontend copied to clipboard

An integer value in a helper is converted to a float

Open WRoss7 opened this issue 4 years ago β€’ 16 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.

Describe the issue you are experiencing

I created an input_number helper with values from 1 to 7 whose unit of measure is days...

Helpers

...but in the card the value is converted to float

Card

Describe the behavior you expected

IMO the values created in the helpers should reflect the values in the cards: so only if there are float values in the helper, they will be displayed as such in the card

Steps to reproduce the issue

...

What version of Home Assistant Core has the issue?

core-2021.5.5

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Chrome and Firefox: the latest versions

Which operating system are you using to run this browser?

Windows 10, Android 11, Android Companion App

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

WRoss7 avatar May 21 '21 21:05 WRoss7

If you check the backend state of the helper (e.g. via the HA dev tools) you will see, that the actual backend value is a float, so the frontend is displaying the correct value in the card.

spacegaier avatar May 22 '21 19:05 spacegaier

Hi spacegaier, correct, let me explain better. What I mean is that for a few weeks a value of a helper has been displayed to me as a float, and it is not the best of life to see 7.0 days: it seems that all integer values ​​are rendered as floats. By heart, the "bug" came out of the introduction of the number format choice # 8811

Timer

Float

WRoss7 avatar May 26 '21 19:05 WRoss7

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 Aug 24 '21 19:08 github-actions[bot]

@matthiasdebaat what do you think? it doesn't seem very nice to see entities with labels like "7.0 days"

WRoss7 avatar Aug 24 '21 20:08 WRoss7

Timer

If I understand you correctly, you want a 7 instead of 7,0? Can an input_number work with decimals? In that case I agree that it would be nicer to remove the decimal.

matthiasdebaat avatar Aug 25 '21 09:08 matthiasdebaat

If I understand you correctly, you want a 7 instead of 7,0?

That's just what I mean

Can an input_number work with decimals?

I don't think so, but I'm just a user here. maybe @spacegaier can answer.

I can only suggest truncating the decimals if they have a zero value, or more elegantly adding a checkbox to allow the user to force the value to integer. In both cases, no complexity would be introduced to the code, but the UI would be much more elegant.

P.s. I have been following the project for just over a year, and it is nice to see how much it is maturing with each new monthly release, and the great effort to make it more and more accessible to everyone. Congratulations, keep it up

WRoss7 avatar Aug 25 '21 21:08 WRoss7

... , or more elegantly adding a checkbox to allow the user to force the value to integer.

I like this, we could add this to the Lovelace card. Wondering if this is a Advanced option.

matthiasdebaat avatar Sep 13 '21 09:09 matthiasdebaat

input_number entities can have float values if the step is set to less than 1.

As @spacegaier said, the actual value of an input_number is always stored as a float, so the frontend number formatting preserves that and intentionally keeps the trailing zero.

For an immediate fix you could create a template sensor that rounds the value of the input_number to an integer and display that in Lovelace.

I like the idea of having more advanced settings for Lovelace cards that enable greater control over how things are displayed, but that seems like an architecture decision, see https://github.com/home-assistant/architecture/discussions/571

joshmcrty avatar Oct 30 '21 17:10 joshmcrty

@joshmcrty thank you for the tip. Sorry for the late reply: my microSD card has broken and no longer boots 😭 . I am awaiting the delivery of an SSD to be used in conjunction with a new microSD.

input_number entities can have float values if the step is set to less than 1.

@spacegaier @joshmcrty @matthiasdebaat I thought ... wouldn't it be easier to automatically format the value of an input-number at the card level if its step is an integer?

WRoss7 avatar Nov 04 '21 13:11 WRoss7

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 Feb 02 '22 14:02 github-actions[bot]

IMHO: There is no need for any Advanced options. The input_number integration has a "step" option. Frontend should display as many digits after point as the "step" accuracy: step: 1000,100,10,1 -> display 0 digits after point step: 0.1 -> display 1 digit after point step: 0.01 -> display 2 digits after point and so on

ildar170975 avatar Feb 02 '22 14:02 ildar170975

If you look at the screenshot the step is set to 1 (not 0.1), but the card shows 7.0 days.

WRoss7 avatar Feb 03 '22 21:02 WRoss7

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 May 04 '22 22:05 github-actions[bot]

Please un-stale

ildar170975 avatar May 04 '22 22:05 ildar170975

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 Aug 03 '22 00:08 github-actions[bot]

Bump

ildar170975 avatar Aug 03 '22 09:08 ildar170975

On Home Assistant 2022.10.1

in more info the data is formatted correctly Img

but in cards no Img2

WRoss7 avatar Oct 08 '22 14:10 WRoss7

Another squashed bug. Thanks joshmcrty

WRoss7 avatar Nov 03 '22 14:11 WRoss7