Using Nuki Lock 3.0 Fully Local without Bridge

Thanks for your reply. Let me check it out.

To be fair, the authorization key might be usable but it changes and is Bluetooth connection only. So I really didn’t think it would be an issue and just posted it.

When using the web connected nuki or in general, yes you’re definitely right. Redacted !

Thanks again for helping out.

So I’m using:

Home Assistant 2022.12.8
Supervisor 2022.12.1
Operating System 9.4
Frontend-versie: 20221213.1 - latest

It’s installed on a NUC.

Therefore I configured as followed:
http://127.0.0.1

Sadly it’s still refusing connection:


Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.nuki_ng.config_flow
Source: custom_components/nuki_ng/nuki.py:78 
Integration: Nuki Lock (documentation, issues) 
First occurred: 20:28:29 (1 occurrences) 
Last logged: 20:28:29

Failed to get list of devices from bridge: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //127.0.0.1:8080/info?token=redacted (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6673502680>: Failed to establish a new connection: [Errno -2] Name does not resolve'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f6673502680>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //127.0.0.1:8080/info?token=94649fc705cf19f602156262869d568a1b5b9c91d7690e64c92ba99caa736ac3 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6673502680>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/config_flow.py", line 34, in find_nuki_devices
    info = await nuki.bridge_info()
  File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info
    return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT))
  File "/config/custom_components/nuki_ng/nuki.py", line 37, in async_json
    response = await self.hass.async_add_executor_job(lambda: cb(requests))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/nuki_ng/nuki.py", line 37, in <lambda>
    response = await self.hass.async_add_executor_job(lambda: cb(requests))
  File "/config/custom_components/nuki_ng/nuki.py", line 78, in <lambda>
    return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT))
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //127.0.0.1:8080/info?token=94649fc705cf19f602156262869d568a1b5b9c91d7690e64c92ba99caa736ac3 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f6673502680>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

Use 127.0.0.1:8087 if HAOS

Since you are using HAOS, you need to set the IP AND the port because you changed it to 8087.
You need to use 127.0.0.1:8087

1 Like

Dude… This might be inappropriate but you’re a gifted fella!

I used:
127.0.0.1:8087 and it finally worked.

There was no need to use http:// in the beginning of the address. That did the trick.

Now let’s play :smirk:

Thanks again!

1 Like

You are welcome! Enjoy!

So I got it finally working, but I did a few mistakes.
First of all I had the internal WLAN enabled in my SL3.0 Pro which isn’t supposed to work with the Nuki Bridge or the Raspi Nuki Bridge together. It has to be the one or the other.
Next problem was the Bluetooth dongle. I now use an extension cable. I think this was the reason for better bluetooth connection. Finally I should have read the initial post more carefully about restarting the bridge after pairing. I couldn’t get the integration nuki ng setup without this restart.
And I also needed the

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps --format '{{.Names}}' | grep nuki)

to find the IP of my host. So I used 172.30.33.10 without port. That’s it

Many Thanks @victorigualada for your help and your patience.

1 Like

That’s great! I’m glad you mamaged to solve it!

Hey. I would appreciate some help here please.

I want to use HA (HAOS in rpi 3b+) with Nuki 3.0 without Nuki Bridge and Without Nuki 3.0 pro

Add-on: Nuki Bridge
Virtual Nuki Bridge to use instead of the physical device

Add-on version: 0.0.23
You are running the latest version of this add-on.
System: Home Assistant OS 9.4 (aarch64 / raspberrypi3-64)
Home Assistant Core: 2023.1.1
Home Assistant Supervisor: 2022.12.1

I can get the Access Token but when i put the details on Nuki-ng it fails saying
“Error communicating with Nuki bridge”.

In the Nuki ip address i have tried:

