homebridge-lib 5.1.18-0 → 5.1.20

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.
@@ -53,10 +53,15 @@ class CommandLineTool {
53
53
  .on('SIGINT', this._onSignal.bind(this))
54
54
  .on('SIGTERM', this._onSignal.bind(this))
55
55
  .on('SIGABRT', this._onSignal.bind(this))
56
- .on('uncaughtException', (error) => { this.fatal(error) })
57
- .on('unhandledRejection', (error) => { this.fatal(error) })
56
+ .on('uncaughtException', async (error) => {
57
+ await this.fatal('uncaught exception: %s', error.stack)
58
+ })
59
+ .removeAllListeners('unhandledRejection')
60
+ .on('unhandledRejection', async (error) => {
61
+ await this.fatal('unhandled rejection: %s', error.stack)
62
+ })
58
63
  } catch (error) {
59
- this.fatal(error)
64
+ this._log({ label: 'fatal', chalk: chalk.bold.red }, error)
60
65
  }
61
66
  }
62
67
 
@@ -120,6 +120,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
120
120
  * <br>Used by: homebridge-otgw.
121
121
  * @property {Class} PumpStarts - Number of pump starts.
122
122
  * <br>Used by: homebridge-otgw.
123
+ * @property {Class} Recall - Recall a scene.
124
+ * <br>Used by: homebridge-hue.
123
125
  * @property {Class} Repeat - Repeat tracks (off, 1, all).
124
126
  * <br>Used by: homebridge-zp.
125
127
  * @property {Class} Resource - REST API resource corresponding for
@@ -133,6 +135,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
133
135
  * <br>Used by: homebridge-otgw.
134
136
  * @property {Class} RingToOpen - Ring to Open active.
135
137
  * <br> Used by: homebridge-nb.
138
+ * @property {Class} Search - Search for new devices.
139
+ * <br>Used by: homebridge-hue.
136
140
  * @property {Class} Sensitivity - Motion sensor sensitivity.
137
141
  * <br>See also: {@link EveHomeKitTypes#Characteristics eve.Sensitivity}.
138
142
  * <br>Previously used by: homebridge-hue in MotionSensor service.
@@ -664,6 +668,17 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
664
668
  perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
665
669
  }, 'Motor Speed')
666
670
 
671
+ this.createCharacteristicClass('Search', uuid('073'), {
672
+ format: this.Formats.BOOL,
673
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
674
+ adminOnlyAccess: [this.Access.WRITE]
675
+ })
676
+
677
+ this.createCharacteristicClass('Recall', uuid('074'), {
678
+ format: this.Formats.BOOL,
679
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
680
+ })
681
+
667
682
  // Characteristic for Unique ID, used by homebridge-hue.
668
683
  // Source: as exposed by the Philips Hue bridge. This characteristic is
669
684
  // used by the Hue app to select the accessories when syncing Hue bridge
package/lib/SystemInfo.js CHANGED
@@ -113,25 +113,16 @@ class SystemInfo extends events.EventEmitter {
113
113
  */
114
114
  static parseRpiCpuInfo (cpuInfo) {
115
115
  const id = /Serial\s*: ([0-9a-f]{16})/.exec(cpuInfo)[1].toUpperCase()
116
- const revision = parseInt(/Revision\s*: ([0-9a-f]{4,})/.exec(cpuInfo)[1], 16)
117
- const rpi = SystemInfo.parseRpiRevision(revision & 0x00FFFFFF)
118
- return Object.assign({ id: id }, rpi)
119
- }
120
-
121
- /** Parse the revision of a Raspberry Pi.
122
- *
123
- * @see https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
124
- * @param {int} revision - The Raspberry Pi revision.
125
- * @return {object} - The parsed revision.
126
- */
127
- static parseRpiRevision (revision) {
116
+ const revision = parseInt(
117
+ /Revision\s*: ([0-9a-f]{4,})/.exec(cpuInfo)[1], 16
118
+ ) & 0x00FFFFFF
128
119
  let gpioMask, manufacturer, memory, model, modelRevision, processor
129
120
  if ((revision & 0x00800000) !== 0) { // New revision scheme.
130
- manufacturer = rpiInfo.manufacturers[(revision & 0x000f0000) >> 16]
121
+ manufacturer = rpiInfo.manufacturers[(revision & 0x000F0000) >> 16]
131
122
  memory = rpiInfo.memorySizes[(revision & 0x00700000) >> 20]
132
- model = rpiInfo.models[(revision & 0x00000ff0) >> 4]
133
- modelRevision = '1.' + ((revision & 0x0000000f) >> 0).toString()
134
- processor = rpiInfo.processors[(revision & 0x0000f000) >> 12]
123
+ model = rpiInfo.models[(revision & 0x00000FF0) >> 4]
124
+ modelRevision = '1.' + ((revision & 0x0000000F) >> 0).toString()
125
+ processor = rpiInfo.processors[(revision & 0x0000F000) >> 12]
135
126
  } else if (rpiInfo.oldRevisions[revision] != null) { // Old incremental revisions.
136
127
  manufacturer = rpiInfo.oldRevisions[revision].manufacturer
137
128
  memory = rpiInfo.oldRevisions[revision].memory
@@ -155,6 +146,8 @@ class SystemInfo extends events.EventEmitter {
155
146
  return {
156
147
  gpioMask: gpioMask,
157
148
  gpioMaskSerial: (1 << 15) | (1 << 14),
149
+ id: id,
150
+ isRpi: true,
158
151
  manufacturer: manufacturer,
159
152
  memory: memory,
160
153
  model: model,
@@ -164,7 +157,8 @@ class SystemInfo extends events.EventEmitter {
164
157
  ].join(' '),
165
158
  powerLed: !(['A', 'B', 'Zero', 'Zero W', 'Zero 2 W'].includes(model)),
166
159
  processor: processor,
167
- revision: homebridgeLib.toHexString(revision, 6)
160
+ revision: homebridgeLib.toHexString(revision, 6),
161
+ usbPower: ['B+', '2B', '3B', '3B+'].includes(model)
168
162
  }
169
163
  }
170
164
 
@@ -215,22 +209,7 @@ class SystemInfo extends events.EventEmitter {
215
209
  */
216
210
  async getRpiInfo () {
217
211
  const cpuInfo = await this.readTextFile('/proc/cpuinfo')
218
- const rpi = SystemInfo.parseRpiCpuInfo(cpuInfo)
219
- return {
220
- gpioMask: rpi.gpioMask,
221
- gpioMaskSerial: rpi.gpioMaskSerial,
222
- id: rpi.id,
223
- isRpi: true,
224
- manufacturer: rpi.manufacturer,
225
- memory: rpi.memory,
226
- model: rpi.model,
227
- modelRevision: rpi.modelRevision,
228
- nCores: os.cpus().length,
229
- powerLed: rpi.powerLed,
230
- prettyName: rpi.prettyName,
231
- processor: rpi.processor,
232
- revision: rpi.revision
233
- }
212
+ return SystemInfo.parseRpiCpuInfo(cpuInfo)
234
213
  }
235
214
 
236
215
  /** Extract OS info from /etc/os-release.
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.1.18-0",
6
+ "version": "5.1.20",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"
@@ -21,8 +21,8 @@
21
21
  "upnp": "cli/upnp.js"
22
22
  },
23
23
  "engines": {
24
- "homebridge": "^1.3.6",
25
- "node": "^16.13.0"
24
+ "homebridge": "^1.3.8",
25
+ "node": "^16.13.1"
26
26
  },
27
27
  "dependencies": {
28
28
  "bonjour-hap": "^3.6.3",