Issue with input_number rounding

I have an automation that adds a value to an input_number when a contact door sensor is activated, the line in the automation is:

value: “{{ (states.input_number.gas_meter_m3.state | float ) + 0.010 }}”

however, I’m getting strange results from the input_number, nothing else is interacting with the value as its specifically for this automation, but the number ends up as 0.24000000000000007

How is that possible?

I believe what you are experiencing is due to what is known as Machine epsilon.

Petro mentioned it here:

You can try doing this:

value: "{{ '{:.2f}'.format(states('input_number.gas_meter_m3') | float + 0.010) }}"
1 Like