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

If no one is up to updating the implementation, maybe it’s possible to create a template sensor that would be triggered viatwo IFTTT webhooks to show if the door is closed or opened.

Have you contacted the original author?


Hi, original author here.

The lock/unlock functionality is implemented and has been for years. When you set it up correctly you end up with a lock entity that you can lock and unlock :man_shrugging:

I haven’t tried with a 2.0 device since I do not own one, but I am very confident it’ll work just fine. If it does not, please open an issue on GitHub.

Regarding the opener, I’ve started working on it at the pynuki level (see https://github.com/pschmitt/pynuki/tree/api_v1.10) . I don’t own one either. I need people to try it out. I can only code blindly.

Happy to try it out

I have tested the available 4 services on my Nuki Combo 2.0 today:

lock.lock <- seems to work fine
lock.unlock <- unlocks the lock, but does not open the door
lock.open <- unlocks the lock, but does not open the door
nuko.lock_n_go <- unlocks the lock, but does not open the door, after 20 sec. locks again.

If I use the Nuki app, I can open the door just fine.

The automation I’m firings is:

  action:
  - service: lock.unlock
    data:
      entity_id: lock.voordeur

and

  action:
  - service: lock.open
    data:
      entity_id: lock.voordeur

I am happy to send you logs, if you can tell me what/where you need.

Interestingly I just tried doing the same from the development tools in HA and then lock.open works and opens the door:

If I however trigger the automation above (which theoretically does exactly the same), the locks unlocks, but not far enough to open the door.

I am having an issue with my brand new Nuki Lock and Opener, on latest firmware.

Both of them appear in HASS, but they keep going into “unavailable” status, always one at a time, not both, it’s quite odd.

At the same time, control through the Nuki Web api and the IOS App are working fine, so it does seem like a HA issue?

Hola! Estoy intentando integrar nuki a HA pero no soy capaz,sacaba el token de nuki web. No sé como puedo conseguirlo?
Gracias!!

What’s the status on development?

I noticed that the nuki bridge doesn’t support state checks? (If the door is closed or not, with the magnet sensor)
That only seems to work with the nuki web appu

@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