NUKI Binding - Keeps INITIALIZING - Could not handle Exception

Hello

Just installed a new NUKI Smart Lock and NUKI Bridge in our home.
NUKI App is working but not the OpenHab integration.

API-URL is working, have tried it with curl http://192.168.184.109:8080/list?token=******* on the server:
[{“nukiId”: *******, “name”: “Test”, “lastKnownState”: {“state”: 1, “stateName”: “locked”, “batteryCritical”: false, “timestamp”: “2019-07-04T20:32:45+00:00”}}]

But the OpenHAB part will not work:

    2019-07-04 23:15:59.825 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'nuki.things'

    2019-07-04 23:15:59.959 [.ItemChannelLinkAddedEvent] - Link 'Frontdoor_State-nuki:smartlock:NB1:SL1:lockState' has been added.

    2019-07-04 23:15:59.960 [.ItemChannelLinkAddedEvent] - Link 'Frontdoor_LowBattery-nuki:smartlock:NB1:SL1:lowBattery' has been added.

    2019-07-04 23:15:59.962 [.ItemChannelLinkAddedEvent] - Link 'Frontdoor_Lock-nuki:smartlock:NB1:SL1:lock' has been added.

    2019-07-04 23:16:00.030 [hingStatusInfoChangedEvent] - 'nuki:smartlock:NB1:SL1' changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)

    2019-07-04 23:16:00.088 [hingStatusInfoChangedEvent] - 'nuki:bridge:NB1' changed from UNINITIALIZED to INITIALIZING

    2019-07-04 23:17:29.794 [ERROR] [internal.dataexchange.NukiHttpClient] - Could not handle Exception! Exception[java.io.EOFException: HttpConnectionOverHTTP@23a2996(l:/192.168.184.170:33524 <-> r:/192.168.184.109:8080,closed=false)=>HttpChannelOverHTTP@473958c0(exchange=HttpExchange@49febe57 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@4dc133b0(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@8c3b46c{s=START}],recv=HttpReceiverOverHTTP@53112ec(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-SocketChannelEndPoint@3981181b{/192.168.184.109:8080<->/192.168.184.170:33524,ISHUT,fill=-,flush=-,to=89346/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@23a2996(l:/192.168.184.170:33524 <-> r:/192.168.184.109:8080,closed=false)=>HttpChannelOverHTTP@473958c0(exchange=HttpExchange@49febe57 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@4dc133b0(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@8c3b46c{s=START}],recv=HttpReceiverOverHTTP@53112ec(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]]

    	at org.openhab.binding.nuki.internal.dataexchange.NukiHttpClient.executeRequest(NukiHttpClient.java:79) ~[?:?]

    	at org.openhab.binding.nuki.internal.dataexchange.NukiHttpClient.getBridgeCallbackList(NukiHttpClient.java:205) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.manageNukiBridgeCallbacks(NukiBridgeHandler.java:134) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.initializeHandler(NukiBridgeHandler.java:103) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.lambda$0(NukiBridgeHandler.java:79) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.manageNukiBridgeCallbacks(NukiBridgeHandler.java:137) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.initializeHandler(NukiBridgeHandler.java:103) ~[?:?]

    	at org.openhab.binding.nuki.handler.NukiBridgeHandler.lambda$0(NukiBridgeHandler.java:79) ~[?:?]

Please Help

is it okay to ask for help again? ^^

could you provide your items & things definition? looks like you do not have added the things via paperui.

I have tried both.
First PaperUI and second via text files.

I have followed https://www.openhab.org/addons/bindings/nuki/

Here is the actual config:
items:


Switch Frontdoor_Lock		"Frontdoor Lock"		<nukiwhite>		{ channel="nuki:smartlock:NB1:SL1:lock" }
Number Frontdoor_State		"Frontdoor (State)"				<nukisl>		{ channel="nuki:smartlock:NB1:SL1:lockState" }
Switch Frontdoor_LowBattery	"Frontdoor Low Battery"			<nukibattery>	{ channel="nuki:smartlock:NB1:SL1:lowBattery" }

things:

Bridge nuki:bridge:NB1 [ ip="192.168.184.109", port=8080, apiToken="******", manageCallbacks=true ] {
    Thing smartlock SL1 [ nukiId="101010101", unlatch=false ]
}

I have changed

Switch Frontdoor_Lock		"Frontdoor"		<nukiwhite>		{ channel="nuki:smartlock:NB1:SL1:lock" }"

in this moment, because

Switch Frontdoor_Lock		"Frontdoor (Unlock / Lock)"		<nukiwhite>		{ channel="nuki:smartlock:NB1:SL1:lock" }

had wrong color highlighting.

But it doesn’t help

In both scenarias in PaperUI the Bridge is Status: INITIALIZING
And the Thing is Status: UNINITIALIZED - BRIDGE_UNINITIALIZED

Token and ID anonymous

The HomeKIT integration on Nuki isn’t activated, only the API.

I have a working solution, but I added the thing(s) in PaperUI.
And finally I have 2 things, you have only defined (Nuki Bridge, Nuki SmartLock)
I set manageCallbacks=false -> I set this directly on the bridge via API (http://10.0.1.53:8080/callback/add?nukiId={{NukiId}}&url=http%3A%2F%2FMY_IP%3A8082%2Fnuki%2Fbcb&token={{NukiToken}})
The thing “Nuki Bride” I set the API Token directly in PaperUI.
The thing “Nuki Smart Lock” I got the nukiID via the web API (http://10.0.1.53:8080/list?token={{NukiToken}}) and set it also in PaperUI.

How could I use/config the manual Callback?
Seems to be a bit complex and why is it necessary?

You are right, the same should be possible in openHAB.
But try removing the things definitions from yout file and add the bridge and the smartlock via PaperUI.
If both things came online this way, then the documentation is probably wrong.

see also:

or things definition like that:

Bridge nuki:bridge:NukiBridge1 [ IP="192.168.x.x", PORT=8080, APITOKEN="xxxxxx", CALLBACK_PORT=8081 ] { 
  Thing smartLock FrontDoorLock [ NUKIID="123456789" ]
}

It seems like I am coming to my limits:

http://192.168.184.170:8080/nuki/bcb/callback/add
http://192.168.184.170:8080/nuki/bcb/callback/add?token=******&url=http%3A%2F%2F192.168.184.109%3A8080%2Fnuki%2F*********
http://192.168.184.170:8080/nuki/bcb/callback/add?token=******&url=http%3A%2F%2F192.168.184.109%3A8080%2Fnuki%2Fbcb

{“status”:“Invalid BCB-Request!”}

2019-07-15 22:01:39.415 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not create BridgeApiLockStateRequestDto from BCB-Request! Message[null]

2019-07-15 22:01:39.417 [ERROR] [internal.dataexchange.NukiApiServlet] - requestContent[]

2019-07-15 22:01:39.417 [ERROR] [internal.dataexchange.NukiApiServlet] - Could not handle Bridge CallBack Request - Discarding!

2019-07-15 22:01:39.418 [ERROR] [internal.dataexchange.NukiApiServlet] - Please report a bug, if this request was done by the Nuki Bridge!

http://192.168.184.170:8080/callback/add?token=******&url=http%3A%2F%2F192.168.184.109%3A8080%2Fnuki%2F*********

HTTP ERROR 404
Problem accessing /callback/add. Reason:

Not Found

And all together I get now:


2019-07-15 22:12:15.939 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'nuki.things' has errors, therefore ignoring it: [6,6]: mismatched input '<EOF>' expecting RULE_ID

So I have changed the think back to manageCallbacks=true

My first try was adding the thing via PaperUI

Try once if the WebAPI is working. I attached the Postman (https://www.getpostman.com) collection and environment which you can import.
You have to define the two following parameters in the environment settings:
{{NukiId}}
{{NukiToken}}
- Openhab.postman_environment.json (375 Bytes) Nuki.postman_collection.json (5.1 KB)

At the moment I have tried to delete the files, reinstall the nuki binding and using PaperUI to add the NUKI Bridge:

2019-07-17 18:30:23.109 [hingStatusInfoChangedEvent] - 'nuki:bridge:9e3a4cce' changed from UNINITIALIZED to INITIALIZING

2019-07-17 18:31:53.242 [ERROR] [internal.dataexchange.NukiHttpClient] - Could not handle Exception! Exception[java.io.EOFException: HttpConnectionOverHTTP@1f25397b(l:/192.168.184.170:60314 <-> r:/192.168.184.109:8080,closed=false)=>HttpChannelOverHTTP@4aab9ce4(exchange=HttpExchange@446c7bc1 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@4053f794(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@55171fa{s=START}],recv=HttpReceiverOverHTTP@138b8108(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-SocketChannelEndPoint@341e52cb{/192.168.184.109:8080<->/192.168.184.170:60314,ISHUT,fill=-,flush=-,to=89764/0}{io=0/0,kio=0,kro=1}->HttpConnectionOverHTTP@1f25397b(l:/192.168.184.170:60314 <-> r:/192.168.184.109:8080,closed=false)=>HttpChannelOverHTTP@4aab9ce4(exchange=HttpExchange@446c7bc1 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@4053f794(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@55171fa{s=START}],recv=HttpReceiverOverHTTP@138b8108(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]]

	at org.openhab.binding.nuki.internal.dataexchange.NukiHttpClient.executeRequest(NukiHttpClient.java:79) ~[?:?]

	at org.openhab.binding.nuki.internal.dataexchange.NukiHttpClient.getBridgeCallbackList(NukiHttpClient.java:205) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.manageNukiBridgeCallbacks(NukiBridgeHandler.java:134) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.initializeHandler(NukiBridgeHandler.java:103) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.lambda$0(NukiBridgeHandler.java:79) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.manageNukiBridgeCallbacks(NukiBridgeHandler.java:137) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.initializeHandler(NukiBridgeHandler.java:103) ~[?:?]

	at org.openhab.binding.nuki.handler.NukiBridgeHandler.lambda$0(NukiBridgeHandler.java:79) ~[?:?]

I think I fixed the bug with the bridge remaining in INITIALIZING state. It could happen when manageCallbacks setting was true due to a forgotten null check leading to a potential NPE.

You have a jar to test in the following PR: