homebridge-lib 5.8.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.pressureDelegate - A reference to
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.pressureDelegate != null &&
68
- !(params.pressureDelegate instanceof homebridgeLib.CharacteristicDelegate)
67
+ params.airPressureDelegate != null &&
68
+ !(params.airPressureDelegate instanceof homebridgeLib.CharacteristicDelegate)
69
69
  ) {
70
- throw new TypeError('pressureDelegate: not a CharacteristicDelegate')
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.pressureDelegate != null) {
85
- this._entry.pressure = params.pressureDelegate.value
86
- params.pressureDelegate.on('didSet', (value) => {
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._h.currentEntry % this._memorySize
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
- this.addCharacteristicDelegate({
121
- key: 'configuredName',
122
- Characteristic: this.Characteristics.hap.ConfiguredName,
123
- value: params.name,
124
- setter: (value) => {
125
- if (value == null || value === '') {
126
- throw new Error('cannot be empty')
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
- }).on('didSet', (value) => {
130
- this.name = value
131
- for (const key in this._characteristicDelegates) {
132
- this._characteristicDelegates[key].name = value
133
- }
134
- if (params.primaryService) {
135
- accessoryDelegate.values.name = value
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": "5.8.0",
6
+ "version": "6.0.1",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"