homebridge-lib 8.0.1 → 8.1.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.
@@ -249,11 +249,6 @@ class AccessoryDelegate extends Delegate {
249
249
 
250
250
  set heartbeatEnabled (value) { this._heartbeatEnabled = !!value }
251
251
 
252
- setAlive () {
253
- this.warn('setAlive() has been deprecated, use heartbeatEnabled instead')
254
- this._heartbeatEnabled = true
255
- }
256
-
257
252
  /** Plugin-specific context to be persisted across Homebridge restarts.
258
253
  *
259
254
  * After restart, this object is passed back to the plugin through the
package/lib/Platform.js CHANGED
@@ -181,7 +181,7 @@ class Platform extends Delegate {
181
181
  this._homebridge
182
182
  .on('didFinishLaunching', this.#main.bind(this))
183
183
  .on('shutdown', this.#shutdown.bind(this))
184
- process.on('exit', this.#exit.bind(this))
184
+ process.on('exit', () => { this.log('goodbye') })
185
185
  }
186
186
 
187
187
  // ===== Main ================================================================
@@ -315,7 +315,7 @@ class Platform extends Delegate {
315
315
  }
316
316
 
317
317
  // Called by homebridge when shutting down.
318
- #shutdown () {
318
+ async #shutdown () {
319
319
  if (this._shuttingDown) {
320
320
  return
321
321
  }
@@ -323,6 +323,7 @@ class Platform extends Delegate {
323
323
  if (this._ui?.abortController != null) {
324
324
  this._ui.abortController.abort()
325
325
  }
326
+ const jobs = []
326
327
  for (const id in this._accessoryDelegates) {
327
328
  /** Emitted when Homebridge is shutting down.
328
329
  *
@@ -331,6 +332,9 @@ class Platform extends Delegate {
331
332
  * @event AccessoryDelegate#shutdown
332
333
  */
333
334
  this._accessoryDelegates[id].emit('shutdown')
335
+ if (typeof this._accessoryDelegates[id].shutdown === 'function') {
336
+ jobs.push(this._accessoryDelegates[id].shutdown())
337
+ }
334
338
  }
335
339
  /** Emitted when Homebridge is shutting down.
336
340
  *
@@ -339,12 +343,15 @@ class Platform extends Delegate {
339
343
  * @event Platform#shutdown
340
344
  */
341
345
  this.emit('shutdown')
342
- }
343
-
344
- // Called by NodeJS when process is exiting.
345
- #exit () {
346
+ if (typeof this.shutdown === 'function') {
347
+ jobs.push(this.shutdown())
348
+ }
349
+ for (const job of jobs) {
350
+ try {
351
+ await job
352
+ } catch (error) { this.warn(error) }
353
+ }
346
354
  this.#flushCachedAccessories()
347
- this.log('goodbye')
348
355
  }
349
356
 
350
357
  // Issue an identity message.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "ebaauw"
7
7
  ],
8
8
  "license": "Apache-2.0",
9
- "version": "8.0.1",
9
+ "version": "8.1.0",
10
10
  "keywords": [
11
11
  "homekit",
12
12
  "homebridge"
@@ -29,12 +29,12 @@
29
29
  "upnp": "cli/upnp.js"
30
30
  },
31
31
  "engines": {
32
- "homebridge": "^2.0.0",
32
+ "homebridge": "^2.0.1",
33
33
  "node": "24.15.0||^24||^22"
34
34
  },
35
35
  "dependencies": {
36
36
  "@homebridge/plugin-ui-utils": "~2.2.3",
37
- "hb-lib-tools": "~3.0.4"
37
+ "hb-lib-tools": "~3.0.5"
38
38
  },
39
39
  "scripts": {
40
40
  "prepare": "standard && rm -rf out && jsdoc -c jsdoc.json",