Git Product home page Git Product logo

pyzatt's Introduction

PyZatt

Documentation Status Updates

Python lib to access ZKTeco's standalone devices

  • Supports TFT and iFace(partial) devices, B&W devices are not supported yet.
  • Documentation: https://pyzatt.readthedocs.io.
  • Free software: MIT license

Introduction

This project is part of an effort to make an alternative to ZKTeco's software, to manage attendance devices, it was made using the protocol spec shown in zk-protocol repo.

Project overview

Functions in this module follow a similar grouping used on zk-protocol repo.

ZK Modules

  • Access: Includes functions to get/set access parameters (permissions, groups, timezones).
  • Data Record: Includes functions to manage the attendance records and operation records.
  • Data User: Includes functions to manage users info, including passwords, fingerprints, names, verification styles, etc).
  • Realtime: Includes functions to receive and parse realtime events (e.g. user auth at door).
  • Terminal: Includes functions to get/set device parameters.
  • Other: Misc operations (enable/disable device, restart, power off, etc).

For more info about these operations take a look at zk-protocol.

Tests

A series of tests scrips are included to test the library and to show how the lib may be used. Some of the actions that can be done with these scripts include:

  • Creating/modifying users.
  • Creating groups.
  • Enrolling users.
  • Downloading/uploading fingerprint info.
  • Monitor realtime events.

and more ...

For more details about running tests see docs/tests.rst

Check also docs/usage.rst to understand how to use the lib

Installation

For more details see docs/installation.rst

Develop

Currently this lib is intended for devices of the TFT series, but there's no reason to keep it that way.

Capture files of network traffic of documented tests are welcomed, to expand the protocol spec and then add support in the lib.

For more details see ./CONTRIBUTING.rst

Contact

Author: Alexander Marin <[email protected]>

pyzatt's People

Contributors

adrobinoga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyzatt's Issues

Connection refused

  • PyZatt version: 2.0.0
  • Python version: 3.9.7
  • Operating System: Ubuntu 21.10

Description

I used a simple script to connect to a specific device but I'; always getting the same error that the connection was refused. My device is ZKTecho F22.

image

What I Did

Here is my script
image

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Date error and workcode need

  • PyZatt version: 2.0.0
  • Python version: 3.7.8
  • Operating System: macOs

Description

Hi Alexander!
I use a iFace302. When try read_att_log show me an incorrect datetime attendance: 2021-08-26 23:08:49 (now is 2020!). On terminal screen the date is correct.
One more... is possible add a workcode/incidence in this function? when download the attendance log to pendrive on the terminal, get a .dat file with this value on the last colum:

id - att datetime - terminalnumber - ? - ? - workcode
200 2020-08-26 23:08:49 7 0 1 53

What I Did

zk.read_att_log()

Thank you from Argentina

AttributeError: module 'pyzatt.misc' has no attribute 'print_hex'

  • PyZatt version: 2
  • Python version: 3.7.4
  • Operating System: Windows 10 64 bit

Description

I wanted to check realtime for my Zkteco F18/ID machine. When I try to run I get following conclusion.

What I Did

D:\xampp\htdocs\tad-php-mysql\pyzatt-master\tests>python test_realtime.py

