Add local push capability to Nuki lock integration

The Nuki lock integration currently is of type local polling. Efforts are underway to extend this to local push. If you are impatient, you can enable local push capability with some manual effort and this simple blueprint.

Prerequisites

  • you have a Nuki bridge setup and running
  • you have access to your terminal and can issue a few simple commands from the command line

Manually setup a webhook callback for the Nuki bridge

I suggest you to read the excellent post here. The basic logic is:

  • Create a webhook ID in Home Assistant
  • Register this ID as a callback with the Nuki Bridge

Note: the bridge can only store three callback URLs. If you experiment a bit, you can easily fill-up the slots. There is also a command in the Nuki API that allows you to remove a callback from the bridge. If you’re done experimenting or don’t want to use this blueprint anymore, I strongly suggest that you remove your callback from the device. As this is not covered in the reading above, here are the calls:

List the registered callbacks with IDs:

curl -X GET ‘http://[IP]:8080/callback/list?token=[Token]’ | jq

Remove a specific callback:

curl -X GET ‘http://[IP]:8080/callback/remove?token=[Token]&id=[ID]’

with the parameters:

  • [IP] = IP of your Nuki bridge
  • [Token] = Token of your Nuki bridge
  • [ID] = ID of the callback slot you would like to remove

Automate the callback to update your Nuki integration

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Use this blueprint and

  • enter the webhook ID you created before
  • select the Nuki integration entities to be updated when the bridge notifies Home Assistant about a change

Here is the code:

blueprint:
  name: Update Nuki integration
  domain: automation
  description: Update the Nuki integration by listening to a webhook request from the bridge
  input:
    webhook_id:
      name: Webhook ID
      description: A Home Assistant webhook ID that has been registered with the Nuki bridge for a callback
      selector:
        text:
    lock_entities:
      name: Lock and sensor entities
      description: A list of lock and sensor entities from the Nuki integration to be updated when the Nuki bridge issues a callback
      selector:
        target:
          device:
            integration: nuki
trigger:
  - platform: webhook
    webhook_id: !input webhook_id
condition: []
action:
  - service: homeassistant.update_entity
    target: !input lock_entities
mode: single
3 Likes

Thanks for sharing.
By reading instructions, I have some questions.
Why using an API Token?
As the Nuki bridge does not use any Home Assistant Api, is there another reason to generate a token and not to use an arbitrary webhook ID?

And could it be possible to give again the instructions to generate the Nuki token?
I use a screen reader and was not placed to the right post with instructions so I am not sure to have them right.
There are so much posts in the mentioned topic :slight_smile:

The Home Assistant blueprint doesn’t need the Token from Nuki. This is just a simple webhook from the Home Assistant perspective.

However, to set that webhook in the Nuki bridge, you have to call the bridge interface using a token. This is to protect the bridge from being reconfigured by unauthorized machines on your network. To find the token of your bridge, check the first paragraph here: Nuki - Home Assistant It is the same token that you use to setup your Nuki configuration in HA.

EDIT: I tried and there is no need to create any API token, the webhook ID an arbitrary string of the user’s choice.
Context of the linked post is different.

It looks like I was not precize enough, sorry.
I talk about the webhook ID on the Home Assistant side.
In the post you link to, after some long minutes of reading :slight_smile: I found we had to create a token in the profile section. In the case of your blueprint, is it necessary or can we just create an arbitrary string for the webhook ID? I talk about the webhook ID we specify when setting the URL the Nuki bridge will call. I refer to the webhook_id field of your blueprint;

And could it be possible to give again the instructions in this topic to avoid searching a long time in the post you link to please? Assistive technologies for visually impaired users does not bring us directly to the right post.

Thanks again for your sharing as polling for Nuki won’t be replaced by push before a long time now the pull request to implement web hook has been closed.

I’m not sure if I understand. As far as I know, HA needs the webhook ID to create the webhook. The automation needs a webhook.

Please don’t use this blueprint anymore, it is no longer maintained.

I recommend to move to the next generation Nuki integration, which is a much improved replacement for the built-in Nuki integration, that doesn’t seem to be maintained anymore.