Slider getting strange value (non rounded)


I am running hassio 0.73.0

my 2 input_numbers are defined in input_number.yaml
their stepping is 0.1 :slight_smile:

the High slider has this bug, where the values ending with .2 .4 and .7 get values like
1.2000000000000002, etc…

#high comfort for climate control
name: Comfort High
initial: 1.5
min: 1.1
max: 1.8
step: 0.1

the Low slider, defined below, behaves correctly:

#Low comfort for climate control
name: Comfort Low
initial: 0.9
min: 0
max: 1
step: 0.1

I saw there was a similar issue in the angular material github but it was fixed
By mistake i posted there first, in fact reporting that issue is still not resolved (!!!) - will edit my post in angular issue tracking, to reflect this confusion.

But, i assume that home assistant is using angular material for these controls. Any idea how to check what is the used version?


This is just the nature of floats in Python. E.g., at a Python prompt I did this:

>>> x = 1.5
>>> x = x - 0.1
>>> x
>>> x = x - 0.1
>>> x

Same thing in jinja:

{% set x = 1.5 %}
{% set x = x - 0.1 %}
{{ x }}
{%- set x = x - 0.1 %}
{{ x }}



If you want it rounded to some precision, you can do that when you need to using the round filter. E.g., adding this to the above:

{{ x|round(2) }}



thanks @pnbruckner

your explanation is most probably the root cause, but i think the ui control (slider) should be fixed to display a rounded value - e.g. to the same decimal number as used by the step… (in my case, 1).

visually it’s hurting :slight_smile: for example, take a look at these 2 screenshots; it’s same control, changing from 1.3 to 1.2…


Agreeeeeed (Post has to be at least 10 characters. Argh! :slight_smile:)