Nuki Smart Lock 2.0 - support all available API actions (i.e. add lock/unlock)

@pschmitt
In the newest Bridge beta it’s finally possible to see door states and not just lock states. Will you be able to add this to the HA component?

2 Likes

@PizzaPino
Until that is supported from the nuki integration you could simply use a REST sensor in order to catch the /list or /lockState endpoint from your Nuki Bridge.
With that info you could collect the “doorsensorStateName”: “door closed” value into a template sensor.

Could be a good starting point for further automations - like notify if nobody is at home & door is open since xx minutes

Update:

If anybody needs the template for the sensor, here it is - please note that i’m using the /list API Call instead of /lockState

- platform: rest
  name: nuki bridge
  resource: !secret nuki_bridge_info_url
  value_template: "{{ value_json[0]['lastKnownState']['doorsensorStateName'] }}"

Then you will get something like this in your state overview:
image

8 Likes

Would also be nice to switch to the hashed token:

Generate token
sha256("2019-03-05T01:06:53Z,4711,123456") = f52eb5ce382e356c4239f8fb4d0a87402bb95b7b3124f0762b806ad7d0d01cb6

3.2.2 Example calls

Plain token:
http://192.168.1.50:8080/info?token=123456

Hashed token:
http://192.168.1.50:8080/info?ts=2019-03-05T01:06:53Z&rnr=4711&hash=f52eb5ce382e356c4239f8fb4d0a87402bb95b7b3124f0762b806ad7d0d01cb6

A hashed token will only be valid with a sufficiently current timestamp and can not be reused, to prevent replay attacks. So making two calls with the exact same timestamp will only work with different random numbers.
To debug problems with non synchronous times you can check the current time on the bridge via bridge discovery

@Freshhat noob question here, how do I find the secret nuki_bridge_info_url?

@NiMa008 Please check out the assigned IP address from your Nuki bridge and for sure if you have activated the API inside the Nuki app (There also the API Key should be displayed)

Then you can build this entry in your secrets.yaml or you can also directly have it in your config:

nuki_bridge_info_url: "http:// <<IP address Nuki Bridge>> :8080/list?token= <<API Key>> " 

Hope this was clear, if not i can also give you a screenshot from the Nuki app where you can find this information

Yes that works perfectly. I have the ip and token. Thank You!

I have a slightly improved version which creates a binary_sensor which shows up as a door.

binary_sensor:
- platform: rest
  name: Nuki deur
  device_class: door
  resource: !secret nuki_url
  value_template: >
    {% if value_json[0].lastKnownState.doorsensorState in [ 2, 3 ] %}
      {{ value_json[0].lastKnownState.doorsensorState == 3 }}
    {% else %}
      Unknown
    {% endif %}
5 Likes

Hello, i use your code, but unfortunately the status of the door “locked” or “unlocked” no longer works as a result of this.

Can you share your exact config?

Same config of you

Can you share your nuki_url (remember to mak your token)?
Can you share the JSON which you get when you open that nuki_url in your browser?

Good news; pynuki 1.4.0 now supports door statuses: https://github.com/pschmitt/pynuki/pull/61
So, this custom sensor might become obsolete soon.

2 Likes

Apologies if this question was already asked, but I have installed this lock/unlock and sensor capability, which worked fine until my NUKI bridge decided to get a different IP address.
Is there a way to get the discovery of the IP address automated by using this URL: https://api.nuki.io/discover/bridges

It returns a JSON string that has all the details in it: {“bridges”:[{“bridgeId”:xxxxxx,“ip”:“192.168.0.xx”,“port”:8080,“dateUpdated”:“2020-10-07T06:54:43Z”}],“errorCode”:0}

Well I think simplest solution would be to just set a static IP in your router for the Device.

Hello,

I just bought a Nuki 2.0 but not installed it yet.
As I read the post from @michel72 I wondered if there is now a service to open the door fully ?

The service to call is lock.open (opposed to lock.unlock). Works for quite some time already.

Is anybody using the Nuki Opener?

The Opener has been recognized by the integration and has been named “lock.nuki” (there is no way to give it another entity name). However, unlocking this opener only enables the “ring to open” functionality (which does not work in my installation) and is therefore unusable.
Moreover, the Opener seems to vacillate between on- and offline all the time.

True, but my ISP does not provide the capability and I don’t want to add another router and have double NATting.

Nuki does not support that yet, I saw a post that they are working on it to configure a static IP. I have never seen a router which cannot do static mapping, even a crappy ISP delivered router, and I have seen a lot of them. I’d buy my own to have this functionality. Almost all my devices are static setups, the horror for my NVR and cameras if leases would change…

I think someone should update the Nuki integration page haha