homebridge-nb 1.2.1 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cli/nb.js +41 -13
- package/config.schema.json +2 -3
- package/index.js +1 -1
- package/lib/NbAccessory.js +8 -1
- package/lib/NbClient.js +3 -2
- package/lib/NbDiscovery.js +1 -1
- package/lib/NbListener.js +1 -1
- package/lib/NbPlatform.js +1 -1
- package/lib/NbService.js +1 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</span>
|
|
17
17
|
|
|
18
18
|
## Homebridge plugin for Nuki Bridge
|
|
19
|
-
Copyright © 2020-
|
|
19
|
+
Copyright © 2020-2022 Erik Baauw. All rights reserved.
|
|
20
20
|
|
|
21
21
|
This [Homebridge](https://github.com/homebridge/homebridge) plugin exposes
|
|
22
22
|
[Nuki Smart Lock](https://nuki.io/nl/smart-lock/) and
|
package/cli/nb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// homebridge-nb/cli/nb.js
|
|
4
|
-
// Copyright © 2020-
|
|
4
|
+
// Copyright © 2020-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
//
|
|
6
6
|
// Homebridge plug-in for Nuki Bridge.
|
|
7
7
|
|
|
@@ -27,6 +27,7 @@ const usage = {
|
|
|
27
27
|
getlog: `${b('getlog')} [${b('-h')}]`,
|
|
28
28
|
clearlog: `${b('clearlog')} [${b('-h')}]`,
|
|
29
29
|
reboot: `${b('reboot')} [${b('-h')}]`,
|
|
30
|
+
fwupdate: `${b('fwupdate')} [${b('-h')}]`,
|
|
30
31
|
list: `${b('list')} [${b('-h')}]`,
|
|
31
32
|
|
|
32
33
|
lockState: `${b('lockState')} [${b('-h')}] ${u('nukiId')} ${u('deviceType')}`,
|
|
@@ -49,6 +50,7 @@ const description = {
|
|
|
49
50
|
getlog: 'Get Nuki bridge log.',
|
|
50
51
|
clearlog: 'Clear Nuki bridge log.',
|
|
51
52
|
reboot: 'Reboot Nuki bridge.',
|
|
53
|
+
fwupdate: 'Trigger a firmware update of the bridge and connected devices.',
|
|
52
54
|
list: 'Get list of paired Nuki devices.',
|
|
53
55
|
|
|
54
56
|
lockState: 'Refresh state from paired Nuki device.',
|
|
@@ -77,10 +79,12 @@ Parameters:
|
|
|
77
79
|
Print debug messages for communication with Nuki bridge.
|
|
78
80
|
|
|
79
81
|
${b('-H')} ${u('hostname')}[${b(':')}${u('port')}], ${b('--host=')}${u('hostname')}[${b(':')}${u('port')}]
|
|
80
|
-
Connect to ${u('hostname')}${b(':8080')} or ${u('hostname')}${b(':')}${u('port')}.
|
|
82
|
+
Connect to Nuki bridge at ${u('hostname')}${b(':8080')} or ${u('hostname')}${b(':')}${u('port')}.
|
|
83
|
+
You can also specify the hostname and port in the ${b('NB_HOST')} environment variable.
|
|
81
84
|
|
|
82
85
|
${b('-T')} ${u('token')}, ${b('--token=')}${u('token')}
|
|
83
|
-
Use ${u('token')}
|
|
86
|
+
Use token ${u('token')} to connect to the Nuki bridge.
|
|
87
|
+
You can also specify the token in the ${b('NB_TOKEN')} environment variable.
|
|
84
88
|
|
|
85
89
|
Commands:
|
|
86
90
|
${usage.discover}
|
|
@@ -101,6 +105,9 @@ Commands:
|
|
|
101
105
|
${usage.reboot}
|
|
102
106
|
${description.reboot}
|
|
103
107
|
|
|
108
|
+
${usage.fwupdate}
|
|
109
|
+
${description.fwupdate}
|
|
110
|
+
|
|
104
111
|
${usage.list}
|
|
105
112
|
${description.list}
|
|
106
113
|
|
|
@@ -165,6 +172,13 @@ Parameters:
|
|
|
165
172
|
|
|
166
173
|
Usage: ${usage.reboot}
|
|
167
174
|
|
|
175
|
+
Parameters:
|
|
176
|
+
${b('-h')}, ${b('--help')}
|
|
177
|
+
Print this help and exit.`,
|
|
178
|
+
fwupdate: `${description.fwupdate}
|
|
179
|
+
|
|
180
|
+
Usage: ${usage.fwupdate}
|
|
181
|
+
|
|
168
182
|
Parameters:
|
|
169
183
|
${b('-h')}, ${b('--help')}
|
|
170
184
|
Print this help and exit.`,
|
|
@@ -188,8 +202,10 @@ Parameters:
|
|
|
188
202
|
|
|
189
203
|
${u('deviceType')}
|
|
190
204
|
The type of the Nuki device (from ${b('nb list')}):
|
|
191
|
-
0:
|
|
192
|
-
2:
|
|
205
|
+
0: Smart Lock 1.0 or 2.0
|
|
206
|
+
2: Opener
|
|
207
|
+
3: Smart Door
|
|
208
|
+
4: Smart Lock 3.0`,
|
|
193
209
|
lock: `${description.lock}
|
|
194
210
|
|
|
195
211
|
Usage: ${usage.lock}
|
|
@@ -203,8 +219,10 @@ Parameters:
|
|
|
203
219
|
|
|
204
220
|
${u('deviceType')}
|
|
205
221
|
The type of the Nuki device (from ${b('nb list')}):
|
|
206
|
-
0:
|
|
207
|
-
2:
|
|
222
|
+
0: Smart Lock 1.0 or 2.0
|
|
223
|
+
2: Opener
|
|
224
|
+
3: Smart Door
|
|
225
|
+
4: Smart Lock 3.0`,
|
|
208
226
|
unlock: `${description.unlock}
|
|
209
227
|
|
|
210
228
|
Usage: ${usage.unlock}
|
|
@@ -218,8 +236,10 @@ Parameters:
|
|
|
218
236
|
|
|
219
237
|
${u('deviceType')}
|
|
220
238
|
The type of the Nuki device (from ${b('nb list')}):
|
|
221
|
-
0:
|
|
222
|
-
2:
|
|
239
|
+
0: Smart Lock 1.0 or 2.0
|
|
240
|
+
2: Opener
|
|
241
|
+
3: Smart Door
|
|
242
|
+
4: Smart Lock 3.0`,
|
|
223
243
|
lockAction: `${description.lockAction}
|
|
224
244
|
|
|
225
245
|
Usage: ${usage.lockAction}
|
|
@@ -233,12 +253,14 @@ Parameters:
|
|
|
233
253
|
|
|
234
254
|
${u('deviceType')}
|
|
235
255
|
The type of the Nuki device (from ${b('nb list')}):
|
|
236
|
-
0:
|
|
237
|
-
2:
|
|
256
|
+
0: Smart Lock 1.0 or 2.0
|
|
257
|
+
2: Opener
|
|
258
|
+
3: Smart Door
|
|
259
|
+
4: Smart Lock 3.0
|
|
238
260
|
|
|
239
261
|
${u('action')}
|
|
240
262
|
The action to send to the Nuki device:
|
|
241
|
-
|
|
263
|
+
Smart Lock, Smart Door Opener
|
|
242
264
|
- ------------------------ -------------------------
|
|
243
265
|
1 unlock activate rto
|
|
244
266
|
2 lock deactivate rto
|
|
@@ -376,7 +398,7 @@ class Main extends homebridgeLib.CommandLineTool {
|
|
|
376
398
|
args += ' -H ' + clargs.options.host
|
|
377
399
|
}
|
|
378
400
|
await this.fatal(
|
|
379
|
-
`Missing token. Run ${b('nb' + args + ' auth')}
|
|
401
|
+
`Missing token. Set ${b('NB_TOKEN')} or specify ${b('-T')}. Run ${b('nb' + args + ' auth')} to obtain the token.`
|
|
380
402
|
)
|
|
381
403
|
}
|
|
382
404
|
}
|
|
@@ -465,6 +487,12 @@ class Main extends homebridgeLib.CommandLineTool {
|
|
|
465
487
|
this.print(this.jsonFormatter.stringify(response.body))
|
|
466
488
|
}
|
|
467
489
|
|
|
490
|
+
async fwupdate (...args) {
|
|
491
|
+
this.parser.parse(...args)
|
|
492
|
+
const response = await this.client.fwupdate()
|
|
493
|
+
this.print(this.jsonFormatter.stringify(response.body))
|
|
494
|
+
}
|
|
495
|
+
|
|
468
496
|
async list (...args) {
|
|
469
497
|
this.parser.parse(...args)
|
|
470
498
|
const response = await this.client.list()
|
package/config.schema.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "object",
|
|
9
9
|
"properties": {
|
|
10
10
|
"name": {
|
|
11
|
-
"description": "Plugin name as displayed in the
|
|
11
|
+
"description": "Plugin name as displayed in the Homebridge log.",
|
|
12
12
|
"type": "string",
|
|
13
13
|
"required": true,
|
|
14
14
|
"default": "Nuki"
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
"type": "integer",
|
|
23
23
|
"maximum": 65535
|
|
24
24
|
},
|
|
25
|
-
"timeout":
|
|
26
|
-
{
|
|
25
|
+
"timeout": {
|
|
27
26
|
"description": "The timeout in seconds to wait for a response from a Nuki bridge. Default: 15.",
|
|
28
27
|
"type": "integer",
|
|
29
28
|
"minimum": 1,
|
package/index.js
CHANGED
package/lib/NbAccessory.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// homebridge-nb/lib/NbAccessory.js
|
|
2
|
-
// Copyright © 2020-
|
|
2
|
+
// Copyright © 2020-2022 Erik Baauw. All rights reserved.
|
|
3
3
|
//
|
|
4
4
|
// Homebridge plug-in for Nuki Bridge.
|
|
5
5
|
|
|
@@ -63,6 +63,7 @@ class Bridge extends homebridgeLib.AccessoryDelegate {
|
|
|
63
63
|
this.doorSensors = {}
|
|
64
64
|
this.openers = {}
|
|
65
65
|
this.service = new NbService.Bridge(this)
|
|
66
|
+
this.manageLogLevel(this.service.characteristicDelegate('logLevel'))
|
|
66
67
|
this.dummyService = new homebridgeLib.ServiceDelegate.Dummy(this)
|
|
67
68
|
|
|
68
69
|
this.client = new NbClient({
|
|
@@ -133,6 +134,9 @@ class Bridge extends homebridgeLib.AccessoryDelegate {
|
|
|
133
134
|
async init (beat) {
|
|
134
135
|
try {
|
|
135
136
|
await this.client.init()
|
|
137
|
+
this.values.firmware = this.client.firmware
|
|
138
|
+
this.context.firmware = this.values.firmware
|
|
139
|
+
// TODO firmware version check
|
|
136
140
|
} catch (error) {
|
|
137
141
|
return
|
|
138
142
|
}
|
|
@@ -220,6 +224,9 @@ class Bridge extends homebridgeLib.AccessoryDelegate {
|
|
|
220
224
|
await this.checkSubscription()
|
|
221
225
|
let response = await this.client.info()
|
|
222
226
|
this.debug('bridge: %j', response.body)
|
|
227
|
+
// this.values.firmware = response.body.versions.firmwareVersion
|
|
228
|
+
// this.context.firmware = this.values.firmware
|
|
229
|
+
// TODO firmware check
|
|
223
230
|
this.service.update(response.body)
|
|
224
231
|
response = await this.client.list()
|
|
225
232
|
for (const device of response.body) {
|
package/lib/NbClient.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// homebridge-nb/lib/NbClient.js
|
|
2
|
-
// Copyright © 2020-
|
|
2
|
+
// Copyright © 2020-2022 Erik Baauw. All rights reserved.
|
|
3
3
|
//
|
|
4
4
|
// Homebridge plug-in for Nuki Bridge.
|
|
5
5
|
|
|
@@ -136,9 +136,10 @@ class NbClient extends homebridgeLib.HttpClient {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
async info () { return this._get('/info') }
|
|
139
|
+
async list () { return this._get('/list') }
|
|
139
140
|
async log () { return this._get('/log') }
|
|
140
141
|
async reboot () { return this._get('/reboot') }
|
|
141
|
-
async
|
|
142
|
+
async fwupdate () { return this._get('/fwupdate') }
|
|
142
143
|
|
|
143
144
|
async lockState (nukiId, deviceType) {
|
|
144
145
|
return this._get('/lockState', { nukiId: nukiId, deviceType: deviceType })
|
package/lib/NbDiscovery.js
CHANGED
package/lib/NbListener.js
CHANGED
package/lib/NbPlatform.js
CHANGED
package/lib/NbService.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// homebridge-nb/lib/NbAccessory.js
|
|
2
|
-
// Copyright © 2020-
|
|
2
|
+
// Copyright © 2020-2022 Erik Baauw. All rights reserved.
|
|
3
3
|
//
|
|
4
4
|
// Homebridge plug-in for Nuki Bridge.
|
|
5
5
|
|
|
@@ -63,8 +63,6 @@ class Bridge extends homebridgeLib.ServiceDelegate {
|
|
|
63
63
|
key: 'logLevel',
|
|
64
64
|
Characteristic: this.Characteristics.my.LogLevel,
|
|
65
65
|
value: nbAccessory.platform.logLevel
|
|
66
|
-
}).on('didSet', (value) => {
|
|
67
|
-
nbAccessory.logLevel = value
|
|
68
66
|
})
|
|
69
67
|
this.addCharacteristicDelegate({
|
|
70
68
|
key: 'statusFault',
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName": "Homebridge NB",
|
|
5
5
|
"author": "Erik Baauw",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"version": "1.2.
|
|
7
|
+
"version": "1.2.5",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"homebridge-plugin",
|
|
10
10
|
"homekit",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"nb": "cli/nb.js"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"homebridge": "^1.
|
|
22
|
-
"node": "^16.
|
|
21
|
+
"homebridge": "^1.4.0",
|
|
22
|
+
"node": "^16.14.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"homebridge-lib": "~5.
|
|
25
|
+
"homebridge-lib": "~5.2.3"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"prepare": "standard",
|