dauden1184 / raspinukibridge Goto Github PK
View Code? Open in Web Editor NEWSimple Nuki Bridge implementation using asyncio
License: GNU General Public License v3.0
Simple Nuki Bridge implementation using asyncio
License: GNU General Public License v3.0
I can easily control my Nuki 3.0 Pro using the bridge in this repository, but the changes in Nuki state are not reported to Home Assistant using callbacks when I lock/unlock Nuki using original Nuki app. Is that something that should work or only the changes triggered using this bridge are reported through the callbacks? Thanks
Hi,
I found your project after failing hard myself (I assumed I can just hack together a small esp32 program to build my own wifi bridge).
I think I managed to get it set up correctly. However it seems like there is no door lock state update.
I am currently using a raspberry pi zero 2.
If I lock the door manually via the button on the device the doorlock state seems to always be 0 no matter what the actual state is.
(.venv) pi@zero2:~/Programming/RaspiNukiBridge $ python .
2022-03-01 22:56:52.928|I|nuki.py:133|Start scanning
======== Running on http://0.0.0.0:8080 ========
(Press CTRL+C to quit)
2022-03-01 22:56:53.782|I|nuki.py:149|Nuki: 54:D2:72:6E:B0:EC, RSSI: -76 AdvertisementData(local_name='Nuki_2D6EB0EC', manufacturer_data={76: b'\x02\x15\xa9.\xe2\x00U\x01\x11\xe4\x91l\x08\x00 \x0c\x9af-n\xb0\xec\xc9'})
2022-03-01 22:56:53.783|I|nuki.py:437|Updating nuki state
2022-03-01 22:56:53.784|I|nuki.py:137|Stop scanning
2022-03-01 22:56:53.820|I|nuki.py:416|Nuki connecting
2022-03-01 22:56:57.053|I|nuki.py:420|Connected
Task exception was never retrieved
future: <Task finished name='Task-12' coro=<Nuki._notification_handler() done, defined at /home/pi/Programming/RaspiNukiBridge/./nuki.py:305> exception=ValueError('0 is not a valid DoorsensorState')>
Traceback (most recent call last):
File "/home/pi/Programming/RaspiNukiBridge/./nuki.py", line 312, in _notification_handler
command, data = await self._parse_command(uncrypted)
File "/home/pi/Programming/RaspiNukiBridge/./nuki.py", line 250, in _parse_command
"door_sensor_state": DoorsensorState(values[16]),
File "/usr/lib/python3.9/enum.py", line 360, in __call__
return cls.__new__(cls, value)
File "/usr/lib/python3.9/enum.py", line 677, in __new__
raise ve_exc
ValueError: 0 is not a valid DoorsensorState
2022-03-01 22:57:27.075|I|nuki.py:425|Connection timeout
2022-03-01 22:57:27.075|I|nuki.py:429|Nuki disconnecting
2022-03-01 22:57:27.076|I|nuki.py:133|Start scanning
Hi people
I've configured properly the NukiBridge, I got the public and private keys of the locker 4 of them
I was expecting then to pair it with the nuki lock, as if it was a normal nuki bridge.... but android app does not find the bridge
Do I need to install HASS? I'm on raspberry pi lite distribution, using raspberry pi 3b+ and nuki lock 3
Hello!
Your Bridge works very well with the smartlock!
Could you please implement support for the opener?
And another question. How can I enable it so it autostarts when my Linux comes up?
Hi,
Thanks for the time you put into this project. I'm thinking about buying Nuki Opener, but I don't want to buy the bridge as I have a Rapsberry P Zero 2 W.
I just want to make sure your project supports the Opener, right? I saw this thread, but it's not clear to me.
Thanks,
Tony
hey there
i'm using your repo to control my nuki lock via bluetooth, which basically works quite good via your test commands `python . --unlock' but if i want to run the server, there are some issues...
Just want to mention, that the server itself is alive and i can talk to the endpoints like '/info' but nothing else, because i need the nuki_id for the api calls , which cannot be retrieved until now.
Do you have any idea?
2023-01-28 15:07:47.483|I|nuki.py:185|Nuki: 54:D2:xx:xx:xx:xx, RSSI: -67 AdvertisementData(local_name='Nuki_04xxxxxx', manufacturer_data={76: b'\x02\x15\xa9.\xe2\x00U\x01\x11\xe4\x91l\x08\x00 \x0c\x9af\x04k0i\xc4'}, service_uuids=['00001800-0000-1000-8000-00805f9b34fb', '00001801-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', 'a92ee100-5501-11e4-916c-0800200c9a66', 'a92ee200-5501-11e4-916c-0800200c9a66', 'a92eea00-5501-11e4-916c-0800200c9a66'])
2023-01-28 15:07:47.491|I|nuki.py:173|Stop scanning
2023-01-28 15:07:47.626|I|nuki.py:543|Nuki connecting
2023-01-28 15:07:50.185|I|nuki.py:247|Device type: DeviceType.SMARTLOCK_1_2
2023-01-28 15:07:50.316|I|nuki.py:555|Connected
2023-01-28 15:07:50.320|I|nuki.py:572|Updating nuki state
2023-01-28 15:07:50.396|I|nuki.py:435|State: {'nuki_state': <NukiState.DOOR_MODE: 2>, 'lock_state': <LockState.UNLOCKED: 3>, 'trigger': 0, 'current_time': datetime.datetime(2023, 1, 28, 15, 8, 6), 'timezone_offset': 60, 'critical_battery_state': 200, 'current_update_count': 2, 'lock_n_go_timer': 0, 'last_lock_action': <NukiAction.UNLATCH: 3>, 'last_lock_action_trigger': 0, 'last_lock_action_completion_status': 0, 'door_sensor_state': <DoorsensorState.UNAVAILABLE: 0>, 'nightmode_active': 0}
2023-01-28 15:07:50.399|I|nuki.py:606|Retrieve nuki configuration
Task exception was never retrieved
future: <Task finished name='Task-11' coro=<Nuki._notification_handler() done, defined at /home/pi/RaspiNukiBridge/./nuki.py:419> exception=error('unpack requires a buffer of 74 bytes')>
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 426, in _notification_handler
command, data = await self._parse_command(uncrypted)
File "/home/pi/RaspiNukiBridge/./nuki.py", line 336, in _parse_command
values = struct.unpack("<I32sffBBBBBHBBBBBhBBBBBBBBBBBBBBH", data[:74])
struct.error: unpack requires a buffer of 74 bytes
2023-01-28 15:08:20.344|I|nuki.py:560|Connection timeout
2023-01-28 15:08:20.347|I|nuki.py:564|Nuki disconnecting
2023-01-28 15:08:20.353|I|nuki.py:169|Start scanning
After generating the config file and updating the infos I tried to pair my Nuki Lock 3 with the bridge and get the follwoing error message: Error 16
Smart Lock Version 3.9.5
nuki.yaml:
server:
host: xxx.xxx.xxx.xx
port: xxxx
name: RaspiNukiBridge
app_id: xxxxxxx
token: xxxxxx
id: xxxxxx
RaspiNukiBridge $ python . --pair XX:XX:XX:XX:XX:XX
2024-05-16 10:03:24.833|I|main.py:278|Generatig keys for Nuki XX:XX:XX:XX:XX:XX
2024-05-16 10:03:24.834|I|main.py:282|bridge_public_key: 14e2a1c4eebb64b9f967532515d90d4353b8ff6573a7a98748dcd588e1a52705
2024-05-16 10:03:24.834|I|main.py:283|bridge_private_key: 4b59acb8b7ddbe5ab42a4efa8da1f112016904e95540663bd780424f90dd2afa
2024-05-16 10:03:24.835|I|nuki.py:173|Stop scanning
2024-05-16 10:03:24.835|I|nuki.py:570|Nuki connecting
2024-05-16 10:03:28.810|I|nuki.py:248|Device type: DeviceType.SMARTLOCK_1_2
2024-05-16 10:03:28.917|I|nuki.py:582|Connected
2024-05-16 10:03:28.963|E|nuki.py:456|Error 16
2024-05-16 10:03:28.963|I|nuki.py:591|Nuki disconnecting
2024-05-16 10:03:31.654|I|nuki.py:169|Start scanning
^CTraceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/pi/RaspiNukiBridge/./main.py", line 294, in
loop.run_forever()
File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
self._run_once()
File "/usr/lib/python3.9/asyncio/base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "/usr/lib/python3.9/selectors.py", line 469, in select
fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt
any suggestions?? Thanks
root@raspberrypi:/home/david/RaspiNukiBridge# python3 . --verbose --pair 54:D2:72:30:BA:5D
/home/david/RaspiNukiBridge/./nuki.py:135: FutureWarning: This method will be removed in a future version of Bleak. Use the detection_callback of the BleakScanner constructor instead.
self._scanner.register_detection_callback(self._detected_ibeacon)
2023-12-29 22:15:47.332|I|__main__.py:278|Generatig keys for Nuki 54:D2:72:30:BA:5D
2023-12-29 22:15:47.338|I|__main__.py:282|bridge_public_key: 7d10679a249f5f7e9c556b985be90d0d10c0401d24cbe578d773d18330bd4447
2023-12-29 22:15:47.341|I|__main__.py:283|bridge_private_key: 7c05370796e527efe846c09590d8634ef327a1a67e6c9a231125f38b5f9bdfef
2023-12-29 22:15:47.365|I|nuki.py:173|Stop scanning
2023-12-29 22:15:47.367|I|nuki.py:570|Nuki connecting
2023-12-29 22:15:48.395|D|nuki.py:572|Services ['0000003e-0000-1000-8000-0026bb765291 (Handle: 44): Unknown', '000000a2-0000-1000-8000-0026bb765291 (Handle: 30): Unknown', 'a92ee200-5501-11e4-916c-0800200c9a66 (Handle: 12): Unknown', 'a92ee100-5501-11e4-916c-0800200c9a66 (Handle: 8): Unknown', '00000045-0000-1000-8000-0026bb765291 (Handle: 119): Unknown', '00000044-0000-1000-8000-0026bb765291 (Handle: 151): Unknown', '00000055-0000-1000-8000-0026bb765291 (Handle: 96): Unknown', '00000096-0000-1000-8000-0026bb765291 (Handle: 164): Unknown', '0000180a-0000-1000-8000-00805f9b34fb (Handle: 21): Device Information']
2023-12-29 22:15:48.403|D|nuki.py:573|Characteristics ['00000220-0000-1000-8000-0026bb765291 (Handle: 91): Unknown', '00000030-0000-1000-8000-0026bb765291 (Handle: 67): Unknown', '00000014-0000-1000-8000-0026bb765291 (Handle: 47): Hardcopy Data Channel', '00000023-0000-1000-8000-0026bb765291 (Handle: 62): Unknown', '00000052-0000-1000-8000-0026bb765291 (Handle: 72): Unknown', '000000a6-0000-1000-8000-0026bb765291 (Handle: 82): Unknown', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 45): Unknown', '00000021-0000-1000-8000-0026bb765291 (Handle: 57): Unknown', '00000053-0000-1000-8000-0026bb765291 (Handle: 77): Unknown', '00000020-0000-1000-8000-0026bb765291 (Handle: 52): Unknown', '00000037-0000-1000-8000-0026bb765291 (Handle: 33): Unknown', '000000a5-0000-1000-8000-0026bb765291 (Handle: 38): Unknown', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 31): Unknown', 'a92ee202-5501-11e4-916c-0800200c9a66 (Handle: 16): Unknown', 'a92ee203-5501-11e4-916c-0800200c9a66 (Handle: 19): Unknown', 'a92ee201-5501-11e4-916c-0800200c9a66 (Handle: 13): Unknown', 'a92ee101-5501-11e4-916c-0800200c9a66 (Handle: 9): Unknown', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 120): Unknown', '00000023-0000-1000-8000-0026bb765291 (Handle: 146): Unknown', '000000a5-0000-1000-8000-0026bb765291 (Handle: 122): Unknown', '0000001d-0000-1000-8000-0026bb765291 (Handle: 128): Unknown', '0000001e-0000-1000-8000-0026bb765291 (Handle: 137): MCAP Control Channel', '00000037-0000-1000-8000-0026bb765291 (Handle: 159): Unknown', '00000019-0000-1000-8000-0026bb765291 (Handle: 154): AVDTP', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 152): Unknown', '0000004e-0000-1000-8000-0026bb765291 (Handle: 104): Unknown', '0000004c-0000-1000-8000-0026bb765291 (Handle: 99): Unknown', '0000004f-0000-1000-8000-0026bb765291 (Handle: 109): Unknown', '00000050-0000-1000-8000-0026bb765291 (Handle: 114): Unknown', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 97): Unknown', 'e604e95d-a759-4817-87d3-aa005083a0d1 (Handle: 165): Unknown', '00000068-0000-1000-8000-0026bb765291 (Handle: 167): Unknown', '00000023-0000-1000-8000-0026bb765291 (Handle: 185): Unknown', '0000008f-0000-1000-8000-0026bb765291 (Handle: 173): Unknown', '00000079-0000-1000-8000-0026bb765291 (Handle: 179): Unknown', '00002a26-0000-1000-8000-00805f9b34fb (Handle: 26): Firmware Revision String', '00002a27-0000-1000-8000-00805f9b34fb (Handle: 24): Hardware Revision String', '00002a25-0000-1000-8000-00805f9b34fb (Handle: 22): Serial Number String', '00002a24-0000-1000-8000-00805f9b34fb (Handle: 28): Model Number String']
/home/david/RaspiNukiBridge/./nuki.py:575: FutureWarning: This method will be removed future version, use the services property instead.
services = await self._client.get_services()
2023-12-29 22:15:48.414|I|nuki.py:248|Device type: DeviceType.SMARTLOCK_1_2
2023-12-29 22:15:48.481|I|nuki.py:582|Connected
2023-12-29 22:15:48.483|D|nuki.py:547|Sending data to a92ee101-5501-11e4-916c-0800200c9a66: b"\x01\x00\x03\x00'\xa7"
2023-12-29 22:15:48.647|D|nuki.py:447|Notification handler: a92ee101-5501-11e4-916c-0800200c9a66 (Handle: 9): Unknown, data: bytearray(b'\x03\x00\xacN\x01I2X\xab\xca\x93)\xaf\x02\\\x19xu\xdd\xfc\x1b\xc1\xb1c\x9e%\xb9\x14\xf7Q\xd12\xe5\rZ\x12')
Task exception was never retrieved
future: <Task finished name='Task-9' coro=<Nuki._notification_handler() done, defined at /home/david/RaspiNukiBridge/./nuki.py:446> exception=AttributeError("'Nuki' object has no attribute '_box'")>
Traceback (most recent call last):
File "/home/david/RaspiNukiBridge/./nuki.py", line 452, in _notification_handler
uncrypted = self._decrypt_command(bytes(data))
File "/home/david/RaspiNukiBridge/./nuki.py", line 287, in _decrypt_command
decrypted = self._box.decrypt(encrypted)
AttributeError: 'Nuki' object has no attribute '_box'
2023-12-29 22:16:18.495|I|nuki.py:587|Connection timeout
2023-12-29 22:16:18.498|I|nuki.py:591|Nuki disconnecting
2023-12-29 22:16:19.200|I|nuki.py:169|Start scanning
Hi,
what can be reason of that?
Im trying to connect my nuki 3.0 using Home Assistant Addon. I installed nuki integration but there is no device :( Should I put nuki lock to factory reset? And than try to connect to raspberry pi home assisnant?
[services.d] done. 2022-12-11 10:48:31.428|I|config.py:49|******************************************************************** 2022-12-11 10:48:31.428|I|config.py:50|* * 2022-12-11 10:48:31.429|I|config.py:51|* Access Token * 2022-12-11 10:48:31.429|I|config.py:52|* a5a06a6c374b7fe93b375e9****************** * 2022-12-11 10:48:31.429|I|config.py:53|* * 2022-12-11 10:48:31.429|I|config.py:54|******************************************************************** 2022-12-11 10:48:31.434|I|nuki.py:176|Starting a scan 2022-12-11 10:48:31.435|I|nuki.py:179|Scanning attempt 1 2022-12-11 10:48:31.460|I|nuki.py:181|Scanning succeeded on attempt 1 ======== Running on http://0.0.0.0:8080 ======== (Press CTRL+C to quit) 2022-12-11 10:48:31.620|I|nuki.py:207|No manufacturer_data (76) in advertisement_data: AdvertisementData(local_name='Nuki_32BE0***', service_data={'a92ee100-5501-11e4-916c-0800200c9a66': b'2\xbe\x04\xf5'}) 2022-12-11 10:49:21.034|I|web_server.py:110|Listed 0 devices
Hello,
I am successfully using this software Nuki Bridge.
The only problem is that sometimes it re-generate itself as new device in home assistant.
The bridge continues to work ok but I have a lot of "dead" bridges as picture below....(i have disabled the dead ones).
Why is happening this?
Thank you
Chris
please change in /etc/systemd/system/nukibridge.service
WorkingDirectory=/home/pi/NukiBridge/
to WorkingDirectory=/home/pi/RaspiNukiBridge/
thank you for your work.
I'm wondering how to make it run in a HASSIO core (Alpine) config....
So far I've been able to install all needed, pair the lock and get it working but then I broke everything trying to run the service as u mentioned but through openrc instead.
Now I'm stopped here and can0t find how to go ahead...
PS: I'm definitely not an expert on any linux distro.... still much to learn
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/RaspiNukiBridge/./__main__.py", line 261, in <module>
web_server.start()
File "/root/RaspiNukiBridge/./__main__.py", line 54, in start
web.run_app(app, host=self._host, port=self._port)
File "/usr/lib/python3.9/site-packages/aiohttp/web.py", line 514, in run_app
loop.run_until_complete(main_task)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/lib/python3.9/site-packages/aiohttp/web.py", line 321, in _run_app
await runner.setup()
File "/usr/lib/python3.9/site-packages/aiohttp/web_runner.py", line 279, in setup
self._server = await self._make_server()
File "/usr/lib/python3.9/site-packages/aiohttp/web_runner.py", line 375, in _make_server
await self._app.startup()
File "/usr/lib/python3.9/site-packages/aiohttp/web_app.py", line 417, in startup
await self.on_startup.send(self)
File "/usr/lib/python3.9/site-packages/aiosignal/__init__.py", line 36, in send
await receiver(*args, **kwargs) # type: ignore
File "/root/RaspiNukiBridge/./__main__.py", line 88, in _startup
await self.nuki_manager.start_scanning()
File "/root/RaspiNukiBridge/./nuki.py", line 135, in start_scanning
await self._scanner.start()
File "/usr/lib/python3.9/site-packages/bleak/backends/bluezdbus/scanner.py", line 88, in start
self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
File "/usr/lib/python3.9/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
super().__init__(bus_address, bus_type, ProxyObject)
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 85, in __init__
self._setup_socket()
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
raise err
File "/usr/lib/python3.9/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory
First of all thanks for a great project.
I tend to write my MAC addresses lowercase. When writing the config yaml file, I wrote the MAC address for my Nuki (found via a BLE scanner as described in your README) lowercase as well. As a consequence, the check at
Line 180 in 2f450b2
A helper method which lowercases both inputs might make this a bit more robust - it took me a fair while to figure out why my device wasn't being shown.
(As an aside: the yaml file being auto-generated so that the user never has to edit it would make all this largely redundant - and be a lot easier for the end user as well.)
Thanks again!
Hey,
great project you're working on :D! Tried several different ways to get the old Nuki Android Bridge working - without success. Now I wanted to give this here a try.
I have a pi 4 and the Smart Lock 3.0.
When I execute the pairing cmd, it comes back to me with:
INFO:root:Generatig keys for Nuki x:y:z
INFO:root:bridge_public_key: 8b8a889ccef47702c4432b04e9754bae7ab8e36238cc049d47e9e2cf315ec732
INFO:root:bridge_private_key: ac60d5d6c98ce7fe7080456f3138f9b7fcf3b4c73136145f40b38157526cc55a
INFO:root:Stop scanning
INFO:root:Nuki connecting
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<Nuki._notification_handler() done, defined at ./nuki.py:287> exception=error('unpack requires a buffer of 6 bytes')>
Traceback (most recent call last):
File "./nuki.py", line 292, in _notification_handler
uncrypted = self._decrypt_command(bytes(data))
File "./nuki.py", line 202, in _decrypt_command
auth_id, length = struct.unpack("<IH", data[24:30])
struct.error: unpack requires a buffer of 6 bytes
When I first press the button on the Nuki and then execute the pairing I get
INFO:root:Generatig keys for Nuki x:y:z
INFO:root:bridge_public_key: 6cf7c07badf98908e0777dad938757db903db38313d22c790da6aff3da3a2517
INFO:root:bridge_private_key: 77381437857238afed62579c6f1b7af245e668f9925fc6cdb7d4b5ef3be441d5
INFO:root:Stop scanning
INFO:root:Nuki connecting
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<Nuki._notification_handler() done, defined at ./nuki.py:287> exception=AttributeError("'Nuki' object has no attribute '_box'")>
Traceback (most recent call last):
File "./nuki.py", line 292, in _notification_handler
uncrypted = self._decrypt_command(bytes(data))
File "./nuki.py", line 204, in _decrypt_command
decrypted = self._box.decrypt(encrypted)
AttributeError: 'Nuki' object has no attribute '_box'
Any idea what might be wrong?
Raspberry Pi 3B
tested Nuki v2 and v3
v2:
2022-09-10 15:28:39.562|I|__main__.py:252|Generatig keys for Nuki 54xxxx
2022-09-10 15:28:39.564|I|__main__.py:256|bridge_public_key: 545b2868fb64e24056ef0456ce0134e1d740142ab10bd66bdc9d2bcac1661618
2022-09-10 15:28:39.564|I|__main__.py:257|bridge_private_key: 0d03e2eb626e69212ff00e24d23896af634af751d4a168e6eade2d6fe6d35c81
2022-09-10 15:28:39.567|I|nuki.py:173|Stop scanning
2022-09-10 15:28:39.568|I|nuki.py:543|Nuki connecting
2022-09-10 15:28:48.422|I|nuki.py:247|Device type: DeviceType.SMARTLOCK_1_2
2022-09-10 15:28:48.510|I|nuki.py:555|Connected
2022-09-10 15:28:48.555|E|nuki.py:429|Error 16
2022-09-10 15:28:48.556|I|nuki.py:564|Nuki disconnecting
2022-09-10 15:28:50.815|I|nuki.py:169|Start scanning
2022-09-10 15:28:52.881|I|nuki.py:185|Nuki: 54:xxxxx, RSSI: -81 AdvertisementData(local_name='Nuki_23F9DAB4', manufacturer_data={76: b'\x02\x15\xa9.\xe2\x00U\x01\x11\xe4\x91l\x08\x00 \x0c\x9af#\xf9\xda\xb4\xc5'}, service_uuids=['0000003e-0000-1000-8000-0026bb765291', '00000044-0000-1000-8000-0026bb765291', '00000045-0000-1000-8000-0026bb765291', '00000055-0000-1000-8000-0026bb765291', '00000096-0000-1000-8000-0026bb765291', '000000a2-0000-1000-8000-0026bb765291', '00001800-0000-1000-8000-00805f9b34fb', '0000180a-0000-1000-8000-00805f9b34fb', 'a92ee100-5501-11e4-916c-0800200c9a66', 'a92ee200-5501-11e4-916c-0800200c9a66'])
2022-09-10 15:28:52.882|I|nuki.py:572|Updating nuki state
Task exception was never retrieved
future: <Task finished name='Task-16' coro=<NukiManager._detected_ibeacon() done, defined at /home/pi/RaspiNukiBridge/./nuki.py:179> exception=TypeError("unsupported operand type(s) for +: 'NoneType' and 'bytes'")>
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 197, in _detected_ibeacon
await nuki.update_state()
File "/home/pi/RaspiNukiBridge/./nuki.py", line 575, in update_state
cmd = self._encrypt_command(NukiCommand.REQUEST_DATA.value, payload)
File "/home/pi/RaspiNukiBridge/./nuki.py", line 273, in _encrypt_command
unencrypted = self.auth_id + self._prepare_command(cmd_code, payload)[:-2]
TypeError: unsupported operand type(s) for +: 'NoneType' and 'bytes'
v3:
2022-09-10 15:25:59.607|I|__main__.py:252|Generatig keys for Nuki 54:xxxxx
2022-09-10 15:25:59.608|I|__main__.py:256|bridge_public_key: ccf5f46fa0815eadf8dc545e3b864f82b65fd0aa7a5bc62f8f8db567674aaf09
2022-09-10 15:25:59.608|I|__main__.py:257|bridge_private_key: 25d9eb5e75cc57d117fb2984d498f33325e8846c6042939c36987395cd482ed5
2022-09-10 15:25:59.611|I|nuki.py:173|Stop scanning
2022-09-10 15:25:59.612|I|nuki.py:543|Nuki connecting
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<Nuki.pair() done, defined at /home/pi/RaspiNukiBridge/./nuki.py:612> exception=BleakDBusError('org.bluez.Error.Failed', 'Software caused connection abort')>
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 617, in pair
await self.connect()
File "/home/pi/RaspiNukiBridge/./nuki.py", line 544, in connect
await self._client.connect()
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 278, in connect
assert_reply(reply)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort
^CTraceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/pi/RaspiNukiBridge/./__main__.py", line 268, in <module>
loop.run_forever()
File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
self._run_once()
File "/usr/lib/python3.9/asyncio/base_events.py", line 1854, in _run_once
event_list = self._selector.select(timeout)
File "/usr/lib/python3.9/selectors.py", line 469, in select
fd_event_list = self._selector.poll(timeout, max_ev)
Is there a way to add the open door function of the app? It works well to lock and unlock the door. But my door has a door knob so I need an open door function.
Best regards
Hi, im stuck at the first line when i paste it in the termianl i get this:
pi@homebridge:~ $ wget http://ftp.hk.debian.org/debian/pool/main/b/bluez/bluez_5.50-1.2\~deb10u1_armhf.deb
sudo apt install ./bluez_5.50-1.2~deb10u1_armhf.deb
--2023-06-18 21:12:53-- http://ftp.hk.debian.org/debian/pool/main/b/bluez/bluez_5.50-1.2~deb10u1_armhf.deb
Resolving ftp.hk.debian.org (ftp.hk.debian.org)... 45.125.0.6, 2403:2c80:5::6
Connecting to ftp.hk.debian.org (ftp.hk.debian.org)|45.125.0.6|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2023-06-18 21:12:53 ERROR 404: Not Found.
Reading package lists... Done
E: Unsupported file ./bluez_5.50-1.2~deb10u1_armhf.deb given on commandline
what have i done wrong?
Hi, i have running the server from this project on a rb4 4gb with rpi os 32 bit lite. the server is working perfectly fine, but home assistant can not communicate somehow anymore (it communicated a couple of days ago). i know this is not HA, but as the "bridge" is also custom i assume if i create a issue in HA project they state, they only support official bridge, so i thought i try to ask here.
i have home assistant on rpi 4 8gb running with latest HA os and latest HA core (2022.04) as my main smart home server since quiet a while. in the last coupe of days i tried to manage to get this project running, and on one point i successfully was able to lock/unlock doors from home assistant, but failed on stuff like proper booting of rp4 bluetooth/hci service.
now as i reduced my approach to rpi os 32 bit lite, the server of the project runs smoothly and i can lock/unlock with direct http calls, but HA can not communicate anymore.
this is the error from home assinstan:
Logger: homeassistant.components.nuki
Source: components/nuki/__init__.py:45
Integration: Nuki (documentation, issues)
First occurred: 17:47:43 (6 occurrences)
Last logged: 17:50:13
Unexpected error fetching nuki devices data: Failed to update data for Nuki device 1d935134
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 190, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data
return await self.update_method()
File "/usr/src/homeassistant/homeassistant/components/nuki/__init__.py", line 88, in async_update_data
await hass.async_add_executor_job(_update_devices, locks + openers)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/nuki/__init__.py", line 45, in _update_devices
device.update(level)
File "/usr/local/lib/python3.9/site-packages/pynuki/device.py", line 81, in update
raise NukiUpdateException(
pynuki.exceptions.NukiUpdateException: Failed to update data for Nuki device 1d935134
do you have an idea what could be the reason for this ? thank you.
I followed your tutorial and thank you! I have an error when integrating the new device. What is the web API token and the bridge API token?
in nuki lock I can put http://@:p ort + Token of nuki.yaml file but it does not work
First of all, thanks for creating and maintaing the project.
I wanted to try and connect to my Nuki Smart Lock 3 using my Raspi 3B using the library in this repository. Sadly something goes wrong in the pairing process:
$ python . --pair xx:xx:xx:xx:xx:xx
2023-11-30 22:43:52.604|I|__main__.py:278|Generatig keys for Nuki xx:xx:xx:xx:xx:xx
2023-11-30 22:43:52.606|I|__main__.py:282|bridge_public_key: <pubic-key>
2023-11-30 22:43:52.606|I|__main__.py:283|bridge_private_key: <private-key>
2023-11-30 22:43:52.608|I|nuki.py:173|Stop scanning
2023-11-30 22:43:52.609|I|nuki.py:570|Nuki connecting
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<Nuki.pair() done, defined at /home/pi/Downloads/RaspiNukiBridge/./nuki.py:639> exception=BleakDBusError('org.freedesktop.DBus.Error.AccessDenied', 'Rejected send message, 2 matched rules; type="method_call", sender=":1.248417" (uid=1000 pid=8609 comm="python . --pair xx:xx:xx:xx:xx:xx ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=8400 comm="/usr/lib/bluetooth/bluetoothd ")')>
Traceback (most recent call last):
File "/home/pi/Downloads/RaspiNukiBridge/./nuki.py", line 644, in pair
await self.connect()
File "/home/pi/Downloads/RaspiNukiBridge/./nuki.py", line 571, in connect
await self._client.connect()
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 112, in connect
device = await BleakScannerBlueZDBus.find_device_by_address(
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/scanner.py", line 220, in find_device_by_address
return await cls.find_device_by_filter(
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/scanner.py", line 249, in find_device_by_filter
async with cls(detection_callback=apply_filter, **kwargs):
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/scanner.py", line 95, in __aenter__
await self.start()
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/scanner.py", line 133, in start
assert_reply(reply)
File "/home/pi/Downloads/RaspiNukiBridge/venv/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.freedesktop.DBus.Error.AccessDenied] Rejected send message, 2 matched rules; type="method_call", sender=":1.248417" (uid=1000 pid=8609 comm="python . --pair xx:xx:xx:xx:xx:xx ") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination="org.bluez" (uid=0 pid=8400 comm="/usr/lib/bluetooth/bluetoothd ")
Used software stack:
The error occures when the Nuki is in paring mode. When the pairing mode times out and the command is run again, the same error is raised.
I initiated the pairing process with bluez 5.55 (the most recent version) and that yielded a different error: bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Software caused connection abort
As I don't have a clue what the error means, is this something I need to fix on my end?
Hi all,
trying to install this repo with python version 3.11.2 I'm getting an error:
aiohttp/_websocket.c:198:12: fatal error: longintrepr.h: No such file or directory
I think its related to: aio-libs/aiohttp#6600 but I dont know how to fix this. Tried installing with aoihttp==3.9.1 which works but then I get an error when trying to pair with the Nuki Lock.
Thank you for your help!
After preparing my virtual environment
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
$ python3 -m venv .venv
$ source .venv/bin/activate
$ python3 --version
Python 3.10.12
$ python3 -m pip install -r requirements.txt
$ python3 . --generate-config > nuki.yaml
It fail to pairing with this message:
File "/home/ubuntu/RaspiNukiBridge/./nuki.py", line 643, in pair
cmd = self._prepare_command(NukiCommand.REQUEST_DATA.value, payload)
File "/home/ubuntu/RaspiNukiBridge/./nuki.py", line 269, in _prepare_command
crc = crc16.crc16xmodem(message, 0xffff).to_bytes(2, "little")
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
The problem is known here
I temporarily fixed the problem using this fork in the requirements.txt
file
requirements.txt
aiohttp==3.8.1
bleak==0.14.0
PyNaCl==1.3.0
PyYAML==6.0
git+https://github.com/ljelen/pycrc16.git
Best regards
Hey there (again),
we have some weird issues with our setup when we trigger the API calls at some time but not always.
Mostly the error occured after the lock / api was unused for some time (~ hours / days)
The following Logging shows the error message.
2023-07-05 16:55:17.851|I|nuki.py:625|Lock action 3
2023-07-05 16:55:17.857|I|nuki.py:173|Stop scanning
2023-07-05 16:55:26.760|I|nuki.py:569|Nuki connecting
2023-07-05 16:55:33.548|I|nuki.py:581|Connected
2023-07-05 16:55:33.705|E|nuki.py:549|Error: <class 'bleak.exc.BleakDBusError'> [org.bluez.Error.InProgress] In Progress
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 547, in _send_data
await self._client.write_gatt_char(characteristic, data)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 800, in write_gatt_char
assert_reply(reply)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] In Progress
2023-07-05 16:55:33.714|E|nuki.py:549|Error: <class 'bleak.exc.BleakDBusError'> [org.bluez.Error.InProgress] In Progress
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 547, in _send_data
await self._client.write_gatt_char(characteristic, data)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 800, in write_gatt_char
assert_reply(reply)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] In Progress
2023-07-05 16:55:33.774|E|nuki.py:497|Last action: {'status': <StatusCode.ACCEPTED: 1>}
2023-07-05 16:55:33.778|E|nuki.py:497|Last action: {'status': <StatusCode.ACCEPTED: 1>}
2023-07-05 16:55:33.783|E|nuki.py:497|Last action: {'status': <StatusCode.ACCEPTED: 1>}
2023-07-05 16:55:33.850|I|nuki.py:461|State: {'nuki_state': <NukiState.DOOR_MODE: 2>, 'lock_state': <LockState.UNLATCHING: 7>, 'trigger': 0, 'current_time': datetime.datetime(2023, 7, 5, 16, 56), 'timezone_offset': 120, 'critical_battery_state': 120, 'current_update_count': 5, 'lock_n_go_timer': 0, 'last_lock_action': <NukiAction.UNLATCH: 3>, 'last_lock_action_trigger': 0, 'last_lock_action_completion_status': 0, 'door_sensor_state': <DoorsensorState.UNAVAILABLE: 0>, 'nightmode_active': 0}
2023-07-05 16:55:33.856|I|nuki.py:461|State: {'nuki_state': <NukiState.DOOR_MODE: 2>, 'lock_state': <LockState.UNLATCHING: 7>, 'trigger': 0, 'current_time': datetime.datetime(2023, 7, 5, 16, 56), 'timezone_offset': 120, 'critical_battery_state': 120, 'current_update_count': 5, 'lock_n_go_timer': 0, 'last_lock_action': <NukiAction.UNLATCH: 3>, 'last_lock_action_trigger': 0, 'last_lock_action_completion_status': 0, 'door_sensor_state': <DoorsensorState.UNAVAILABLE: 0>, 'nightmode_active': 0}
2023-07-05 16:55:33.861|I|nuki.py:461|State: {'nuki_state': <NukiState.DOOR_MODE: 2>, 'lock_state': <LockState.UNLATCHING: 7>, 'trigger': 0, 'current_time': datetime.datetime(2023, 7, 5, 16, 56), 'timezone_offset': 120, 'critical_battery_state': 120, 'current_update_count': 5, 'lock_n_go_timer': 0, 'last_lock_action': <NukiAction.UNLATCH: 3>, 'last_lock_action_trigger': 0, 'last_lock_action_completion_status': 0, 'door_sensor_state': <DoorsensorState.UNAVAILABLE: 0>, 'nightmode_active': 0}
2023-07-05 16:55:34.750|E|nuki.py:549|Error: <class 'bleak.exc.BleakDBusError'> [org.bluez.Error.InProgress] In Progress
Traceback (most recent call last):
File "/home/pi/RaspiNukiBridge/./nuki.py", line 547, in _send_data
await self._client.write_gatt_char(characteristic, data)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/client.py", line 800, in write_gatt_char
assert_reply(reply)
File "/home/pi/.local/lib/python3.9/site-packages/bleak/backends/bluezdbus/utils.py", line 23, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] In Progress
2023-07-05 16:55:34.809|E|nuki.py:455|Error 34
2023-07-05 16:55:34.812|I|nuki.py:590|Nuki disconnecting
2023-07-05 16:55:34.826|E|nuki.py:455|Error 34
2023-07-05 16:55:34.829|I|nuki.py:590|Nuki disconnecting
2023-07-05 16:55:34.836|E|nuki.py:455|Error 34
2023-07-05 16:55:34.838|I|nuki.py:590|Nuki disconnecting
Do you have any idea what that could be and how to fix it?
As i mentioned this is not always the behaviour, sometimes it works quite fast, but sometimes the lock keeps unresponsive and shows those messages in the log
Thx in advance
BR
technotroll
Hello,
i can't install the nuki virtual bridge add-on on Home Assistant OS. it gives an error.
is it possible to create a Virtual Nuki bridge with Home assistant OS bluetooth component?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.