Comparing to item.state to null probem

I have such situation:

Item file:

Number HT_Salon_Temperature (gTempSensor) { channel=“mihome:sensor_ht:158d0001b8cd10:temperature” }

Rule:

sensor = HT_Salon_Temperature 	
if(sensor.state==null) {
   logWarn("FILE", "Temperature_control: Sensor.state == NULL")
 return 	
}
logInfo( "FILE", "Temperature_control: sensor.state [" + sensor.state + "]")

and log file:

017-12-01 23:53:02.635 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘Temperature_control’: org.eclipse.smarthome.core.library.types.DecimalType
2017-12-01 23:53:02.758 [INFO ] [.eclipse.smarthome.model.script.FILE] - Temperature_control: sensor.state [NULL]

item.state is null but when I compare to null it is not true. I check with

if(sensor.state==“NULL”) {

but it is also does not work. Any idea what is wrong?

Michal

The all-caps NULL is the proper comparison.

sensor.state == NULL

No quotes, all caps.

1 Like