struct.unpack issue and no connection for a longer time
Closed this issue · 10 comments
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
Hi,
What is your device and what version?
hey
i use a Nuki Lock v1 and a raspi pi zero
Try to run the server with the --verbose
parameter, and post here the logs please
here is the verbose output of the server startup
2023-02-15 21:12:04.235|I|nuki.py:185|Nuki: 54:XX:XX:XX:XX:69, RSSI: -51 AdvertisementData(local_name='Nuki_04XXXXXX', manufacturer_data={76: b'\x02\x15\xa9.\xe2\x00U\x01\x11\xe4\x91l\x08\x00 \x0c\x9af\x04k0i\xc5'}, 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-02-15 21:12:04.243|I|nuki.py:173|Stop scanning
2023-02-15 21:12:04.377|I|nuki.py:543|Nuki connecting
2023-02-15 21:12:07.170|D|nuki.py:545|Services ['a92eea00-5501-11e4-916c-0800200c9a66 (Handle: 32): Unknown', 'a92ee100-5501-11e4-916c-0800200c9a66 (Handle: 28): Unknown', 'a92ee200-5501-11e4-916c-0800200c9a66 (Handle: 19): Unknown', '0000180a-0000-1000-8000-00805f9b34fb (Handle: 12): Device Information', '00001801-0000-1000-8000-00805f9b34fb (Handle: 8): Generic Attribute Profile']
2023-02-15 21:12:07.180|D|nuki.py:546|Characteristics ['a92ee101-5501-11e4-916c-0800200c9a66 (Handle: 29): Unknown', 'a92ee203-5501-11e4-916c-0800200c9a66 (Handle: 26): Unknown', 'a92ee202-5501-11e4-916c-0800200c9a66 (Handle: 23): Unknown', 'a92ee201-5501-11e4-916c-0800200c9a66 (Handle: 20): Unknown', '00002a26-0000-1000-8000-00805f9b34fb (Handle: 17): Firmware Revision String', '00002a25-0000-1000-8000-00805f9b34fb (Handle: 15): Serial Number String', '00002a27-0000-1000-8000-00805f9b34fb (Handle: 13): Hardware Revision String', '00002a05-0000-1000-8000-00805f9b34fb (Handle: 9): Service Changed']
2023-02-15 21:12:07.189|I|nuki.py:247|Device type: DeviceType.SMARTLOCK_1_2
2023-02-15 21:12:07.327|I|nuki.py:555|Connected
2023-02-15 21:12:07.331|I|nuki.py:572|Updating nuki state
2023-02-15 21:12:07.337|D|nuki.py:520|Sending data to a92ee202-5501-11e4-916c-0800200c9a66: b'\x9c\xf4\x9d\x94\xbfa\x02\xd4\xc5m\xbcMYW\x1d$H"\\\xcba&\xb7\xad\x00\x03\x00\x00\x1a\x00\xd7\xd92\xab\x0f\xbc\xaa\x10F\x05bs\x9f\x06\xf2\xdf\x80W?<\xb8\x13\xae~\x99\x86'
2023-02-15 21:12:07.405|D|nuki.py:420|Notification handler: 23, data: bytearray(b'\xb7\xe04\xf3\xef\xbf\x9bu\x1b\x08\x99\xe0<\x95-\xa4A9t\xe3\xabWs\x00\x00\x03\x00\x00-\x00?.\x10<5\xb3\x137\xb4\xb3\xa0\xcd\x8d\xb7\x059\xec\xbf\xf3\x94 c\xf3\n\xc2\xd2\xe4$\xe7\x97\x02\xa7\xe9\xfb\xd8\x13\x1a"\xc7[\xcdb[\x90\xb4')
2023-02-15 21:12:07.410|D|nuki.py:294|Parsing command: NukiCommand.KEYTURNER_STATES, data: b'\x02\x03\x00\xe7\x07\x02\x0f\x15\x0c#<\x00\xbc\x02\x00\x03\x00\x00\x00\x00\x00'
2023-02-15 21:12:07.415|I|nuki.py:435|State: {'nuki_state': <NukiState.DOOR_MODE: 2>, 'lock_state': <LockState.UNLOCKED: 3>, 'trigger': 0, 'current_time': datetime.datetime(2023, 2, 15, 21, 12, 35), 'timezone_offset': 60, 'critical_battery_state': 188, '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-02-15 21:12:07.422|I|nuki.py:606|Retrieve nuki configuration
2023-02-15 21:12:07.426|D|nuki.py:520|Sending data to a92ee202-5501-11e4-916c-0800200c9a66: b'\x8a\xf4i-(\xfal-1/\x8dQ\x91\x05t\xf9\xb3h\xec]\x8e\xe2\xcfi\x00\x03\x00\x00\x1a\x00\xc2v\x9aK\x8f\x86\xd7\x01\xdd\\\xd9\x16\xeb0O\xb5\xf0\x8b\xad\xc1\x07\xf6\x19T\xee\xc2'
2023-02-15 21:12:07.494|D|nuki.py:420|Notification handler: 23, data: bytearray(b'\xb1\xed\x18\rY\x12\x15c?\xa4`ps\xde\n\xe7|\x86;\xf2\x98=Q\n\x00\x03\x00\x008\x00\x9b\xafL\xcd\x8ct\xab\xc0g\x1d\xfcA\xect\x03\x80y\\\xa1\xff\xe4\xc6\xa5\x8cH\xaf\xef\xaa\xad\xc3\xeeE\x89\xe7e\xd5\x90\x17\x81\xecz\x96\t\x85S+x\xdcq~\x98\x0c\xd9\xf9\xe6\xeb')
2023-02-15 21:12:07.500|D|nuki.py:294|Parsing command: NukiCommand.CHALLENGE, data: b'&@\n\xde\xf3\xce\xa4\x8f\xeb\x16\xf8\xd7\xb3\xaa\x9e\xb4\xaa\x80\xc3\xacw\xcb\xff\xe6zN\xd4\xec-jo\xe4'
2023-02-15 21:12:07.504|D|nuki.py:480|Challenge for NukiCommand.REQUEST_CONFIG
2023-02-15 21:12:07.510|D|nuki.py:520|Sending data to a92ee202-5501-11e4-916c-0800200c9a66: b'\x17\xef\xd0\xf6\xc3R\xd6\xc5O>\xbb\xd7_\x12\xd93\xda\xb1\x8b\xf2O!`\x9c\x00\x03\x00\x008\x00\xdakQ)jV\xddx\xf9\xdfR\x992\xf7\x930;\x06gqy-\xecuR\xfap\x18\xc7\xee\x9c\xcbfM\xf5\xc1`=!\xea\x85\xf7/\x8a\x18>\xdfykD\x9a\xc9f\xf9\xb4\xe1'
2023-02-15 21:12:07.578|D|nuki.py:420|Notification handler: 23, data: bytearray(b'\xbb6f\xb6\xdc\xc6_\x9fM\xc7\x94d_\xc6\x7f\xcf\x0c\xc9\xdc\xe2\xa0\xce\xd9G\x00\x03\x00\x00`\x00j\xd7\xa7\x07\x80\x8d\x1bdM!+Kp@\xa3\xb4o\xaeu\x18&W\xa7\xe9\xdf\xefxV#ZhmiSG\x90\xdd\xf8\r\xd6\xb6\x8e2\xee\xc65%\x89!\xb0\xe51\x83$\xa5H7x\xe7#x\x95\xf4\x03\xed\xea\xc6\x02\xd9\xfc#\xb6|\xf3\x80}\xf3\xc8\x1bF{e\xad\x9b\xd74 \xd9\xc3\x10\xf9\xcb%\xfe\x1f\xb7')
2023-02-15 21:12:07.584|D|nuki.py:294|Parsing command: NukiCommand.CONFIG, data: b'i0k\x04Port39\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000\x0000\x01\x00\x01\x00\x01\xe7\x07\x02\x0f\x15\x0c#<\x00\x01\x00\x04\x01\x02\x00\x00\x00\x01\x0e\x01\x05\x00\x00'
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
Can you try to upgrade the nuki firmware?
according to the nuki app the lock firmware is up to date
Smart Lock Version 1.14.1 is installed
Ok thanks, that version have a different size of the config message, I'll look into it. will push an update probably tomorrow
Thanks for the logs!
awesome 🙏
thank you very much
Just uploaded a quick fix, try to run the updated software and let me know
sry for the late response
just tested it and it works like a charm
Thx for your quick fix 🙏