Webhook senden, wenn es an der Tür klingelt?

Hallo,

ich bin vielleicht etwas von der Doorbird verwöhnt, aber kann man mit Niki keinen Webhook senden, wenn es an der Tür klingelt? Ich würde gerne einen Klingelton über meine Sonos Lautsprecher über Homeassistant ausgeben…

Grüße Tino

1 Like

This does work already, via the Bridge API.
Take a look at the docs: Nuki Developers (if the direct link doesn’t jump to the right section, go to: “5. Endpoints/callback”)

For the opener, the bridge will send the following data:

{
  "nukiId": 11,
  "deviceType": 2,
  "mode": 3,
  "state": 3,
  "stateName": "rto active",
  "batteryCritical": false,
  "ringactionTimestamp": "2020-04-27T16:13:00+00:00",
  "ringactionState": false
}

What you will want to use is the key ringactionState. Whenever that’s set to true, it’s indicating a doorbell ring. And cause I’m in a good mood, I’ll help you with the Home Assistant part too!

This automation will setup a webhook on home assistant and whenever a ringAction is triggered on the opener, the webhook will be called and hence this automation triggered. It then verifies, that it’s an actual doorbell ring (true state).

Then you can do whatever you like, I stop the media playback on my TVs and send a notification. :slight_smile:

alias: Nuki Opener Callback
trigger:
  - platform: webhook
    webhook_id: nuki_callback
condition:
  - condition: template
    value_template: '{{ trigger.json.ringactionState == True }}'
action:
  - service: notify.my_lg_tv
    data:
      message: Riiing riiing!
  - service: media_player.media_pause
    target:
      entity_id:
        - media_player.my_lg_tv
        - media_player.my_android_tv
mode: single

Last step is to register the webhook against the nuki bridge via the /callback/add endpoint.
I.e. call: http://your-bridge.local:8080/callback/add?url=http://homeassistant.local:8123/api/webhook/nuki_callback&token=123456

(Of course, adjust the values for your bridge and home assistant IP / DNS names as well as add the proper token for the /add call).

Hope this helps.

4 Likes

Thank you @bit !!

How could I activate this within the bridge? I tested this:

http://IP-Adress of the bridge:8080/auth and I get as response:

{“success”: false}

HTTP API is activated!

Did you provide the bridge api token via the query parameter ?token=?

I think you don’t need to call /auth anymore, as the api token is already listed in your Nuki app. Just grab the token and modify the callback add request I posted above. :slight_smile:

Thank You @bit ! But I struggle a little bit with the /callback/add. I added this URL:

http://192.168.178.xx:8080/callback/add?url=http://192.168.178.yy:8000/nuki&token=123456

I Checked it with callback/list:

{“callbacks”: [{“id”: 0, “url”: “http://192.168.178.yy:8000/nuki”}]}

But if I ring the bell, nothing happened

Please follow this format, to register the correct target for the home assistant incoming webhook part.
/api/webhook/nuki_callback is crucial for home assistant, so it can identify the incoming callback requests from the bridge.

So basically, just adjust this to the correct IP and port of your home assistant instance.


http://192.168.178.xx:8080/callback/add?url=http://192.168.178.yy:8123/api/webhook/nuki_callback&token=123456

Maybe this helps to understand the HA part: Automation Trigger - Home Assistant

1 Like

Thanks a lot! Now it’s working!

1 Like

Yay - cool! Happy to help. :slight_smile:

2 Likes