[SOLVED] UserCode Input in sitemap

Hi,
i need to input some userlevel string as “1234”. According this I will mask some sitemap rows.
How to do it please ?

items

String usercode  "4 digits user code [%.0f ]"

sitemap seems be wrong, need input some digits via keyboard like “1234” not arrows down/up

Setpoint item=usercode

There is currently no way to enter arbitrary text via sitemap.

People have created keypad type things hough.

Thanks, but it is no nice method.
A user verification is most important, like PIN protection.

I think HabPanel is the better UI for this.
There is also a Custom Widget for this:

https://community.openhab.org/t/custom-widget-keypad/18154

Thanks, but i need to protect some setpoint functions in one sitemap from unauthorised manipulation
from all web and mobile apps. I don’t want to use many sitemaps.

HabPanel widged is nice for touch display.

It must not be a string value, numerical 4 digit value is OK, but how put it in sitemap as number not with incremental arrows ?

As already said, there is no such a function in BasicUI od ClassicUI and I am afraid there never will be, as nobody steped up to implement this, cause of other existing alternatives.

You can do it using a Webview element in sitemap and create a html file in your html folder with a java script sending the value on specific triggers, just like in this example:

:wink:

Hi George.
Thanks for post.
I make some substitution in script:

<html>
<script language="JavaScript">
    function getParam(param)
    {
        var qs = (function(a) {
            if (a == "") return {};
            var b = {};
            for (var i = 0; i < a.length; ++i)
            {
                var p=a[i].split('=', 2);
                if (p.length == 1)
                    b[p[0]] = "";
                else
                    b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
            }
            return b;
        })(window.location.search.substr(1).split('&'));       
        return qs[param]
    }
    function checkInput(id)
    {
        var x=document.getElementById(id).value;
        if (isNaN(x)) 
        {   document.getElementById(id).value = ""
            return false;
        }
        else
        {   return true;
        }
    }
    function resetInput(id)
    {
        document.getElementById(id).value = ""
    }
    function httpGetAsync(theUrl)
    {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.open("GET", theUrl, true); // true for asynchronous 
        xmlHttp.send(null);
    }
    function sendValue() {
        if checkInput('Userlevel') 
        {
            url = "http://192.168.100.11:8080/CMD?" + getParam('item') + "=" + document.getElementById('Userlevel').value
            httpGetAsync(url)
            resetInput('Userlevel')
        }
         else {
            resetInput('Userlevel')
        }
    }
</script>
<form>
    <input name="Userlevel" id="Userlevel" type="number" onChange="sendValue()">
</form>
</html>

They are:
textInput -> Number item=Userlevel
localhost -> RpiIP
type=text -> number (Userlevel is a Number Item)

But transfer to Userelevel item does not work.
What is the problem please ?
Thanks.

If you are using openHAB 2.x the above script will not work (openHAB 2.x is using the REST API). Use the one on post number 6 in the same link I’ve posted previously! It should work.

Yes!

Thanks George working OK inOH2.
Is it possible to extend the code for only four digit input (PIN number) and delete the input filed after pressing Enter ?
Can be AJAX values supressed, that the last values are not remembered ?
Thanks.