Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ÄNDERT FOLGENDE ANGABEN AB: YOUR_HC2_IP, YOUR_ADMIN_PW, RFID_DEVICE_ID, YOUR_RFID_CODE, YOUR_RFID_CODE2, YOUR_PIN_CODE
- -- DEN RFID-CODE FINDET IHR UNTER: http://YOUR_HC2_IP/api/devices?id=RFID_DEVICE_ID (unter: properties/userCodes/id:0 (looks like u00C2A)
- local HC2 = Net.FHttp("YOUR_HC2_IP", 80);
- HC2:setBasicAuthentication("admin", "YOUR_ADMIN_PW");
- local response ,status, errorCode = HC2:GET("/api/devices?id=RFID_DEVICE_ID");
- jsontbl= json.decode(response)
- if (tonumber(status)==200 and errorCode==0) then
- rfid1 = string.match(jsontbl.properties.userCodes, "YOUR_RFID_CODE");
- rfid2 = string.match(jsontbl.properties.userCodes, "YOUR_RFID_CODE2");
- code = string.match(jsontbl.properties.userCodes, "YOUR_PIN_CODE");
- if (rfid1 == "YOUR_RFID_CODE" or rfid2 == "YOUR_RFID_CODE2")
- then
- fibaro:debug('home'); -- THE HOME-PART
- elseif (code == "YOUR_PIN_CODE")
- then
- fibaro:debug('away'); -- THE AWAY-PART
- else
- fibaro:debug('Error');
- end
- else
- fibaro:debug('Error: Failed to load JSON');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement