Nuki Smartlock


(Zakaria Mohamed) #1

Hi,

I would like to add Nuki Smartlock into Smartthings. It is a bluetooth Smartlock that has a wifi bridge. Nuki have released the API to lock/unlock etc. They use REST api so it will be like http://192.168.0.2:8080/lockAction?nukiId=1&action=2&token=c8v7b6 to lock and http://192.168.0.2:8080/lockAction?nukiId=1&action=1&token=c8v7b6 to unlock. Is this possible to integrate to Smartthings? I would need a Device Handler and a SmartApp correct? Is there any example for device handler with REST api? I can only see zigbee and zwave examples.

Thanks for the assist.


#2

You can use this:


(Zakaria Mohamed) #3

Thanks alot for the link.

Is it possible to change it from a button to a lock so that smartthings will recognize it as a lock so that other smartapps will work with the lock.


#4

I think a virtual switch with on and off state will meet you needs instead of virtual button.

Try this


(Zakaria Mohamed) #5

Hi,

Thanks for the links. But where do I enter the IP address and other details? I have copied device handler and smartapp and publish them for me. But when I run the SmartApp it doesn’t for IP, just asked for label name.


#6

Have you created a button? Access the button, then click on the gear :gear: icon, then edit device. You will see the screen that allow you to enter the details.


(Zakaria Mohamed) #7

Thanks so much for the assist Chan. I can now see the place to enter the details.

I see that the tile icon is showing as an outlet. Is it possible to change it to a lock icon?
Is it something like change the standardTile to:

standardTile(“toggle”, “device.lock”, width: 2, height: 2)

Thanks again


(Zakaria Mohamed) #8

Hi,

Thanks again for the code. I have managed to use a Danalock device handler code to made this a “http lock”.

However I have a query on the last part of the code.

if (varCommand == “off”){
sendEvent(name: “switch”, value: “off”)
log.debug “Executing OFF”
} else {
sendEvent(name: “switch”, value: “on”)
log.debug “Executing ON”
}

The varCommand variable is the path correct? So the statement if (varCommand == “off”) will never be satisfied right?
And the actual HTTP POST command is executed in this loop or it is executed in the def hubAction = new physicalgraph.device.HubAction portion?

Thanks again.


#9

No. You can safely ignore that part, it’s just to update the switch label on UI. Path is taken from the path you define in the settings.

Take a look on my sample screen below


#10


(Zakaria Mohamed) #11

I see. Thank you for the quick response.

So can I remove the entire section from the code? It will not affect the on/off fuctionality right?
//sendEvent
if (varCommand == “off”){
sendEvent(name: “switch”, value: “off”)
log.debug “Executing OFF”
} else {
sendEvent(name: “switch”, value: “on”)
log.debug “Executing ON”
}

Thanks.


#12

Why you want to remove it? It’s to update the front-end display


(Zakaria Mohamed) #13

Hi Chan,

Ok, I am just trying to understand what that last part does, as it seems like it would always go to the else statement.
For me it doesn’t log either “Executing …” statement.

Here is my revised version.

http://pastebin.com/pHgDTR8x


#14

Does it work for your lock?


(Zakaria Mohamed) #15

Hi Chan,

I am not sure as I will only receive my lock next week. :grin:
but the hubaction returned this:

GET /lockAction?nukiId=1&action=2&token=c8v7b6 HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 192.168.0.200:8080
Content-Type: application/x-www-form-urlencoded

Does this mean that the Get was successful?


(Pedro Ponte) #16

Hi, did you manage to integrate this and test it sucessfully in the end? I’m quite interested in this and would like to avoid having to buy the hub myself.
Many thanks


(Zakaria Mohamed) #17

Hi,

I have successfully integrated it to my Smartthings. However I am using the Nuki Bridge to talk to the Smartthings Hub. Without the Nuki Bridge the Nuki lock cannot talk to the Smartthings Hub as the Nuki Lock is using Bluetooth.


(Travis Mielonen) #18

Hi @kaznad, I also have a Nuki Lock with bridge and am wondering if you could share your Device Handler code? Does it properly handle the lock/unlock status (displaying correctly locked or unlocked in smartthings) as well (in the event someone uses the physical button to lock/unlock, or the nuki app)?


(Frank Reymenants) #19

Any news on this? I just installed my nuki locks. Waiting for the bridge to arrive from backorder but I have the software bridge installed.


(Gregoiredore) #20

Hi there…
I have 2 Nukis at home.
For now I have only been using IFTTT to connect Nuki and Smartthings, and a simulated switch on the ST side.
But a DH would be great !
Thanks @kaznad :smiley: