Advertisement
boomx

RFID-Tagreader VD

Aug 21st, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. -- ÄNDERT FOLGENDE ANGABEN AB: YOUR_HC2_IP, YOUR_ADMIN_PW, RFID_DEVICE_ID, YOUR_RFID_CODE, YOUR_RFID_CODE2, YOUR_PIN_CODE
  2. -- DEN RFID-CODE FINDET IHR UNTER: http://YOUR_HC2_IP/api/devices?id=RFID_DEVICE_ID (unter: properties/userCodes/id:0 (looks like u00C2A)
  3.  
  4. local HC2 = Net.FHttp("YOUR_HC2_IP", 80);
  5. HC2:setBasicAuthentication("admin", "YOUR_ADMIN_PW");
  6. local response ,status, errorCode = HC2:GET("/api/devices?id=RFID_DEVICE_ID");
  7.  
  8. jsontbl= json.decode(response)
  9.  
  10. if (tonumber(status)==200 and errorCode==0) then
  11.         rfid1 = string.match(jsontbl.properties.userCodes, "YOUR_RFID_CODE");
  12.         rfid2 = string.match(jsontbl.properties.userCodes, "YOUR_RFID_CODE2");
  13.         code = string.match(jsontbl.properties.userCodes, "YOUR_PIN_CODE");
  14.  
  15.         if (rfid1 == "YOUR_RFID_CODE" or rfid2 == "YOUR_RFID_CODE2")
  16.                 then
  17.         fibaro:debug('home'); -- THE HOME-PART
  18.         elseif (code == "YOUR_PIN_CODE")
  19.                 then
  20.         fibaro:debug('away'); -- THE AWAY-PART
  21.         else
  22.         fibaro:debug('Error');
  23.         end
  24. else
  25.         fibaro:debug('Error: Failed to load JSON');
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement