UndefType but item has numeric value and is declared as DecimalType in Binding


I’m the author of the Zibase binding and I’m encountering problem trying to use item value to do some tests and comparison.

I tried to simplify things to make it easy to understand.

Item file :
Number Sonde_SDE_Hum "Humidite SDE [%d %%]" {zibase="EMT,OS439187201,hum" }

rule file:
rule "my rule"
Item Sonde_SDE_Hum received update
logInfo( “FILE”, “***************** state =” + Sonde_SDE_Hum.state)
if( !(Sonde_SDE_Hum.state instanceof UnDefType)) {
logInfo( “FILE”, "***************** State UndefType !!! ")
if (Sonde_SDE_Hum.state instanceof DecimalType) {
logInfo( “FILE”, “***************** DecimalType”)

log file :
22:31:15.546 INFO runtime.busevents[:26] - Sonde_SDE_Hum state updated to 46
22:31:15.548 DEBUG o.o.m.r.i.engine.RuleEngine[:298] - Executing rule 'my rule’
22:31:15.547 DEBUG o.o.b.z.internal.ZibaseBinding[:255] - value of item state 46
22:31:15.555 INFO org.openhab.model.script.FILE[:53] - ***************** state =46
22:31:15.561 INFO org.openhab.model.script.FILE[:53] - ***************** State UndefType !!!

==> I don’t undertstand why the state is undeftype : there is a value assigned to it… and when I run in debug mode in eclipse, I can even see that the value passed to postUpdate() is of type “DecimalType”.

I even tried to do the following in by binding, but no luck ;(
DecimalType value = new DecimalType(52);
eventPubisher.postUpdate(itemName, value);

Reading item works perfectly, I can see values, but I can use rules with some comparison (eg: testing if value is < 52) because of this undeftype ;(

What am I doing wrong ? Any idea is welcome !

You are testing the opposite of what you want!

Damn it ! It was definitly too late (I’m in France) when I tested that and my eyes were too tired :wink:
Thank you for pointing this out.

Nevertheless, the second “if” should be valid and the log should read “***************** DecimalType” right after “***************** State UndefType !!!” but it’s not the case.

I don’t see why it wouldn’t match on instanceof DecimalType. Maybe you could just log

logInfo("FILE", "state class is " + Sonde_SDE_Hum.state.getClass().getName() )

ok, I found the problem : I did not imported the types library in my rule files

Thank you for your help !