Add local push capability to Nuki lock integration

Tags: #<Tag:0x00007fc408be0bd0>

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