fananimi / pyzk

Unofficial library of zkteco fingerprint attendance machine
GNU General Public License v2.0
489 stars 319 forks source link

Add RFID card number to zkteco user #213

Closed nacer2015 closed 3 months ago

nacer2015 commented 3 months ago

I recently purchased a ZKTeco Uface800 Plus device. I've developed a small Python application to manage it, allowing me to connect, add users, and enroll fingerprints using the PyZK library. When the PyZK method zk.enroll_user(uuid, fingernumber) is executed, it prompts the user to place their finger on the fingerprint reader three times, registering their fingerprint into the device.

Now, I'm looking to implement similar functionality for RFID cards. I need a function enroll_card(uuid) that, when executed, prompts the user with the specified UUID to swipe their RFID card on the device, registering the card number.

Alternatively, I'm also interested in a simpler method to just read the RFID number of a card and print it. For example, a method like zk.set_user(uuid=1, card=card_number) could be used for this purpose."

I attempted to replicate the functionality of the zk.enroll_user method from PyZK for RFID cards. However, I found this task challenging as I'm new to Python and ZKTeco

kurenai-ryu commented 3 months ago

indeed zk.set_user(uuid=1, card=card_number) should work.

if it doesnt work it could be because the card number format is incorrect.

the easiest way to test is to use another method to register a user with card lets say by the ui (or by zkacess) then read the user list and print all the details. you'll need to access the user.card property because it isn't in the default user.str (for direct print)

i remember that some cards uses a 4 bytes hex format and other uses a 10 digit integer on its format and most uses de 26 bit wiegand format for that you'll need a calculator similar to this one https://www.ccdesignworks.com/wiegand_calc.htm I'm pretty sure you could implement a similar functionality with a live capture if you enable alll the events so it should detect any card and print the result, but it was too noisy to interpret the event.

it should be easier to convert the number once you get the correct format

nacer2015 commented 3 months ago

I tested zk.set_user(uuid=12, card='48908'). This method will add the RFID card number 48908 to the user with UUID 12. The problem is I can't read or enroll RFID cards like enroll_user does for fingerprints.

kurenai-ryu commented 3 months ago

as I said it's up to you to implement something like that with live_capture