iobroker-community-adapters / ioBroker.nuki-extended

Nuki Smart Lock - Keyless electronic door lock for smart access with your ioBroker
MIT License
29 stars 15 forks source link

Nuki 3.0 Pro support without bridge #169

Closed jhubig closed 2 years ago

jhubig commented 2 years ago

The release of the new Nuki 3.0 Pro with built in WiFi seems to not offer the built in bridge capabitlity and therefore no access to the bridge/http API. To get that, I guess I need to buy the bridge. But the device will offer the access to the WEB API.

What I wrote above was also confirmed by the Nuki Support team.

Would there be the possibility to enable the web api "only"? I think currently your adapter needs to have the bridge/http api as pre-requesite, or?

Thanks for your help.

jayfizzle commented 2 years ago

has anybody already tested this adapter with the Nuki 3.0 pro?

jhubig commented 2 years ago

Yes. I have tested it. I have configured the Nuki Web settings (in the settings of the adapter) and added the API Token and left the Nuki Bridge settings empty. Then I get the following and the adapter stays amber.

nuki-extended.0 2021-12-01 14:39:05.021 warn No bridges have been defined in settings so far!
nuki-extended.0 2021-12-01 14:39:04.906 info starting. Version 2.3.1 in /opt/iobroker/node_modules/iobroker.nuki-extended, node: v14.18.1, js-controller: 3.3.21