running manual test
?[1m?[32m
################################################################################
#       TEST OF REALTIME FUNCTIONS
?[0m
?[1m?[32m
################################################################################
#       1.Realtime Test
?[0m
Invalid checksum
Bad start tag
Bad start tag
?[1m?[32mReady to receive events from the machine?[0m
Bad start tag

##################################################
Received event
Unknown event:
Traceback (most recent call last):
  File "test_realtime.py", line 134, in <module>
    test_realtime(opts)
  File "test_realtime.py", line 123, in test_realtime
    misc.print_hex(z.get_last_packet())
AttributeError: module 'pyzatt.misc' has no attribute 'print_hex'

Unable to install this library

I am unable to install this library because of invalid syntax in setup.py:

version='version='2.0.0'',
                            ^
    SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

version='version='2.0.0'',

The problematic line was added in commit 6e81779.

How to Use pyzatt APIs ?

  • PyZatt version: 2.0
  • Python version: 3.9.5
  • Operating System: win 10

Description

I ran test file and all of them gives
Screenshot_1

Could not find a version that satisfies the requirement pyzatt

pip --version
pip 23.0.1 from /usr/lib/python3/dist-packages/pip (python 3.11)
โžœ ~ pip install pyzatt
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pyzatt (from versions: none)
ERROR: No matching distribution found for pyzatt

Read all user info Bad start tag

adti@pi222:/home/pyzatt/tests$ python3 test_access.py
#############################################
TEST OF ACCESS FUNCTIONS
1.Read all user info
Bad start tag

How to install the package using pip?

pip install pyzatt

Out:

ERROR: Could not find a version that satisfies the requirement pyzatt (from versions: none)
ERROR: No matching distribution found for pyzatt

I'm using python 3.9

create list of working devices

I'm planning a new setup and I don't really know which ones work with this lib.

ZKTeco has many devices even in the TFT family, so it would be nice to maintain a list of working devices.

ERROR: Could not find a version that satisfies the requirement pyzatt

Hi, I've the terminal K40 right here and want to test your script, I had the python 2.7 but it said it doesn't suite your script when installing, then I upgrade everything and now I have this error. I really don't know what to do! Please help, how can I install manyually?

  • PyZatt version: I used your command pip install pyzatt
  • Python version: Just downloaded and updated pip
  • Operating System: Win 10
    Thanks

struct.error: ushort format requires 0 <= number <= 0xffff

  • PyZatt version: 2.0.0
  • Python version: 3.8
  • Operating System: Windows 10

Enroll Fingerprint

I Tried to enroll fingerprint according to test_other.py but i got this error :(

Traceback (most recent call last):
  File "D:/Projects/GitHub/Tman/tman_tests/zkteco_test.py", line 42, in <module>
    outfile.write(z.download_fp(user1_id, user1_fp_idx))
  File "D:\Projects\GitHub\Tman\venv\lib\site-packages\pyzatt-2.0.0-py3.8.egg\pyzatt\zkmodules\data_user.py", line 291, in download_fp
    req_fp.extend(struct.pack('<H', self.id_to_sn(user_id)))
struct.error: ushort format requires 0 <= number <= 0xffff

Can Face templates be read?

  • PyZatt version: Latest
  • Python version: 3.10
  • Operating System: Windows / WSL

Description

Is it possible to download Face templates using this library?

I found a recommendation to check out this library from an issue in the PYZK library (fananimi/pyzk#183 (comment)).

What I Did

Running the codebase locally, but am unable to find any reference to face templates or information.

Help me: ImportError: No module named 'pyzk'

root@OrangePI:/home/zk/pyzatt/tests# python3 test_terminal.py
Traceback (most recent call last):
File "test_terminal.py", line 5, in
import pyzk.pyzk as pyzk
ImportError: No module named 'pyzk'
Help me!

Test event EF_VERIFY (OnVerify in TFT-SDK description)

  • PyZatt version: current version
  • Python version: 3.8.10
  • Operating System: Ubuntu 20.04
  • Model: ZKteco MB20 on platform ZLM60-TFT

Description

  • Verify a finger/face are valid or not in real-time.

What I Did

  • To realize this function, I have tried to catch the event OnVerify to use EF_VERIFY by 2 ways: set event-mask=(1<<7) or event-mask=0xffff.
  • Context: use a valid finger and an invalid finger to check the verification is successful / failed.
  • Both of the cases, no event triggered (no message from MB20 to be sent to PC)

=> Should I try other ways or TFT-SDK do not support this context?

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

Bad start tag

Unknown event:
b'5050827d28000000f401adad010003003232000000000000000000000000000000000000000000000100120c11010411'
Bad start tag
Traceback (most recent call last):
File "realtime.py", line 28, in
z.recv_event()
File "/usr/local/lib/python3.6/dist-packages/PyZatt-1.0-py3.6.egg/pyzk/zkmodules/packet.py", line 181, in recv_event
File "/usr/local/lib/python3.6/dist-packages/PyZatt-1.0-py3.6.egg/pyzk/zkmodules/packet.py", line 210, in send_packet
BrokenPipeError: [Errno 32] Broken pipe

How to reconnect when realtime is lost?
Please help me!

Read attendance log: I am testing a WL10 with the following error:

I am testing a WL10, Firmware: Ver 6.60 Sep 18 2016, with the following error:
Bad start tag
Traceback (most recent call last):
File "test_data_record.py", line 36, in
z.read_att_log()
File "/home/adti/.local/lib/python3.6/site-packages/PyZatt-1.0-py3.6.egg/pyzk/zkmodules/data_record.py", line 30, in read_att_log
struct.error: unpack requires a buffer of 2 bytes

test_multiple_realtime.py not working

  • PyZatt version:
  • Python version:3.11
  • Operating System: windows 11

Description

I am trying to test the multiple real time device. I modified the code a little bit by just commenting out the continue in loop.

What I Did

ip_addresses = ['192.168.3.50']
for [ip_addr, z] in zk_dev:
        print(ip_addr, z)
        # continue
        # connection
        z.connect_net(ip_addr, machine_port)
        # read user ids
        z.disable_device()
        z.read_all_user_id()
        z.enable_device()

        # enable the report of rt packets
        z.enable_realtime()

misc.print_info("Ready to receive events from the machines")

after modifying above code,
this is the result:
test

But when I time in in biometrics, no realtime attendance log will appear.

No module named 'pyzk'

When i run "make html" command getting error No module named 'pyzk'
But i installed pyzk

Possible to use it with Filemaker?

Hi man, sorry to report an issue just to ask a public question (maybe somebody can be interested on it too), thanks for your contribute, I'm asking myself some questions, as I've to decide to buy some devices which don't uspport ADMS, and actually when I've tested some years ago one ZkTeco device I had found a way using ADMSand its database to import datas to Filemaker..
But, if your script work like ZkTeco Access does.. then it should be compatible with any devices, at least to downolad only the attendances (to configure/add users I'll use Access).. and it will be just necessary to poll the device every X seconds to get a acceptable update of datas coming.
Do you think this is possibile? Any idea about how how can I exchange datas from your library to Filemaker?
Thank you a lot!

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Please help me with this error:
root@OrangePI:/home/zk/pyzatt/tests# python3 test_realtime.py
##############################################################################

TEST OF REALTIME FUNCTIONS

##############################################################################

1.Realtime Test

Traceback (most recent call last):
File "test_realtime.py", line 36, in
z.read_all_user_id()
File "/root/.local/lib/python3.4/site-packages/PyZatt-1.0-py3.4.egg/pyzk/zkmodules/data_user.py", line 49, in read_all_user_id
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Best regards!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.