Configuration example for Nuki 3.0 Pro Lock working with the MQTT API (no bridge)

Prerequisites

  • You need to set up your MQTT broker beforehand
  • You need a username/password to allow access to the broker, modify the MQTT broker thing parameters accordingly
  • You can use a different MQTT broker name (“mosquitto” in the string “mqtt:broker:mosquitto”)
  • You need to set up your lock with the Nuki app.
  • You need to enable MQTT with the Nuki app for your lock.

Notes

  • This gives you the simple three commands in the sitemap: Unlock, Lock and Unlatch/Open. You can use the item to do what you want, if you a different solution as an interface to your lock.
  • The transform map is necessary to give the indication of the lock’s state in the sitemap. The action (command) side does not use the name numbers as the state (what is the lock actually doing).
  • This could be improved upon by using the error codes that the lock can give to display an error message.
  • You need to supply your Nuki Lock ID. The Nuki App will display it within the lock’s setting.
  • You do not need to register an account with Nuki or have some cloud thing. Everything is local!

items/mqtt.items

Number                 door_lockAction   "Door"     <keyring>              { channel = "mqtt:topic:door:lockAction"[profile="transform:MAP", function="nuki30pro.map"] }
Number                 door_battery      "Door"     <battery>  (gBattery)  { channel = "mqtt:topic:door:battery" }

sitemaps/main.sitemap

Switch      item=door_lockAction          mappings=[3="OPN",1="UNL",2="LCK"]

transform/nuki30pro.map

1=2
2=1
3=1
4=2
5=3
6=1
7=3

things/mqtt.things

Bridge mqtt:broker:mosquitto [ host="<yourMQTThostname>", secure=false, username="<yourMQTTusername>", password="<yourMQTTpassword>" ]


Thing mqtt:topic:haustuer "Door" (mqtt:broker:mosquitto) {
    Channels:
    Type number : lockAction   "Lock command"   [ commandTopic="nuki/<yourNukiLockIDhere>/lockAction" ]
    Type number : lockState    "Lock state"     [ stateTopic="nuki/<yourNukiLockIDhere>/state" ]
    Type number : battery      "Lock battery"   [ stateTopic="nuki/<yourNukiLockIDhere>/batteryChargeState" ]
}

Thx.

You can get a lot more of information from the mqtt api, for example subscribe to the lockActionEvent channel and then split the data into different items (sorry, transformation maps in German):

String Nuki_V_Action_LockAction "Lock Action [%s]" <lock> { channel="mqtt:topic:mosquitto:mynuki:lockActionEvent" } 
String Nuki_V_Action_LockAction_LockAction "Nuki Lock Action [MAP(nuki_lockaction.map):%s]"
String Nuki_V_Action_LockAction_NukiTrigger "Nuki Trigger [MAP(nuki_trigger.map):%s]"
String Nuki_V_Action_LockAction_NukiAuthID "Nuki Auth ID [MAP(nuki_authid.map):%s]"
String Nuki_V_Action_LockAction_NukiCodeID "Nuki Code ID [MAP(nuki_codeid.map):%s]"
String Nuki_V_Action_LockAction_NukiAutoUnlock "Nuki AutoUnlock [MAP(nuki_autounlock.map):%s]"
rule "Split Nuki Lock Action Events"
when
    Item Nuki_V_Action_LockAction changed
then
    val String NukiLockAction = Nuki_V_Action_LockAction.state.toString.split(",").get(0)
    val String NukiTrigger = Nuki_V_Action_LockAction.state.toString.split(",").get(1)
    val String NukiAuthID = Nuki_V_Action_LockAction.state.toString.split(",").get(2)
    val String NukiCodeID = Nuki_V_Action_LockAction.state.toString.split(",").get(3)
    val String NukiAutoUnlock = Nuki_V_Action_LockAction.state.toString.split(",").get(4)
    Nuki_V_Action_LockAction_LockAction.postUpdate(NukiLockAction)
    Nuki_V_Action_LockAction_NukiTrigger.postUpdate(NukiTrigger)
    Nuki_V_Action_LockAction_NukiAuthID.postUpdate(NukiAuthID)
    Nuki_V_Action_LockAction_NukiCodeID.postUpdate(NukiCodeID)
    Nuki_V_Action_LockAction_NukiAutoUnlock.postUpdate(NukiAutoUnlock)
end

nuki_lockaction.map:

1=aufgeschlossen
2=abgeschlossen
3=geöffnet
4=lock'n'go
5=lock'n'go mit öffnen
6=2 x abgeschlossen
80=Fernbedienung
90=Lock Button ohne weitere Aktion
NULL=unbekannt
-=unbekannt
UNDEF=unbekannt

nuki_trigger.map:

0=Bluetooth
1=reserviert
2=Lock Button
3=automatisch
6=auto lock
171=HomeKit
172=MQTT
NULL=unbekannt
-=unbekannt
UNDEF=unbekannt

nuki_authid.map:

123456789=ThisIsMe
234567890=ThisIsMyWife
0=Lock Button
NULL=unbekannt
-=unbekannt
UNDEF=unbekannt

nuki_codeid.map:

0=unbekannter Code
NULL=unbekannt
-=unbekannt
UNDEF=unbekannt

nuki_autounlock.map:

0=ohne auto-unlock
1=mit auto-unlock
2=Lock Button 2x
NULL=unbekannt
-=unbekannt
UNDEF=unbekannt

2 Likes