cspiby
(Cspiby)
February 11, 2021, 5:04pm
1
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?
123
(Taras)
February 11, 2021, 5:27pm
2
I believe what you are experiencing is due to what is known as Machine epsilon .
Petro mentioned it here:
What your seeing is called machine epsilon
This happens sometimes, you can’t do anything about it other than convert the number to a string (format or string filter).
You can try doing this:
value: "{{ '{:.2f}'.format(states('input_number.gas_meter_m3') | float + 0.010) }}"
1 Like