junkfix / numberbox-card

Replace input_number sliders with plus and minus buttons
110 stars 9 forks source link

Strange values after adjusting #15

Closed TTLucian closed 3 years ago

TTLucian commented 3 years ago

Hello! First, thanks! This is a very useful card. I'm having some problems with the actual value of the input_number helper. I don't know from where this comes but, here it is:

1

htmltiger commented 3 years ago

The card is only requesting to increase/decrease the step value in the original value. You may have to manually change the original value to a round number first to fix the issue.

https://github.com/home-assistant/frontend/issues/1687

azlux commented 3 years ago

I see the same, My temperature was 20.2 °C , then I click two times on the "+" of numberbox-card , and the temp is now 20,400000000000002 °C

I think you can reopen this issue

azlux commented 3 years ago

It's a float issue from most of programming language, javascript have it too. image

I think you need to add a fix here : https://github.com/htmltiger/numberbox-card/blob/main/numberbox-card.js#L80 (not sure, I don't know javascript well)

You know you have a 0.001 max step : https://www.home-assistant.io/integrations/input_number/#step So you can add : variable_of_the_value=Math.round(variable_of_the_value*1000)/1000

htmltiger commented 3 years ago

I have updated as suggested. please check the updated version.

Thanks.

azlux commented 3 years ago

Looks good to me. Thank for the changes