zkh-lib
v1.0.0
Published
This package allows for real-time tracking of employee attendance using a ZKTeco device and the device's IP address.
Downloads
52
Maintainers
Readme
Installation
npm i zkh-lib
Or, if you prefer Yarn:
yarn add zkh-lib
Usage Example
const ZKHLIB = require("zkh-lib");
const runMachine = async () => {
let obj = new ZKHLIB("192.168.1.106", 4370, 5200, 5000);
try {
// Create socket to machine
await obj.createSocket();
// Get all logs in the machine
const logs = await obj.getAttendances();
console.log(logs);
// Read real-time logs
await obj.getRealTimeLogs((data) => {
console.log(data);
});
// Disconnect from device
await obj.disconnect(); // when you are using real-time logs, you need to disconnect manually
} catch (e) {
console.log(e);
}
};
runMachine();
API Reference :
createSocket()
- creates a connection to the devicegetInfo()
- returns general information about the device, such as log capacity and user countgetUsers()
- returns an array of all users in the devicesetUser(uid, userid, name, password, role = 0, cardno = 0)
- adds a new user to the devicegetAttendances()
- returns an array of all attendance logs in the devicegetRealTimeLogs(callback)
- sets up a real-time log stream and calls the provided callback function with each new loggetPIN()
- returns the device PINgetFaceOn()
- returns the device Face On statusgetSSR()
- returns the device Self-Service-Recorder (SSR) statusgetDeviceVersion()
- returns the device versiongetDeviceName()
- returns the device namegetPlatform()
- returns the device platform versiongetOS()
- returns the device OS versiongetAttendanceSize()
- returns the device attendance sizeclearAttendanceLog()
- clears the attendance logdisconnect()
- disconnects from the device