{"id":13631593,"url":"https://github.com/0x7466/python-nuki-client","last_synced_at":"2025-04-17T22:31:14.660Z","repository":{"id":88699108,"uuid":"106034550","full_name":"0x7466/python-nuki-client","owner":"0x7466","description":"A python client for the Nuki KT. https://nuki.io/","archived":true,"fork":false,"pushed_at":"2017-10-06T17:57:16.000Z","size":113,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-01T22:49:04.334Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0x7466.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-10-06T17:56:53.000Z","updated_at":"2023-03-06T17:24:19.000Z","dependencies_parsed_at":"2024-01-19T11:16:46.978Z","dependency_job_id":"d6c39442-65fa-4beb-b7e1-02ff5d5de3b5","html_url":"https://github.com/0x7466/python-nuki-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x7466%2Fpython-nuki-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x7466%2Fpython-nuki-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x7466%2Fpython-nuki-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x7466%2Fpython-nuki-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x7466","download_url":"https://codeload.github.com/0x7466/python-nuki-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223768522,"owners_count":17199356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:02:30.995Z","updated_at":"2024-11-08T23:31:02.991Z","avatar_url":"https://github.com/0x7466.png","language":"Python","readme":"# Nuki client for Python 3\n\nThis python library let's you talk with the Nuki smart lock (https://nuki.io/)\n\n## Get started\n\n### 1. Hardware\nInstall a BLE-compatible USB dongle (or use the built-in bluetooth stack if available)\n\n### 2. Install dependencies\n```\n$ sudo apt install libffi-dev pkg-config libboost-python-dev libboost-thread-dev libbluetooth-dev libglib2.0-dev python3-dev bluetooth libbluetooth-dev\n```\n\n### 3. Install bluez\nYou'll get more infos [here](https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation)\n\n### 4. Some hacks\nReplace the `/usr/local/lib/python3.[YOUR-PY-VERSION]/dist-packages/pygatt/backends/gatttool/gatttool.py` file with the file from this repository.\n\n### 5. Install Nuki Client\n```\n$ sudo pip3 install python-nuki-client\n```\n\n### That's all!\nYou are now ready to use the library in python!\n\n## Example usage\n### Authenticate\nBefore you will be able to send commands to the Nuki lock using the library, you must first authenticate (once!) yourself with a self-generated public/private keypair (using NaCl):\n\n```python\nfrom nukiclient import Nuki\nfrom nacl.public import PrivateKey\nimport binascii\n\nnuki_mac_address = \"00:00:00:00:00:01\"\n# generate the private key which must be kept secret\nkey_pair = PrivateKey.generate()\npublic_key_hex = binascii.hexlify(key_pair.public_key.encode())\nprivate_key_hex = binascii.hexlify(key_pair.encode())\nid = 50\n# id-type = 00 (app), 01 (bridge) or 02 (fob)\n# take 01 (bridge) if you want to make sure that the 'new state available'-flag is cleared on the Nuki if you read it out the state using this library\nid_type = '01'\nname = \"PiBridge\"\n\nnuki = Nuki(nuki_mac_address, config_path='path_to_your_config/config.ini')\nnuki.authenticate_user(public_key_hex, private_key_hex, id, id_type, name)\n```\n\n**REMARK 1** The credentials are stored in the file you define at instantiation : Default is `./nuki.cfg`\n\n**REMARK 2** Authenticating is only possible if the lock is in 'pairing mode'. You can set it to this mode by pressing the button on the lock for 5 seconds until the complete LED ring starts to shine.\n\n**REMARK 3** You can find out your Nuki's MAC address by using 'hcitool lescan' for example.\n\n### Commands to the Nuki KT\nOnce you are authenticated (and the nuki.cfg file is created on your system), you can use the library to send command to your Nuki lock:\n\n```python\nfrom nukiclient import Nuki\n\nnuki_mac_address = \"00:00:00:00:00:01\"\npin = 0000\n\nnuki = Nuki(nuki_mac_address, config_path='path_to_your_config/config.ini')\n\n# Reads the lock state\nnuki.read_lock_state()\n\n# Performs an action\nnuki.lock_action(\"UNLOCK\")\n\n# Gets log entries\nlogs = nuki.get_log_entries(10, pin)\nprint(\"received {} log entries\".format(len(logs)))\n\n# Requests calibration\nnuki.request_calibration(pin)\n\n# Checks if a new state is available\navailable = nuki.is_new_nuki_state_available()\nprint(\"New state available: {}\".format(available))\n```\n\n**REMARK** the method `is_new_nuki_state_available()` only works if you run your python script as root (sudo). All the other methods do not require root privileges\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x7466%2Fpython-nuki-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x7466%2Fpython-nuki-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x7466%2Fpython-nuki-client/lists"}