Got an arithmetic exception converting value

Finally got it to work, had to divide my arithmetic operations into two to make it work. Don’t now why it is like this, but it works :-).

I also found out that there is a difference between /100 and * 0.01. /100 throws a lot of decimals, whereas * 0.01 only throws 2.

My working rule:

rule "temperature control" // det er denne kontrol som opdaterer de enkelte radiatorers setpunkter
when
    Time cron "0 0/5 * 1/1 * ? *"
then
   if (Heat_auto.state == ON) //setpunkterne bliver kun opdateret hvis automatikken er ON
   {
   TempDiff.postUpdate(3*(Rad_TEMP_SP.state as DecimalType - Temperature_GF_Living2.state as DecimalType))		
	if(TempDiff.state > 1.5)
		{
		TempDiff.postUpdate(1.5)
		}
	if(TempDiff.state < -1.5)
		{
		TempDiff.postUpdate(-1.5)
		}
   var Number setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + GF_Kitchen_offset.state as DecimalType + TempDiff.state as DecimalType).floatValue())
   sendCommand(GF_Kitchen_setpoint, setPointDec*0.01)    
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + GF_Living_east_offset.state as DecimalType + TempDiff.state as DecimalType).floatValue())
   sendCommand(GF_Living_east_setpoint, setPointDec*0.01) 
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + GF_Living_south_offset.state as DecimalType + TempDiff.state as DecimalType).floatValue())
   sendCommand(GF_Living_south_setpoint, setPointDec*0.01)
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + GF_Corridor_offset.state as DecimalType).floatValue())
   sendCommand(GF_Corridor_setpoint, setPointDec*0.01)
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + GF_Jonas_offset.state as DecimalType).floatValue())
   sendCommand(GF_Jonas_setpoint, setPointDec*0.01) 
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + FF_Living_east_offset.state as DecimalType).floatValue())
   sendCommand(FF_Living_east_setpoint, setPointDec*0.01)
   setPointDec = Math::round(100*(Rad_TEMP_SP.state as DecimalType + FF_Living_west_offset.state as DecimalType).floatValue())
   sendCommand(FF_Living_west_setpoint, setPointDec*0.01)
   }
end	
1 Like