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

Support Nuki Opener (Bridge HTTP API 1.9.0) #18

Closed AntiHeld889 closed 5 years ago

AntiHeld889 commented 5 years ago

Hello the adapter in the future will support the new Nuki opener synonymous?

Zefau commented 5 years ago

I'm currently working on the support of the Nuki Opener, which will definitely be supported in future releases. I do not own one at the moment, which makes it a little challenging.

In that course the adapter will also be renamed to nuki-extended.

Zefau commented 5 years ago

Do you own one? Are you able to support testing?

AntiHeld889 commented 5 years ago

yes I have one installed and could assist in testing

twitowski commented 5 years ago

I also own a nuki opener and in case you need more testing I would also support you in testing your nuki-extended adapter

Zefau commented 5 years ago

@AntiHeld889 @twitowski has one of you the Nuki Web API enabled and a valid token generated?

If so, could you please run the following command in a Linux console and post the result?

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <TOKEN>' 'https://api.nuki.io/opener/intercom' 

Replace <TOKEN> (including both parenthesis) with your Nuki Web API token.

Thanks, Zefau

AntiHeld889 commented 5 years ago

Result:

{"code":500,"description":"The server encountered an unexpected condition which prevented it from fulfilling the request","homeRef":"/","reasonPhrase":"Internal Server Error","uri":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"}

Zefau commented 5 years ago

Same for me. I opened an issue at https://developer.nuki.io/t/endpoint-opener-intercom-throws-500/2625?u=zefau

Zefau commented 5 years ago

@AntiHeld889 Could you please try and run the following command as well?

http://<bridgeIp>:8080/lockState?nukiId=<NukiOpenerId>&token=<token>

Does this open your door?

What about the tomorrow command as well?

http://<bridgeIp>:8080/lockState?nukiId=<NukiOpenerId>&deviceType=2&token=<token>

Please replace bridgeIp, NukiOpenerId and token with your information. See https://developer.nuki.io/t/nuki-opener-api-error/2576/2?u=zefau

AntiHeld889 commented 5 years ago

This is working for me:

Status: http://0.0.0.0:8080/lockState?nukiId=XXXXXXXX&deviceType=2&token=yyyyyy {"mode": 2, "state": 1, "stateName": "online", "batteryCritical": false, "success": true}

Tür öffnen http://0.0.0.0:8080/lockAction?nukiId=XXXXXXXX&deviceType=2&action=3&token=yyyyyy {"success": true, "batteryCritical": false}

Dauermodus aktivert http://0.0.0.0:8080/lockAction?nukiId=XXXXXXXX&deviceType=2&action=4&token=yyyyyy {"success": true, "batteryCritical": false}

Dauermodus deaktiviert http://0.0.0.0:8080/lockAction?nukiId=XXXXXXXX&deviceType=2&action=5&token=yyyyyy {"success": true, "batteryCritical": false}

Zefau commented 5 years ago

Thanks so far. Could you additionally provide the payload received by calling /smartlock? I need the information of the index OpenerAdvancedConfig of that payload in order to add those as states.

Zefau commented 5 years ago

@AntiHeld889 Could you actually please send me the whole paypload (not only OpenerAdvancedConfig). This would make it easier to know which states to create.

Thanks and Cheers, Zefau

AntiHeld889 commented 5 years ago

Hi, yes I can do, but I can not do it before Monday.

AntiHeld889 commented 5 years ago

Hi, here is it

[{"deviceType": 0, "nukiId": XXXXXXX, "name": "Wohungstür"},{"deviceType": 2, "nukiId": XXXXXX, "name": "Haustür", "firmwareVersion": "1.0.4", "lastKnownState": {"mode": 2, "state": 1, "stateName": "online", "batteryCritical": false, "timestamp": "2019-09-15T13:36:51+00:00"}}]

Zefau commented 5 years ago

Sorry, I was wrong. I meant by Nuki Web API. Means calling

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer -TOKEN-

Since I own a Software Bridge myself (not a Hardware Bridge), could you let me know what the following returns to you?

curl -X GET --header 'Accept: application/json'  'http://-bridgeIp-:8080/log?token=-TOKEN-'
AntiHeld889 commented 5 years ago

curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer XXXXXXX' 'https://api.nuki.io/smartlock'

[
   {
      "smartlockId":XXXXXXX,
      "accountId":XXXXXXX,
      "type":0,
      "authId":XXXXXXX,
      "name":"Wohungstür",
      "favorite":false,
      "config":{
         "name":"Wohungstür",
         "latitude":XXXXXXX,
         "longitude":XXXXXXX,
         "capabilities":0,
         "autoUnlatch":true,
         "pairingEnabled":true,
         "buttonEnabled":true,
         "ledEnabled":false,
         "ledBrightness":0,
         "timezoneOffset":0,
         "daylightSavingMode":0,
         "fobPaired":false,
         "fobAction1":4,
         "fobAction2":1,
         "fobAction3":2,
         "singleLock":true,
         "operatingMode":0,
         "advertisingMode":1,
         "keypadPaired":false,
         "homekitState":1,
         "timezoneId":37
      },
      "advancedConfig":{
         "totalDegrees":-19136,
         "unlockedPositionOffsetDegrees":0,
         "lockedPositionOffsetDegrees":0,
         "singleLockedPositionOffsetDegrees":0,
         "unlockedToLockedTransitionOffsetDegrees":0,
         "lngTimeout":20,
         "singleButtonPressAction":1,
         "doubleButtonPressAction":5,
         "detachedCylinder":false,
         "batteryType":1,
         "automaticBatteryTypeDetection":true,
         "unlatchDuration":3,
         "autoLockTimeout":0
      },
      "state":{
         "mode":2,
         "state":3,
         "trigger":0,
         "lastAction":3,
         "batteryCritical":false,
         "doorState":1,
         "ringToOpenTimer":0
      },
      "firmwareVersion":132608,
      "hardwareVersion":2817,
      "serverState":4,
      "adminPinState":0,
      "virtualDevice":false,
      "creationDate":"2018-12-07T22:38:12.476Z",
      "updateDate":"2019-08-31T23:20:09.475Z"
   },
   {
      "smartlockId":XXXXXXX,
      "accountId":XXXXXXX,
      "type":2,
      "authId":XXXXXXX,
      "name":"Haustür",
      "favorite":true,
      "config":{
         "name":"Haustür",
         "latitude":XXXXXXX,
         "longitude":XXXXXXX,
         "capabilities":1,
         "autoUnlatch":false,
         "pairingEnabled":true,
         "buttonEnabled":true,
         "ledEnabled":false,
         "ledBrightness":0,
         "timezoneOffset":60,
         "daylightSavingMode":1,
         "fobPaired":false,
         "fobAction1":7,
         "fobAction2":0,
         "fobAction3":0,
         "singleLock":false,
         "operatingMode":4,
         "advertisingMode":0,
         "keypadPaired":false,
         "homekitState":0,
         "timezoneId":37
      },
      "openerAdvancedConfig":{
         "intercomId":124,
         "busModeSwitch":0,
         "shortCircuitDuration":0,
         "electricStrikeDelay":0,
         "randomElectricStrikeDelay":false,
         "electricStrikeDuration":3000,
         "disableRtoAfterRing":true,
         "rtoTimeout":20,
         "doorbellSuppression":2,
         "doorbellSuppressionDuration":3000,
         "soundRing":0,
         "soundOpen":0,
         "soundRto":0,
         "soundCm":0,
         "soundConfirmation":1,
         "soundLevel":-128,
         "singleButtonPressAction":1,
         "doubleButtonPressAction":4,
         "batteryType":0,
         "automaticBatteryTypeDetection":false
      },
      "state":{
         "mode":2,
         "state":1,
         "trigger":1,
         "lastAction":2,
         "batteryCritical":false,
         "doorState":0,
         "ringToOpenTimer":0
      },
      "firmwareVersion":65540,
      "hardwareVersion":1041,
      "serverState":0,
      "adminPinState":0,
      "virtualDevice":false,
      "creationDate":"2019-08-26T18:32:46.265Z",
      ...

curl -X GET --header 'Accept: application/json' 'http://0.0.0.0:8080/log?token=XXXXXXX'

{"timestamp": "2019-09-16T06:20:58+00:00", "type": "HTTP-Log"},
{"timestamp": "2019-09-16T06:20:58+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-16T05:51:24+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-16T05:51:24+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-16T05:48:27+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-16T05:48:27+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-16T05:47:50+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-16T05:47:50+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-16T05:47:34+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-16T05:47:34+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-16T05:44:08+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T05:44:08+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-16T04:44:07+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T04:44:07+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-16T03:44:06+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T03:44:06+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-16T02:44:05+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T02:44:05+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-16T01:44:04+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T01:44:04+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-16T00:44:03+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-16T00:44:03+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T23:44:02+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T23:44:02+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T22:44:01+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T22:44:01+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T21:44:00+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T21:44:00+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T20:43:59+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T20:43:59+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T19:43:58+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T19:43:58+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T18:43:57+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T18:43:57+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T17:43:56+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T17:43:56+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T17:34:50+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:34:50+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:34:50+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:34:23+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:34:19+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:34:14+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:34:13+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:33:41+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:33:36+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:33:31+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:33:31+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:33:25+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:33:21+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:33:15+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:33:15+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:32:05+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:32:00+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:31:55+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:31:55+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:50+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:45+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:31:40+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:31:40+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:40+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:36+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:31:31+00:00", "type": "HTTP-List"},
{"timestamp": "2019-09-15T17:31:30+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:21+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:31:17+00:00", "type": "WLAN-TxAborted", "connection": 0},
{"timestamp": "2019-09-15T17:31:11+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:57+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:47+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:08+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:08+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:06+00:00", "type": "WLAN-SocketDisconnected", "connection": 0},
{"timestamp": "2019-09-15T17:30:06+00:00", "type": "WLAN-SocketConnected", "connection": 0},
{"timestamp": "2019-09-15T16:43:55+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T16:43:55+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T15:43:54+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T15:43:54+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T14:43:53+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T14:43:53+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T13:43:52+00:00", "type": "SSE-PushNukisResponse", "error": 0},
{"timestamp": "2019-09-15T13:43:52+00:00", "type": "SSE-PushNukisRequest", "count": 2},
{"timestamp": "2019-09-15T13:36:59+00:00", "type": "BLE-Disconnected", "nukiId": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:59+00:00", "type": "BLE-Disconnect", "nukiId": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:57+00:00", "type": "HTTP-PostFailed", "urlId": 1},
{"timestamp": "2019-09-15T13:36:56+00:00", "type": "BLE-ReceivingMsg", "nukiId": "XXXXXXXX", "cmdId": "000E"},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "SSE-KeyturnerResponse", "nukiId": "XXXXXXXX", "bytes": 205},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "BLE-ReceivingSSE", "bytes": 55, "auth": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "SSE-KeyturnerResponse", "nukiId": "XXXXXXXX", "bytes": 277},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "BLE-ReceivingSSE", "bytes": 110, "auth": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "WLAN-SocketDisconnected", "connection": 3},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "HTTP-PostFailed", "urlId": 0},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "BLE-SendingSSE", "bytes": 96, "auth": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:55+00:00", "type": "SSE-KeyturnerRequest", "nukiId": "XXXXXXXX", "bytes": 96},
{"timestamp": "2019-09-15T13:36:54+00:00", "type": "BLE-ReceivingMsg", "nukiId": "XXXXXXXX", "cmdId": "000E"},
{"timestamp": "2019-09-15T13:36:54+00:00", "type": "SSE-KeyturnerResponse", "nukiId": "XXXXXXXX", "bytes": 245},
{"timestamp": "2019-09-15T13:36:54+00:00", "type": "BLE-ReceivingSSE", "bytes": 86, "auth": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:54+00:00", "type": "BLE-SendingSSE", "bytes": 56, "auth": "XXXXXXXX"},
{"timestamp": "2019-09-15T13:36:54+00:00", "type": "SSE-KeyturnerRequest", "nukiId": "XXXXXXXX", "bytes": 56},
{"timestamp": "2019-09-15T13:36:53+00:00", "type": "WLAN-SocketDisconnected", "connection": 3},
{"timestamp": "2019-09-15T13:36:53+00:00", "type": "BLE-ReceivingMsg", "nukiId": "XXXXXXXX", "cmdId": "000E"},
{"timestamp": "2019-09-15T13:36:53+00:00", "type": "SSE-KeyturnerResponse", "nukiId": "XXXXXXXX", "bytes": 229}
Zefau commented 5 years ago

@AntiHeld889 @twitowski

I would appreciate if you could test the new version v2.0.0, which supports the Nuki Opener now. You can install it via SSH in the /opt/iobroker/node_modules directory:

npm i https://github.com/Zefau/ioBroker.nuki2.git#nuki-extended

following

iobroker add nuki-extended
AntiHeld889 commented 5 years ago

Top, mache ich gleich mal.

twitowski commented 5 years ago

Sorry about the late response. New v2.0.0 is working perfectly with the opener so far. Will do some testing later.

Zefau commented 5 years ago

@AntiHeld889 @twitowski Any issues so far? Or any requests for improvements / features?

AntiHeld889 commented 5 years ago

No issuses so far :) is it possible to see if RingtoOpen or Dauermodus is activatet or off?

Zefau commented 5 years ago

The state state.lockState holds that information, according to the API documentation (see https://api.nuki.io/#!/Smartlock/get -> model).

If state.lockState has the value 3 it turns to RING_TO_OPEN_ACTIVE.

Zefau commented 5 years ago

v2.0.0-rc.3 has been release with some bug fixes (see https://forum.iobroker.net/post/307134). I appreciate if you give it a try. If no more errors are found, v2.0.0 will be release shortly.

Zefau commented 5 years ago

Feature added with nuki-extended v.2.0.0 (see https://github.com/Zefau/ioBroker.nuki2/projects)