homebridge-lib 5.1.19 → 5.1.22
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/lib/MyHomeKitTypes.js +19 -0
- package/lib/ServiceDelegate.js +28 -7
- package/lib/SystemInfo.js +14 -5
- package/package.json +2 -2
package/lib/MyHomeKitTypes.js
CHANGED
|
@@ -105,6 +105,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
105
105
|
* @property {Class} LogLevel - Level of logging.
|
|
106
106
|
* @property {Class} Loudness - Audio loudness.
|
|
107
107
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
108
|
+
* @property {Class} LowBatteryThreshold - Threshold value for setting
|
|
109
|
+
* Status Low Battery.
|
|
108
110
|
* @property {Class} MotorSpeed - Speed at which to move the blinds.
|
|
109
111
|
* <br>Used by: homebridge-soma in Window Covering service.
|
|
110
112
|
* @property {Class} MorningMode - Move the blinds slowly, making less
|
|
@@ -679,6 +681,23 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
679
681
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
680
682
|
})
|
|
681
683
|
|
|
684
|
+
this.createCharacteristicClass('LowBatteryThreshold', uuid('075'), {
|
|
685
|
+
format: this.Formats.UINT8,
|
|
686
|
+
unit: this.Units.PERCENTAGE,
|
|
687
|
+
minValue: 0,
|
|
688
|
+
maxValue: 95,
|
|
689
|
+
minStep: 5,
|
|
690
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
691
|
+
}, 'Low Battery Threshold')
|
|
692
|
+
|
|
693
|
+
this.createCharacteristicClass('PositionChange', uuid('076'), {
|
|
694
|
+
format: this.Formats.INT,
|
|
695
|
+
minValue: -1,
|
|
696
|
+
maxValue: 1,
|
|
697
|
+
minStep: 1, // Force Down|Up control in Eve
|
|
698
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
699
|
+
}, 'Position Change')
|
|
700
|
+
|
|
682
701
|
// Characteristic for Unique ID, used by homebridge-hue.
|
|
683
702
|
// Source: as exposed by the Philips Hue bridge. This characteristic is
|
|
684
703
|
// used by the Hue app to select the accessories when syncing Hue bridge
|
package/lib/ServiceDelegate.js
CHANGED
|
@@ -429,6 +429,8 @@ class AccessoryInformation extends ServiceDelegate {
|
|
|
429
429
|
* `batteryLevel` | `Characteristics.hap.BatteryLevel` | Y
|
|
430
430
|
* `chargingState` | `Characteristics.hap.ChargingState` | Y
|
|
431
431
|
* `statusLowBattery` | `Characteristics.hap.StatusLowBattery` | Y
|
|
432
|
+
* `lowBatteryThreshold`| `Characteristics.my.LowBatteryThreshold` | Y
|
|
433
|
+
*
|
|
432
434
|
* @extends ServiceDelegate
|
|
433
435
|
* @memberof ServiceDelegate
|
|
434
436
|
*/
|
|
@@ -436,14 +438,16 @@ class Battery extends ServiceDelegate {
|
|
|
436
438
|
/** Create a new instance of an _Battery_ service delegate.
|
|
437
439
|
* @param {!AccessoryDelegate} accessoryDelegate - The delegate of the
|
|
438
440
|
* corresponding HomeKit accessory.
|
|
439
|
-
* @param {
|
|
441
|
+
* @param {object} params - The parameters for the
|
|
440
442
|
* _AccessoryInformation_ HomeKit service.
|
|
441
|
-
* @param {
|
|
442
|
-
* `Characteristics.hap.BatteryLevel
|
|
443
|
-
* @param {
|
|
444
|
-
* `Characteristics.hap.ChargingState
|
|
445
|
-
* @param {
|
|
446
|
-
* `Characteristics.hap.StatusLowBattery
|
|
443
|
+
* @param {integer} [params.batteryLevel=100] - Initial value for
|
|
444
|
+
* `Characteristics.hap.BatteryLevel`.
|
|
445
|
+
* @param {integer} [params.chargingState=NOT_CHARGEABLE] - Initial value for
|
|
446
|
+
* `Characteristics.hap.ChargingState`.
|
|
447
|
+
* @param {integer} [params.statusLowBattery=BATTERY_LEVEL_NORMAL] - Initial
|
|
448
|
+
* value for `Characteristics.hap.StatusLowBattery`.
|
|
449
|
+
* @param {integer} [params.lowBatteryThreshold=20] - Initial value for
|
|
450
|
+
* low battery threshold.
|
|
447
451
|
*/
|
|
448
452
|
constructor (accessoryDelegate, params = {}) {
|
|
449
453
|
params.name = accessoryDelegate.name + ' Battery'
|
|
@@ -454,6 +458,8 @@ class Battery extends ServiceDelegate {
|
|
|
454
458
|
Characteristic: this.Characteristics.hap.BatteryLevel,
|
|
455
459
|
unit: '%',
|
|
456
460
|
value: params.batteryLevel != null ? params.batteryLevel : 100
|
|
461
|
+
}).on('didSet', (value) => {
|
|
462
|
+
this.updateStatusLowBattery()
|
|
457
463
|
})
|
|
458
464
|
this.addCharacteristicDelegate({
|
|
459
465
|
key: 'chargingState',
|
|
@@ -469,6 +475,21 @@ class Battery extends ServiceDelegate {
|
|
|
469
475
|
? params.statusLowBattery
|
|
470
476
|
: this.Characteristics.hap.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
471
477
|
})
|
|
478
|
+
this.addCharacteristicDelegate({
|
|
479
|
+
key: 'lowBatteryThreshold',
|
|
480
|
+
Characteristic: this.Characteristics.my.LowBatteryThreshold,
|
|
481
|
+
unit: '%',
|
|
482
|
+
value: params.lowBatteryThreshold != null ? params.lowBatteryThreshold : 20
|
|
483
|
+
}).on('didSet', (value) => {
|
|
484
|
+
this.updateStatusLowBattery()
|
|
485
|
+
})
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
updateStatusLowBattery () {
|
|
489
|
+
this.values.statusLowBattery =
|
|
490
|
+
this.values.batteryLevel <= this.values.lowBatteryThreshold
|
|
491
|
+
? this.Characteristics.hap.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
492
|
+
: this.Characteristics.hap.StatusLowBattery.BATTERY_LEVEL_NORMAL
|
|
472
493
|
}
|
|
473
494
|
}
|
|
474
495
|
|
package/lib/SystemInfo.js
CHANGED
|
@@ -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/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.22",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"homebridge": "^1.3.8",
|
|
25
|
-
"node": "^16.13.
|
|
25
|
+
"node": "^16.13.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"bonjour-hap": "^3.6.3",
|