homebridge-lib 6.5.1 → 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.
@@ -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 SwitchOnValue extends HistoryValue {
226
+ class OnValue extends HistoryValue {
227
227
  get tag () { return 0x0E }
228
228
  get length () { return 1 }
229
- get id () { return 'w' }
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.lastSwitchOnDelegate.value = parent.lastActivationValue(now)
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
- switchOn: SwitchOnValue,
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
  }
@@ -402,10 +382,10 @@ class History extends ServiceDelegate {
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
387
  * `Characteristics.eve.LastActivation` characteristic delegate
408
- * for a `hap.Outlet` service.
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
@@ -432,12 +412,6 @@ class History extends ServiceDelegate {
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
- * `Characteristics.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.
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.5.1",
6
+ "version": "6.6.0",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"