Nuki fails

Hi!

I got my nuki today and wanted to integrate it into homeassistant right away.
First I fell for the oldest error ever and mistook the captal I in the API token for an small l and couln’t imaginge why that doesn’t work.
But even now, that the token is correct, it doesn’t work. I get the following error

Mär 17 20:12:34 cs hass[20883]: Traceback (most recent call last):
Mär 17 20:12:34 cs hass[20883]:   File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_component.py", line 153, in _async_setup_platform
Mär 17 20:12:34 cs hass[20883]:     entity_platform.schedule_add_entities, discovery_info
Mär 17 20:12:34 cs hass[20883]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Mär 17 20:12:34 cs hass[20883]:     yield self  # This tells Task to wait for completion.
Mär 17 20:12:34 cs hass[20883]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Mär 17 20:12:34 cs hass[20883]:     future.result()
Mär 17 20:12:34 cs hass[20883]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Mär 17 20:12:34 cs hass[20883]:     raise self._exception
Mär 17 20:12:34 cs hass[20883]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Mär 17 20:12:34 cs hass[20883]:     result = self.fn(*self.args, **self.kwargs)
Mär 17 20:12:34 cs hass[20883]:   File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/lock/nuki.py", line 39, in setup_platform
Mär 17 20:12:34 cs hass[20883]:     add_devices([NukiLock(lock) for lock in bridge.locks])
Mär 17 20:12:34 cs hass[20883]:   File "/home/cs/.homeassistant/deps/pynuki/pynuki.py", line 176, in locks
Mär 17 20:12:34 cs hass[20883]:     state_data = {k: v for k, v in l['lastKnownState'].items() \
Mär 17 20:12:34 cs hass[20883]: KeyError: 'lastKnownState'

Any idea?

Are you using an Android as a bridge?

No, it’s the hardware bridge.

In case it might be helpful, relpy for /list is:

[{"nukiId": 123456789, "name": "test", "lastKnownState": {"state": 1, "stateName": "locked", "batteryCritical": false, "timestamp": "2017-03-17T20:11:06+00:00"}}]

Strange enough, now it works. The only thing I changed today is that I added the port (default, 8080) to the configuration. No other change whatsoever…

I’m experiencing same problem but I already have the port in the configuration :frowning:

for all looking for help with nuki connection problems take a look here: https://developer.nuki.io/t/random-http-503-unavailable/909/95

there are some api problems. With Nuki Opener and Lock connected i think this cause even more problems and result in a unstable connection with ha.

1 Like

I have this error in the log:

File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://192.168.1.11:8080/list?ts=2020-12-06T20...

Although I have followed the instructions to configure Nuki:

lock:
  - platform: nuki
    host: 192.168.1.11
    port: 8080
    token: abcdef

as well as activated API Nuki Web and generated the API token ‘abcdef’.
Where do I make mistakes ?
TIA for your help.

I reply to myself, it might help others:
by taking out the line “port: 8080” it happens to work now :grinning: