hass_nuki_bt icon indicating copy to clipboard operation
hass_nuki_bt copied to clipboard

Can't setup Nuki 1.0

Open DeamBeam opened this issue 1 year ago • 2 comments
trafficstars

System Health details

System Information

version core-2024.7.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.33-haos
arch x86_64
timezone Europe/Berlin
config_dir /config
Home Assistant Community Store
GitHub API ok
GitHub Content ok
GitHub Web ok
GitHub API Calls Remaining 4868
Installed Version 1.34.0
Stage running
Available Repositories 1388
Downloaded Repositories 10
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Home Assistant Supervisor
host_os Home Assistant OS 12.4
update_channel stable
supervisor_version supervisor-2024.06.2
agent_version 1.6.0
docker_version 26.1.4
disk_total 30.8 GB
disk_used 8.4 GB
healthy true
supported true
host_connectivity true
supervisor_connectivity true
ntp_synchronized true
virtualization kvm
board ova
supervisor_api ok
version_api ok
installed_addons File editor (5.8.0), Vaultwarden (Bitwarden) (0.22.0), Mosquitto broker (6.4.1), Terminal & SSH (9.14.0), Meross Local Broker Addon (0.0.1-alpha49), Zigbee2MQTT (1.39.0-1)
Dashboards
dashboards 2
resources 2
views 9
mode storage
Recorder
oldest_recorder_run 21. Juli 2024 um 20:53
current_recorder_run 31. Juli 2024 um 22:28
estimated_db_size 181.86 MiB
database_engine sqlite
database_version 3.45.3
Spotify
api_endpoint_reachable ok

Checklist

  • [X] I have enabled debug logging for my installation.
  • [X] I have filled out the issue template to the best of my ability.
  • [X] This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • [x] This issue is not a duplicate issue of currently previous issues..

Nuki Device type

Nuki Smartlock 1.0

hass_nuki_bt version

0.0.14

Describe the issue

Devices failes to setup. It automatically discovers the device and i can configure it. It also recognizes if the device is in pairing mode (instantly shows a message that pairing mode needs to enabled). If i set it up as client type "App" it creates the "Homeassistant" User on the Nuki lock. But with either client type it fails to setup the device.

I also tried to enable and disable passive scanning in the bluetooth integration.

(i use this Bluetooth adapter: https://www.amazon.de/gp/product/B0BW97QCTX/ )

Reproduction steps

  1. Clicking on configure device as it is discovered automatically
  2. Pressing the Button on the Nuki Lock for 6 seconds until the LED stays on
  3. Waiting until it finishes setting up

Debug logs

Logger: homeassistant
Quelle: /usr/src/homeassistant/homeassistant/runner.py:148
Erstmals aufgetreten: 23:06:05 (3 Vorkommnisse)
Zuletzt protokolliert: 23:06:59

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 258, in _notification_handler
    msg = self._parse_message(bytes(data), encrypted)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 208, in _parse_message
    msg = self._const.NukiMessage.parse(self._decrypt_message(data))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 404, in parse
    return self.parse_stream(io.BytesIO(data), **contextkw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 416, in parse_stream
    return self._parsereport(stream, context, "(parsing)")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2236, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2770, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/const.py", line 996, in _parse_other
    ret = super()._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 4556, in _parse
    return self.subcon._parsereport(substream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/const.py", line 993, in _parsereport
    return tmp_subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 4036, in _parse
    return sc._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2236, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2770, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 428, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 1157, in _parse
    data = stream_read(stream, self.length, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 178, in stream_read
    raise StreamError("stream read less than specified amount, expected %d, found %d" % (length, len(data)), path=path)
construct.core.StreamError: Error in path (parsing) -> payload -> accessory_battery_state
stream read less than specified amount, expected 1, found 0




Logger: pyNukiBT.nuki
Quelle: /usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py:350
Erstmals aufgetreten: 23:06:25 (3 Vorkommnisse)
Zuletzt protokolliert: 23:07:19

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 346, in _send_command
    msg = await self._notify_future
          ^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 345, in _send_command
    async with async_timeout.timeout(self.command_response_timeout):
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError




Logger: homeassistant.config_entries
Quelle: config_entries.py:586
Erstmals aufgetreten: 23:07:37 (1 Vorkommnisse)
Zuletzt protokolliert: 23:07:37

Error setting up entry Nuki_11454A71 for hass_nuki_bt
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_nuki_bt/__init__.py", line 90, in async_setup_entry
    if not await coordinator.async_wait_ready():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_nuki_bt/coordinator.py", line 155, in async_wait_ready
    await self._async_update()
  File "/config/custom_components/hass_nuki_bt/coordinator.py", line 112, in _async_update
    await self.device.update_state()
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 421, in update_state
    msg = await self._send_encrtypted_command(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 184, in _send_encrtypted_command
    unencrypted = self._const.NukiMessage.build(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 452, in build
    self.build_stream(obj, stream, **contextkw)
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 464, in build_stream
    self._build(obj, stream, context, "(building)")
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2260, in _build
    buildret = sc._build(subobj, stream, context, path)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2774, in _build
    return self.subcon._build(obj, stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 4559, in _build
    return self.subcon._build(obj, stream, context, path)
           ^^^^^^^^^^^^^^^^^^
AttributeError: 'tmpclass' object has no attribute '_build'

Diagnostics dump

No response

DeamBeam avatar Jul 31 '24 21:07 DeamBeam

Same problem here with nuki 2.0

Error setting up entry Garagentür for hass_nuki_bt Error setting up entry Garagentür for hass_nuki_bt Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hass_nuki_bt/__init__.py", line 90, in async_setup_entry if not await coordinator.async_wait_ready(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hass_nuki_bt/coordinator.py", line 155, in async_wait_ready await self._async_update() File "/config/custom_components/hass_nuki_bt/coordinator.py", line 112, in _async_update await self.device.update_state() File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 421, in update_state msg = await self._send_encrtypted_command( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 184, in _send_encrtypted_command unencrypted = self._const.NukiMessage.build( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 452, in build self.build_stream(obj, stream, **contextkw) File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 464, in build_stream self._build(obj, stream, context, "(building)") File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2260, in _build buildret = sc._build(subobj, stream, context, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2774, in _build return self.subcon._build(obj, stream, context, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 4559, in _build return self.subcon._build(obj, stream, context, path) ^^^^^^^^^^^^^^^^^^ AttributeError: 'tmpclass' object has no attribute '_build'

SlKlElT avatar Aug 03 '24 12:08 SlKlElT

Is this repo also dead?

SlKlElT avatar Aug 20 '24 12:08 SlKlElT

@SlKlElT no, not dead. I was a bit busy during the last few months, but now I'm back :-)

ronengr avatar Nov 11 '24 14:11 ronengr

As I don't have Nuki1 or Nuki2 device to test, this kind of issues are to be expected. It seems the Nuki1 doesn't have accessory_battery_state as part of it's KeyturnerStates message. I will try to fix this for next version.

@SlKlElT Could you please add some more logs? I'm guessing there should also be some StreamError in the Nuki2 case.

ronengr avatar Nov 11 '24 14:11 ronengr

@DeamBeam Should be fixed in latest version (0.0.15) If you get a new error (which might happen, as i don't have a Nuki1 to test), please let me know.

ronengr avatar Nov 11 '24 18:11 ronengr

As I don't have Nuki1 or Nuki2 device to test, this kind of issues are to be expected. It seems the Nuki1 doesn't have accessory_battery_state as part of it's KeyturnerStates message. I will try to fix this for next version.

@SlKlElT Could you please add some more logs? I'm guessing there should also be some StreamError in the Nuki2 case.

i moved to the deprecated addon meanwhile, i will check the new Version and get back to you.

SlKlElT avatar Nov 11 '24 22:11 SlKlElT

As I don't have Nuki1 or Nuki2 device to test, this kind of issues are to be expected. It seems the Nuki1 doesn't have accessory_battery_state as part of it's KeyturnerStates message. I will try to fix this for next version.

@SlKlElT Could you please add some more logs? I'm guessing there should also be some StreamError in the Nuki2 case.

@ronengr i've tried it now with the Version 0.0.16.2 - still not working

Logger: homeassistant.config_entries
Quelle: config_entries.py:635
Erstmals aufgetreten: 16:12:16 (3 Vorkommnisse)
Zuletzt protokolliert: 16:13:33

Error setting up entry Nuki_***** for hass_nuki_bt
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_nuki_bt/__init__.py", line 92, in async_setup_entry
    if not await coordinator.async_wait_ready():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hass_nuki_bt/coordinator.py", line 137, in async_wait_ready
    await self._async_update()
  File "/config/custom_components/hass_nuki_bt/coordinator.py", line 115, in _async_update
    await self.device.update_state()
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 419, in update_state
    msg = await self._send_encrtypted_command(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 173, in _send_encrtypted_command
    return await self._send_command(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 348, in _send_command
    msg = await self._notify_future
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 240, in _notification_handler
    msg = self._parse_message(bytes(data), encrypted)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/nuki.py", line 185, in _parse_message
    msg = self._const.NukiMessage.parse(self._decrypt_message(data))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 288, in parse
    return self.parse_stream(io.BytesIO(data), **contextkw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 300, in parse_stream
    return self._parsereport(stream, context, "(parsing)")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2120, in _parse
    subobj = sc._parsereport(stream, context, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 2653, in _parse
    return self.subcon._parsereport(stream, context, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyNukiBT/const.py", line 1016, in _parse
    hash1 = self.checksumfield._parsereport(stream, context, path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 312, in _parsereport
    obj = self._parse(stream, context, path)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 1041, in _parse
    data = stream_read(stream, self.length, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/construct/core.py", line 91, in stream_read
    raise StreamError("stream read less than specified amount, expected %d, found %d" % (length, len(data)), path=path)
construct.core.StreamError: Error in path (parsing) -> crc
stream read less than specified amount, expected 2, found 1

SlKlElT avatar Nov 23 '24 15:11 SlKlElT

@SlKlElT Thanks for the feedback, I will lock into this.

ronengr avatar Nov 24 '24 12:11 ronengr

@SlKlElT I've just released a new version (0.0.17) that should fix this error.

ronengr avatar Jan 08 '25 15:01 ronengr