- Platform information:runtimeInfo:
version: 3.4.4
buildString: Release Build
locale: de-DE
systemInfo:
configFolder: /openhab/conf
userdataFolder: /openhab/userdata
logFolder: /openhab/userdata/logs
javaVersion: 11.0.19
javaVendor: Eclipse Adoptium
javaVendorVersion: Temurin-11.0.19+7
osName: Linux
osVersion: 5.13.x
osArchitecture: amd64
availableProcessors: 4
freeMemory: 1172249456
totalMemory: 1529872384
startLevel: 100 - Issue of the topic: comparison of two variables not working
I have a rule to control my house ventilation based on the CO2 values from my Netatmo sensors. The rule worked fine until I upgraded from OH 3.0.2 to OH 3.4.4.
Below the rule:
var t1_co2 = new DecimalType(400)
var t0_co2 = new DecimalType(400)
var qt1_t0 = new DecimalType(1)
var cwl_output = new DecimalType(1)
val co2_min = new DecimalType(500)
val fan_max = new DecimalType(45)
val co2_range = new DecimalType(22) //Wert 1500 ppm an dem die Lüftung auf 45 Prozent läuft
rule "Hauslüftung anpassen"
when
Item gNetatmoCO2 changed
then
logInfo("Lüftung","Hauslüftung anpassen")
if (Autolueftung_S.state == ON) {
//Historie aktualisieren
t1_co2 = t0_co2
//Aktualisiere t0
t0_co2 = (gNetatmoCO2.state as DecimalType)
//Quotient berechnen
qt1_t0 = t0_co2 / t1_co2
logInfo("Lüftung","Hauslüftung anpassen 2")
//Berechne neuen Outputwert, wenn CO2 über CO2 min liegt
if (t0_co2 > co2_min) {
cwl_output = (t0_co2 - co2_min) / co2_range * qt1_t0
logInfo("Lüftung","Hauslüftung anpassen 2.1 " + cwl_output)
}
else {
cwl_output = new DecimalType(0)
logInfo("Lüftung","Hauslüftung anpassen 2.2")
}
logInfo("Lüftung","Hauslüftung anpassen 3 " + fan_max)
// Prüfe ob berechneter Wert unter max fan liegt, sonst Lüftung auf fan_max setzen
if (cwl_output < fan_max) {
UG_CWL_Hauslueftung_D.sendCommand(cwl_output as Number)
}
else {
UG_CWL_Hauslueftung_D.sendCommand(fan_max as Number)
}
}
end
When the rule is executed I get the following error (see below). I included additional logs to ensure none of the values is null.
2023-07-08 14:06:15.095 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen
2023-07-08 14:06:15.097 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 2
2023-07-08 14:06:15.098 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 2.1 3.3270181350000000
2023-07-08 14:06:15.099 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 3 45
2023-07-08 14:06:15.100 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Air_control-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.lib.NumberExtensions.operator_lessThan(org.openhab.core.types.Type,java.lang.Number) on instance: null in Air_control
2023-07-08 14:06:15.171 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen
2023-07-08 14:06:15.172 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 2
2023-07-08 14:06:15.173 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 2.1 3.9700645972869072
2023-07-08 14:06:15.174 [INFO ] [rg.openhab.core.model.script.Lüftung] - Hauslüftung anpassen 3 45
2023-07-08 14:06:15.174 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'Air_control-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.lib.NumberExtensions.operator_lessThan(org.openhab.core.types.Type,java.lang.Number) on instance: null in Air_control
Thanks for your help.