HTTP lock device handler (Nuki)

Hi,

With Nuki I found I can operate the lock by using fakeurl.com/action1 = close and fakeurl.com/action2 = open. I also can poll the lock status with faceurl.com/statuslockID1 etc. Is there a device handler that I can use with this info to operate the lock in ST?

TIA! Frank

1 Like

I have created a device handler you can use

Hi,

Thanks a lot for building this DH, was waiting for it!

I seem to have an error where the device is stuck on “Waiting”. Is the handler already functional?

Thanks!

Thank you much for creating this! It works great on 1 of my locks but the 2nd reains on the waiting status. Any ideas how to resolve?

Frank

hi
the handler is working
first make sure you have the latest version from GitHub - https://github.com/volski/Smartthing-nuki
next make sure you have enable http within the nuki bridge
to test that http works from your browser while being in the same lan as your bridge test the url:
http://ipAdressOfBridge:8080/lockState?nukiId=YourNukiID&token=YourToken
a successful result will return a json as here:
{“state”: 3, “stateName”: “unlocked”, “batteryCritical”: false, “success”: true}
after this all works in the device handler make sure the the fields in the settings are correct.
Server IP Address - bridge ip
Server Port - bridge port (default is 8080)
URL Path for Lock - /lockAction?nukiId=YourNukiID&token=YourToken&action=1
URL Path for UnLock - /lockAction?nukiId=YourNukiID&token=YourToken&action=2
URL Path for LockNgo - /lockAction?nukiId=YourNukiID&token=YourToken&action=4
URL Path for Status - /lockState?nukiId=YourNukiID&token=YourToken

if all is correct and lock still not responding - time for looking at the log from the Smartthings

https://graph.api.smartthings.com/ide/logs

share the log I will help you make the lock work

share your log I will try to help
*try deleting the working lock from the smartthings and check if the second lock is working (I think that I need to implement multiple locks within the same device handler otherwise each lock needs a separate device handler)

Thank you for looking into this. Deleting the working lock does not change the waiting state on the other. I deleted both locks then added the lock who had waiting state. This now works. As expected, when adding the seconds previous working lock this now remains in working state.

When looking at the live log when I refresh the state I get this error:

2:07:23 PM: error grails.validation.ValidationException: Validation Error(s) occurred during save():

  • Field error in object ‘physicalgraph.device.Device’ on field ‘deviceNetworkId’: rejected value [C0A85631:1F90]; codes [physicalgraph.device.Device.deviceNetworkId.unique.error.physicalgraph.device.Device.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.error.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.error.java.lang.String,physicalgraph.device.Device.deviceNetworkId.unique.error,device.deviceNetworkId.unique.error.physicalgraph.device.Device.deviceNetworkId,device.deviceNetworkId.unique.error.deviceNetworkId,device.deviceNetworkId.unique.error.java.lang.String,device.deviceNetworkId.unique.error,physicalgraph.device.Device.deviceNetworkId.unique.physicalgraph.device.Device.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.deviceNetworkId,physicalgraph.device.Device.deviceNetworkId.unique.java.lang.String,physicalgraph.device.Device.deviceNetworkId.unique,device.deviceNetworkId.unique.physicalgraph.device.Device.deviceNetworkId,device.deviceNetworkId.unique.deviceNetworkId,device.deviceNetworkId.unique.java.lang.String,device.deviceNetworkId.unique,unique.physicalgraph.device.Device.deviceNetworkId,unique.deviceNetworkId,unique.java.lang.String,unique]; arguments [deviceNetworkId,class physicalgraph.device.Device,C0A85631:1F90]; default message [{0} must be unique]

hi
I think I has duplicate network id - check in the https://graph.api.smartthings.com under device list - does the 2 locks have similar network id?

The working lock is showing the mac as ID and the lock in waiting state shows the network ID I assigned.

Thanks @volski that’s awesome
Thing is … I can’t figure out how to setup the parameters and moreover my 2 bridges have a local ip address
Can you please provide instructions in "newbie mode"
Thanks a lot
Greg

There are some nice instructions in the Nuki website.

Thanks, I updated to the latest version but still had trouble until I figured out the ip needs to be numbers only xxx.xxx.xxx.xxx, I was using the DynDns version allowing access outside the home network.

Is there a way to allow web address for the server instead of only IP?

Also there seems to be a limit for the bridge on the frequency of GET request, and at some point it freezes. Have to pull it out and restart.

Thanks a lot!

in the device handler you need to put the local address of your bridge .
as the communication goes from the smartthings to the nuki bridge, and they are normally both on the local network(same subnet).
so while using the smartthings app from the external network the lock will work normally as from within the local network.
while nuki lock is locking or unlocking the web server does not respond to status command, it can take up to 30 seconds to update the current lock status.
also can be done by press on the refresh button.

I am working on a new device handler that will work with nuki web api - but it is still not finished.

1 Like

finish working on the nuki web api version
visit web.nuki.io -> generate api token - in the device handler setting input the api token and the device id
https://github.com/volski/Smartthing-nuki/blob/master/Nuki_handler_web_api.groovy

Hi @volski, I tried to install but get an error. Previous device handler and devices are removed.

Org.springframework.dao.DuplicateKeyException: a different object with the same identifier value was already associated with the session: [physicalgraph.device.CapabilityDeviceType#physicalgraph.device.CapabilityDeviceType : (unsaved)]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [physicalgraph.device.CapabilityDeviceType#physicalgraph.device.CapabilityDeviceType : (unsaved)]

Never mind :slight_smile: The source code lists capability: Actuator twice causing it to fail. I removed one and was able to install. Next up are the locks :slight_smile:

Locks work great!! perhaps mention your handler to the nuki people so they can update the site that Smartthings is now supported? :slight_smile: Thnx man! No more IFTTT madness

thanks
fixed the code, added battery view (hopefully will alarm on low battery)

hi
I have build a new device handler
the setup is pretty easy
first log in to your account at web.nuki.io
enable the api - and copy the token
next create new device handler from code in the graph.api.smartthings.com - code from here:
https://github.com/volski/Smartthing-nuki/blob/master/Nuki_handler_web_api.groovy

after that you need to create a device in the “my devices” section in the smartthings web console.
once you have it click on the device name you have created
and under Preferences click on edit
you have two fields first is the api token you copied from nuki website
and second is the device id the simplest way is this:
go to https://www.hurl.it select the GET method copy to the Destination url: https://api.nuki.io/smartlock
next add HEADERS - in the name field: Authorization and in the Value write: barer yourApiToken
and click on the Launch Request
if all is good you will get a json response with your locks
if you have more then one you will need to create a device handler for each one.
from the response json copy the value of smartlockId
this is the needed value for the second filed from the device handler
now click on save and you can control your lock!

Also important to note is that you need a bridge from nuki.