Changing string item to number type in rule?

If it is an integer value (i.e. no decimal place) you can do this in your rule:

if(Integer::parseInt(mqttNWBattery.state) < 25)

If it does have a decimal point use Double::parseDouble() instead

However, if you make your Item a Number instead of a String OH should be able to parse the value for you, as long as the String is a parseable number (e.g. no leading or trailing spaces) it will convert it to a DecimalType for you. And if there is something a little off about it you can use a transform to fix it. Then you can do:

if((mqttNWBattery.state as DecimalType) < 25)
1 Like