OH3: Item state UNDEF to USB

the status of a number item is currently displayed as “UNDEV”. To change the display to “USB” I created this js file. Unfortunately my solution doesn’t work. Where could the error lie and does anyone know what format I have to specify?

(function(i) {
    if (i = "UNDEF") return "USB";
    return parseFloat(i);
})(input)

A number item cannot have a state of “USB”. UNDEF and NULL are special states special meanings that all items can have regardless of type. Other than those special states the only states a number item can have is a numerical sequence.

Hello JustinG, I am very pleased to read from you.

That’s a pity, isn’t there another solution?

You’ll have to reveal what the problem is that you are trying to solve. Do you want to display “USB” when some Item state is actually UNDEF ? That would be a display transformation, to define in the Item’s ‘pattern’ metadata.

I use a ShellyHT to show the room temperature. In addition, the battery status is displayed via another item. If the Shelly is now powered via USB, the item status is “UNDEV”, but the display should say “USB”.

Unfortunately, I haven’t been able to implement the solution suggested by @rossko57 yet. My issue is that “USB” should be displayed when the element state is UNDEV. I use the Pattern field for this, but the display doesn’t change. What exactly does the entry in the pattern field have to be?