UoM and compare in a rule with val

Hello,
unfortunately I don’t know how to replace the value “30” with “maxHumidity” in the following code…
I am very grateful for help.

val maxHumidity = 30

rule "testrule"
when
    Time cron "*/5 * * * * ?" 
then 
	// works, but here I want to replace "30" by the varibale maxHumidity
    if (LaCrosseTemperatureSensor1_Luftfeuchtigkeit.state > 30|"%") {
	// don't work
	// if (LaCrosseTemperatureSensor1_Luftfeuchtigkeit.state > maxHumidity|"%") {
	// other solution, but works very well
    //if ((LaCrosseTemperatureSensor1_Luftfeuchtigkeit.state as QuantityType<Number>).doubleValue > maxHumidity) {
		.....
    }
end
val maxHumidity = 30

rule "testrule"
when
    Time cron "*/5 * * * * ?" 
then 
	// works, but here I want to replace "30" by the varibale maxHumidity
    val sensor1Hum = LaCrosseTemperatureSensor1_Luftfeuchtigkeit.getStateAs(QuantityType).doubleValue
    if (sensor1Hum > maxHumidity) {
        .....
    }
end
1 Like