If I enter a fake bridge (because I'm using the 3.0 Pro without the bridge) then I get the following and the adapter also stays in amber.

nuki-extended.0 2021-12-01 14:50:14.434 warn No bridges are sufficiently defined! Name, IP or token missing or all bridges deactivated!
nuki-extended.0 2021-12-01 14:50:10.895 warn Failed retrieving /info from Nuki Bridge with name Testbridge (forcePlainToken: true)!
nuki-extended.0 2021-12-01 14:50:07.387 warn Failed retrieving /list from Nuki Bridge with name Testbridge (forcePlainToken: true)!
nuki-extended.0 2021-12-01 14:50:00.513 info starting. Version 2.3.1 in /opt/iobroker/node_modules/iobroker.nuki-extended, node: v14.18.1, js-controller: 3.3.21

image

jayfizzle commented 2 years ago

Maybe the developer can implement the current web api 1.4 https://developer.nuki.io/page/nuki-web-api-1-4/3/

jhubig commented 2 years ago

I think the Web API is implemented. But it is currently not possible to use the Web API standalone with this adapter.

jayfizzle commented 2 years ago

I think the Web API is implemented. But it is currently not possible to use the Web API standalone with this adapter.

there is another iobroker nuki adapter, does this one work with the new nuki pro device?

jhubig commented 2 years ago

No. Not without the bridge. And it even doesn't support the Web API at all.

simatec commented 2 years ago

Please test Release 2.4.0

jhubig commented 2 years ago

Please test Release 2.4.0

Tested, but same behavior - as expected I would say. The new deviceType has been added but the adapter still requests to have a bridge to be able to use the HTTP API. The adapter still doesn't support the WEB API only.

jhubig commented 2 years ago

@jayfizzle Hey. I've forked the repository and created a pull request (https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/pull/174), but might be rejected because it is not perfectly implemented, but it works for me with my Nuki 3.0 Pro without the Bridge using the WEB API. In case you want to give it a try, you can also install the adapter through my fork here: https://github.com/jhubig/ioBroker.nuki-extended

jayfizzle commented 2 years ago

@jhubig hi, thanks for the information. Whenever my nuki pro arrives i would test your adapter. Do you know if there is any disadvantage in using the WEB API instead of the Bridge API? Is the WEB API "slower" has less functions? Otherwise i would change the pro with the non pro version and buy the nuki bridge.

jhubig commented 2 years ago

Good question. I do not really know. But what I see with this adapter, is that it is polling the data from the Web API based on the refresh time you configure. So there is no push of any update of the smart lock. Means when you lock the door, the reflection of that update might be visible after your configured polling refresh time. Right now this seems to be sufficient for me. For the bridge API maybe there is a push functionality. Not sure.

I wanted to have the Pro, because I wanted this battery pack and no additional device/bridge. But I also thought at the beginning that the bridge is kind of included.

jayfizzle commented 2 years ago

ok,.

i thought the integrated wifi module in the pro will have the same functions like the bridge, but thats not https://support.nuki.io/hc/de/articles/4408533438993-Fernzugriff-%C3%BCber-die-Nuki-Bridge . The guys from nuki should communicate this facts better than hide it anywhere i their documentation

is there a min or max value for the polling refresh time (WEB API)?

jhubig commented 2 years ago

Okay. In your link above, it is now quite clearly written which - I guess - was not the case when I bought it some weeks ago.

I do not know if there is a limit. Currently for me 10 seconds is more than sufficient.

jayfizzle commented 2 years ago

ok, dank dir. Werd es mir mal alles genauer anschauen sobald mir die Hardware vorliegt.

jayfizzle commented 2 years ago

Hi, Which information should I insert in the adapter configuration? IP address of the pro instead of the bridge? Do I need the token too?

jhubig commented 2 years ago

Hey,

I left the bridge config empty. Just entered the Web API Token. Did you receive the Nuki?

Cheers, Johannes

jayfizzle commented 2 years ago

Hi,

no Iā€™m still waiting already 11 working days. I just will be prepared.

regards J

jayfizzle commented 2 years ago

@jhubig hi, i received my nuki 3.0 pro yesterday. configured the usage of web api through the nuki webpage.

the nuki is found by the adapter, but currently it is not possible to control the nuki over the adapter When i change the value of "nuki-extended.0.smartlocks.haustuer._ACTION" or "nuki-extended.0.smartlocks.haustuer._ACTION.LOCK" i receive warnings and the nuki did nothing:

i checked the function with some cURL commands like lock/unlock, and it's working, but not through the adapter.

I hope you can help me.

`nuki-extended.0 2021-12-22 13:31:55.096 debug Updating device smartlocks.haustuer with payload: {"smartlockId":17929391234,"accountId":682876543,"type":4,"authId":3431647,"name":"Haustuer","favorite":false,"config":{"name":"Haustuer","latitude":51.255272,"longitude":6.9920063,"autoUnlatch":true,"liftUpHandle":false,"pairingEnabled":true,"buttonEnabled":true,"ledEnabled":true,"ledBrightness":3,"timezoneOffset":0,"daylightSavingMode":0,"fobPaired":false,"fobAction1":4,"fobAction2":2,"fobAction3":0,"singleLock":false,"advertisingMode":0,"keypadPaired":false,"homekitState":3,"timezoneId":37,"deviceType":4,"wifiEnabled":true},"advancedConfig":{"totalDegrees":970,"singleLockedPositionOffsetDegrees":0,"unlockedToLockedTransitionOffsetDegrees":0,"unlockedPositionOffsetDegrees":0,"lockedPositionOffsetDegrees":0,"detachedCylinder":false,"batteryType":1,"autoLock":false,"autoLockTimeout":300,"autoUpdateEnabled":false,"lngTimeout":20,"singleButtonPressAction":1,"doubleButtonPressAction":5,"automaticBatteryTypeDetection":true,"unlatchDuration":3},"webConfig":{"batteryWarningPerMailEnabled":false},"state":{"mode":2,"state":3,"trigger":0,"lastAction":3,"batteryCritical":false,"batteryCharging":false,"batteryCharge":76,"keypadBatteryCritical":false,"doorsensorBatteryCritical":false,"doorState":0,"ringToOpenTimer":0,"nightMode":false,"timestamp":"2021-12-22T12:31:55+00:00","locked":3},"firmwareVersion":196874,"hardwareVersion":2817,"serverState":0,"adminPinState":0,"virtualDevice":false,"creationDate":"2021-12-21T12:57:13.161Z","updateDate":"2021-12-22T10:15:03.337Z","nukiHexId":"2cace964","deviceType":4,"nukiId":749529444}
nuki-extended.0 2021-12-22 13:31:55.095 debug getWebApi(): [{"smartlockId":17929391234,"accountId":682876543,"type":4,"authId":3431647,"name":"Haustuer","favorite":false,"config":{"name":"Haustuer","latitude":51.255272,"longitude":6.9920063,"autoUnlatch":true,"liftUpHandle":false,"pairingEnabled":true,"buttonEnabled":true,"ledEnabled":true,"ledBrightness":3,"timezoneOffset":0,"daylightSavingMode":0,"fobPaired":false,"fobAction1":4,"fobAction2":2,"fobAction3":0,"singleLock":false,"advertisingMode":0,"keypadPaired":false,"homekitState":3,"timezoneId":37,"deviceType":4,"wifiEnabled":true},"advancedConfig":{"totalDegrees":970,"singleLockedPositionOffsetDegrees":0,"unlockedToLockedTransitionOffsetDegrees":0,"unlockedPositionOffsetDegrees":0,"lockedPositionOffsetDegrees":0,"detachedCylinder":false,"batteryType":1,"autoLock":false,"autoLockTimeout":300,"autoUpdateEnabled":false,"lngTimeout":20,"singleButtonPressAction":1,"doubleButtonPressAction":5,"automaticBatteryTypeDetection":true,"unlatchDuration":3},"webConfig":{"batteryWarningPerMailEnabled":false},"state":{"mode":2,"state":3,"trigger":0,"lastAction":3,"batteryCritical":false,"batteryCharging":false,"batteryCharge":76,"keypadBatteryCritical":false,"doorsensorBatteryCritical":false,"doorState":0,"ringToOpenTimer":0,"nightMode":false},"firmwareVersion":196874,"hardwareVersion":2817,"serverState":0,"adminPinState":0,"virtualDevice":false,"creationDate":"2021-12-21T12:57:13.161Z","updateDate":"2021-12-22T10:15:03.337Z"}]
nuki-extended.0 2021-12-22 13:31:45.213 debug State of nuki-extended.0.smartlocks.haustuer._ACTION.LOCK has changed {"val":false,"ack":true,"ts":1640176305199,"q":0,"from":"system.adapter.nuki-extended.0","user":"system.user.admin","lc":1640176305199}.
nuki-extended.0 2021-12-22 13:31:45.202 debug Web API: {"token":"738e315c4966aee59cb69cee02047ee32bee569XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","url":"https://api.nuki.io"}
nuki-extended.0 2021-12-22 13:31:45.202 debug Bridge API:undefined
nuki-extended.0 2021-12-22 13:31:45.201 debug DEVICE:{"id":749529444,"hex":"2cace964","smartlockId":17929391234,"name":"Haustuer","type":"Smartlock","path":"smartlocks.haustuer","bridge":null,"config":{"name":"Haustuer","latitude":51.255272,"longitude":6.9920063,"autoUnlatch":true,"liftUpHandle":false,"pairingEnabled":true,"buttonEnabled":true,"ledEnabled":true,"ledBrightness":3,"timezoneOffset":0,"daylightSavingMode":0,"fobPaired":false,"fobAction1":4,"fobAction2":2,"fobAction3":0,"singleLock":false,"advertisingMode":0,"keypadPaired":false,"homekitState":3,"timezoneId":37,"deviceType":4,"wifiEnabled":true},"advancedConfig":{"totalDegrees":970,"singleLockedPositionOffsetDegrees":0,"unlockedToLockedTransitionOffsetDegrees":0,"unlockedPositionOffsetDegrees":0,"lockedPositionOffsetDegrees":0,"detachedCylinder":false,"batteryType":1,"autoLock":false,"autoLockTimeout":300,"autoUpdateEnabled":false,"lngTimeout":20,"singleButtonPressAction":1,"doubleButtonPressAction":5,"automaticBatteryTypeDetection":true,"unlatchDuration":3}}
nuki-extended.0 2021-12-22 13:31:45.201 warn Neither Bridge API or Web API initialized!
nuki-extended.0 2021-12-22 13:31:45.200 info Trigger action -LOCK- on Nuki Smartlock Haustuer (via Bridge API).
nuki-extended.0 2021-12-22 13:31:45.199 debug State of nuki-extended.0.smartlocks.haustuer._ACTION.LOCK has changed {"val":true,"ack":false,"ts":1640176305196,"q":0,"from":"system.adapter.admin.0","user":"system.user.admin","lc":1640176305196}.`
StrathCole commented 2 years ago

I have created a pull request that allows (at least for me) operation with web-api only. https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/pull/179

jayfizzle commented 2 years ago

I have created a pull request that allows (at least for me) operation with web-api only.

179

Hi, I thought @jhubig had already created a pull request https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/pull/174

I will check if your changes fix my issues later.

StrathCole commented 2 years ago

Hi, I thought @jhubig had already created a pull request #174

I will check if your changes fix my issues later.

Yes, but he missed one place where it blocks.

jayfizzle commented 2 years ago

@StrathCole i think there is still an error in your fix. See line 201 in file nuki-extended.js.

i think it should be "nukiWebApi" instead of "NukiWepApi".

grafik

After this change, the communication through the WebAPI seems to be working. my first tests were successfull. thank you very much for helping to fix the issues with nuki pro working without a bridge.

StrathCole commented 2 years ago

@StrathCole i think there is still an error in your fix. See line 201 in file nuki-extended.js. i think it should be "nukiWebApi" instead of "NukiWepApi".

You are totally right. I changed it now.

jhubig commented 2 years ago

Thanks @StrathCole. I also used your code from your repository. One thing I noticed, is that with your code the lockState was not updated:

image

Therefore I commented out the following part of your code and then it worked. But to be honest, I do not know what would be the effect on users having the bridge.

image

jayfizzle commented 2 years ago

@jhubig I checked today my states in the iobroker, in yours are two states which I am missing. lastStateUpdate and lockstate is missing, do you know maybe why?

jhubig commented 2 years ago

@jayfizzle Had the same thing but when I commented out the part mentioned above, I got the two states/objects displayed.

jayfizzle commented 2 years ago

Thanks your right

StrathCole commented 2 years ago

But to be honest, I do not know what would be the effect on users having the bridge.

Me neither. I have a bridge now, so I do not need the workaround anymore, but I guess the code would have to be rewritten a bit more to support both ways correctly.

StrathCole commented 2 years ago

I would propose adding the "check if bridge config is there" instead of commenting out the code. That should do it.

StrathCole commented 2 years ago

@jhubig I have updated the repository. Maybe that should work for both types now.

jhubig commented 2 years ago

@StrathCole Perfect. Thanks. Tried it. Works like a charm šŸ˜€ Maybe you can add a comment in your pull request (https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/pull/179) that you tested it also in combination with your bridge.

Why did you buy the bridge on top?

StrathCole commented 2 years ago

@jhubig Why did you buy the bridge on top?

Because I want to be sure my smart home also works when internet connection is gone. The bridge has a local api and shows lock status etc. also on missing internet connection. The 3.0 pro does not.

ali86x commented 2 years ago

hello. I have a Nuki 3.0 pro with integrated Wifi. I tried to install it in iobroker with ver. 2.4.0 but it doesn't work.

nuki-extended.0 | 2022-01-10 20:00:08.470 | warn | No bridges have been defined in settings so far! -- | -- | -- | -- nuki-extended.0 | 2022-01-10 20:00:08.375 | info | starting. Version 2.4.0 in /opt/iobroker/node_modules/iobroker.nuki-extended, node: v14.18.2, js-controller: 3.3.22

Can anyone help?

jhubig commented 2 years ago

Hello,

this means you can only make it work by using the Web API and more important: currently the only chance to make it work is to use the fork done by @StrathCole (supported by @theimo1221): https://github.com/StrathCole/ioBroker.nuki-extended

  1. Install this version in ioBroker by installing from custom url - Enter this URL https://github.com/StrathCole/ioBroker.nuki-extended
  2. Then you need to get your Web API from Nuki and enter it in the adapter settings for the Nuki Web API and adapt the refresh time (don't leave it set to 0)

As soon as the pull request (https://github.com/iobroker-community-adapters/ioBroker.nuki-extended/pull/179) is accepted you will have this also available through the official adapter. As you prefer.

Hope this helps.

ali86x commented 2 years ago

Hello,

this means you can only make it work by using the Web API and more important: currently the only chance to make it work is to use the fork done by @StrathCole (supported by @theimo1221): https://github.com/StrathCole/ioBroker.nuki-extended

  1. Install this version in ioBroker by installing from custom url - Enter this URL https://github.com/StrathCole/ioBroker.nuki-extended
  2. Then you need to get your Web API from Nuki and enter it in the adapter settings for the Nuki Web API and adapt the refresh time (don't leave it set to 0)

As soon as the pull request (#179) is accepted you will have this also available through the official adapter. As you prefer.

Hope this helps.

Thank you. I changed the js file as in #179 and now it works great now

jhubig commented 2 years ago

Hello, this means you can only make it work by using the Web API and more important: currently the only chance to make it work is to use the fork done by @StrathCole (supported by @theimo1221): https://github.com/StrathCole/ioBroker.nuki-extended

  1. Install this version in ioBroker by installing from custom url - Enter this URL https://github.com/StrathCole/ioBroker.nuki-extended
  2. Then you need to get your Web API from Nuki and enter it in the adapter settings for the Nuki Web API and adapt the refresh time (don't leave it set to 0)

As soon as the pull request (#179) is accepted you will have this also available through the official adapter. As you prefer. Hope this helps.

Thank you. I changed the js file as in #179 and now it works great now

Also an option šŸ˜€ . Great that it works.