Not quite right. null !== NULL
NULL
is an Object of type State and it is a special State Items can have to indicated the Item is uninitialized. As an Object, NULL
does have a .equals method so ==
should be used.
null
is a primitive speical work in the programming langauge to indicate no value. As a primitive, null
does not have a .equals method so one should use the identity operator ===
instead of the equivalency operator ==
.
So ===
and !==
should only be used with null
and never used with NULL
.
Its confusing and I rue the day they changed from using UNDEF
to using NULL
.
From what version of OH did you upgrade from?
Do not import anything from org.eclipse.smarthome. They are already imported for you.
When you Rule runs Rolladen_OG_Bad’s state is NULL. NULL is not of type DecimalType so you cannot cast it to DecimalType. As for why that is the case I cannot say but as long as that Item’s state remains NULL, that line as written will always generate an error. To avoid the error you need to do something like:
var int actual = -1
if(Rolladen_OG_Bad.state == NULL) {
// what to do in an error
}
else {
actual = (Rolladen_OG_Bad.state as DecimalType).intValue
}