127.0.0.1
127.0.0.1:8080
172.30.33.4 »»» that’s the output of the
docker inspect -f ‘{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ $(docker ps --format ‘{{.Names}}’ | grep nuki)
172.30.33.4:8080

In the HA url i am using http://192.168.1.xx:8123 (this is how i access my HA so it must be correct

And in the Bridge Api Token i am pasting the Access Token retireved from the Nuki Bridge addon seconds ago.

Any help would be great. thanks

Did you try @Daniel76 solutions in his last comment? Using Nuki Lock 3.0 Fully Local without Bridge - #42 by Daniel76

Seems the same problem. Restart the Raspberry, and, since you have HAOS, use 127.0.0.1 if you haven’t changed the port or 127.0.0.1:<port> if you changed it in the addon config.

Yes i did. That’s why i tried those 4 combinations of ip address, 2 ip each one with and whithout port. I didn’t change anything so my port shall be the default one.
Maybe the problem can be related to nginx ssl addon? (just guessing)

It shouldn’t be related to nginx since it has nothing to do with communication between the HA instance and the containers running in it.

Unless you run rhe bridge in a different system than HA is running? In thay case you should use the local IP of the bridge (192.168.1.xxx)

Also did you restart the bridge? Did you disabled WiFi in the Lock if you use the 3.0 Pro version?

I don’t have a Nuki Bridge. I want to use HA (HAOS) as the bridge so i can use my Nuki 3.0 without having to buy the Nuki bridge.
Did i understood all wrong and i must have a Nuki Bridge?
It is Nuki 3.0 non-pro, so no wifi

Sorry when I said the bridge I meant the raspberry running the addon.

You don’t need the Nuki Bridge at all. You got right the purpose of the guide.

I would suggest to go through the guide again and see if you skipped a step. Also check the addon logs for errors and come back and post them if any.

I did several times with reboots and still no way to undertsand what is happening.
The only strange thin i have is afterit gets the token and after i try to use it on nuki-ng and fails, the log shows

2023-01-06 17:31:12.471|I|nuki.py:254|Waiting for more tasks with timeout
======== Running on http://0.0.0.0:8080 ========

Like an user post it before. Is that 0.0.0.0 expected?

Thanks

Did you see on the first start during the pairing process pairing completed?

********************************************************************
*                                                                  *
*                         Pairing completed!                       *
*                            Access Token                          *
* abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca *
*                                                                  *
********************************************************************

This is very important, because you will see it only once. I needed to do the pairing several times to be successful. If it is successful it takes only a few seconds, if not a minute or so.

Nope, never ever it shows Pairing completed. Only the token like this:

[services.d] starting services
[services.d] done.
2023-01-06 23:33:11.989|I|config.py:72|********************************************************************
2023-01-06 23:33:11.990|I|config.py:73|* *
2023-01-06 23:33:11.990|I|config.py:74|* Access Token *
2023-01-06 23:33:11.991|I|config.py:75|* [ 64 char token ] *
2023-01-06 23:33:11.992|I|config.py:76|* *
2023-01-06 23:33:11.992|I|config.py:77|********************************************************************
2023-01-06 23:33:12.026|I|nuki.py:254|Waiting for more tasks with timeout

The [64 char token] is like abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabca

So I think the pairing wasn’t successful. I had to try it also several times. You can always see an access token. I had also to try several times before I could really pair the lock. I started with installing the add-on again and started again.

Tried several times with no success. Also tried the manual way, runing the python and i found out it can’t install all the dependencies, specificly pynacl that looks impossible to install. Don’t know if can be related or not.
The error is “ModuleNotFoundError: No module named ‘nacl’”

ciao, bella guida, pensavo di comprare il nuki lock quello bluetooth e collegarlo direttamente a home assistant, solo che nel mio server debian non ho la scheda bluetooth, mi consigliate una chiavetta bluetooth da aggiungerci specifica o ne va bene una qualsiasi?

That’s probably because the RPi is too far away from the lock. Remember that it works through Bluetooth and that its range is limited.