I have a ERPNext v15 (with Frappe HR v15) - self hosted instance accessible at https://erp.example.com.
I have a ZKteco K40 Pro attendance device connected to my router.
I have a static public IP address and I have forwarded port 4370. Online port open check tools show port 4370 open for my IP.
[Not related to ERPNext but helpful for this topic]
I have even setup Attendance Management Program and connected to my ZK device from a remote location. {which was possible because port forwarding is open for port 4370}.
[Back to Topic]
I set up the biometric attendance tool using these steps:
git clone https://github.com/frappe/biometric-attendance-sync-tool
cd biometric-attendance-sync-tool
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
The following is my local_config.py
file. (I used my own IP instead of 1.1.1.1)
# ERPNext related configs
ERPNEXT_API_KEY = 'my api key' # user role = system manager
ERPNEXT_API_SECRET = 'my secret'
ERPNEXT_URL = 'https://erp.example.com'
ERPNEXT_VERSION = 15
# operational configs
PULL_FREQUENCY = 2 # in minutes
LOGS_DIRECTORY = 'logs' # logs of this script is stored in this directory
IMPORT_START_DATE = 20230101 # format: '20190501'
devices = [
{'device_id':'zkteco1','ip':'1.1.1.1', 'punch_direction': 'AUTO', 'clear_from_device_on_fetch': False}
]
shift_type_device_mapping = [
{'shift_type_name': ['Day Shift'], 'related_device_id': ['zkteco1']}
]
allowed_exceptions = [1,2,3]
After all setup,
I ran the code:
python3 erpnext_sync.py
I am not getting any punch in records pulled.
I checked the error log:
2024-08-05 14:10:53,683 ERROR 1.1.1.1 exception when fetching from device...
Traceback (most recent call last):
File "/home/user/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 149, in get_all_attendance_from_device
conn = zk.connect()
File "/home/user/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/zk/base.py", line 367, in connect
raise ZKNetworkError("can't reach device (ping %s)" % self.__address[0])
zk.exception.ZKNetworkError: can't reach device (ping 1.1.1.1)
2024-08-05 14:10:53,683 ERROR exception when calling pull_process_and_push_data function for device{"device_id": "zkteco1", "ip": "1.1.1.1", "punch_direction": "AUTO", "clear_from_device_on_fetch": false}
Traceback (most recent call last):
File "/home/user/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 149, in get_all_attendance_from_device
conn = zk.connect()
File "/home/user/frappe-bench/biometric-attendance-sync-tool/venv/lib/python3.10/site-packages/zk/base.py", line 367, in connect
raise ZKNetworkError("can't reach device (ping %s)" % self.__address[0])
zk.exception.ZKNetworkError: can't reach device (ping 1.1.1.1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 62, in main
pull_process_and_push_data(device, device_attendance_logs)
File "/home/user/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 89, in pull_process_and_push_data
device_attendance_logs = get_all_attendance_from_device(device['ip'], device_id=device['device_id'], clear_from_device_on_fetch=device['clear_from_device_on_fetch'])
File "/home/user/frappe-bench/biometric-attendance-sync-tool/erpnext_sync.py", line 170, in get_all_attendance_from_device
raise Exception('Device fetch failed.')
Exception: Device fetch failed.
What am I doing wrong here ?