Fighting UNDEF

Hi,

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;

UNDEF=-
=-

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.

I have the same issue with home connect devices

tried state Description without success.

tried like

value: " "
config:
pattern: “%1$tH:%1$tM:%1$tS”
options: =0,UNDEF=0,NULL=0

or just

value: " "
config:
pattern: “%1$tH:%1$tM:%1$tS”
options: =0

it shows as UNDEF

I’m on OH3 m4

Where are you looking? The Item state will still be UNDEF, so an “administrators” view of the Item should still show UNDEF.
Fpr prettifying a “user” view, you’ll need to identify what UI and widget you are trying to use.

I’m not sure that 0 is going to work well with datetime formatters.

I was looking at Equipment tab, but the issue was everywhere.

When I look at location tab on overview page it shows

Even when It had some value, stateDescription did not work and I spotted something wired related to default profile in F12 Developers tool, I had to delete this item and re-create it.

After this when value exist it started showing value like xx:xx:xx.

then I added these metadata

I define value to be shown like

=items.Dishwasher_RemainingProgramTime.state ==="UNDEF"?"-":items.Dishwasher_RemainingProgramTime.state

Now I got this:

So this is what I wanted.