homebridge-lib 5.2.2 → 5.2.3-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.
@@ -40,13 +40,12 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
40
40
  super(homebridge)
41
41
 
42
42
  /** @member EveHomeKitTypes#Characteristics
43
- * @property {Class} AirParticulateDensity - Density (in ppm) of air
44
- * particulates.
45
- * <br>Used by: Eve Room.
43
+ * @property {Class} AirParticulateDensity - Deprecated. use `VOCLevel`
44
+ * instead.
46
45
  * @property {Class} AirPressure - Air pressure (in hPa).
47
46
  * <br>Used by: Eve Weather.
48
- * @property {Class} ClosedDuration - Time in seconds that door has been
49
- * open.
47
+ * @property {Class} ClosedDuration - Duration (in seconds) that door has
48
+ * been closed.
50
49
  * <br>Used by: Eve Door.
51
50
  * @property {Class} Clouds - Cloud coverage (in %).
52
51
  * <br>Used by: weather station.
@@ -59,6 +58,10 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
59
58
  * @property {Class} ConditionCategory - Weather condition
60
59
  * (as numberic code).
61
60
  * <br>Used by: weather station.
61
+ * @property {Class} ConfigCommand - Used by Eve app to set configuration.
62
+ * <br> Used by: `History` service.
63
+ * @property {Class} ConfigData - Used by Eve app to read configuration.
64
+ * <br> Used by: `History` service.
62
65
  * @property {Class} CurrentConsumption - Current electric consumption
63
66
  * (in W).
64
67
  * <br>Used by: Eve Energy.
@@ -98,7 +101,7 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
98
101
  * @property {Class} ObservationTime - Time of observation.
99
102
  * <br>Used by: weather station.
100
103
  * @property {Class} OpenDuration - Duration (in seconds) that door has
101
- * been closed.
104
+ * been open.
102
105
  * <br>Used by: Eve Door.
103
106
  * @property {Class} Ozone - Ozone level (in DU).
104
107
  * <br>Used by: weather station.
@@ -138,6 +141,8 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
138
141
  * <br>Used by: Eve Thermo.
139
142
  * @property {Class} Visibility - Visibility (in km).
140
143
  * <br>Used by: weather station.
144
+ * @property {Class} VOCLevel - Volatile Organic Compound level (in ppm).
145
+ * <br>Used by: Eve Room (1st gen).
141
146
  * @property {Class} Voltage - Electric voltage (in V).
142
147
  * <br>Used by: Eve Energy.
143
148
  * @property {Class} WindDirection - Wind direction (as text).
@@ -167,23 +172,32 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
167
172
  maxValue: 5000,
168
173
  minStep: 1,
169
174
  perms: [this.Perms.READ, this.Perms.NOTIFY]
170
- }, 'Air Particulate Density')
175
+ }, 'VOC Level')
176
+
177
+ this.createCharacteristicClass('VOCLevel', uuid('10B'), {
178
+ format: this.Formats.INT16,
179
+ unit: 'ppm',
180
+ minValue: 5,
181
+ maxValue: 5000,
182
+ minStep: 5,
183
+ perms: [this.Perms.READ, this.Perms.NOTIFY]
184
+ }, 'VOC Level')
171
185
 
172
186
  this.createCharacteristicClass('TotalConsumption', uuid('10C'), {
173
187
  format: this.Formats.FLOAT,
188
+ unit: 'kWh',
174
189
  minValue: 0,
175
190
  maxValue: 1000000,
176
191
  minStep: 0.1,
177
- unit: 'kWh',
178
192
  perms: [this.Perms.READ, this.Perms.NOTIFY]
179
193
  }, 'Total Consumption')
180
194
 
181
195
  this.createCharacteristicClass('CurrentConsumption', uuid('10D'), {
182
196
  format: this.Formats.FLOAT,
197
+ unit: 'W',
183
198
  minValue: 0,
184
199
  maxValue: 12000,
185
200
  minStep: 0.1,
186
- unit: 'W',
187
201
  perms: [this.Perms.READ, this.Perms.NOTIFY]
188
202
  }, 'Current Consumption')
189
203
 
@@ -236,6 +250,11 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
236
250
  perms: [this.Perms.WRITE, this.Perms.HIDDEN]
237
251
  }, 'History Request')
238
252
 
253
+ this.createCharacteristicClass('ConfigCommand', uuid('11D'), {
254
+ format: this.Formats.DATA,
255
+ perms: [this.Perms.WRITE, this.Perms.HIDDEN]
256
+ }, 'Config Command')
257
+
239
258
  this.createCharacteristicClass('Sensitivity', uuid('120'), {
240
259
  format: this.Formats.UINT8,
241
260
  minValue: 0,
@@ -314,6 +333,11 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
314
333
  adminOnlyAccess: [this.Access.WRITE]
315
334
  })
316
335
 
336
+ this.createCharacteristicClass('ConfigData', uuid('131'), {
337
+ format: this.Formats.DATA,
338
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.HIDDEN]
339
+ }, 'Config Data')
340
+
317
341
  // =========================================================================
318
342
 
319
343
  // The following custom characteristics are supported by the Eve app.
@@ -541,10 +565,10 @@ class EveHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
541
565
  this.Characteristics.HistoryStatus,
542
566
  this.Characteristics.HistoryEntries
543
567
  ], [
544
- // this.Characteristics.Char11E,
568
+ // this.Characteristics.Char11E, // Used for firmware update?
545
569
  this.Characteristics.ResetTotal
546
- // this.Characteristics.Char11D,
547
- // this.Characteristics.Char131
570
+ // this.Characteristics.ConfigCommand,
571
+ // this.Characteristics.ConfigData
548
572
  ])
549
573
 
550
574
  this.createServiceClass('AirPressureSensor', uuid('00A'), [
@@ -75,15 +75,14 @@ class Motion extends History {
75
75
  const now = Math.round(new Date().valueOf() / 1000)
76
76
  lastActivationDelegate.value = now - this._h.initialTime
77
77
  this._entry.status = value
78
- // Eve v5.4.2 fills in missing temperature at 0.00°C.
79
- // if (this._entry.temp != null) {
80
- // const temp = this._entry.temp
81
- // this._entry.temp = null
82
- // this._addEntry(now)
83
- // this._entry.temp = temp
84
- // } else {
85
- this._addEntry(now)
86
- // }
78
+ if (this._entry.temp != null) {
79
+ const temp = this._entry.temp
80
+ this._entry.temp = null
81
+ this._addEntry(now)
82
+ this._entry.temp = temp
83
+ } else {
84
+ this._addEntry(now)
85
+ }
87
86
  })
88
87
  if (temperatureDelegate != null) {
89
88
  this._entry.temp = temperatureDelegate.value
@@ -94,27 +93,24 @@ class Motion extends History {
94
93
  }
95
94
 
96
95
  get _fingerPrint () {
97
- if (this._entry.temp != null) {
98
- return '02 1c01 0102'
99
- }
100
- return '01 1c01'
96
+ return '02 1c01 0102'
101
97
  }
102
98
 
103
99
  _entryStream (entry) {
104
- if (this._entry.temp != null) {
100
+ if (entry.temp == null) {
105
101
  return util.format(
106
- '|0d %s %s 03 %s %s',
102
+ '|0b %s %s 01 %s',
107
103
  numToHex(swap32(this._h.currentEntry), 8),
108
104
  numToHex(swap32(entry.time - this._h.initialTime), 8),
109
- numToHex(entry.status, 2),
110
- numToHex(swap16(entry.temp * 100), 4)
105
+ numToHex(entry.status, 2)
111
106
  )
112
107
  }
113
108
  return util.format(
114
- '|0b %s %s 01 %s',
109
+ '|0d %s %s 03 %s %s',
115
110
  numToHex(swap32(this._h.currentEntry), 8),
116
111
  numToHex(swap32(entry.time - this._h.initialTime), 8),
117
- numToHex(entry.status, 2)
112
+ numToHex(entry.status, 2),
113
+ numToHex(swap16(entry.temp * 100), 4)
118
114
  )
119
115
  }
120
116
  }
@@ -74,9 +74,7 @@ class Weather extends ServiceDelegate.History {
74
74
  }
75
75
  this._entry = {
76
76
  time: 0,
77
- temp: temperatureDelegate.value,
78
- humidity: 0,
79
- pressure: 0
77
+ temp: temperatureDelegate.value
80
78
  }
81
79
  temperatureDelegate.on('didSet', (value) => {
82
80
  this._entry.temp = value
@@ -95,11 +93,26 @@ class Weather extends ServiceDelegate.History {
95
93
  }
96
94
  }
97
95
 
98
- get _fingerPrint () {
99
- return '03 0102 0202 0302'
100
- }
96
+ get _fingerPrint () { return '03 0102 0202 0302' }
101
97
 
102
98
  _entryStream (entry) {
99
+ if (entry.humidity == null) {
100
+ return util.format(
101
+ '|0c %s %s 01 %s',
102
+ numToHex(swap32(this._h.currentEntry), 8),
103
+ numToHex(swap32(entry.time - this._h.initialTime), 8),
104
+ numToHex(swap16(entry.temp * 100), 4)
105
+ )
106
+ }
107
+ if (entry.pressure == null) {
108
+ return util.format(
109
+ '|0e %s %s 03 %s %s',
110
+ numToHex(swap32(this._h.currentEntry), 8),
111
+ numToHex(swap32(entry.time - this._h.initialTime), 8),
112
+ numToHex(swap16(entry.temp * 100), 4),
113
+ numToHex(swap16(entry.humidity * 100), 4)
114
+ )
115
+ }
103
116
  return util.format(
104
117
  '|10 %s %s 07 %s %s %s',
105
118
  numToHex(swap32(this._h.currentEntry), 8),
@@ -144,6 +144,7 @@ class History extends ServiceDelegate {
144
144
  setter: this._onSetHistoryRequest.bind(this),
145
145
  silent: true
146
146
  })
147
+
147
148
  this.addCharacteristicDelegate({
148
149
  key: 'setTime',
149
150
  Characteristic: this.Characteristics.eve.SetTime,
@@ -155,12 +156,14 @@ class History extends ServiceDelegate {
155
156
  const date = dateToString(buffer.readUInt32LE())
156
157
  this.debug('SetTime changed to %s', date)
157
158
  })
159
+
158
160
  this.addCharacteristicDelegate({
159
161
  key: 'historyStatus',
160
162
  Characteristic: this.Characteristics.eve.HistoryStatus,
161
163
  value: params.historyStatus,
162
164
  silent: true
163
165
  })
166
+
164
167
  this.addCharacteristicDelegate({
165
168
  key: 'historyEntries',
166
169
  Characteristic: this.Characteristics.eve.HistoryEntries,
@@ -168,6 +171,21 @@ class History extends ServiceDelegate {
168
171
  getter: this._onGetEntries.bind(this),
169
172
  silent: true
170
173
  })
174
+
175
+ // this.addCharacteristicDelegate({
176
+ // key: 'configCommand',
177
+ // Characteristic: this.Characteristics.eve.ConfigCommand,
178
+ // setter: this._onSetConfig.bind(this)
179
+ // // silent: true
180
+ // })
181
+
182
+ // this.addCharacteristicDelegate({
183
+ // key: 'configData',
184
+ // Characteristic: this.Characteristics.eve.ConfigData,
185
+ // getter: this._onGetConfig.bind(this)
186
+ // // silent: true
187
+ // })
188
+
171
189
  this._accessoryDelegate.heartbeatEnabled = true
172
190
  this._accessoryDelegate
173
191
  .once('heartbeat', (beat) => {
@@ -214,30 +232,31 @@ class History extends ServiceDelegate {
214
232
 
215
233
  const usedMemeoryOffset = this._h.usedMemory < this._memorySize ? 1 : 0
216
234
  const firstEntryOffset = this._h.usedMemory < this._memorySize ? 0 : 1
217
- const buffer = Buffer.alloc(1024)
218
- let offset = 0
219
- buffer.writeUInt32LE(this._entry.time - this._h.initialTime, offset)
220
- offset += 4
221
- buffer.writeUInt32LE(0, offset)
222
- offset += 4
223
- buffer.writeUInt32LE(this._h.initialTime - epoch, offset)
224
- offset += 4
225
- buffer.write(this._fingerPrint.replace(/[^0-9A-F]/ig, ''), offset, 'hex')
226
- const length = 1 + 2 * parseInt(this._fingerPrint.slice(0, 2))
227
- this.debug('fingerprint length: %d', length)
228
- offset += length
229
- buffer.writeUInt16LE(this._h.usedMemory + usedMemeoryOffset, offset)
230
- offset += 2
231
- buffer.writeUInt16LE(this._memorySize, offset)
232
- offset += 2
233
- buffer.writeUInt32LE(this._h.firstEntry + firstEntryOffset, offset)
234
- offset += 4
235
- buffer.writeUInt32LE(0, offset)
236
- offset += 4
237
- buffer.writeUint8(1, offset)
238
- offset += 1
239
- buffer.writeUint8(1, offset)
240
- offset += 1
235
+
236
+ // const buffer = Buffer.alloc(1024)
237
+ // let offset = 0
238
+ // buffer.writeUInt32LE(this._entry.time - this._h.initialTime, offset)
239
+ // offset += 4
240
+ // buffer.writeUInt32LE(0, offset)
241
+ // offset += 4
242
+ // buffer.writeUInt32LE(this._h.initialTime - epoch, offset)
243
+ // offset += 4
244
+ // buffer.write(this._fingerPrint.replace(/[^0-9A-F]/ig, ''), offset, 'hex')
245
+ // const length = 1 + 2 * parseInt(this._fingerPrint.slice(0, 2))
246
+ // this.debug('fingerprint length: %d', length)
247
+ // offset += length
248
+ // buffer.writeUInt16LE(this._h.usedMemory + usedMemeoryOffset, offset)
249
+ // offset += 2
250
+ // buffer.writeUInt16LE(this._memorySize, offset)
251
+ // offset += 2
252
+ // buffer.writeUInt32LE(this._h.firstEntry + firstEntryOffset, offset)
253
+ // offset += 4
254
+ // buffer.writeUInt32LE(0, offset)
255
+ // offset += 4
256
+ // buffer.writeUint8(1, offset)
257
+ // offset += 1
258
+ // buffer.writeUint8(1, offset)
259
+ // offset += 1
241
260
 
242
261
  const value = util.format(
243
262
  '%s 00000000 %s [%s] %s %s %s 000000000101',
@@ -251,7 +270,7 @@ class History extends ServiceDelegate {
251
270
 
252
271
  this.debug('add entry %d: %j', this._h.lastEntry, this._entry)
253
272
  this.debug('set history status to: %j', value)
254
- this.debug('set history status to: %j', buffer.slice(0, offset).toString('hex'))
273
+ // this.debug('set history status to: %j', buffer.slice(0, offset).toString('hex'))
255
274
  this.values.historyStatus = hexToBase64(value)
256
275
  }
257
276
 
@@ -313,6 +332,13 @@ class History extends ServiceDelegate {
313
332
  this.debug('send data: %s', dataStream)
314
333
  return hexToBase64(dataStream)
315
334
  }
335
+
336
+ // async _onGetConfig () {
337
+ // return hexToBase64('D200')
338
+ // }
339
+
340
+ // async _onSetConfig () {
341
+ // }
316
342
  }
317
343
 
318
344
  module.exports = History
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.2.2",
6
+ "version": "5.2.3-0",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "engines": {
24
24
  "homebridge": "^1.4.0",
25
- "node": "^16.13.2"
25
+ "node": "^16.14.0"
26
26
  },
27
27
  "dependencies": {
28
28
  "bonjour-hap": "^3.6.3",