openHAB Integration

ok perhaps there is a problem in the openhab binding itself, I have set “manageCallback=true” therefore the binding should take care by itself… strange…

is it possible that the API for callback registration changed over time? it seems that the callback list is empty on the lock, I have to check the source code on openHAB binding how the callback is registered right now @MatthiasK

I just tested it with a Bridge with FW 2.2.0 (latest Beta) here and Callbacks are working fine for me (https://developer.nuki.io/page/nuki-bridge-http-api-180/4/#heading--callback-add) and exactly the same as in older versions.

Only thing you have to keep in mind is, that it only supports http:// URLs and the API will through an error if you try to add a https:// URL for a callback.

Hi,

I have also an issue with the callbacks. I do not get any callback of the lock states.

With http://NUKI_IP:8080/callback/list?token=XXXX I got the following response: {“callbacks”: [{“id”: 0, “url”: “http://OPENHAB_IP:8081/nuki/bcb”}]}

With http://OPENHAB_IP:8081/nuki/bcb I got the following response: {“status”:“Invalid BCB-Request!”}

And in the openhab logs I found the following error messages:
2019-04-13 11:26:38.891 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not create BridgeApiLockStateRequestDto from BCB-Request! Message[null]

2019-04-13 11:26:38.899 [ERROR] [internal.dataexchange.NukiApiServlet] - requestContent[]

2019-04-13 11:26:38.902 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not handle Bridge CallBack Request - Discarding!

2019-04-13 11:26:38.904 [ERROR] [internal.dataexchange.NukiApiServlet] - Please report a bug, if this request was done by the Nuki Bridge!

Note: Manage Nuki Bridge Callback ist set to ON

You mean you directyl opened the URL?
Then the error message makes sense because you triggerd a callback without content.

The callback itself looks fine to me. So if the lock status change you still see such an error in the open HAB logs or is there just nothing?

Sadly log files for the bridge are still only available for the old hardware-revision, so if you got a new one its a bit tricky to debug.

Do you use Nuki Web and are status updates pushed there immediatly?

Hi,

I got 100% same issue as ssaado. Callbacks only works when lock changes are initiated by Openhab.
Changes initiated by the nuki app or keypad or bluetooth access do not trigger any callbacks.
The callback list seems ok: {“callbacks”: [{“id”: 0, “url”: “http://openhabian:8080/nuki/bcb”}]} this is the only callback installed.
This is a Nuki V2.

And also got the bridge api error:
2019-04-28 16:04:06.707 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not create BridgeApiLockStateRequestDto from BCB-Request! Message[null]

2019-04-28 16:04:06.714 [ERROR] [internal.dataexchange.NukiApiServlet] - requestContent[]

2019-04-28 16:04:06.718 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not handle Bridge CallBack Request - Discarding!

2019-04-28 16:04:06.723 [ERROR] [internal.dataexchange.NukiApiServlet] - Please report a bug, if this request was done by the Nuki Bridge!

Also the question for you?

Was the second callback initiiated from Nuki or did you manually open the callback URL?

Bc. the error seems to inidicate an empty/wrong format response which makes not a lot of sense if it works other times. (Else the callbacks would never work.)

If callbacks really never work (and the one you posted looks correct to me) it could also be some problem with your Bridge. Which Bridge Firmware are you running on atm?

Hi,

I have the latest public version 1.11.4. I tried to simulate this error, using the Nuki App and using the openhab binding, but did not get this error anymore. Callbacks are still not working.

Mmh, 1.11.4 (and newer) has no issues with callbacks (in general) here for me with Smart Lock 2.0.
Maybe it is something Openhab specific. Could you try to see if Callbacks to other URLs work for you? Then best contact the developer of the openhab binding.
Else I will try to investigate further on our side.

I added two extra call backs: one for Openhab and for Loxone:
{“callbacks”: [{“id”: 0, “url”: “http://IP:8080/nuki/bcb"},{"id”: 1, “url”: “http://IP:7777/dev/sps/io/Callback_Nuki/Pulse"},{"id”: 2, “url”: “http://IP:8080/rest/items/Nuki_Callback”}]}
None of them have been triggered.
Executing bridge commands via url like http://192.168.1.137:8080/callback/list?token=??? seems not always to work: HTTP 503 Unavailable. But after trying several times I get the correct response.

I did manage to get callbacks but the problem is the bridge being offline most of the time.
When I go to the connection status there is only a connection between smartphone and server and then full connection. I will experiment with the position of the bridge.

Thanks for your feedback and patience!
We did a lot of stress tests with the bridge lately and will push some updates which are supposed to stabilize a lot of this issues.

Please keep an eye on our Beta section here where I will update you when the new Beta firmware is available (the Bridge automatically updates 1 hour after reboot and then all subsequent 24 hours, so to update it is best left running for some time). If your bridge is not part of the Beta programm you can do this by following this steps:

If this version is stable for the beta users it will be provided as a public update as soon as possible.
After that update we hopefully can hunt down remaining issues with this easier (when other factors with persisting connectivity problems are ruled out).

unfortunately I cannot get the smartlock online in the OH binding
I use smartlock version 2.6.5. It is connected to my bridge. The bridge gets online but the smartlock not.
more details:
https://github.com/mkatter/openhab2-addons/issues/12

Hi Stephan - could you please hav a look at my problem (see above).
Thanks a lot

@stephan1 If you have issue with the openhab integration itself - and not a Nuki Smart Lock in general - you have to contact the developer of the integration.

Dear Mr.Lendl,

i am using Nuki with openHAB 2.5 and generally speaking i am satisfied. I use it via openHAB binding, as well as API HTTP JSON at the moment (just to compare results and actions). But there are three issues i want to get rid of:

a) When working with the API (http://myIP:8080/lockState?nukiId=1234567&token=abcdefgh) i do get a JSON response with its state, see the following image. Thats fine. But while locking or opening, or in some undefined intervals in between, i get HTTP 503 Errors and others in my openHAB logfile

2020-02-20 13:55:30.025 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation ‘JSONPATH($.state)’ threw an exception. [response=HTTP 503 Unavailable]
org.openhab.core.transform.TransformationException: Invalid path ‘$.state’ in ‘HTTP 503 Unavailable’

As well as another API error like:

2020-02-20 14:14:39.089 [vent.ItemStateChangedEvent] - Nuki_Status changed from 1 to {“success”: false}
2020-02-20 14:14:39.089 [WARN ] [rm.AbstractFileTransformationService] - Could not transform ‘{“success”: false}’ with the file ‘nukilockstates.map’ : Target value not found in map for ‘{“success”: false}’

But manually looking at the API JSON, it says:

{
“mode”: 2,
“state”: 1,
“stateName”: “locked”,
“batteryCritical”: true,
“success”: true
}

Why is that and can it be fixed?

b) When working with the official openHAB binding (which i would prefer), the lock state does not get updated. When i click “lock door now”, the state changes to “locking” but never succeeds to “locked”. It always stays in its moving state so to say, with no confirmation result

Unbenannt-1

c) My Nuki battery gets drained within 2 weeks of operation. Maybe it is because of one of these faults a) or b)?

Thank you for your kind help!

ad a) This sounds like some issue with calling the HTTP API while the Bridge is busy and not retrying correctly.
{“success”: false} is no device state, but a response to an (failed) action.

ad b) As this integration was not done by us I can not tell you why it does not update the correct state. We suggest to do this via callbacks, but as said I am not sure if and how this is implemented.

ad c) Yes, this could be due to an integration constantly polling the Smart Lock directly and so keeping it awake and drawing battery for the BLE-connection. Typically if /lockSate is called in very short intervalls (instead of using callbacks or /list) - see also https://developer.nuki.io/page/nuki-bridge-http-api-1-10/4#heading--lockstate

Dear Mr. Lendl,

Thank you for your reply.
ad a) So this is a general Nuki issue, that the bridge does not deliver API data while being busy - or is it just in my case?

ad b) I will ask the developer of the openHAB binding, alright. The official documentation says it works with callbacks (https://www.openhab.org/addons/bindings/nuki/) but while using it exactly like that, it might not work actually

ad c) But let me get things right in my understanding: my JSON API call is directed to the bridge, right? So why does calling the bridge draw battery from the smartlock? Or is the bridge itself calling then the smartlock for actual status every time?

Hi…I have entryway/window sensors with homematic just as lights and will add a caution. I am intrigued to get a keen lock, for example, NUKI. I will probably have the caution killed once I go into my home by utilizing the NUKI brilliant lock application. Is it conceivable with openHAB to impart a sign when NUKI opens the entryway so that homematic will kill alert and turn on lights?