Fighting UNDEF


I have a couple of Siemens devices connected via the Home-Connect binding. As soon as you turn the device off, a bunch of items return to the ‘UNDEF’ status. As far as I can tell, this is expected behavior.
But not really a nice sight in the UI…

Looking for a way to replace 'UNDEF with something nicer in the UI, I am trying to solve this with a ‘State Description’ pattern, hoping the following transformation would do the trick, but it does absolutely nothing.
JS(| input == 'UNDEF' ? '-' : input):%s

I have a feeling I am approaching this the wrong way.

Could someone point me in the right direction?

Usually I do this within the item definition, using a MAP file. Works well. In have no experience with the script version. Maybe the documentation can help.

I tried with a map as well;


But this does not seem to change the item’s representation.

Is there anything in the openhab.log? I assume you installed the Map Transformation Add-on.
You may check the real items value that needs to be transformed with a logInfo statement in a rule so the entry in the MAP file matches exactly.

Did some investigation in a test system: The value to map is not UNDEF but NULL. For all types of items.

States NULL and UNDEF are both valid for all Item types. Whether you ever see one or the other in service depends on circumstances.

Just to confirm. In the openHAB 3 UI, that would be done with the ‘State Description’ metadata, right?

I just tried mapping NULL and/or UNDEF, but still no change to what I see in the item’s representation. It feels like I am missing something really obvious :sweat_smile:

In OH2, internal “preprocessing” for the equivalent of displayState presented a “-” for display, when actual state is NULL or UNDEF.
This will still be present in OH3, i.e.if you look at a sitemap-using UI you will see - not NULL, with no other formatting.

I don’t know where you’re working.