How to compare String item with some number

Hello All,

I am a beginner here, I have a question,
I am making a rule, where I want to compare if my state value is greater than 100 then publish some message, but it is publishing message even if it is less than 100:-

*** My item is defined as a string**

rule “airflow alert AF2021000001_d”
when
Item Airflow_AF2021000001_d changed
then

if (Airflow_AF2021000001_d.state.toString > 100) {​​​​​​​​
val mqttActions = getActions(“mqtt”,“mqtt:broker:MyMQTTBroker”)
mqttActions.publishMQTT(“xyz”, Airflow_AF2021000001_d.state)
}​​​​​​​​
end

Thank you.

if you want to compare your item you will have to convert it to a number. perhaps try this in your condition:

if ((Airflow_AF2021000001_d.state as Number).intValue > 100) {​​​​​​​​