I’ve always struggled with number formats in openhab rules but got something up and running about a year ago but I’ve just noticed that the numbers aren’t comparing well.
var setPos = currentSet1.state.toString val actualTemp = (xrf_temp1.state as DecimalType).intValue val Number setTemp = new Integer(setPos)
These are my inputs. Basically a temperature set point that comes in as a string as it can sometimes be ON or OFF as well and then a 1Wire temperature which is a Number in the item file.
The set point will be 17 but the 1Wire temperature will be 17.00
Once I’ve done this conversion I can then compare them together.
if (actualTemp > setTemp) .....
However I noticed that 16.9 > 17 is false (correct) but 17.1 > 17 is also false (incorrect). 18.1 > 17 is true (correct).
I can only assume that the actualTemp is being stripped of it’s decimal point and is actually comparing 17 > 17.
How can I maintain the decimal points and put one on setTemp?