Nuki Card with Callback support (supports both Lock & Opener, it replaces the official integration)

Hi,

What guide did you follow? Did you install the custom component or the Nuki Card (automation)?
The guide in the first post is related to the Nuki Card, I’m recommending to switch to the custom component version developed by @kvj now, you can install it through HACS: GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant

Let me know how it goes…

Welcome to the disfunctional DNS resolution subsystem of HA, that relies on a buggy configuration and mDNS/zeroconf buggy stuff. :slight_smile:

We had several discussions about this, but devs think that this is the correct way to do name resolution, while many users face these kind of issues every day. They don’t want to change it, so you have to adapt to it.

The component should pickup the default HA url automatically. In my Nuki Card, you were able to configure it manually, and I advised users to use the IP in case of issues like this. Maybe this is something that could be implemented by @kvj through config_flow: right now you can’t reconfigure the component, it would be good to add the two hostnames/IPs (HA and Bridge) to the configuration, with the default being the autodetected hostnames, so users with dns issues can switch to IP as a workaround.

Some questions for you:

  1. do you have internal_url / external_url set in config.yaml?
  2. are you running HassOS or supervised?
  3. go to Supervisor->System, what do you see under Hostname?

Sorry for this issue, I’ll wait for your feedback. Thanks.

Hi,

  1. do you have internal_url / external_url set in config.yaml?
    Yes, the internal use homeassistant.local:8123.
  2. are you running HassOS or supervised?
    Running HassOS
  3. go to Supervisor->System, what do you see under Hostname?
    Hostname = homeassistant

Is it an idea to ask for an ip-address during configuation of the integration? (by default the dns name?)
Btw. no problem.

Regards,
Wouter

Thanks Wouter, now I need your support for the following, if you can obviously:

  • If you have homeassistant as hostname under System->Hostname, I’d suggest to change internal_url to homeassistant, stripping away the suffix .local.

  • Make sure that HA has a DHCP reservation or static IP and that the hostname homeassistant is correctly resolved by clients on the LAN (the bridge is a client, but can’t resolve .local mDns nightmare stuff, and rightly so) doing an nslookup from a couple of other clients.

  • Once you’re sure that the hostname of HA is resolved, change internal_url to the correct one, uninstall the component, delete the callback on the bridge, then restart HA and retry the installation of the component, please let us know if this time it works without issues.

I know you already solved the issue, but if you could do this it would help other users with the same problem.

Thanks for your help, looking forward to your feedback.

Alessandro

Wouter, I just reinstalled the component to check the config dialog, and what you ask is already there:

As you can see, you can use IP both in the first and second field. :slight_smile:

The only thing that is missing is the possibility to change settings after it has been installed.

Hi, must have completely overlooked that option :flushed:
Wanted just to reinstall the integration to check things again based on the earlier reply.
Re-installed the integration and put an ip-address in the field you highligted.
And now there is a call back url with an ip-address active on the bridge.

Great! and thanks again.

Regards,
Wouter

Sorry if I didn’t tell you immediately…:slight_smile:

Anyway, change the internal_url and align it to the hostname. :wink:

No problem, it is working great and that 's all what matters :slight_smile:

Hi Alex,

thanks for your support.

  1. in log i see:

Logger: homeassistant.components.nuki
Source: helpers/update_coordinator.py:193
Integration: Nuki (documentation, issues)
First occurred: 22:35:56 (2 occurrences)
Last logged: 22:41:43

Timeout fetching nuki devices data

  1. the previous image is from the integration page. Looks like is not loading the logo image if there is any.

  1. Home Assistant 2021.11.2

  2. Previously I was running your previous version and I deleted the entiry file from the package folder. I recall that was the only file I added with the card in lovelace. Am I missing something?

f

Ciao,

from the log you can clearly see (homeassistant.components.nuki) that the component you are using is the official Nuki one integrated in HA, not the custom component developed by @kvj: GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant

If you used the custom component, you would see this: custom_components.nuki_ng.nuki

So, first of all, you have to clean everything: remove the Nuki Card package, then clean all orphan entities that Nuki Card created (input_* helpers etc.), then remove the Nuki official integration that you are currently using.

Double-check that everything’s clean, then install Nuki NG custom component I linked before. When you configure it, I advice to use IPs for the bridge and for HA internal url, some users are having DNS issues due to HA bugged DNS implementation.

Let me know how it goes…

Hi, sorry for the late reply. That Custom Component works like a charme! Thank you!

Happy to hear that. :slight_smile:

1 Like

Hello.

I have installed the nuki lock custom component and it works great.
But I have to disable it, because every 30 sec I got errors in the log, that the webhook doesn’t work.
Can somebody help me with this?

Here is the log…


2021-11-12 23:26:07 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to update callback http://192.168.1.33:8123/api/webhook/nuki_ng_bridge_hook_8e124336f0c59a6cd3d494e314a5870c
Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/nuki.py", line 201, in _update
    await self.api.bridge_check_callback(self.bridge_hook)
  File "/config/custom_components/nuki_ng/nuki.py", line 117, in bridge_check_callback
    raise ConnectionError(result.get("message"))
ConnectionError: too many callbacks registered
2021-11-12 23:26:08 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error while fetching auth:
Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/nuki.py", line 216, in _update
    item["web_auth"] = await self.api.web_list_all_auths(dev_id)
  File "/config/custom_components/nuki_ng/nuki.py", line 131, in web_list_all_auths
    response = await self.web_async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 123, in web_async_json
    return await self.async_json(lambda r: cb(r, {
  File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json
    raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 401

Did you enforce https to access HA? The bridge doesn’t support https. You need to allow HTTP locally.
Do you have any kind of proxy or something in between the client (nuki bridge in this case) and HA?

Tagging @kvj for this.

@Dominik.W
the issue is in the stack trace: ConnectionError: too many callbacks registered
You probably already have 3 callbacks registered in your bridge. You can remove them though, via the API.
From here: Nuki Developers

Thank you.
I reset the bridge to defaults and reinstalled everything.
Now the callback works, but I have a new error…


2021-11-13 09:04:28 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error while fetching auth:
Traceback (most recent call last):
  File "/config/custom_components/nuki_ng/nuki.py", line 216, in _update
    item["web_auth"] = await self.api.web_list_all_auths(dev_id)
  File "/config/custom_components/nuki_ng/nuki.py", line 131, in web_list_all_auths
    response = await self.web_async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 123, in web_async_json
    return await self.async_json(lambda r: cb(r, {
  File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json
    raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 401

such a huge :man_facepalming: for me. just added the repository without enabling it and I was installing over and over again the official component. thanks for support. everything up and running!

don’t worry, these things can happen. glad it’s working for you. :slight_smile:

Konstantin, the “too many callbacks registered” is generated by the component? That means: “I can’t add another callback because 3 are already present”, correct?

@alexdelprete No, this error comes from the Bridge. It doesn’t support more than 3 callbacks