homebridge-lib 6.0.0 → 6.0.2
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
|
}
|
|
@@ -103,6 +103,7 @@ class History extends ServiceDelegate {
|
|
|
103
103
|
* _History_ HomeKit service.
|
|
104
104
|
* @param {integer} [params.memorySize=2304] - The memory size, in number of
|
|
105
105
|
* history entries. The default is 4 weeks of 6 entries per hour.
|
|
106
|
+
* @param {?boolean} params.config - Expose config.
|
|
106
107
|
*/
|
|
107
108
|
constructor (accessoryDelegate, params = {}) {
|
|
108
109
|
params.name = accessoryDelegate.name + ' History'
|
|
@@ -175,19 +176,21 @@ class History extends ServiceDelegate {
|
|
|
175
176
|
silent: true
|
|
176
177
|
})
|
|
177
178
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
if (params.config) {
|
|
180
|
+
this.addCharacteristicDelegate({
|
|
181
|
+
key: 'configCommand',
|
|
182
|
+
Characteristic: this.Characteristics.eve.ConfigCommand,
|
|
183
|
+
setter: this._onSetConfig.bind(this)
|
|
184
|
+
// silent: true
|
|
185
|
+
})
|
|
184
186
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
this.addCharacteristicDelegate({
|
|
188
|
+
key: 'configData',
|
|
189
|
+
Characteristic: this.Characteristics.eve.ConfigData,
|
|
190
|
+
getter: this._onGetConfig.bind(this)
|
|
191
|
+
// silent: true
|
|
192
|
+
})
|
|
193
|
+
}
|
|
191
194
|
|
|
192
195
|
accessoryDelegate.propertyDelegate('name')
|
|
193
196
|
.on('didSet', (value) => {
|
|
@@ -310,7 +313,9 @@ class History extends ServiceDelegate {
|
|
|
310
313
|
|
|
311
314
|
let dataStream = ''
|
|
312
315
|
for (let i = 0; i < 11; i++) {
|
|
313
|
-
const address = this.
|
|
316
|
+
const address = this._memorySize === 0
|
|
317
|
+
? 0
|
|
318
|
+
: this._h.currentEntry % this._memorySize
|
|
314
319
|
if (
|
|
315
320
|
this._h.history[address].setRefTime === 1 ||
|
|
316
321
|
this._h.currentEntry === this._h.firstEntry + 1
|
|
@@ -341,12 +346,14 @@ class History extends ServiceDelegate {
|
|
|
341
346
|
return hexToBase64(dataStream)
|
|
342
347
|
}
|
|
343
348
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
349
|
+
async _onSetConfig (value) {
|
|
350
|
+
// const buffer = Buffer.from(value, 'base64')
|
|
351
|
+
this.debug('Config Request changed to %j', base64ToHex(value))
|
|
352
|
+
}
|
|
347
353
|
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
async _onGetConfig () {
|
|
355
|
+
return hexToBase64('D200')
|
|
356
|
+
}
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
module.exports = History
|
|
@@ -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
|
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": "6.0.
|
|
6
|
+
"version": "6.0.2",
|
|
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.
|
|
24
|
+
"homebridge": "^1.6.0",
|
|
25
25
|
"node": "^18.12.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|