How to delete string oh-input-item contents

I have a string input widget but I have been unable to find out how to delete contents there once I have entered anything.
When I delete everything in the input form and press the hook button, the associated item is NOT set to be to empty (or NULL which I believe is the proper representation of an empty string).

(yeah I can enter “NULL” but that is not user-friendly, is it)

                          - component: oh-input-item
                            config:
                              clearButton: true
                              icon: iconify:mdi:user
                              item: weisseWareUser
                              sendButton: true
                              style:
                                font-size: 1.0em
                              title: Benutzername Zwischenstecker für weiße Ware
                              type: string

What about a blank space?

that would just be a workaround at best, and wrong as such.

But it is used friendly😀

It should allow to set the Item to an empty string so file an issue on the webui repo for that. I’m sure it’s just a check somewhere that disallows an empty string. But there is nothing wrong with commanding an Item with an empty string; it should be allowed.

However, NULL is not the proper representation of an empty string. "" is the empty string. UI Widgets only command Items, not update them and the special states of NULL and UNDEF cannot be sent as a command. So without changing that underlying architecture, there is no way to set an Item to NULL from a widget directly.

"NULL" is not the same as NULL. There is some ambiguity here because in JS Scripting rules the states of Items are always converted to Strings for use in the rule. So if an Item’s state was NULL myItem.state == "NULL" would be true. However, myItem.isUninitialized would be false.

There isn’t enough detail here to offer more except have you considered whether something like Expire could serve the end goal you are after?

Yes of course. I meant to enter the literal NULL in UI, not "NULL".

Yes the proper string representation of the empty string is "". I should have rather said the proper implementation of “no UI input given” is NULL, i.e. the default when one creates an item but does not initialize it. Which actually quite is what I want it to express when you “delete” all UI input.
Resetting myItem.isUninitialized isn’t the point.
UX is. My example use case is an input field for a username.
If I set that to empty, authentication shall not be attempted else it shall be used as the username.
That’s what a user would expect to happen, too, wouldn’t they.

Additionally, the clear button of the input is an f7 property so the clearing of the value is handled by the f7 libraries and therefore is not currently associated with anything specific to OH. The send button is implemented by the oh-input which is why that button does integrate with oh items, variables, etc.

f7 does fire an event when the input clear button is clicked, but at the moment there is no listener for that event in OH, so OH is completely unaware of when the value is cleared other than responding to the change in the input value. That’s not to say this couldn’t be implemented, but it’s a bigger re-factoring than just changing a response value.

1 Like