Item for input text or numbers

Is it possible to define items for input text or numbers e.g. a code/password?

Unfortunately there is no input widget. To enter numbers there is somewhere a topic how to create a keypad

Thomas

If you want it on your sitemap you can make a simple web page with some JavaScript that posts to the REST API, and show it in a webview.

Edit: if it’s just text or a number you might not even need JavaScript, you could just make a html-form that posts to the right path in the rest API. I’m not able to test at the moment, but I think it should work.

There is a widget for HabPanel

Universal Keypad for HABPanel

And a alarm panel / password widget and rules in the library too, simply called Keypad

I’m using the following code on a HABPanel widget to show a “Textbox” (empty space taking the text) followed by a button that hands the text to a string item (SayCommand).

  <div class="form-group">
    <input type="text" class="form-control" no-snap-drag="true"
           ng-model="myvalue" ng-value="itemValue('SayCommand')"></input>
    <button type="button" class="btn btn-primary"
           ng-click="sendCmd('SayCommand', myvalue)">Sag es!</button>
  </div>
3 Likes

I really like your widget, but can you explain to me, how to select an item that will be updated with the entered value?

I’m sorry, this widget has a hardcoded item connected, no selection possible.

Can you explain to me how I can change that for my use case? I just need to set that for my item once. I have no experience with creating widgets.

Can you help me understand, how to hardcode one of my items into the widget? I don’t need it to have a selection after setting up. I just need to connect (hardcode) my own items into it and don’t know how.

If you replace

SayCommand

with your item-name …

1 Like

Hi Jürgen.
I have some question about according our code.
My example for item ip_address:

<div class="form-group">
    <input type="text" class="form-control" no-snap-drag="true"
           ng-model="myvalue1" ng-value="itemValue('ip_address')"></input>
    <button type="button" class="btn btn-primary"
           ng-click="sendCmd('ip_address', myvalue1)">Local IP address</button>
  </div>

Item is stored as String in Influxdb with option restoreOnStartup, so the value can be read out in case of restart of openhab2. The value is displayed according stored value.
But if I press the value setting button, the current displayed value will be deleted and will be substituted with empty string.
Any idea how to resolve that the displayed value will be succesfully passed to item please ?
Thank’s for help.

HabpanelProblem
HabpanelAfterEnter

Openhab.log
2022-12-15 12:02:57.121 [ome.event.ItemCommandEvent] - Item ‘ip_address’ received command
2022-12-15 12:02:57.123 [vent.ItemStateChangedEvent] - ip_address changed from 212.89.229.22 to