Error while executing rule

Hi, i get this error message, but i do´t know why? It is only visible, when the rule will be triggered, if the states of the parameters are to high, there is no error message. Only when the 2nd or 3rd if-part is matched, the error is visible.

I think it has to do something with && - do i have to make some () somewhere in this row?

[ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Soll-Temp-Heizung d?mpfen - wenn Unterschied 1h und 24h Aussentemp zu gro?': Could not invoke method: org.eclipse.xtext.xbase.lib.BooleanExtensions.operator_and(boolean,boolean) on instance: null

Here is the rule:

rule "Soll-Temp-Heizung dämpfen - wenn Unterschied 1h und 24h Aussentemp zu groß" when Item HeatPump_Temperature_4 received update then if (HeatPump_Temperature_4.state as DecimalType - HeatPump_Temperature_5.state as DecimalType > -2.5) { if (HeatPump_adapt_heating.state as DecimalType != 0) { sendCommand(HeatPump_adapt_heating, 0) } } if (HeatPump_Temperature_4.state as DecimalType - HeatPump_Temperature_5.state as DecimalType <= -3 && HeatPump_Temperature_4.state as DecimalType - HeatPump_Temperature_5.state as DecimalType < -5.8) { if (HeatPump_adapt_heating.state as DecimalType != -0.5) { sendCommand(HeatPump_adapt_heating, -0.5) } } if (HeatPump_Temperature_4.state as DecimalType - HeatPump_Temperature_5.state as DecimalType <= -6 && HeatPump_Temperature_4.state as DecimalType - HeatPump_Temperature_5.state as DecimalType < -8.8) { if (HeatPump_adapt_heating.state as DecimalType != -1.0) { sendCommand(HeatPump_adapt_heating, -1.0) } } end

What´s wrong?

I’d thrown in some extra parentheses pairs as follows:

A. For compound IF tests —

IF ((a > b) && (b <=c)) {.....
}

B. For an extra dose of paranoia, put entire WHEN clause inside a pair of braces–

THEN 
    { .....


   }
END

Ok, i will try this.


How about doing this with var-function?

Then i can make something like this:

when item xxx changed
var difference_temps = temp1 as decimaltype - temp2 as decimaltype
if difference_temp > x && difference_temp < y
then

Can someone tell me how to do this with var? Maybe this would be a better solution?

rule "Soll-Temp-Heizung dämpfen - wenn Unterschied 1h und 24h Aussentemp zu groß"
when
  Item HeatPump_Temperature_4 received update
then
  // making sure these item states are DecimalType; choose smarter defaults than 0 below
  val DecimalType hpt4 = if (HeatPump_Temperature_4.state instanceof DecimalType) HeatPump_Temperature_4.state else 0
  val DecimalType hpt5 = if (HeatPump_Temperature_5.state instanceof DecimalType) HeatPump_Temperature_5.state else 0
  val DecimalType hpah = if (HeatPump_adapt_heating.state instanceof DecimalType) HeatPump_adapt_heating.state else 0
  val DecimalType hpdt = hpt4 - hpt5

  if (hpdt > -2.5) {
    if (hpah != 0) {
      HeatPump_adapt_heating.sendCommand(0)
    }
  }

  if (hpdt <= -3 && hpdt < -5.8) {
    if (hpah != -0.5) {
      HeatPump_adapt_heating.sendCommand(-0.5)
    }
  }

  if (hpdt <= -6 && hpdt < -8.8) {
    if (hpah != -1.0) {
      HeatPump_adapt_heating.sendCommand(-1.0)
    }
  }
end