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”
Item Airflow_AF2021000001_d changed

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

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) {​​​​​​​​