Comparing number:length with number in a rule

Hello,

i would like to compare a numer:length with a number in a rule.
I already tried to handle it with parseInt and …state as Number and as DecimalType but it didnt work.

This is the rule:

rule "Geringer Tankinhalt"
when
    Item BMW_G31_VerbrennerReichweite changed
then
    if ((BMW_G31_VerbrennerReichweite.state as DecimalType) < 200 ) {
        val message = new StringBuilder
        Group_Tankpreise.members.forEach[i | message.append(i.name + ":\n" + i.state + "€\n") ]
        val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot1_Alexander")
        telegramAction.sendTelegram(1234567890,"Der Tank ist fast leer, die Reichweite beträg nur noch: "+BMW_G31_VerbrennerReichweite.state+".\n\nÜbersicht Tankpreise:\n" + message)
    }
end

grafik

Thanks for your help in advance,
Alex

See

It’s probably easiest to compare with 200 of whatever it was you intended.
if (BMW_G31_VerbrennerReichweite.state < 200 | mm {

1 Like

Great, thank you! Thats it - i didnt find this topic at my search.

Changed rule now and it works fine:

(BMW_G31_VerbrennerReichweite.state < 200|km )