homebridge-lib 5.1.12 → 5.1.16
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/lib/CharacteristicDelegate.js +23 -14
- package/lib/HttpClient.js +6 -1
- package/lib/MyHomeKitTypes.js +17 -7
- package/package.json +4 -4
|
@@ -236,18 +236,7 @@ class CharacteristicDelegate extends homebridgeLib.Delegate {
|
|
|
236
236
|
: this._characteristic.displayName
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
*/
|
|
241
|
-
get value () {
|
|
242
|
-
return this._serviceDelegate._context[this._key]
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
set value (value) {
|
|
246
|
-
// Check for actual change.
|
|
247
|
-
if (value === this.value && !this._notifyOnly) {
|
|
248
|
-
return
|
|
249
|
-
}
|
|
250
|
-
|
|
239
|
+
validate (value) {
|
|
251
240
|
let s = ''
|
|
252
241
|
if (this._characteristic != null) {
|
|
253
242
|
switch (this._characteristic.props.format) {
|
|
@@ -258,6 +247,8 @@ class CharacteristicDelegate extends homebridgeLib.Delegate {
|
|
|
258
247
|
case this.Characteristic.Formats.UINT32:
|
|
259
248
|
case this.Characteristic.Formats.UINT64:
|
|
260
249
|
case this.Characteristic.Formats.INT:
|
|
250
|
+
value = Math.round(value)
|
|
251
|
+
// fallsthrough
|
|
261
252
|
case this.Characteristic.Formats.FLOAT:
|
|
262
253
|
if (value < this._characteristic.props.minValue) {
|
|
263
254
|
value = this._characteristic.props.minValue
|
|
@@ -279,6 +270,22 @@ class CharacteristicDelegate extends homebridgeLib.Delegate {
|
|
|
279
270
|
break
|
|
280
271
|
}
|
|
281
272
|
}
|
|
273
|
+
return { value: value, s: s }
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Value of associated Characteristic.
|
|
277
|
+
*/
|
|
278
|
+
get value () {
|
|
279
|
+
return this._serviceDelegate._context[this._key]
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
set value (v) {
|
|
283
|
+
const { value, s } = this.validate(v)
|
|
284
|
+
|
|
285
|
+
// Check for actual change.
|
|
286
|
+
if (value === this.value && !this._notifyOnly) {
|
|
287
|
+
return
|
|
288
|
+
}
|
|
282
289
|
|
|
283
290
|
// Issue info message that Characteristic value is updated by the plugin.
|
|
284
291
|
if (this._notifyOnly) {
|
|
@@ -366,11 +373,13 @@ class CharacteristicDelegate extends homebridgeLib.Delegate {
|
|
|
366
373
|
}
|
|
367
374
|
|
|
368
375
|
// Called when characteristic is updated from HomeKit.
|
|
369
|
-
async _onSet (
|
|
376
|
+
async _onSet (v, callback) {
|
|
377
|
+
const { value } = this.validate(v)
|
|
378
|
+
|
|
370
379
|
// Issue info message that Characteristic value was updated from HomeKit.
|
|
371
380
|
if (this._writeOnly || this.value == null) {
|
|
372
381
|
this._log('%s changed to %j%s', this.displayName, value, this._unit)
|
|
373
|
-
} else {
|
|
382
|
+
} else if (value !== this.value) {
|
|
374
383
|
this._log(
|
|
375
384
|
'%s changed from %j%s to %j%s', this.displayName,
|
|
376
385
|
this.value, this._unit, value, this._unit
|
package/lib/HttpClient.js
CHANGED
|
@@ -39,7 +39,11 @@ class HttpError extends Error {
|
|
|
39
39
|
* @memberof HttpClient
|
|
40
40
|
*/
|
|
41
41
|
class HttpRequest {
|
|
42
|
-
constuctor (id, method, resource, headers, body, url) {
|
|
42
|
+
constuctor (name, id, method, resource, headers, body, url) {
|
|
43
|
+
/** @member {string} - The server name.
|
|
44
|
+
*/
|
|
45
|
+
this.name = name
|
|
46
|
+
|
|
43
47
|
/** @member {integer} - The request ID.
|
|
44
48
|
*/
|
|
45
49
|
this.id = id
|
|
@@ -349,6 +353,7 @@ class HttpClient extends events.EventEmitter {
|
|
|
349
353
|
this.__params.suffix + suffix
|
|
350
354
|
const options = Object.assign({ method: method }, this.__options)
|
|
351
355
|
const requestInfo = Object.assign({
|
|
356
|
+
name: this.name,
|
|
352
357
|
id: requestId,
|
|
353
358
|
method: method,
|
|
354
359
|
resource: resource,
|
package/lib/MyHomeKitTypes.js
CHANGED
|
@@ -50,7 +50,7 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
50
50
|
* @property {Class} ChangeVolume - For relative changes to `Volume`.
|
|
51
51
|
* <br>Used by: homebridge-zp in Sonos and Speaker service.
|
|
52
52
|
* @property {Class} CloseUpwards - Set to close venetian blinds upwards.
|
|
53
|
-
* <br>Used by: homebridge-sc in Window Covering service.
|
|
53
|
+
* <br>Used by: homebridge-sc, homebridge-soma in Window Covering service.
|
|
54
54
|
* @property {Class} ColorLoop - Enabled/disable color loop effect.
|
|
55
55
|
* <br>Used by: homebridge-hue.
|
|
56
56
|
* @property {Class} ColorLoopSpeed - Speed (in sec) of color loop effect.
|
|
@@ -85,7 +85,7 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
85
85
|
* <br>Used by: homebridge-hue.
|
|
86
86
|
* @property {Class} Heartrate - Refresh rate.
|
|
87
87
|
* <br>Used by: homebridge-hue in HueBridge service,
|
|
88
|
-
* by Homebridge
|
|
88
|
+
* by Homebridge-soma, by Homebridge-rpi, by Homebridge-ws.
|
|
89
89
|
* @property {Class} LastBoot - Date/time of last device boot.
|
|
90
90
|
* <br>Used by: homebridge-hue, homebridge-rpi.
|
|
91
91
|
* @property {Class} LastEvent - Last Daylight event (e.g. Noon).
|
|
@@ -105,9 +105,11 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
105
105
|
* @property {Class} LogLevel - Level of logging.
|
|
106
106
|
* @property {Class} Loudness - Audio loudness.
|
|
107
107
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
108
|
+
* @property {Class} MotorSpeed - Speed at which to move the blinds.
|
|
109
|
+
* <br>Used by: homebridge-soma in Window Covering service.
|
|
108
110
|
* @property {Class} MorningMode - Move the blinds slowly, making less
|
|
109
111
|
* noise.
|
|
110
|
-
* <br>Used by: homebridge-sc in Window Covering service.
|
|
112
|
+
* <br>Used by: homebridge-sc, homebridge-soma in Window Covering service.
|
|
111
113
|
* @property {Class} NightSound - Audio night sound.
|
|
112
114
|
* <br>Used by: homebridge-zp in Speaker service.
|
|
113
115
|
* @property {Class} Offset - Temperature offset.
|
|
@@ -644,15 +646,23 @@ class MyHomeKitTypes extends homebridgeLib.CustomHomeKitTypes {
|
|
|
644
646
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
645
647
|
}, 'Close Upwards')
|
|
646
648
|
|
|
647
|
-
this.createCharacteristicClass('
|
|
649
|
+
this.createCharacteristicClass('Unlatch', uuid('070'), {
|
|
648
650
|
format: this.Formats.BOOL,
|
|
649
651
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
650
|
-
}, '
|
|
652
|
+
}, 'Unlatch')
|
|
651
653
|
|
|
652
|
-
this.createCharacteristicClass('
|
|
654
|
+
this.createCharacteristicClass('MorningMode', uuid('071'), {
|
|
653
655
|
format: this.Formats.BOOL,
|
|
654
656
|
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
655
|
-
}, '
|
|
657
|
+
}, 'Morning Mode')
|
|
658
|
+
|
|
659
|
+
this.createCharacteristicClass('MotorSpeed', uuid('072'), {
|
|
660
|
+
format: this.Formats.UINT8,
|
|
661
|
+
unit: this.Units.PERCENTAGE,
|
|
662
|
+
minValue: 0,
|
|
663
|
+
maxValue: 100,
|
|
664
|
+
perms: [this.Perms.READ, this.Perms.NOTIFY, this.Perms.WRITE]
|
|
665
|
+
}, 'Motor Speed')
|
|
656
666
|
|
|
657
667
|
// Characteristic for Unique ID, used by homebridge-hue.
|
|
658
668
|
// Source: as exposed by the Philips Hue bridge. This characteristic is
|
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.
|
|
6
|
+
"version": "5.1.16",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"homekit",
|
|
9
9
|
"homebridge"
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"upnp": "cli/upnp.js"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"homebridge": "^1.3.
|
|
24
|
-
"node": "^
|
|
23
|
+
"homebridge": "^1.3.5",
|
|
24
|
+
"node": "^16.13.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"bonjour-hap": "^3.6.
|
|
27
|
+
"bonjour-hap": "^3.6.3",
|
|
28
28
|
"chalk": "^4.1.2",
|
|
29
29
|
"semver": "^7.3.5"
|
|
30
30
|
},
|