This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Password for keypad!
#1
Hi everybody ! I have a difficulty, I have 4 addresses 5/1/1; 5/5/2; 5/5/3; 5/5/4. How do I know in which order I have clicked one by one? For example:

I press one by one: 5/1/1; 1/5/3; 1/5/4; 5/1/2 ->, then I know the turn is 1,3,4,2. My intention is to make a password.
I press one by one: 5/1/4; 1/5/2; 1/5/1; 1/5/3 ->, then I know the turn is 4,2,1,3

Does anyone have a solution for it, or anyone who has ever done it. Hope everyone help me! Thank so much!

Attached Files Image(s)
   
Reply
#2
Why not use built-in PIN code option for objects?
Reply
#3
Thank Admin !
Not so! My intention is to enter the password using the keypads.
The idea is that for each key a number, the problem is to press the correct number (its order). Example 1243
Smile
Reply
#4
You can always check the update time and sort them from oldest to latest.
Reply
#5
Yes, It's right !
We use the function os.time() or os.microtime() ?
thank everyone !
Reply
#6
Single object update time you collect like this
Code:
myobject = grp.find('0/0/2')
log(myobject.updatetime)

You can do the same with multiple objects when using tag for several objects.

Code:
myobjects = grp.tag('TAG')

for _, object in ipairs(myobjects) do
  log(object.updatetime)
end
Reply
#7
Hi,

I created this a few years ago in custom JS, works a lot faster and smoother..

1) Create 10 buttons and give it a custom class pin0 to pin9
2) Create 1 button with custom class "pinback"
3) Create 1 button with custom class "pincancel"
4) Create a text label with custom cllass "entered"
5) Create a 4 byte signed integer object (in this sample "63/7/254")
6) Add this script to custom JS :
Code:
$(function(){
 
  // Reset pin on visu load
  var pin = ""
  var enteredpin = ""
  var maxlenght = 8
  $(".entered").text(pin);
 
  function Pin(pinnumber) {
    if (pin.length < maxlenght){
      pin = pin + String(pinnumber);
      enteredpin = enteredpin + '*'
      $(".entered").text(enteredpin);
      if (pin.length == maxlenght){
          Pin_Send();
      }
    }
  }
    
  function Pin_Back() {
    if (pin.length > 1){
      pin = pin.substring(0, pin.length - 1);
      enteredpin = enteredpin.substring(0, enteredpin.length - 1);
      $(".entered").text(enteredpin);
    } else {
      Pin_Cancel();
    }
  }

  function Pin_Cancel() {
    pin = "";
    enteredpin = "";
    $(".entered").text(enteredpin);
  }

  function Pin_Send() {
    if (pin.length > 0 && pin.length < (maxlenght + 1) ){
      grp.write('63/7/254', pin);
      Pin_Cancel();
    } else {
      Pin_Cancel();
    }
  } 

  $( ".pin1" ).click(function() {
    Pin(1);
  });
  $( ".pin2" ).click(function() {
    Pin(2);
  });
  $( ".pin3" ).click(function() {
    Pin(3);
  });
  $( ".pin4" ).click(function() {
    Pin(4);
  });
  $( ".pin5" ).click(function() {
    Pin(5);
  });
  $( ".pin6" ).click(function() {
    Pin(6);
  });
  $( ".pin7" ).click(function() {
    Pin(7);
  });
  $( ".pin8" ).click(function() {
    Pin(8);
  });
  $( ".pin9" ).click(function() {
    Pin(9);
  });
  $( ".pin0" ).click(function() {
    Pin(0);
  });
  $( ".pincancel" ).click(function() {
    Pin_Cancel();
  });
  $( ".pinback" ).click(function() {
    Pin_Back();
  });
});

You can attached a LUA script to 63/7/254 to compare the enter code with your desired code and if it match execute the action..

BR,

Erwin
Reply
#8
Thank so much ! Everyone ! Smile
But I want an address to reset. For example, the address 1/1/1 1byte (it's from 0-255). I want if in 10s it has no activity, it will reset 1/1/1 = 0, and if less than 10s it has an impact then it will count from the last impact. Like the sensor, it turns off every 10 seconds if there is no motion.
---------------
(In other words I mean)
Alternatively, my Delay command (os.delay) is repeated every time I change the value. I don't want that, I just want the Delay command to work for the first time.
For example:
grp.write ('1/1/1', true)
os.sleep (10)
grp.write ('1/1/1', false)
----------------
Then in about 10 seconds, I press the address 1/1/1 4 times, then my Delay command was repeated 4 times, and it made the value of 1/1/1 = fasle repeat 4 times. I don't want that, I just need it to work for the first time(1/1/1 = fasle repeat 0 times).
I was thinking Delay just paused the command line to execute. It then executes again after the set number of seconds. Leads to 1/1/1 = false repetition. I tried os.kill and return. but not work.
Thanks everyone !
thank all!
Reply
#9
What about if you just use
grp.checkwrite('1/1/1', false)
Reply
#10
oh..
Thank so much ! Daniel ! I done it's !
Thank all!
Reply


Forum Jump: