homebridge-lib 6.0.0 → 6.0.1
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.
|
@@ -48,7 +48,7 @@ class Weather extends ServiceDelegate.History {
|
|
|
48
48
|
* @param {?CharacteristicDelegate} params.humidityDelegate - A reference
|
|
49
49
|
* to the delegate of the associated
|
|
50
50
|
* `Characteristics.hap.CurrentRelativeHumidity` characteristic.
|
|
51
|
-
* @param {?CharacteristicDelegate} params.
|
|
51
|
+
* @param {?CharacteristicDelegate} params.airPressureDelegate - A reference to
|
|
52
52
|
* the delegate of the associated `Characteristics.eve.AirPressure`
|
|
53
53
|
* characteristic.
|
|
54
54
|
*/
|
|
@@ -61,13 +61,13 @@ class Weather extends ServiceDelegate.History {
|
|
|
61
61
|
params.humidityDelegate != null &&
|
|
62
62
|
!(params.humidityDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
63
63
|
) {
|
|
64
|
-
throw new TypeError('humidityDelegate: not a CharacteristicDelegate')
|
|
64
|
+
throw new TypeError('params.humidityDelegate: not a CharacteristicDelegate')
|
|
65
65
|
}
|
|
66
66
|
if (
|
|
67
|
-
params.
|
|
68
|
-
!(params.
|
|
67
|
+
params.airPressureDelegate != null &&
|
|
68
|
+
!(params.airPressureDelegate instanceof homebridgeLib.CharacteristicDelegate)
|
|
69
69
|
) {
|
|
70
|
-
throw new TypeError('
|
|
70
|
+
throw new TypeError('params.airPressureDelegate: not a CharacteristicDelegate')
|
|
71
71
|
}
|
|
72
72
|
this._entry = {
|
|
73
73
|
time: 0,
|
|
@@ -81,9 +81,9 @@ class Weather extends ServiceDelegate.History {
|
|
|
81
81
|
params.humidityDelegate.on('didSet', (value) => {
|
|
82
82
|
this._entry.humidity = value
|
|
83
83
|
})
|
|
84
|
-
if (params.
|
|
85
|
-
this._entry.pressure = params.
|
|
86
|
-
params.
|
|
84
|
+
if (params.airPressureDelegate != null) {
|
|
85
|
+
this._entry.pressure = params.airPressureDelegate.value
|
|
86
|
+
params.airPressureDelegate.on('didSet', (value) => {
|
|
87
87
|
this._entry.pressure = value
|
|
88
88
|
})
|
|
89
89
|
}
|
|
@@ -310,7 +310,9 @@ class History extends ServiceDelegate {
|
|
|
310
310
|
|
|
311
311
|
let dataStream = ''
|
|
312
312
|
for (let i = 0; i < 11; i++) {
|
|
313
|
-
const address = this.
|
|
313
|
+
const address = this._memorySize === 0
|
|
314
|
+
? 0
|
|
315
|
+
: this._h.currentEntry % this._memorySize
|
|
314
316
|
if (
|
|
315
317
|
this._h.history[address].setRefTime === 1 ||
|
|
316
318
|
this._h.currentEntry === this._h.firstEntry + 1
|
|
@@ -47,6 +47,9 @@ class ServiceDelegate extends homebridgeLib.Delegate {
|
|
|
47
47
|
* @params {?ServiceDelegate} params.linkedServiceDelegate - The delegate
|
|
48
48
|
* of the service this service links to.
|
|
49
49
|
* @params {?boolean} params.hidden - Hidden service.
|
|
50
|
+
* @params {?boolean} params.exposeConfiguredName - Expose
|
|
51
|
+
* `Characteristics.hap.ConfiguredName`, so device name can be synced with
|
|
52
|
+
* HomeKit service name.
|
|
50
53
|
*/
|
|
51
54
|
constructor (accessoryDelegate, params = {}) {
|
|
52
55
|
if (!(accessoryDelegate instanceof homebridgeLib.AccessoryDelegate)) {
|
|
@@ -117,24 +120,26 @@ class ServiceDelegate extends homebridgeLib.Delegate {
|
|
|
117
120
|
value: params.name
|
|
118
121
|
})
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
if (params.exposeConfiguredName) {
|
|
124
|
+
this.addCharacteristicDelegate({
|
|
125
|
+
key: 'configuredName',
|
|
126
|
+
Characteristic: this.Characteristics.hap.ConfiguredName,
|
|
127
|
+
value: params.name,
|
|
128
|
+
setter: (value) => {
|
|
129
|
+
if (value == null || value === '') {
|
|
130
|
+
throw new Error('cannot be empty')
|
|
131
|
+
}
|
|
127
132
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
}
|
|
133
|
+
}).on('didSet', (value) => {
|
|
134
|
+
this.name = value
|
|
135
|
+
for (const key in this._characteristicDelegates) {
|
|
136
|
+
this._characteristicDelegates[key].name = value
|
|
137
|
+
}
|
|
138
|
+
if (params.primaryService) {
|
|
139
|
+
accessoryDelegate.values.name = value
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
}
|
|
138
143
|
|
|
139
144
|
this.once('initialised', () => {
|
|
140
145
|
this.values.configuredName = this.name
|