Difficulties with IF statement in rule - SOLVED

I have difficulties with IF statement in a very simple rule. Basically I want to control a TPLink smart plug KP115 in my garage using the humidity value. I have a dehumidifier connected to this KP115.

My DSL rule is:

val Autotalli_RH2 = Autotalli_RH.state as Number
val Autotalli_RH_asetus2 = Autotalli_RH_asetus.state as Number

logInfo("test" , "Autotalli_RH2= " + Autotalli_RH2)
logInfo("test2" , "Autotalli_RH_asetus2= " + Autotalli_RH_asetus2)

If (Autotalli_RH2 > Autotalli_RH_asetus2) {
    KP115_Switch.sendCommand(ON) 
} else {
    KP115_Switch.sendCommand(OFF)

Both Autotalli_RH and Autotalli_RH_asetus are defined as number items. KP115_Switch was created by the TPLink binding. The rule works if I comment out the line with IF and the following lines so I think the problem is with the IF statement. The error in the log is:

2022-02-02 19:20:00.835 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'f048745633' failed: val Autotalli_RH2 = Autotalli_RH.state as Number
val Autotalli_RH_asetus2 = Autotalli_RH_asetus.state as Number

logInfo("test" , "Autotalli_RH2= " + Autotalli_RH2)
logInfo("test2" , "Autotalli_RH_asetus2= " + Autotalli_RH_asetus2)

If (Autotalli_RH2 > Autotalli_RH_asetus2) {
    KP115_Switch.sendCommand(ON) 
} else {
    KP115_Switch.sendCommand(OFF)
}

Any ideas what is wrong with this rule?

Case matters. It’s if not If.

That did the trick. What a stupid mistake I made. I have several rules with if statements but I didn’t realise that Case matters. I had already spent few hours in trying to get this simple rule working and most likely I would have spent few hours more without your help. Many thanks for your help.