Logic Machine Forum
Disarming the system after Entering correct PIN - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Application Store (https://forum.logicmachine.net/forumdisplay.php?fid=11)
+--- Thread: Disarming the system after Entering correct PIN (/showthread.php?tid=3880)



Disarming the system after Entering correct PIN - Shimaa - 17.02.2022

Hello Everyone Please I'm trying to create a security system with scripting (Arming / Disarming after entering a specific PIN code), but I'm still a beginner, I used your script with the same steps mentioned here:

 https://openrb.com/example-allow-switch-on-tv-after-entering-correct-pin-from-lm2-visualization/
but I faced an issue when pressing the Enter button which has the following script : 


local value = dpt.decode(event.datahex, dt.bool)
if value then
  -- get current pin
  local pin = storage.get('pin', '')

  -- verify pin number
  if pin == '1234' then
    grp.write('1/1/7', 1)
  end

  -- reset pin
    storage.set('pin', '')
    grp.write(event.dst, false, dt.bool)
end


I noticed that only it get the current pin then rest PIN only without verifying the PIN code. 
so what should I do? 
Thanks for your time.


RE: Disarming the system after Entering correct PIN - admin - 17.02.2022

You can assign PIN to a visualization object directly. This way it can only be change if a valid PIN is supplied. Script is not needed in this case.


RE: Disarming the system after Entering correct PIN - Shimaa - 17.02.2022

(17.02.2022, 13:40)admin Wrote: You can assign PIN to a visualization object directly. This way it can only be change if a valid PIN is supplied. Script is not needed in this case.
Thanks for your reply, I already tried using pin code in the visualized object, and I have no problem with it, but I'm asking if I want to use scripting why this error occurred.


RE: Disarming the system after Entering correct PIN - admin - 17.02.2022

Have you mapped a script to each number button? Still I would not use this approach because there's no way of knowing how many numbers were pressed and if the supplied PIN is correct or not.


RE: Disarming the system after Entering correct PIN - Shimaa - 17.02.2022

(17.02.2022, 13:53)admin Wrote: Have you mapped a script to each number button? Still I would not use this approach because there's no way of knowing how many numbers were pressed and if the supplied PIN is correct or not.

Okay, I got your concept. yes, the PIN was 1234, I created 4 group objects, and made 4 event scripts for them, each has its own script :  

pindigit(event, n)          -- n=1:4