Input_number with step=0.1 Why / How does it get set to multiple decimal places?

Hoping someone can help me see why / how this is happening.

I have some input numbers, defined in configuration.yaml as follows:

input_number:
  max_living_temp:
    name: Maximum Living Room Temperature
    min: 20.0
    max: 26.0
    step: 0.1
    icon: mdi:thermometer-chevron-up
    mode: box
    unit_of_measurement: °C
  
  set_living_temp:
    name: Desired Living Room Temperature
    min: 20.0
    max: 26.0
    step: 0.1
    icon: mdi:thermometer-lines
    mode: box
    unit_of_measurement: °C
  
  min_living_temp:
    name: Minimum Living Room Temperature
    min: 11.0
    max: 21.0
    step: 0.1
    icon: mdi:thermometer-chevron-down
    mode: box
    unit_of_measurement: °C

I select the inputs using my HADashboard setup:
image

here are the definitons in my .dash file:

MinimumTemp:
  widget_type: input_slider
  title: Minimum Temperature
  widget_style: "background-image: url(/custom_css/blur_light/img/Cold.jpg);"
  title_style: "font-weight: bold;"
  level_style: "padding-top: 20px; font-weight: bold; font-size: 250%"
  level_up_style: "font-size: 150%"
  level_down_style: "font-size: 150%"
  unit_style: "padding-top: 15px; font-weight: bold"
  units: "°C"
  entity: input_number.min_living_temp
  step: 0.1
  precision: 1

MaxTemp:
  widget_type: input_slider
  title: Maximum Temperature
  widget_style: "background-image: url(/custom_css/blur_light/img/Hot.jpg);"
  title_style: "font-weight: bold;"
  level_style: "padding-top: 20px; font-weight: bold;"
  unit_style: "padding-top: 15px; font-weight: bold"
  level_up_style: "font-size: 150%"
  level_down_style: "font-size: 150%"
  units: "°C"
  entity: input_number.max_living_temp
  step: 0.1
  precision: 1

SetTemp:
  widget_type: input_slider
  title: Desired Temperature
  widget_style: "background-image: url(/custom_css/blur_light/img/Ideal.jpg);"
  title_style: "font-weight: bold;"
  level_style: "padding-top: 20px; font-weight: bold;"
  level_up_style: "font-size: 150%"
  level_down_style: "font-size: 150%"
  unit_style: "padding-top: 15px; font-weight: bold"
  units: "°C"
  entity: input_number.set_living_temp
  step: 0.1
  precision: 1

I also use these values as conditions in value templates in automations:

- alias: Set Flame to 1 once half way between desired and max temps
  trigger:
    - platform: state
      entity_id: sensor.ht_living_temp
  condition:
    condition: and
    conditions:
    - condition: template
      value_template: "{{ (states('sensor.ht_living_temp')|float) < states('input_number.max_living_temp')|float }}"
    - condition: template
      value_template: "{{ (states('sensor.ht_living_temp')|float) - (states('input_number.set_living_temp')|float) > (((states('input_number.max_living_temp')|float) - (states('input_number.set_living_temp')|float)) /2|float) }}"
    - condition: template
      value_template: "{{ states('input_datetime.stove_morning_start') [0:5] <= states('sensor.time') < states('input_datetime.stove_evening_finish') [0:5] }}"
  action:
    service: input_select.select_option
    data:
      entity_id: input_select.stove_flame_set
      option: 1

Other than that I never set these values prgramatically (with scripts or automations).

Despite the step 0.1, in lovelace, my values show with multiple decimal places:

Is it the value templates calculations that is changing the values? It should NOT, AFAIK.
I’m not hugely bothered, as it does not change an awful lot, but:

  1. I would like to understand why this is happening
  2. I would like a workaround so that I can display only 1 decimal place in the lovelace card

Any ideas?

Thanks.

This is just the nature of floats in Python:

>>> x = 25
>>> x -= 0.1; print(x)
24.9
>>> x -= 0.1; print(x)
24.799999999999997

AFAIK there’s nothing you can do about this when displaying the input_number itself. However you could make a template sensor that always shows only one decimal place using the |fomat() filter.

Thanks.

So nature of floats in Python is the issue.
It should not change anything functional with my setup, so I will leave it as it is.