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

Hey,

I have a question concerning the component: I have two locks registered at the bridge. Will the component support both?

Thanks

Yes, it will

1 Like

I tried the custom component today the first time (coming from the card automation before). The lock.nuki_lock entity works fine, but every time i try to unlock the lock.opener entity it throws me error 404.

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/nuki_ng/nuki.py:40
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 10:21:32 (4 occurrences)
Last logged: 10:23:05

* [140497261273536] Http response: 404
* [140497261273536] Error handling message: Unknown error

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service await handler.job.target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 658, in entity_service_call future.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in async_request_call await coro File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 695, in _handle_entity_call await result File "/config/custom_components/nuki_ng/lock.py", line 57, in async_unlock await self.coordinator.action(self.device_id, "unlock") File "/config/custom_components/nuki_ng/nuki.py", line 245, in action result = await self.api.bridge_lock_action(dev_id, action) File "/config/custom_components/nuki_ng/nuki.py", line 82, in bridge_lock_action return await self.async_json( File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json raise ConnectionError(f"Http response: {response.status_code}")
 ConnectionError: Http response: 404

The states were submitted by the callbacks, i can see correct status changes of both lock and opener.
Any idea where to search further?

Mike

Ciao Alessandro

Thanks for the hint, that component seems to be only 3 wks old :slight_smile: Moved to the custom component, that one changes the door state even quicker than the Nuki card, its now down to 2s-3s although the polling is set to 10s. I tried it more than 5 times :slight_smile: so either its really faster or I did hit the button 5 times in the right timing, lol.
I’ll see tonight when the night mode kicks in, what the result is and revert back.
(I agree, night mode would be very easy to automate with HA - since its already in the Nuki App, I just used it from there so far).

Understood one should not mix and match HA and the Nuki App, however there is one thing you dont get with the Nuki card or component but only with the Nuki app: auto unlock in a more safe way. Once you enter the geofence, the lock will auto unlock only as soon as your smartphone connects via bluetooth to the lock (at least thats how its described in their documentation).

Thats why I want to open the door with the Nuki App instead of HA. However, since iOS 14.8, that does not work realiable anymore since Apple apparently changed their location update behaviour and Nuki is struggling to fix it. They blame Apple for it however with HA, location updates always work so I believe its really on the Nuki side and not with Apple.

I keep you posted.

The component, like Nuki Card, is based on callbacks. I thought that was pretty clear now. :slight_smile:

When you lock/unlock, the bridge sends the component/card the updated states, without need to poll. That’s why I made the Nuki Card in the first place: because the official integration relied on polling.

You can create an automation for this. You have geofencing also with HA, and instead of relying on bluetooth, you could rely on the wifi connection or something else.

Drop the apps, concentrate on doing things with HA, so everything will be under YOUR control. :slight_smile:

And this is another advantage vs Nuki Card. :slight_smile:

Bug confirmed. What version of HA are you running? I’m on 11b2.

I tested this a couple of weeks ago and it was working.

I’m on 10.6, trying to be always up to date (but not using a beta) :wink:

Let’s see if Konstantin nails this issue. I’m pretty sure I had tested the opener with 10.6 and it was working.

I’ll wait patiently, if i can help with anything please let me know.

@madface I’ve pushed the fix. Thanks for reporting

Works now. Thanks.

@kvj updated with HACS and unlocking the opener works now.
Thanks for help on a sunday!

Mike

1 Like

That was clear to me, however I can confirm the component reports the state change faster than the card, at least in my environment. (I was wondering though, in the card I was in need to provide the API-Key and a long-term token, whilst on the component I just need to provide the API-Key).

True - are you using that?
I’m worried that the mobile device, in my case an iPhone, will not instantly connect to the Wifi when reaching the door and thus, the unlocking will be either delayed or I’m in need of waking up the phone in front of the door - I did not test it yet though.

BTW, with the component the issue of two push notifications with night mode is gone: in the logbook, I can see now:

  1. Nuki Lock unlocked
  2. Nuki Lock locking
  3. Nuki Lock locked

The component fires / reports a locking insted of a locked, so only 1 push msg - excellent :slight_smile:

Hi,

Thank you for this great Nuki integration. Just received a new version of the Nuki bridge (one that can be updated :wink: and installed the card. All seems to be working so that’s nice.

In the HA log a see this message when I lock or unlock the door.:

2021-11-01 13:49:00 WARNING (MainThread) [homeassistant.components.rest.sensor] JSON result was not a dictionary or list with 0th element a dictionary
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Choose at step 1: choice 3: Error executing script. Invalid data for call_service at pos 8: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Error executing script. Invalid data for choose at pos 1: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Error while executing automation automation.nuki_card_callback: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Choose at step 1: choice 3: Error executing script. Invalid data for call_service at pos 8: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Error executing script. Invalid data for choose at pos 1: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Error while executing automation automation.nuki_card_callback: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Choose at step 1: choice 3: Error executing script. Invalid data for call_service at pos 8: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Nuki Card Callback: Error executing script. Invalid data for choose at pos 1: expected float for dictionary value @ data['value']
2021-11-01 13:49:01 ERROR (MainThread) [homeassistant.components.automation.nuki_card_callback] Error while executing automation automation.nuki_card_callback: expected float for dictionary value @ data['value']
2021-11-01 13:49:03 WARNING (MainThread) [homeassistant.components.rest.sensor] JSON result was not a dictionary or list with 0th element a dictionary

Is there something I did not configure the right way? Hope you can help me with this.
Thanks.

Regards Wouter

But you said that it was 2-3s despite the polling set to 10s. Polling is not relevant, it’s all work made by the bridge, the card/component are passive for status updates when the bridge does the callbacks. Hope it’s clear now. Regarding the token: I hope you understand that my Nuki Card was made using ONLY automation features of HA, while the component is a sw made with Python. Totally different what you can do with a component respect to an automation. Nuki Card was a HUGE automation. I made it as an exercise to learn HA functionalities, and I’m very proud of what I achieved with that. But right now I obviously recommend using the Custom Component. :slight_smile:

No I don’t like automating opening/closing locks, I don’t trust technology enough when we’re talking about house safety. I have children, can’t afford bugs or other things. Security must be absolutely perfect. So no auto-open or lock for me. :slight_smile:

Don’t worry, those are errors that happen when the communication with the bridge was not ok. You didn’t do anything wrong.

But now, the custom component is available, I would suggest switching from Nuki Card to Nuki NG: GitHub - kvj/hass_nuki_ng: Better support for Nuki devices in the Home Assistant

Much more simpler to install/configure. :slight_smile:

Thanks for the reply, great to hear that everything is working as it should :slight_smile:
Nice that there is a custom component also!
Before using the custom component should I remove the installof the current setup?

Ah ok I got it regarding polling and the callbacks.
Regardless of how the card and the component work, its by far better than the official integration and you have done a bloody awesome job! Actually I was just too busy lately, I should have moved to the card (and now component) way earlier. It always bothered me that it took so freaking long to update the status in the frontend - now thats sorted :slight_smile:

I think it doesnt matter, the component will install new sensors anyway. I removed the card, then added the component. Nevertheless, I was in need to remove some orphaned entities in the entity list - not a big deal.