Java.long.number error

I get an error in my rule, even thought the designer does not point out any errors:

01:01:30.189 [INFO ] [marthome.event.ItemStateChangedEvent] - Netatmo_Indoor_Max_CO2 changed from 725 to 750
01:01:30.216 [INFO ] [marthome.event.ItemStateChangedEvent] - Netatmo_MasterBedroom_CO2 changed from 1443 to 1496
01:01:30.224 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Heater in living room': java.lang.Number
01:01:30.239 [INFO ] [marthome.event.ItemStateChangedEvent] - Netatmo_Indoor_CO2 changed from 725 to 750
01:01:30.250 [INFO ] [marthome.event.ItemStateChangedEvent] - Netatmo_Bedroom_CO2 changed from 1431 to 1511
01:01:30.272 [INFO ] [marthome.event.ItemStateChangedEvent] - Netatmo_Bedroom_Temperature changed from 18.4 to 18.6

I have a lambda function (when commented as below, no error occurs, so its in that lambda function the error is):

import org.eclipse.smarthome.core.items.GenericItem
import org.eclipse.smarthome.core.library.types.DecimalType
import org.eclipse.xtext.xbase.lib.Functions

val Functions.Function3 heatings = [ GenericItem setPoint,GenericItem temperature,GenericItem relay |
	// Turn on the heater if the temp gets more than 2 degrees below the Heating_LivingRoom_Setpoint to prevent rapid cycling
    if(temperature.state as Number-1.0< setPoint.state as Number) {
		//Items connected to NC, i.e sendcommand off is ON!!
		if(relay.state != OFF) relay.sendCommand(OFF)
	else {
		//Items connected to NC, i.e sendcommand off is ON!!
		if(relay.state != ON) relay.sendCommand(ON)

This lambda function is triggered by this rule, which generates the error:

// Rule to drive the Heater
rule "Heater in living room"
		Item Netatmo_Indoor_Temperature received update or
		Item Heating_LivingRoom_Setpoint received update

Any idea what the error can be?

Since you know and in fact require that temperature be a NumberItem, why not pass it as one instead of a GenericItem?

Similarly with the SetPoint.

Furthermore, you only care about the state so why not just pass the start of each as a Number instead of the whole Item?

Try putting the cast in parens: (temperature.state as Number)

Finally you do not import anything from org.openhab not org.eclipse.smarthome. That is ashtray fine by default.

Think that did the trick, thanks