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

Thanks, so far everything worked flawlessly and I’m really impressed with the custom component. I can finally see the usage of the keypad as well.

Yes, @kvj made a great job. It’s an excellent component.

A quick question to the people who are using the opener. When im trying to open the external gate with

  - service: lock.open
    entity_id: lock.nuki_opener_lock

i have to do this 2-4 times until the opener is blinking and opens the electric strike actuater.
If it opened and i repeat it works every time but if i wait a few minutes it is the same problem.
Is this only my opener? What Firmware is yours, mine is on 1.7.3?

+1 Last attempts to open my building door failed. I had to click a few times, and eventually I think only when I opened the actual entity details (long press on card [ Android app]) it changed color and was then ready to receive instructions.

Hey guys, i have setup https://github.com/kvj/hass_nuki_ng and it’s working.
Also using my bridge access token which worked like charm in fhem.

Sometimes the lock states are a little bit slow.
My “binary_sensor.nuki_bridge_bridge_callback_set” is on/true.

So my question are:

  • Does the true/on of the binary sensor mean my callback is really working?
  • If not, how can i check if the callback is working?

thx

If you open the sensor and check its attributes, you’ll see the URL that is in the callback list of the bridge. That url is configured by the component when you first configure it. The binary_sensor is simply telling the user that the callback is present on the bridge.

image

When the lock or door sensor changes state, the bridge calls that url to communicate the change of state. If everything works fine it is immediate. That means that if you have the door sensor and open the door, you should see the door transition to the open state. If you lock the lock, you should see immediate transition too. If it takes more than 3 seconds, it means there’s a problem.

First thing: double-check the url that you see in the binary sensor, make sure the IP and port are correct, those are the HA ip and port, and that’s where the bridge calls back. If those parameters are correct, and you still don’t see state changes in 3-4 seconds then that’s not the problem.

Second thing: the bridge doesn’t support HTTPS, its hw is very limited (and the fw too). So make sure the URL is plain http. If you hardened HA configuration to support only https, that is your problem.

Third thing: you can enable debug logging for the component in the logger integration, adding this line:

custom_components.nuki_ng: debug

After restarting HA, all activity of the components, callbacks included, will be written in HA logs with many details, and you can check if the callback has been received.

Let us know how it goes.

Thanks a lot for your help.
Yes the callback seems correct:

image

But sometimes it takes up to ~12 seconds until the state changes. Sometimes it takes ~5 seconds.

In may case, it’s set with the local hostname (because when i set it up i was accessing HA with the host name). Does the bridge support hostnames?

When i access the link internally with my browser i get “405: Method Not Allowed”.
I think this does mean that i just have not accessed the callback API correctly but the callback URL is working, right?

thx

@alexdelprete i solved it by removing the integration and readding it with the HA IP address instead of the hostname for the internal URL.

Now it’s working and states changing way faster.

thx
pOpY

1 Like

I always recommend for the bridge, being so low power hardware, to use IP or use the FQDN. In your case, you had the hostname without domain name, that kind of name resolution is usually slower because the host (the bridge in this case) has to search for the name of domain name before reaolving it, I’ve seen hosts take 3-4s to resolve those because of bad configuration.

When you configured HA did you set internal_url and external_url? the internal_url is the one autodetected by the integration on first configuration.

Anyway, glad that now it’s working. :slight_smile:

Thx for the hints. Yep, it’s working now :slight_smile:

On initial HA setup the internal URL is “http://homeassistant:8123”.
What’s recommended? Change it to the actual IP?

No, the initial url is generally always the hostname. I change it to the FQDN: http://homeassistant.domain.name:8123

For some integrations with legacy or “weak” devices like the bridge, I use the IP instead of the internal_url: http://10.1.10.28:8123.

1 Like

Because it works now, i leave my configuration as it is :slight_smile:
thx a lot.

It’s HA internal_url, now that your component is configured ok there’s no potential issue.

If you don’t fix it now that you understand the potential problem, something will break in the future, for some other thing. :wink:

Is there a way to detect if the lock was locked with Lock ‘n Go and trigger an automation?
Ideally without using ifttt.
Thx

Hi There,

Anyone that can help me with the following?:
The card for both the opener and lock work great. Everything is connected, and all sensors work.
The only problem I have are with the lock.nuki_lock_action
The state is unavailable at all times as you can see below.
Anybody that can help me understand why this whole integration works fine, except for the lock/unlock action?
Thanks!! Big Kudos to @alexdelprete , thanks for this work. It is amazing, and far superior to the official integration thanks to the support for the opener!
Cheers!!


Hi, and thanks for your kind words.

did you read the “important update” notice in the first lines of the OP? :slight_smile:

Well, that’s on me for missing that :stuck_out_tongue: . Thanks for pointing that out :slight_smile:
I got too excited when I found this topic which gave me access to the nuki opener doorbel sensor.

Thanks anyway for your previous hard work on this!! Looks like it was a great project!

Thanks again for your kind words. All the ideas that went into that project have been ported to the custom component, so you won’t lose any functionality, plus, it’s more efficient having everything in a python native component than doing everything as a HUGE automation, that’s what Nuki Card was, and when I think about it I’m still quite amazed about everything it did using only HA automation features. :slight_smile:

Remember to clean everything up before using the component. Good luck.

Any hints on why I am getting this error?

2022-03-17 15:19:48 ERROR (MainThread) [homeassistant.components.webhook] Error processing webhook nuki_ng_bridge_hook_7d07fd866f13463a97b7839d1202d693
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 121, in async_handle_webhook
response = await webhook["handler"](hass, webhook_id, request)
File "/config/custom_components/nuki_ng/nuki.py", line 311, in _hook_handler
self._add_update(body.get("nukiId"), body)
File "/config/custom_components/nuki_ng/nuki.py", line 264, in _add_update
self.async_set_updated_data(data)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 287, in async_set_updated_data
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 325, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 553, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 590, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in _stringify_state
if (state := self.state) is None:
File "/config/custom_components/nuki_ng/sensor.py", line 93, in state
return self.native_value
File "/config/custom_components/nuki_ng/sensor.py", line 89, in native_value
return self.data.get("bridge_info", {}).get("rssi")
AttributeError: 'NoneType' object has no attribute 'get'

how did you configure the component? reconfigure it from scratch (uninstall and reinstall the integration) and before submitting, do a screenshot of the config screen.

It seems the communication with the bridge is not working, but this can depend on several things, please show me how you configured it.

1 Like