am not quiet sure if [ if(item.state == Undefined) is meaningful in the first place ? specially for values that is not persisted and openhab is running for the first time
Error is :
[See nested exception: java.lang.RuntimeException: The name 'Undefined' cannot be resolved to an item or type.]
Actually yes, checking for Undefined can be meaningful, particularly for Items that are not restored on startup. It tells you that an Item is in an uninitialized state. There can be many circumstances where knowing whether your Item has been initialized can be meaningful and cause a rule to take a certain action it otherwise wouldn’t.
For example, if I have an Item that stores some sort of value (e.g. an alarm time) I might want to check that it isn’t Undefined before trying to process it as if it had a value or at least do something different if it is Undefined.
It may be irrelevant in most cases. For example you can test for ON and then threat OFF and Undefined as the same thing.
Personally I use restoreOnStartup on all my Items as I would much rather have my home automation run based on its past state than deal with Undefined.