New openHAB2 Binding for Nuki Smart Locks

Tags: #<Tag:0x00007fe05e5d8b80> #<Tag:0x00007fe05e5d8978>

(Markus) #101

@Falk Good to hear and thanks for the feedback! :+1:

(kevin) #102

I’ve been using the binding to control my Nuki Lock for several months now, and its most used to lock the door after I close it. Once OH detects the door has closed it waits for a few seconds in case its opened again before locking. I’ve also found it’s possible to open and close the door before it notices its unlocked which can result in the door not locking. I’ve used a rule to get around this which is below in case it helps anyone.

 var boolean LockBusy = false

rule "Nuki Available"
when Item NukiLockState changed then {
LockBusy = true
   LockBusy = false

rule "lock door"
when Item Door changed from OPEN to CLOSED then {
if (Door.state == CLOSED && !LockBusy && NukiLockState.state == OFF) {
   logInfo("Nuki", "Door Locked on first attempt") } else {
      if (Door.state == CLOSED && !LockBusy && NukiLockState.state == OFF) {
          logInfo("Nuki", "Door Locked on second attempt") } else {
          if (Door.state == CLOSED && !LockBusy && NukiLockState.state == OFF) {
              logInfo("Nuki", "Door Locked on third attempt")
              } else {
              logInfo("Nuki", "Door couldn't be locked")

(Markus) #103

Thanks for sharing! :+1:

Maybe I get your problem wrong but why are you not simply using the “Auto Lock” feature of the Smart Lock?
The SL will automatically lock the door after your configured time. And the Nuki Bridge will report the SL state back via the callback to openHAB. This works fine for me.

Regarding unrecognized state changes if unlock and lock are executed in a very short period of time:
Yes it is very likely to happen in an every day scenario: Unlock the door e.g. via App from the outside (1sec), open the door, enter the hall, close the door (3secs), lock the door via SL button from the inside (1sec).
The Bridge will not report the unlocked state via the callback to openHAB. Simply because it is to “slow”, meaning it is “doing other more important things” before it is executing the callback. But it will report the very last state, here locked, via the callback to openHAB. This also works fine for me.

What I am saying is, use the features of the SL (if possible) and use the callback of the Bridge for handling the state.

BTW: The latest dev build (see first post) manages the callback on the Bridge by itself.

Oh forgot to ask: What additional systems or sensors are you using?

(kevin) #104

I don’t use the “Auto Lock” as the lock doesn’t know whether the door is open or not. I have contacts on the door handle so when the handle is moved into the ready to lock position it tells OH to lock the door. If for example I want to leave the door open for ventilation Nuki would lock it even though the handle wasn’t in the closed and locked position,
With my door its:
1)Press button on Nuki to unlock
2)Turn Handle 1/4 turn
3)Pull door open
1)Close door
2)Turn Handle 1/4 Turn
3)OH detects Handle turn
4)OH locks Nuki via Bridge and Binding

I also use the system to unlock the door when I return on my ebike using a combination of OH, Bluetooth Beacons and OwnTracks Geofencing. Nuki’s auto unlocking didn’t allow for us getting home by car or when the phone was in deep sleep mode.

Additional systems and sensors - you mean for Nuki or in general? I have a lot going on here and outgrew the Pi sometime back :slight_smile:

(Markus) #105

Just to get it right: With your door locking system it is not possible to lock until you pulled the handle 1/4 turn up?

Yes, I meant sensors in general. Like the one you are using to recognize the handle turns.
I think I understand your set-up now. What sensors are you using to recognize the handle turns? Do you also have sensors to check if the door itself is closed/opened?

(kevin) #106

Yes 1/4 turn is correct. Moving this moves 4 rollers on the door mechanism so they lock against 4 hooks on the uPVC door frame. I pass a voltage through the hooks via an ESP8266, this detects the door is closed and the handle has been turned. I don’t have a door open sensor.
I also use the hook and roller setup on other doors for detection purposes.
In the case of the Nuki equipped door I don’t have an outside keyhole making “bumping” the lock impossible

(Stefan) #107


