homebridge-lib 5.1.21 → 5.1.24-0
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/hap.js +1 -1
- package/cli/json.js +1 -1
- package/cli/sysinfo.js +1 -1
- package/cli/upnp.js +1 -1
- package/index.js +1 -1
- package/lib/AccessoryDelegate.js +2 -3
- package/lib/AdaptiveLighting.js +1 -1
- package/lib/CharacteristicDelegate.js +1 -1
- package/lib/Colour.js +1 -1
- package/lib/CommandLineParser.js +1 -1
- package/lib/CommandLineTool.js +1 -1
- package/lib/CustomHomeKitTypes.js +1 -1
- package/lib/Delegate.js +1 -1
- package/lib/EveHomeKitTypes.js +1 -1
- package/lib/HttpClient.js +5 -6
- package/lib/JsonFormatter.js +1 -1
- package/lib/MyHomeKitTypes.js +46 -1
- package/lib/OptionParser.js +1 -1
- package/lib/Platform.js +1 -1
- package/lib/ServiceDelegate.js +3 -3
- package/lib/SystemInfo.js +15 -6
- package/lib/UpnpClient.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</span>
|
|
14
14
|
|
|
15
15
|
## Library for Homebridge Plugins
|
|
16
|
-
Copyright © 2018-
|
|
16
|
+
Copyright © 2018-2022 Erik Baauw. All rights reserved.
|
|
17
17
|
|
|
18
18
|
While developing a number of [Homebridge](https://github.com/homebridge/homebridge) plugins, I find myself duplicating a lot of code.
|
|
19
19
|
The idea behind this library is to ease developing and maintaining Homebridge plugins by separating this generic code, dealing with [HomeKit](http://www.apple.com/ios/home/) and Homebridge, from the specific code, dealing with the actual devices being exposed to HomeKit.
|
package/cli/hap.js
CHANGED
package/cli/json.js
CHANGED
package/cli/sysinfo.js
CHANGED
package/cli/upnp.js
CHANGED
package/index.js
CHANGED
package/lib/AccessoryDelegate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/AccessoryDelegate.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2017-
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
@@ -103,8 +103,7 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
|
|
|
103
103
|
|
|
104
104
|
// Remove associated accessory from platform
|
|
105
105
|
destroy () {
|
|
106
|
-
this.removeAllListeners(
|
|
107
|
-
this.removeAllListeners('shutdown')
|
|
106
|
+
this.removeAllListeners()
|
|
108
107
|
this._platform._removeAccessory(this._accessory)
|
|
109
108
|
}
|
|
110
109
|
|
package/lib/AdaptiveLighting.js
CHANGED
package/lib/Colour.js
CHANGED
package/lib/CommandLineParser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/CommandLineParser.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2017-
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
|
|
6
6
|
// TODO:
|
|
7
7
|
// - Change parameters to (params, callback) with:
|
package/lib/CommandLineTool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/CustomeHomeKitTypes.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2017-
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
|
|
6
6
|
const regExps = {
|
|
7
7
|
uuid: /^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/,
|
package/lib/Delegate.js
CHANGED
package/lib/EveHomeKitTypes.js
CHANGED
package/lib/HttpClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/HttpClient.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2018-
|
|
4
|
+
// Copyright © 2018-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
@@ -19,8 +19,7 @@ const https = require('https')
|
|
|
19
19
|
class HttpError extends Error {
|
|
20
20
|
constructor (message, request, statusCode, statusMessage) {
|
|
21
21
|
super(message)
|
|
22
|
-
/** @member {HttpRequest} - The request that caused the error.
|
|
23
|
-
* See {@link HttpClient.HttpRequest HttpRequest}.
|
|
22
|
+
/** @member {HttpClient.HttpRequest} - The request that caused the error.
|
|
24
23
|
*/
|
|
25
24
|
this.request = request
|
|
26
25
|
|
|
@@ -76,8 +75,7 @@ class HttpRequest {
|
|
|
76
75
|
*/
|
|
77
76
|
class HttpResponse {
|
|
78
77
|
constructor (request, statusCode, statusMessage, headers, body, parsedBody) {
|
|
79
|
-
/** @member {HttpRequest} - The request that generated the response.
|
|
80
|
-
* See {@link HttpClient.HttpRequest HttpRequest}.
|
|
78
|
+
/** @member {HttpClient.HttpRequest} - The request that generated the response.
|
|
81
79
|
*/
|
|
82
80
|
this.request = request
|
|
83
81
|
|
|
@@ -423,7 +421,8 @@ class HttpClient extends events.EventEmitter {
|
|
|
423
421
|
request: requestInfo,
|
|
424
422
|
headers: response.headers,
|
|
425
423
|
statusCode: response.statusCode,
|
|
426
|
-
statusMessage: response.statusMessage
|
|
424
|
+
statusMessage: response.statusMessage,
|
|
425
|
+
body: null
|
|
427
426
|
}
|
|
428
427
|
if (buffer != null && buffer.length > 0) {
|
|
429
428
|
responseInfo.body = buffer
|
package/lib/JsonFormatter.js
CHANGED
package/lib/MyHomeKitTypes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/MyHomeKitTypes.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2017-
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
//
|
|
6
6
|
// My own collection of custom HomeKit Services and Characteristics.
|
|
7
7
|
|
|
@@ -83,6 +83,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
83
83
|
* <br>Used by: homebridge-hue.
|
|
84
84
|
* @property {Class} Enabled - Enable/disable service.
|
|
85
85
|
* <br>Used by: homebridge-hue.
|
|
86
|
+
* @property {Class} Expose - Expose to HomeKit.
|
|
87
|
+
* <br>Used by: homebridge-deconz.
|
|
86
88
|
* @property {Class} Heartrate - Refresh rate.
|
|
87
89
|
* <br>Used by: homebridge-hue in HueBridge service,
|
|
88
90
|
* by Homebridge-soma, by Homebridge-rpi, by Homebridge-ws.
|
|
@@ -191,6 +193,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
191
193
|
* for lights.
|
|
192
194
|
* @property {Class} Unlatch - Unlatch the door.
|
|
193
195
|
* <br>Used by: homebridge-nb in the Smart Lock service.
|
|
196
|
+
* @property {Class} Unlock - Unlock gateway
|
|
197
|
+
* <br>Used by: homebridge-deconz.
|
|
194
198
|
* @property {Class} WaterPressure - Water pressure (in bar) of the central
|
|
195
199
|
* heating system.
|
|
196
200
|
* <br>Used by: homebridge-otgw.
|
|
@@ -690,6 +694,26 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
690
694
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
691
695
|
}, 'Low Battery Threshold')
|
|
692
696
|
|
|
697
|
+
this.createCharacteristicClass('PositionChange', uuid('076'), {
|
|
698
|
+
format: this.Formats.INT,
|
|
699
|
+
minValue: -1,
|
|
700
|
+
maxValue: 1,
|
|
701
|
+
minStep: 1, // Force Down|Up control in Eve
|
|
702
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
703
|
+
}, 'Position Change')
|
|
704
|
+
|
|
705
|
+
this.createCharacteristicClass('Unlock', uuid('077'), {
|
|
706
|
+
format: this.Formats.BOOL,
|
|
707
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
|
|
708
|
+
adminOnlyAccess: [this.Access.WRITE]
|
|
709
|
+
})
|
|
710
|
+
|
|
711
|
+
this.createCharacteristicClass('Expose', uuid('078'), {
|
|
712
|
+
format: this.Formats.BOOL,
|
|
713
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
|
|
714
|
+
adminOnlyAccess: [this.Access.WRITE]
|
|
715
|
+
})
|
|
716
|
+
|
|
693
717
|
// Characteristic for Unique ID, used by homebridge-hue.
|
|
694
718
|
// Source: as exposed by the Philips Hue bridge. This characteristic is
|
|
695
719
|
// used by the Hue app to select the accessories when syncing Hue bridge
|
|
@@ -718,6 +742,11 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
718
742
|
/** @member MyHomeKitTypes#Services
|
|
719
743
|
* @property {Class} Alarm - Service for an alarm clock.
|
|
720
744
|
* <br>Used by: homebridge-zp.
|
|
745
|
+
* @property {Class} DeconzGateway - Service for deCONZ gateway config.
|
|
746
|
+
* <br>Used by homebridge-deconz.
|
|
747
|
+
* @property {Class} DeconzDevice - Service for config of device exposed
|
|
748
|
+
* by deCONZ gateway.
|
|
749
|
+
* <br>Used by homebridge-deconz.
|
|
721
750
|
* @property {Class} HueBridge - Service for a Hue bridge.
|
|
722
751
|
* <br>Used by: homebridge-hue for a Hue bridge or deCONZ gateway.
|
|
723
752
|
* @property {Class} Resource - Generic service for resource.
|
|
@@ -752,6 +781,22 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
752
781
|
this.Characteristics.Status
|
|
753
782
|
])
|
|
754
783
|
|
|
784
|
+
this.createServiceClass('DeconzGateway', uuid('014'), [
|
|
785
|
+
this.Characteristics.LogLevel,
|
|
786
|
+
this.Characteristics.Expose,
|
|
787
|
+
this.Characteristics.Heartrate,
|
|
788
|
+
this.Characteristics.LastUpdated,
|
|
789
|
+
this.Characteristics.Restart,
|
|
790
|
+
this.Characteristics.Search,
|
|
791
|
+
this.Characteristics.TransitionTime,
|
|
792
|
+
this.Characteristics.Unlock
|
|
793
|
+
])
|
|
794
|
+
|
|
795
|
+
this.createServiceClass('DeconzDevice', uuid('015'), [
|
|
796
|
+
this.Characteristics.Expose,
|
|
797
|
+
this.Characteristics.Resource
|
|
798
|
+
])
|
|
799
|
+
|
|
755
800
|
this.createServiceClass('Alarm', uuid('048'), [
|
|
756
801
|
this.Characteristics.Enabled,
|
|
757
802
|
this.Characteristics.CurrentTrack,
|
package/lib/OptionParser.js
CHANGED
package/lib/Platform.js
CHANGED
package/lib/ServiceDelegate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/ServiceDelegate.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2017-
|
|
4
|
+
// Copyright © 2017-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
//
|
|
6
6
|
// The logic for handling Eve history was copied from Simone Tisa's
|
|
7
7
|
// fakagato-history repository, copyright © 2017 simont77.
|
|
@@ -401,14 +401,14 @@ class AccessoryInformation extends ServiceDelegate {
|
|
|
401
401
|
Characteristic: this.Characteristics.hap.FirmwareRevision,
|
|
402
402
|
value: params.firmware
|
|
403
403
|
})
|
|
404
|
-
if (params.hardware != null) {
|
|
404
|
+
if (params.hardware != null || this._context.hardware != null) {
|
|
405
405
|
this.addCharacteristicDelegate({
|
|
406
406
|
key: 'hardware',
|
|
407
407
|
Characteristic: this.Characteristics.hap.HardwareRevision,
|
|
408
408
|
value: params.hardware
|
|
409
409
|
})
|
|
410
410
|
}
|
|
411
|
-
if (params.software != null) {
|
|
411
|
+
if (params.software != null || this._context.software != null) {
|
|
412
412
|
this.addCharacteristicDelegate({
|
|
413
413
|
key: 'software',
|
|
414
414
|
Characteristic: this.Characteristics.hap.SoftwareRevision,
|
package/lib/SystemInfo.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// homebridge-lib/lib/SystemInfo.js
|
|
2
2
|
//
|
|
3
3
|
// Library for Homebridge plugins.
|
|
4
|
-
// Copyright © 2019-
|
|
4
|
+
// Copyright © 2019-2022 Erik Baauw. All rights reserved.
|
|
5
5
|
|
|
6
6
|
'use strict'
|
|
7
7
|
|
|
@@ -112,10 +112,16 @@ class SystemInfo extends events.EventEmitter {
|
|
|
112
112
|
* @return {object} - The extracted info.
|
|
113
113
|
*/
|
|
114
114
|
static parseRpiCpuInfo (cpuInfo) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
let a = /Serial\s*: ([0-9a-f]{16})/.exec(cpuInfo)
|
|
116
|
+
if (a == null || a.length < 2) {
|
|
117
|
+
return null
|
|
118
|
+
}
|
|
119
|
+
const id = a[1].toUpperCase()
|
|
120
|
+
a = /Revision\s*: ([0-9a-f]{4,})/.exec(cpuInfo)
|
|
121
|
+
if (a == null || a.length < 2) {
|
|
122
|
+
return null
|
|
123
|
+
}
|
|
124
|
+
const revision = parseInt(a[1], 16) & 0x00FFFFFF
|
|
119
125
|
let gpioMask, manufacturer, memory, model, modelRevision, processor
|
|
120
126
|
if ((revision & 0x00800000) !== 0) { // New revision scheme.
|
|
121
127
|
manufacturer = rpiInfo.manufacturers[(revision & 0x000F0000) >> 16]
|
|
@@ -338,8 +344,11 @@ class SystemInfo extends events.EventEmitter {
|
|
|
338
344
|
case 'ProductName': // e.g. 'macOS' or 'Mac OS X'
|
|
339
345
|
name = fields[1]
|
|
340
346
|
break
|
|
341
|
-
case 'ProductVersion': // e.g. '12.0.1'
|
|
347
|
+
case 'ProductVersion': // e.g. '12.0.1' or '12.1'
|
|
342
348
|
version = fields[1]
|
|
349
|
+
if (version.split('.').length === 2) {
|
|
350
|
+
version += '.0'
|
|
351
|
+
}
|
|
343
352
|
break
|
|
344
353
|
case 'BuildVersion': // e.g. '21A559'
|
|
345
354
|
build = fields[1]
|
package/lib/UpnpClient.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Library for homebridge plugins",
|
|
4
4
|
"author": "Erik Baauw",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "5.1.
|
|
6
|
+
"version": "5.1.24-0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"upnp": "cli/upnp.js"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"homebridge": "^1.3.
|
|
24
|
+
"homebridge": "^1.3.9",
|
|
25
25
|
"node": "^16.13.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|