homebridge-lib 6.5.0 → 6.6.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/lib/MyHomeKitTypes.js +25 -1
- package/lib/ServiceDelegate/History.js +42 -52
- package/package.json +3 -3
package/lib/MyHomeKitTypes.js
CHANGED
|
@@ -101,6 +101,8 @@ class MyHomeKitTypes extends CustomHomeKitTypes {
|
|
|
101
101
|
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
102
102
|
* @property {Class} FireplaceEffect - Enabled/disable fireplace dynamic effect.
|
|
103
103
|
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
104
|
+
* @property {Class} GlistenEffect - Enabled/disable glisten dynamic effect.
|
|
105
|
+
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
104
106
|
* @property {Class} Heartrate - Refresh rate.
|
|
105
107
|
* <br>Used by: homebridge-hue in HueBridge service,
|
|
106
108
|
* by Homebridge-soma, by Homebridge-rpi, by Homebridge-ws.
|
|
@@ -122,6 +124,7 @@ class MyHomeKitTypes extends CustomHomeKitTypes {
|
|
|
122
124
|
* <br>Previously used by homebridge-hue for Thermostat sensor.
|
|
123
125
|
* @property {Class} LogLevel - Level of logging.
|
|
124
126
|
* @property {Class} LoopEffect - Enabled/disable loop dynamic effect.
|
|
127
|
+
* <br>Deprecated - use `PrismEffect`.
|
|
125
128
|
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
126
129
|
* @property {Class} Loudness - Audio loudness.
|
|
127
130
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
@@ -138,10 +141,14 @@ class MyHomeKitTypes extends CustomHomeKitTypes {
|
|
|
138
141
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
139
142
|
* @property {Class} Offset - Temperature offset.
|
|
140
143
|
* <br>Used by: homebridge-hue in Temperature service.
|
|
144
|
+
* @property {Class} OpalEffect - Enabled/disable opal dynamic effect.
|
|
145
|
+
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
141
146
|
* @property {Class} PartyEffect - Enabled/disable party dynamic effect.
|
|
142
147
|
* <br>Used by: homebridge-deconz.
|
|
143
148
|
* @property {Class} Period - Daylight period (e.g. Dawn).
|
|
144
149
|
* <br>Used by: homebridge-hue for Daylight sensor.
|
|
150
|
+
* @property {Class} PrismEffect - Enabled/disable prism dynamic effect.
|
|
151
|
+
* <br>Used by: homebridge-deconz, homebridge-hue2.
|
|
145
152
|
* @property {Class} PumpHours - Pump run time (in hours).
|
|
146
153
|
* <br>Used by: homebridge-otgw.
|
|
147
154
|
* @property {Class} PumpStarts - Number of pump starts.
|
|
@@ -807,7 +814,12 @@ class MyHomeKitTypes extends CustomHomeKitTypes {
|
|
|
807
814
|
this.createCharacteristicClass('LoopEffect', uuid('081'), {
|
|
808
815
|
format: this.Formats.BOOL,
|
|
809
816
|
perms: [this.Perms.PAIRED_READ, this.Perms.NOTIFY, this.Perms.PAIRED_WRITE]
|
|
810
|
-
}, '
|
|
817
|
+
}, 'Prism')
|
|
818
|
+
|
|
819
|
+
this.createCharacteristicClass('PrismEffect', uuid('081'), {
|
|
820
|
+
format: this.Formats.BOOL,
|
|
821
|
+
perms: [this.Perms.PAIRED_READ, this.Perms.NOTIFY, this.Perms.PAIRED_WRITE]
|
|
822
|
+
}, 'Prism')
|
|
811
823
|
|
|
812
824
|
this.createCharacteristicClass('SunriseEffect', uuid('082'), {
|
|
813
825
|
format: this.Formats.BOOL,
|
|
@@ -851,6 +863,18 @@ class MyHomeKitTypes extends CustomHomeKitTypes {
|
|
|
851
863
|
perms: [this.Perms.PAIRED_READ, this.Perms.NOTIFY, this.Perms.PAIRED_WRITE]
|
|
852
864
|
}, 'Night Light')
|
|
853
865
|
|
|
866
|
+
// More dynamic effects for Hue lights.
|
|
867
|
+
|
|
868
|
+
this.createCharacteristicClass('OpalEffect', uuid('08A'), {
|
|
869
|
+
format: this.Formats.BOOL,
|
|
870
|
+
perms: [this.Perms.PAIRED_READ, this.Perms.NOTIFY, this.Perms.PAIRED_WRITE]
|
|
871
|
+
}, 'Opal')
|
|
872
|
+
|
|
873
|
+
this.createCharacteristicClass('GlistenEffect', uuid('08B'), {
|
|
874
|
+
format: this.Formats.BOOL,
|
|
875
|
+
perms: [this.Perms.PAIRED_READ, this.Perms.NOTIFY, this.Perms.PAIRED_WRITE]
|
|
876
|
+
}, 'Glisten')
|
|
877
|
+
|
|
854
878
|
// Characteristic for Unique ID, used by homebridge-hue.
|
|
855
879
|
// Source: as exposed by the Philips Hue bridge. This characteristic is
|
|
856
880
|
// used by the Hue app to select the accessories when syncing Hue bridge
|
|
@@ -223,10 +223,10 @@ class AverageConsumptionValue extends HistoryValue {
|
|
|
223
223
|
prepareEntry (entry) { entry[this.id] = this._delegate.value * 10 }
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
class
|
|
226
|
+
class OnValue extends HistoryValue {
|
|
227
227
|
get tag () { return 0x0E }
|
|
228
228
|
get length () { return 1 }
|
|
229
|
-
get id () { return '
|
|
229
|
+
get id () { return 'o' }
|
|
230
230
|
prepareEntry (entry) { entry[this.id] = this._delegate.value ? 1 : 0 }
|
|
231
231
|
writeEntry (entry, buffer, offset) { buffer.writeInt8(entry[this.id], offset) }
|
|
232
232
|
|
|
@@ -237,7 +237,7 @@ class SwitchOnValue extends HistoryValue {
|
|
|
237
237
|
const entry = { time: now }
|
|
238
238
|
entry[this.id] = this._delegate.value ? 1 : 0
|
|
239
239
|
parent.addEntry(entry)
|
|
240
|
-
parent.
|
|
240
|
+
parent.lastOnDelegate.value = parent.lastActivationValue(now)
|
|
241
241
|
})
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -275,25 +275,6 @@ class MotionValue extends HistoryValue {
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
class OnValue extends HistoryValue {
|
|
279
|
-
get tag () { return 0x1E }
|
|
280
|
-
get length () { return 1 }
|
|
281
|
-
get id () { return 'o' }
|
|
282
|
-
prepareEntry (entry) { entry[this.id] = this._delegate.value ? 1 : 0 }
|
|
283
|
-
writeEntry (entry, buffer, offset) { buffer.writeInt8(entry[this.id], offset) }
|
|
284
|
-
|
|
285
|
-
constructor (parent, delegate) {
|
|
286
|
-
super(parent, delegate)
|
|
287
|
-
delegate.on('didSet', (value) => {
|
|
288
|
-
const now = History.now()
|
|
289
|
-
const entry = { time: now }
|
|
290
|
-
entry[this.id] = this._delegate.value ? 1 : 0
|
|
291
|
-
parent.addEntry(entry)
|
|
292
|
-
parent.lastOnDelegate.value = parent.lastActivationValue(now)
|
|
293
|
-
})
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
278
|
class VocDensityValue extends HistoryValue {
|
|
298
279
|
get tag () { return 0x22 }
|
|
299
280
|
get id () { return 'q' }
|
|
@@ -309,6 +290,7 @@ class ButtonValue extends HistoryValue {
|
|
|
309
290
|
class LightLevelValue extends HistoryValue {
|
|
310
291
|
get tag () { return 0x30 }
|
|
311
292
|
get id () { return 'l' }
|
|
293
|
+
prepareEntry (entry) { entry[this.id] = Math.max(1, this._delegate.value) }
|
|
312
294
|
}
|
|
313
295
|
|
|
314
296
|
// Types of delegates for characteristics for history data points.
|
|
@@ -321,11 +303,10 @@ const historyValueTypes = {
|
|
|
321
303
|
totalConsumption: TotalConsumptionValue,
|
|
322
304
|
consumption: ConsumptionValue,
|
|
323
305
|
averageConsumption: AverageConsumptionValue,
|
|
324
|
-
|
|
306
|
+
on: OnValue,
|
|
325
307
|
valvePosition: ValvePositionValue,
|
|
326
308
|
targetTemperature: TargetTemperatureValue,
|
|
327
309
|
motion: MotionValue,
|
|
328
|
-
on: OnValue,
|
|
329
310
|
vocDensity: VocDensityValue,
|
|
330
311
|
button: ButtonValue,
|
|
331
312
|
lightLevel: LightLevelValue
|
|
@@ -338,7 +319,6 @@ const historyDerivedTypes = {
|
|
|
338
319
|
lastMotion: 'motion',
|
|
339
320
|
lastOn: 'on',
|
|
340
321
|
lastLightOn: 'lightOn',
|
|
341
|
-
lastSwitchOn: 'switchOn',
|
|
342
322
|
computedConsumption: 'totalConsumption',
|
|
343
323
|
computedTotalConsumption: 'consumption'
|
|
344
324
|
}
|
|
@@ -365,79 +345,73 @@ class History extends ServiceDelegate {
|
|
|
365
345
|
* corresponding HomeKit accessory.
|
|
366
346
|
* @param {!object} params - The parameters for the _History_ HomeKit service.
|
|
367
347
|
* @param {?CharacteristicDelegate} params.contactDelegate - The
|
|
368
|
-
* `hap.ContactSensorState` characteristic delegate
|
|
348
|
+
* `Characteristics.hap.ContactSensorState` characteristic delegate
|
|
369
349
|
* for a `hap.ContactSensor` service.
|
|
370
350
|
* @param {?CharacteristicDelegate} params.lastContactDelegate - The
|
|
371
|
-
* `eve.LastActivation` characteristic delegate
|
|
351
|
+
* `Characteristics.eve.LastActivation` characteristic delegate
|
|
372
352
|
* for a `hap.ContactSensor` service.
|
|
373
353
|
* @param {?CharacteristicDelegate} params.timesOpenedDelegate - The
|
|
374
|
-
* `eve.TimesOpened` characteristic delegate
|
|
354
|
+
* `Characteristics.eve.TimesOpened` characteristic delegate
|
|
375
355
|
* for a `hap.ContactSensor` service.
|
|
376
356
|
* @param {?CharacteristicDelegate} params.motionDelegate - The
|
|
377
|
-
*
|
|
357
|
+
* `Characteristics.hap.MotionDetected` characteristic delegate
|
|
378
358
|
* for a `hap.MotionSensor` service.
|
|
379
359
|
* @param {?CharacteristicDelegate} params.lastMotionDelegate - The
|
|
380
|
-
*
|
|
360
|
+
* `Characteristics.eve.LastActivation` characteristic delegate
|
|
381
361
|
* for a `hap.MotionSensor` service.
|
|
382
362
|
* @param {?CharacteristicDelegate} params.lightLevelDelegate - The
|
|
383
|
-
*
|
|
363
|
+
* `Characteristics.hap.CurrentAmbientLightLevel` characteristic delegate
|
|
384
364
|
* for a `hap.LightLevelSensor` service.
|
|
385
365
|
* @param {?CharacteristicDelegate} params.temperatureDelegate - The
|
|
386
|
-
*
|
|
366
|
+
* `Characteristics.hap.CurrentTemperature` characteristic delegate
|
|
387
367
|
* for a `hap.TemperatureSensor`, `eve.Weather`, or `hap.Thermostat` service.
|
|
388
368
|
* @param {?CharacteristicDelegate} params.humidityDelegate - The
|
|
389
|
-
* `hap.CurrentRelativeHumidity` characteristic delegate
|
|
369
|
+
* `Characteristics.hap.CurrentRelativeHumidity` characteristic delegate
|
|
390
370
|
* for a `hap.HumiditySensor` or `eve.Weather` service.
|
|
391
371
|
* @param {?CharacteristicDelegate} params.airPressureDelegate - The
|
|
392
|
-
*
|
|
372
|
+
* `Characteristics.eve.AirPressure` characteristic delegate
|
|
393
373
|
* for an `eve.AirPressureSensor` or `eve.Weather` service.
|
|
394
374
|
* @param {?CharacteristicDelegate} params.vocDensityDelegate - The
|
|
395
|
-
* `hap.VOCDensity` characteristic delegate
|
|
375
|
+
* `Characteristics.hap.VOCDensity` characteristic delegate
|
|
396
376
|
* for a `hap.AirQualilitySensor` service.
|
|
397
377
|
* @param {?CharacteristicDelegate} params.targetTemperatureDelegate - The
|
|
398
|
-
* `hap.TargetTemperature` characteristic delegate
|
|
378
|
+
* `Characteristics.hap.TargetTemperature` characteristic delegate
|
|
399
379
|
* for a `hap.Thermostat` service.
|
|
400
380
|
* @param {?CharacteristicDelegate} params.valvePositionDelegate - The
|
|
401
|
-
*
|
|
381
|
+
* `Characteristics.eve.ValvePosition` characteristic delegate
|
|
402
382
|
* for a `hap.Thermostat` service.
|
|
403
383
|
* @param {?CharacteristicDelegate} params.onDelegate - The
|
|
404
384
|
* `Characteristics.hap.On` characteristic delegate
|
|
405
|
-
* for a `hap.Outlet` service.
|
|
385
|
+
* for a `hap.Outlet` or a `hap.Switch` service.
|
|
406
386
|
* @param {?CharacteristicDelegate} params.lastOnDelegate - The
|
|
407
|
-
*
|
|
408
|
-
* for a `hap.Outlet` service.
|
|
387
|
+
* `Characteristics.eve.LastActivation` characteristic delegate
|
|
388
|
+
* for a `hap.Outlet` or a `hap.Switch` service.
|
|
409
389
|
* @param {?CharacteristicDelegate} params.consumptionDelegate - The
|
|
410
|
-
*
|
|
390
|
+
* `Characteristics.eve.Consumption` characteristic delegate
|
|
411
391
|
* for a `hap.Outlet` or `eve.Consumption` service
|
|
412
392
|
* for a device that reports power.
|
|
413
393
|
* @param {?CharacteristicDelegate} params.computedTotalConsumptionDelegate - The
|
|
414
|
-
* `eve.TotalConsumption` characteristic delegate
|
|
394
|
+
* `Characteristics.eve.TotalConsumption` characteristic delegate
|
|
415
395
|
* for a `hap.Outlet` or `eve.Consumption` service
|
|
416
396
|
* for a device that reports power, but not total consumption.
|
|
417
397
|
* @param {?CharacteristicDelegate} params.totalConsumptionDelegate - The
|
|
418
|
-
*
|
|
398
|
+
* `Characteristics.eve.TotalConsumption` characteristic delegate
|
|
419
399
|
* for a `hap.Outlet` or `eve.Consumption` service
|
|
420
400
|
* for a device that reports total consumption.
|
|
421
401
|
* @param {?CharacteristicDelegate} params.computedConsumptionDelegate - The
|
|
422
|
-
*
|
|
402
|
+
* `Characteristics.eve.Consumption` characteristic delegate
|
|
423
403
|
* for a `hap.Outlet` or `eve.Consumption` service
|
|
424
404
|
* for a device that reports total consumption but not power.
|
|
425
405
|
* @param {?CharacteristicDelegate} params.avarageConsumptionDelegate - The
|
|
426
|
-
*
|
|
406
|
+
* `Characteristics.eve.Consumption` characteristic delegate
|
|
427
407
|
* for a `hap.Outlet` or `eve.Consumption` service
|
|
428
408
|
* for a device that reports runing average for power.
|
|
429
409
|
* @param {?CharacteristicDelegate} params.lightOnDelegate - The
|
|
430
410
|
* `Characteristics.hap.On` characteristic delegate
|
|
431
411
|
* for a `hap.Lightbulb` service.
|
|
432
412
|
* @param {?CharacteristicDelegate} params.lastLightOnDelegate - A
|
|
433
|
-
*
|
|
413
|
+
* `Characteristics.eve.LastActivation` characteristic delegate
|
|
434
414
|
* for a `hap.Lightbulb` service.
|
|
435
|
-
* @param {?CharacteristicDelegate} params.switchOnDelegate - The
|
|
436
|
-
* `Characteristics.hap.On` characteristic delegate
|
|
437
|
-
* for a `hap.Switch` service.
|
|
438
|
-
* @param {?CharacteristicDelegate} params.lastSwitchOnDelegate - A
|
|
439
|
-
* `.eve.LastActivation` characteristic delegate
|
|
440
|
-
* for a `hap.Switch` service.
|
|
441
415
|
* @param {integer} [params.memorySize=4032] - The memory size, in number of
|
|
442
416
|
* history entries. The default is 4 weeks of 1 entry per 10 minutes.
|
|
443
417
|
* @param {?boolean} params.config - Expose config.
|
|
@@ -510,6 +484,10 @@ class History extends ServiceDelegate {
|
|
|
510
484
|
key: 'history',
|
|
511
485
|
silent: true
|
|
512
486
|
})
|
|
487
|
+
if (this.values.history?.initialTime > History.now()) {
|
|
488
|
+
this.warn('resetting history after time travel from %s', dateToString(this.values.history.initialTime))
|
|
489
|
+
this.values.history = null
|
|
490
|
+
}
|
|
513
491
|
this._h = this.values.history
|
|
514
492
|
if (this._h == null) {
|
|
515
493
|
this.values.history = {
|
|
@@ -616,6 +594,18 @@ class History extends ServiceDelegate {
|
|
|
616
594
|
})
|
|
617
595
|
}
|
|
618
596
|
|
|
597
|
+
addLastOnDelegate (onDelegate, lastOnDelegate) {
|
|
598
|
+
if (!(onDelegate instanceof CharacteristicDelegate)) {
|
|
599
|
+
throw new TypeError('onDelegate: not a CharacteristicDelegate')
|
|
600
|
+
}
|
|
601
|
+
if (!(lastOnDelegate instanceof CharacteristicDelegate)) {
|
|
602
|
+
throw new TypeError('lastOnDelegate: not a CharacteristicDelegate')
|
|
603
|
+
}
|
|
604
|
+
onDelegate.on('didSet', (value) => {
|
|
605
|
+
lastOnDelegate.value = this.lastActivationValue()
|
|
606
|
+
})
|
|
607
|
+
}
|
|
608
|
+
|
|
619
609
|
/** Return current time as # seconds since NodeJS epoch.
|
|
620
610
|
* @returns {integer} # seconds since NodeJS epoch.
|
|
621
611
|
*/
|
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.
|
|
6
|
+
"version": "6.6.0",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"homebridge": "^1.6.1",
|
|
25
|
-
"node": "
|
|
25
|
+
"node": "20.7.0||^20||^18"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@homebridge/plugin-ui-utils": "~0.0.19",
|
|
29
|
-
"hb-lib-tools": "~1.1.
|
|
29
|
+
"hb-lib-tools": "~1.1.1"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",
|