homebridge-lib 5.1.22 → 5.1.24-2

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.
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  </span>
14
14
 
15
15
  ## Library for Homebridge Plugins
16
- Copyright © 2018-2021 Erik Baauw. All rights reserved.
16
+ Copyright © 2018-2022 Erik Baauw. All rights reserved.
17
17
 
18
18
  While developing a number of [Homebridge](https://github.com/homebridge/homebridge) plugins, I find myself duplicating a lot of code.
19
19
  The idea behind this library is to ease developing and maintaining Homebridge plugins by separating this generic code, dealing with [HomeKit](http://www.apple.com/ios/home/) and Homebridge, from the specific code, dealing with the actual devices being exposed to HomeKit.
package/cli/hap.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // homebridge-lib/cli/hap.js
4
4
  //
5
5
  // Library for Homebridge plugins.
6
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
6
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
7
7
  //
8
8
  // Logger for HomeKit accessory announcements.
9
9
 
package/cli/json.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // homebridge-lib/cli/json.js
4
4
  //
5
5
  // Library for Homebridge plugins.
6
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
6
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
7
7
  //
8
8
  // JSON formatter.
9
9
 
package/cli/sysinfo.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // homebridge-lib/cli/sysinfo.js
4
4
  //
5
5
  // Library for Homebridge plugins.
6
- // Copyright © 2021 Erik Baauw. All rights reserved.
6
+ // Copyright © 2021-2022 Erik Baauw. All rights reserved.
7
7
  //
8
8
  // Show system info.
9
9
 
package/cli/upnp.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // homebridge-lib/cli/upnp.js
4
4
  //
5
5
  // Library for Homebridge plugins.
6
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
6
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
7
7
  //
8
8
  // Logger for UPnP device announcements.
9
9
 
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/index.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/AccessoryDelegate.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -103,8 +103,7 @@ class AccessoryDelegate extends homebridgeLib.Delegate {
103
103
 
104
104
  // Remove associated accessory from platform
105
105
  destroy () {
106
- this.removeAllListeners('heartbeat')
107
- this.removeAllListeners('shutdown')
106
+ this.removeAllListeners()
108
107
  this._platform._removeAccessory(this._accessory)
109
108
  }
110
109
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/AdaptiveLighting.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2020-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2020-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/CharacteristicDelegate.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
package/lib/Colour.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/Colour.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2016-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2016-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/CommandLineParser.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  // TODO:
7
7
  // - Change parameters to (params, callback) with:
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/CommandLineUtility.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/CustomeHomeKitTypes.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  const regExps = {
7
7
  uuid: /^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/,
package/lib/Delegate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/Delegate.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/EveHomeKitTypes.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  const homebridgeLib = require('../index')
7
7
 
package/lib/HttpClient.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/HttpClient.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -19,8 +19,7 @@ const https = require('https')
19
19
  class HttpError extends Error {
20
20
  constructor (message, request, statusCode, statusMessage) {
21
21
  super(message)
22
- /** @member {HttpRequest} - The request that caused the error.
23
- * See {@link HttpClient.HttpRequest HttpRequest}.
22
+ /** @member {HttpClient.HttpRequest} - The request that caused the error.
24
23
  */
25
24
  this.request = request
26
25
 
@@ -76,8 +75,7 @@ class HttpRequest {
76
75
  */
77
76
  class HttpResponse {
78
77
  constructor (request, statusCode, statusMessage, headers, body, parsedBody) {
79
- /** @member {HttpRequest} - The request that generated the response.
80
- * See {@link HttpClient.HttpRequest HttpRequest}.
78
+ /** @member {HttpClient.HttpRequest} - The request that generated the response.
81
79
  */
82
80
  this.request = request
83
81
 
@@ -423,7 +421,8 @@ class HttpClient extends events.EventEmitter {
423
421
  request: requestInfo,
424
422
  headers: response.headers,
425
423
  statusCode: response.statusCode,
426
- statusMessage: response.statusMessage
424
+ statusMessage: response.statusMessage,
425
+ body: null
427
426
  }
428
427
  if (buffer != null && buffer.length > 0) {
429
428
  responseInfo.body = buffer
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/JsonFormatter.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/MyHomeKitTypes.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
  //
6
6
  // My own collection of custom HomeKit Services and Characteristics.
7
7
 
@@ -83,6 +83,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
83
83
  * <br>Used by: homebridge-hue.
84
84
  * @property {Class} Enabled - Enable/disable service.
85
85
  * <br>Used by: homebridge-hue.
86
+ * @property {Class} Expose - Expose to HomeKit.
87
+ * <br>Used by: homebridge-deconz.
86
88
  * @property {Class} Heartrate - Refresh rate.
87
89
  * <br>Used by: homebridge-hue in HueBridge service,
88
90
  * by Homebridge-soma, by Homebridge-rpi, by Homebridge-ws.
@@ -191,6 +193,8 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
191
193
  * for lights.
192
194
  * @property {Class} Unlatch - Unlatch the door.
193
195
  * <br>Used by: homebridge-nb in the Smart Lock service.
196
+ * @property {Class} Unlock - Unlock gateway
197
+ * <br>Used by: homebridge-deconz.
194
198
  * @property {Class} WaterPressure - Water pressure (in bar) of the central
195
199
  * heating system.
196
200
  * <br>Used by: homebridge-otgw.
@@ -698,6 +702,18 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
698
702
  perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
699
703
  }, 'Position Change')
700
704
 
705
+ this.createCharacteristicClass('Unlock', uuid('077'), {
706
+ format: this.Formats.BOOL,
707
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
708
+ adminOnlyAccess: [this.Access.WRITE]
709
+ })
710
+
711
+ this.createCharacteristicClass('Expose', uuid('078'), {
712
+ format: this.Formats.BOOL,
713
+ perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE],
714
+ adminOnlyAccess: [this.Access.WRITE]
715
+ })
716
+
701
717
  // Characteristic for Unique ID, used by homebridge-hue.
702
718
  // Source: as exposed by the Philips Hue bridge. This characteristic is
703
719
  // used by the Hue app to select the accessories when syncing Hue bridge
@@ -726,6 +742,11 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
726
742
  /** @member MyHomeKitTypes#Services
727
743
  * @property {Class} Alarm - Service for an alarm clock.
728
744
  * <br>Used by: homebridge-zp.
745
+ * @property {Class} DeconzGateway - Service for deCONZ gateway config.
746
+ * <br>Used by homebridge-deconz.
747
+ * @property {Class} DeconzDevice - Service for config of device exposed
748
+ * by deCONZ gateway.
749
+ * <br>Used by homebridge-deconz.
729
750
  * @property {Class} HueBridge - Service for a Hue bridge.
730
751
  * <br>Used by: homebridge-hue for a Hue bridge or deCONZ gateway.
731
752
  * @property {Class} Resource - Generic service for resource.
@@ -760,6 +781,22 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
760
781
  this.Characteristics.Status
761
782
  ])
762
783
 
784
+ this.createServiceClass('DeconzGateway', uuid('014'), [
785
+ this.Characteristics.LogLevel,
786
+ this.Characteristics.Expose,
787
+ this.Characteristics.Heartrate,
788
+ this.Characteristics.LastUpdated,
789
+ this.Characteristics.Restart,
790
+ this.Characteristics.Search,
791
+ this.Characteristics.TransitionTime,
792
+ this.Characteristics.Unlock
793
+ ])
794
+
795
+ this.createServiceClass('DeconzDevice', uuid('015'), [
796
+ this.Characteristics.Expose,
797
+ this.Characteristics.Resource
798
+ ])
799
+
763
800
  this.createServiceClass('Alarm', uuid('048'), [
764
801
  this.Characteristics.Enabled,
765
802
  this.Characteristics.CurrentTrack,
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/OptionParser.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
package/lib/Platform.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/Platform.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
@@ -454,7 +454,8 @@ class Platform extends homebridgeLib.Delegate {
454
454
  const id = accessory.context.id
455
455
  const name = accessory.context.name
456
456
  const context = accessory.context.context
457
- this.debug('%s: cached %s v%s %s: %j', name, className, version, id, context)
457
+ this.debug('%s: cached %s v%s %s', name, className, version, id)
458
+ this.vdebug('%s: cached %s v%s %s: %j', name, className, version, id, context)
458
459
  this._accessories[id] = accessory
459
460
  // Fix homebridge overwrites firmware with package version.
460
461
  const uuid = this.Services.hap.AccessoryInformation.UUID
@@ -511,7 +512,20 @@ class Platform extends homebridgeLib.Delegate {
511
512
  )
512
513
  }
513
514
  } catch (error) {
514
- this.error(error)
515
+ this.warn(error)
516
+ try {
517
+ // Make sure the accessory won't be persisted, since it will fail
518
+ // to be exposed again on restore, causing `configureAccessory()`
519
+ // not to be called.
520
+ this._homebridge.unregisterPlatformAccessories(
521
+ this._pluginName, this._platformName, [accessory]
522
+ )
523
+ } catch (error) {}
524
+ /** Emitted when associated accessory could not be exposed.
525
+ * @event AccessoryDelegate#exposeError
526
+ * @param {Error} error - The error trying to expose the accessory.
527
+ */
528
+ delegate.emit('exposeError', error)
515
529
  }
516
530
  })
517
531
  } else {
@@ -538,14 +552,16 @@ class Platform extends homebridgeLib.Delegate {
538
552
  this.debug('remove history file %s', historyFile)
539
553
  fs.unlink(historyFile, (error) => {
540
554
  if (error) {
541
- this.error(error)
555
+ this.warn(error)
542
556
  }
543
557
  })
544
558
  }
545
559
  this.debug('%s: remove %s %s', name, className, id)
546
- this._homebridge.unregisterPlatformAccessories(
547
- this._pluginName, this._platformName, [accessory]
548
- )
560
+ try {
561
+ this._homebridge.unregisterPlatformAccessories(
562
+ this._pluginName, this._platformName, [accessory]
563
+ )
564
+ } catch (error) { this.warn(error) }
549
565
  delete this._accessoryDelegates[id]
550
566
  delete this._accessories[id]
551
567
  }
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/ServiceDelegate.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2017-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2017-2022 Erik Baauw. All rights reserved.
5
5
  //
6
6
  // The logic for handling Eve history was copied from Simone Tisa's
7
7
  // fakagato-history repository, copyright © 2017 simont77.
@@ -401,14 +401,14 @@ class AccessoryInformation extends ServiceDelegate {
401
401
  Characteristic: this.Characteristics.hap.FirmwareRevision,
402
402
  value: params.firmware
403
403
  })
404
- if (params.hardware != null) {
404
+ if (params.hardware != null || this._context.hardware != null) {
405
405
  this.addCharacteristicDelegate({
406
406
  key: 'hardware',
407
407
  Characteristic: this.Characteristics.hap.HardwareRevision,
408
408
  value: params.hardware
409
409
  })
410
410
  }
411
- if (params.software != null) {
411
+ if (params.software != null || this._context.software != null) {
412
412
  this.addCharacteristicDelegate({
413
413
  key: 'software',
414
414
  Characteristic: this.Characteristics.hap.SoftwareRevision,
package/lib/SystemInfo.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/SystemInfo.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2019-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2019-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
package/lib/UpnpClient.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // homebridge-lib/lib/UpnpClient.js
2
2
  //
3
3
  // Library for Homebridge plugins.
4
- // Copyright © 2018-2021 Erik Baauw. All rights reserved.
4
+ // Copyright © 2018-2022 Erik Baauw. All rights reserved.
5
5
 
6
6
  'use strict'
7
7
 
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.22",
6
+ "version": "5.1.24-2",
7
7
  "keywords": [
8
8
  "homekit",
9
9
  "homebridge"
@@ -21,7 +21,7 @@
21
21
  "upnp": "cli/upnp.js"
22
22
  },
23
23
  "engines": {
24
- "homebridge": "^1.3.8",
24
+ "homebridge": "^1.3.9",
25
25
  "node": "^16.13.1"
26
26
  },
27
27
  "dependencies": {