Hi, just installed OH 3.0 and I’m in the process of migrating some rules (and cleaning them up).
It seems I run into a problem with a check for an undefined state. In my script I check for UnDefType:
Example:
if (itm_vva_ei_cl_req_hw.state instanceof UnDefType) // item is NULL but seems that check fails
{
itm_vva_ei_cl_req_hw.postUpdate(0) // so this postupdate is not executed
}
g_vva_tst_cl_req_hw.members.forEach [item | if (! (item.state instanceof UnDefType) )
{
rq_in = (item.state as Number).intValue
}
rq_out = rq_out.intValue.bitwiseOr(rq_in.intValue)
]
if ((itm_vva_ei_cl_req_hw.state as Number).intValue != rq_out.intValue)
{
itm_vva_ei_cl_req_hw.postUpdate(rq_out.intValue) // So script fails here
}
In my logfile I then find:
Script exe... failed: Could not cast NULL to java.lang.Number; line ...
in VScode I find in the problems tab
UnDefType cannot be resolved to a type
So, how do I get the “instanceof UnDefType” check working? I can check for “state == NULL” and "state == UNDEF) as a work around but that looks messy.
Tips / help appreciated.
Steven