I would like to buy a second NUKI SMARTLOCK.
Is it possible to add two smartlocks to Openhab via one bridge?

(Markus) #108

@The-Elk Yes, just configure another Thing smartlock under the same bridge. But keep in mind that both Smart Locks have to have a good/stable BLE connection to the Bridge!

(Tommaso) #109

I’m interested in buy a nuki device. This month they released the version 2.0. Does anyone tried the new version with the binding? I’m reading some comments online and it seems that the improvements developed (better auto-unlock, open/close faster) are not met as promised, any comments on that?

(Arno) #110

I have the 2.0. Can’t compare with the old one though. It works as advertised, except that the door sensor isn’t really functional right now. It keeps throwing errors.

I can’t see the lock over Zigbee, I guess that it is not enabled yet. I haven’t implemented any unlocking functions via Openhab, but I did program a notification via OH whenever the door unlocks, and that works. Haven’t tried the auto-unlocking yet.

(fridomac) #111

I also replaced my 1.0 Yuki with the 2.0 Version. Seems a little quieter and faster, Auto Unlock now works more consistent. And the door sensor is nice. But I can not get the callback to work again, it is set up in the bridge (I kept my old bridge), but openHAB does not get the status messages from the lock. Locking and unlocking works, though…

Bye, Frido.

(Mark Townley) #113

Hi Guys, I’m new to this forum so excuse any mistakes. Just bought a new Nuki 2 with bridge and followed all the threads here and there seems like a problem with the callback (might have worked with the Nuki 1 but not v2). I am running the latest snapshot 2.5.0 - 17th Dec. Seems like the Nuki name search on the bridge gets confused between the Nuki ID and the BLE name.Debug file below (I hope).

(Markus) #114

Hi @townlema ,

to me it seems you got the Nuki ID wrong! Please check the sticker on the back of the Smartlock, it should be ‭14E2F50F‬!

BR Markus

(Mark Townley) #115

Hi Markus, yep that fixed it and the callback now works - thanks a lot. Great binding!

(Thomas Binder) #116

Did you solve this? I just replaced my v1 Nuki with the v2 Nuki also.
I’m using 2.4 stable and the Nuki 2.4 binding - just replaced the Smartlock Thing with the new Nuki ID.
Locking/Unlocking works - but the callback won’t. Do you need to add a new callback or something?


{"callbacks": [{"id": 2, "url": ""}]}


[{"nukiId": 12345, "name": "BinderTür2", "firmwareVersion": "2.3.1", "lastKnownState": {"state": 3, "stateName": "unlocked", "batteryCritical": false, "timestamp": "2019-01-07T20:37:26+00:00"}},{"nukiId": 54321, "name": "BinderTür"}]

(fridomac) #117

Sorry, but I did not resolve it yet. Did the same thing you did and just replaced the NukiID with the new one. Also deleted all Callbacks and let the Binding recreate it, but to no avail, Callbacks still do not work.

Bye, Frido.

(E. Gerland) #118

one quick Dummy question:
Do I need both The nuki Lock and the Nuki Bridge Hardware as well or can I operate the lock without the bridge from OH?

(Thomas Binder) #119

Without a bridge you can’t operate the Smartlock via OH2. It’s an encrypted Bluetooth protocol.
If you have an spare Android device, you could use the Software Bridge in the AppStore instead.
I never used the App, but it seems it is identical to the hardware bridge.

(E. Gerland) #120

Hi Thomas,

thanks for your quick help.
Nuki seems to be a good smart lock and I will consider to buy one.

(Manuel) #121

I have the Nuki 2.0 Combo (Bridge, Smartlock, Fobs). It’s working perfectly with iobroker for about two month now. Since a week I’m trying to switch over to openHAB. All devices and bindings are fully functional except Nuki.
It installs without issues. The callback is registered automatically in the bridge. Sometimes it reacts to actions sent via openHAB sometimes not. What’s never working is updating the state in openHAB when lockstate is changed via Android App.

I’m running openHAB 2.4 (Release) + 2.4 Binding in Docker on a Synology Diskstation 418play (2 Network Interfaces).

All things and items were created in PaperUI.

Any tips for me?