hap-nodejs 0.12.3-beta.26 → 0.12.3-beta.28
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 +0 -1
- package/dist/BridgedCore.js +19 -18
- package/dist/BridgedCore.js.map +1 -1
- package/dist/Core.js +20 -17
- package/dist/Core.js.map +1 -1
- package/dist/accessories/AirConditioner_accessory.js +24 -24
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +23 -23
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +373 -292
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +21 -15
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +12 -12
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +21 -31
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +48 -45
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +11 -11
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +8 -8
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +10 -10
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +11 -11
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +19 -19
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +17 -17
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +6 -6
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +3 -3
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +4 -4
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +47 -36
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.js +2 -2
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +1088 -780
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/AccessoryLoader.js +40 -40
- package/dist/lib/AccessoryLoader.js.map +1 -1
- package/dist/lib/Advertiser.js +524 -392
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.js +10 -6
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +539 -1510
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.js +265 -215
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +320 -519
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/Camera.js +14 -14
- package/dist/lib/camera/Camera.js.map +1 -1
- package/dist/lib/camera/RTPProxy.js +104 -112
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +257 -286
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +384 -319
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.js +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +3 -19
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +218 -217
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.js +250 -191
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +1 -1
- package/dist/lib/controller/DoorbellController.js +40 -39
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.js +401 -343
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.js +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +57 -56
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +304 -259
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +269 -252
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.js +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +2858 -2089
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +1096 -864
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +679 -383
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +29 -29
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.js +1 -1
- package/dist/lib/model/AccessoryInfo.js +136 -101
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.js +89 -86
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.js +16 -15
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.js +49 -49
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +44 -40
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/clone.js +27 -5
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.js +12 -8
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +409 -301
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.js +32 -31
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.js +12 -9
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.js +53 -32
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.js +8 -3
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.js +13 -8
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.js +3 -2
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.js +5 -5
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.js +75 -57
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.js +19 -15
- package/dist/lib/util/uuid.js.map +1 -1
- package/package.json +16 -16
- package/dist/lib/util/checkName.d.ts +0 -8
- package/dist/lib/util/checkName.d.ts.map +0 -1
- package/dist/lib/util/checkName.js +0 -17
- package/dist/lib/util/checkName.js.map +0 -1
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Characteristic = exports.CharacteristicEventTypes = exports.ChangeReason = exports.Access = exports.Perms = exports.Units = exports.Formats = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
+
var events_1 = require("events");
|
|
8
|
+
var HAPServer_1 = require("./HAPServer");
|
|
9
|
+
var clone_1 = require("./util/clone");
|
|
10
|
+
var hapStatusError_1 = require("./util/hapStatusError");
|
|
11
|
+
var once_1 = require("./util/once");
|
|
12
|
+
var request_util_1 = require("./util/request-util");
|
|
13
|
+
var uuid_1 = require("./util/uuid");
|
|
14
|
+
var debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
|
|
16
15
|
/**
|
|
17
16
|
* @group Characteristic
|
|
18
17
|
*/
|
|
@@ -182,1183 +181,153 @@ var CharacteristicEventTypes;
|
|
|
182
181
|
/**
|
|
183
182
|
* @group Characteristic
|
|
184
183
|
*/
|
|
185
|
-
|
|
186
|
-
props
|
|
187
|
-
constructor(props) {
|
|
184
|
+
var ValidValuesIterable = /** @class */ (function () {
|
|
185
|
+
function ValidValuesIterable(props) {
|
|
188
186
|
(0, assert_1.default)((0, request_util_1.isNumericFormat)(props.format), "Cannot instantiate valid values iterable when format is not numeric. Found " + props.format);
|
|
189
187
|
this.props = props;
|
|
190
188
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* @group Characteristic Definitions
|
|
330
|
-
*/
|
|
331
|
-
static AirParticulateSize;
|
|
332
|
-
/**
|
|
333
|
-
* @group Characteristic Definitions
|
|
334
|
-
*/
|
|
335
|
-
static AirPlayEnable;
|
|
336
|
-
/**
|
|
337
|
-
* @group Characteristic Definitions
|
|
338
|
-
*/
|
|
339
|
-
static AirQuality;
|
|
340
|
-
/**
|
|
341
|
-
* @group Characteristic Definitions
|
|
342
|
-
*/
|
|
343
|
-
static AppMatchingIdentifier;
|
|
344
|
-
/**
|
|
345
|
-
* @group Characteristic Definitions
|
|
346
|
-
*/
|
|
347
|
-
static AssetUpdateReadiness;
|
|
348
|
-
/**
|
|
349
|
-
* @group Characteristic Definitions
|
|
350
|
-
*/
|
|
351
|
-
static AudioFeedback;
|
|
352
|
-
/**
|
|
353
|
-
* @group Characteristic Definitions
|
|
354
|
-
*/
|
|
355
|
-
static BatteryLevel;
|
|
356
|
-
/**
|
|
357
|
-
* @group Characteristic Definitions
|
|
358
|
-
*/
|
|
359
|
-
static Brightness;
|
|
360
|
-
/**
|
|
361
|
-
* @group Characteristic Definitions
|
|
362
|
-
*/
|
|
363
|
-
static ButtonEvent;
|
|
364
|
-
/**
|
|
365
|
-
* @group Characteristic Definitions
|
|
366
|
-
*/
|
|
367
|
-
static CameraOperatingModeIndicator;
|
|
368
|
-
/**
|
|
369
|
-
* @group Characteristic Definitions
|
|
370
|
-
*/
|
|
371
|
-
static CarbonDioxideDetected;
|
|
372
|
-
/**
|
|
373
|
-
* @group Characteristic Definitions
|
|
374
|
-
*/
|
|
375
|
-
static CarbonDioxideLevel;
|
|
376
|
-
/**
|
|
377
|
-
* @group Characteristic Definitions
|
|
378
|
-
*/
|
|
379
|
-
static CarbonDioxidePeakLevel;
|
|
380
|
-
/**
|
|
381
|
-
* @group Characteristic Definitions
|
|
382
|
-
*/
|
|
383
|
-
static CarbonMonoxideDetected;
|
|
384
|
-
/**
|
|
385
|
-
* @group Characteristic Definitions
|
|
386
|
-
*/
|
|
387
|
-
static CarbonMonoxideLevel;
|
|
388
|
-
/**
|
|
389
|
-
* @group Characteristic Definitions
|
|
390
|
-
*/
|
|
391
|
-
static CarbonMonoxidePeakLevel;
|
|
392
|
-
/**
|
|
393
|
-
* @group Characteristic Definitions
|
|
394
|
-
* @deprecated Removed and not used anymore
|
|
395
|
-
*/
|
|
396
|
-
static Category;
|
|
397
|
-
/**
|
|
398
|
-
* @group Characteristic Definitions
|
|
399
|
-
*/
|
|
400
|
-
static CCAEnergyDetectThreshold;
|
|
401
|
-
/**
|
|
402
|
-
* @group Characteristic Definitions
|
|
403
|
-
*/
|
|
404
|
-
static CCASignalDetectThreshold;
|
|
405
|
-
/**
|
|
406
|
-
* @group Characteristic Definitions
|
|
407
|
-
*/
|
|
408
|
-
static CharacteristicValueActiveTransitionCount;
|
|
409
|
-
/**
|
|
410
|
-
* @group Characteristic Definitions
|
|
411
|
-
*/
|
|
412
|
-
static CharacteristicValueTransitionControl;
|
|
413
|
-
/**
|
|
414
|
-
* @group Characteristic Definitions
|
|
415
|
-
*/
|
|
416
|
-
static ChargingState;
|
|
417
|
-
/**
|
|
418
|
-
* @group Characteristic Definitions
|
|
419
|
-
*/
|
|
420
|
-
static ClosedCaptions;
|
|
421
|
-
/**
|
|
422
|
-
* @group Characteristic Definitions
|
|
423
|
-
*/
|
|
424
|
-
static ColorTemperature;
|
|
425
|
-
/**
|
|
426
|
-
* @group Characteristic Definitions
|
|
427
|
-
*/
|
|
428
|
-
static ConfigurationState;
|
|
429
|
-
/**
|
|
430
|
-
* @group Characteristic Definitions
|
|
431
|
-
* @deprecated Removed and not used anymore
|
|
432
|
-
*/
|
|
433
|
-
static ConfigureBridgedAccessory;
|
|
434
|
-
/**
|
|
435
|
-
* @group Characteristic Definitions
|
|
436
|
-
* @deprecated Removed and not used anymore
|
|
437
|
-
*/
|
|
438
|
-
static ConfigureBridgedAccessoryStatus;
|
|
439
|
-
/**
|
|
440
|
-
* @group Characteristic Definitions
|
|
441
|
-
*/
|
|
442
|
-
static ConfiguredName;
|
|
443
|
-
/**
|
|
444
|
-
* @group Characteristic Definitions
|
|
445
|
-
*/
|
|
446
|
-
static ContactSensorState;
|
|
447
|
-
/**
|
|
448
|
-
* @group Characteristic Definitions
|
|
449
|
-
*/
|
|
450
|
-
static CoolingThresholdTemperature;
|
|
451
|
-
/**
|
|
452
|
-
* @group Characteristic Definitions
|
|
453
|
-
*/
|
|
454
|
-
static CryptoHash;
|
|
455
|
-
/**
|
|
456
|
-
* @group Characteristic Definitions
|
|
457
|
-
*/
|
|
458
|
-
static CurrentAirPurifierState;
|
|
459
|
-
/**
|
|
460
|
-
* @group Characteristic Definitions
|
|
461
|
-
*/
|
|
462
|
-
static CurrentAmbientLightLevel;
|
|
463
|
-
/**
|
|
464
|
-
* @group Characteristic Definitions
|
|
465
|
-
*/
|
|
466
|
-
static CurrentDoorState;
|
|
467
|
-
/**
|
|
468
|
-
* @group Characteristic Definitions
|
|
469
|
-
*/
|
|
470
|
-
static CurrentFanState;
|
|
471
|
-
/**
|
|
472
|
-
* @group Characteristic Definitions
|
|
473
|
-
*/
|
|
474
|
-
static CurrentHeaterCoolerState;
|
|
475
|
-
/**
|
|
476
|
-
* @group Characteristic Definitions
|
|
477
|
-
*/
|
|
478
|
-
static CurrentHeatingCoolingState;
|
|
479
|
-
/**
|
|
480
|
-
* @group Characteristic Definitions
|
|
481
|
-
*/
|
|
482
|
-
static CurrentHorizontalTiltAngle;
|
|
483
|
-
/**
|
|
484
|
-
* @group Characteristic Definitions
|
|
485
|
-
*/
|
|
486
|
-
static CurrentHumidifierDehumidifierState;
|
|
487
|
-
/**
|
|
488
|
-
* @group Characteristic Definitions
|
|
489
|
-
*/
|
|
490
|
-
static CurrentMediaState;
|
|
491
|
-
/**
|
|
492
|
-
* @group Characteristic Definitions
|
|
493
|
-
*/
|
|
494
|
-
static CurrentPosition;
|
|
495
|
-
/**
|
|
496
|
-
* @group Characteristic Definitions
|
|
497
|
-
*/
|
|
498
|
-
static CurrentRelativeHumidity;
|
|
499
|
-
/**
|
|
500
|
-
* @group Characteristic Definitions
|
|
501
|
-
*/
|
|
502
|
-
static CurrentSlatState;
|
|
503
|
-
/**
|
|
504
|
-
* @group Characteristic Definitions
|
|
505
|
-
*/
|
|
506
|
-
static CurrentTemperature;
|
|
507
|
-
/**
|
|
508
|
-
* @group Characteristic Definitions
|
|
509
|
-
*/
|
|
510
|
-
static CurrentTiltAngle;
|
|
511
|
-
/**
|
|
512
|
-
* @group Characteristic Definitions
|
|
513
|
-
* @deprecated Removed and not used anymore
|
|
514
|
-
*/
|
|
515
|
-
static CurrentTime;
|
|
516
|
-
/**
|
|
517
|
-
* @group Characteristic Definitions
|
|
518
|
-
*/
|
|
519
|
-
static CurrentTransport;
|
|
520
|
-
/**
|
|
521
|
-
* @group Characteristic Definitions
|
|
522
|
-
*/
|
|
523
|
-
static CurrentVerticalTiltAngle;
|
|
524
|
-
/**
|
|
525
|
-
* @group Characteristic Definitions
|
|
526
|
-
*/
|
|
527
|
-
static CurrentVisibilityState;
|
|
528
|
-
/**
|
|
529
|
-
* @group Characteristic Definitions
|
|
530
|
-
*/
|
|
531
|
-
static DataStreamHAPTransport;
|
|
532
|
-
/**
|
|
533
|
-
* @group Characteristic Definitions
|
|
534
|
-
*/
|
|
535
|
-
static DataStreamHAPTransportInterrupt;
|
|
536
|
-
/**
|
|
537
|
-
* @group Characteristic Definitions
|
|
538
|
-
* @deprecated Removed and not used anymore
|
|
539
|
-
*/
|
|
540
|
-
static DayoftheWeek;
|
|
541
|
-
/**
|
|
542
|
-
* @group Characteristic Definitions
|
|
543
|
-
*/
|
|
544
|
-
static DiagonalFieldOfView;
|
|
545
|
-
/**
|
|
546
|
-
* @group Characteristic Definitions
|
|
547
|
-
*/
|
|
548
|
-
static DigitalZoom;
|
|
549
|
-
/**
|
|
550
|
-
* @group Characteristic Definitions
|
|
551
|
-
* @deprecated Removed and not used anymore
|
|
552
|
-
*/
|
|
553
|
-
static DiscoverBridgedAccessories;
|
|
554
|
-
/**
|
|
555
|
-
* @group Characteristic Definitions
|
|
556
|
-
* @deprecated Removed and not used anymore
|
|
557
|
-
*/
|
|
558
|
-
static DiscoveredBridgedAccessories;
|
|
559
|
-
/**
|
|
560
|
-
* @group Characteristic Definitions
|
|
561
|
-
*/
|
|
562
|
-
static DisplayOrder;
|
|
563
|
-
/**
|
|
564
|
-
* @group Characteristic Definitions
|
|
565
|
-
*/
|
|
566
|
-
static EventRetransmissionMaximum;
|
|
567
|
-
/**
|
|
568
|
-
* @group Characteristic Definitions
|
|
569
|
-
*/
|
|
570
|
-
static EventSnapshotsActive;
|
|
571
|
-
/**
|
|
572
|
-
* @group Characteristic Definitions
|
|
573
|
-
*/
|
|
574
|
-
static EventTransmissionCounters;
|
|
575
|
-
/**
|
|
576
|
-
* @group Characteristic Definitions
|
|
577
|
-
*/
|
|
578
|
-
static FilterChangeIndication;
|
|
579
|
-
/**
|
|
580
|
-
* @group Characteristic Definitions
|
|
581
|
-
*/
|
|
582
|
-
static FilterLifeLevel;
|
|
583
|
-
/**
|
|
584
|
-
* @group Characteristic Definitions
|
|
585
|
-
*/
|
|
586
|
-
static FirmwareRevision;
|
|
587
|
-
/**
|
|
588
|
-
* @group Characteristic Definitions
|
|
589
|
-
*/
|
|
590
|
-
static FirmwareUpdateReadiness;
|
|
591
|
-
/**
|
|
592
|
-
* @group Characteristic Definitions
|
|
593
|
-
*/
|
|
594
|
-
static FirmwareUpdateStatus;
|
|
595
|
-
/**
|
|
596
|
-
* @group Characteristic Definitions
|
|
597
|
-
*/
|
|
598
|
-
static HardwareFinish;
|
|
599
|
-
/**
|
|
600
|
-
* @group Characteristic Definitions
|
|
601
|
-
*/
|
|
602
|
-
static HardwareRevision;
|
|
603
|
-
/**
|
|
604
|
-
* @group Characteristic Definitions
|
|
605
|
-
*/
|
|
606
|
-
static HeartBeat;
|
|
607
|
-
/**
|
|
608
|
-
* @group Characteristic Definitions
|
|
609
|
-
*/
|
|
610
|
-
static HeatingThresholdTemperature;
|
|
611
|
-
/**
|
|
612
|
-
* @group Characteristic Definitions
|
|
613
|
-
*/
|
|
614
|
-
static HoldPosition;
|
|
615
|
-
/**
|
|
616
|
-
* @group Characteristic Definitions
|
|
617
|
-
*/
|
|
618
|
-
static HomeKitCameraActive;
|
|
619
|
-
/**
|
|
620
|
-
* @group Characteristic Definitions
|
|
621
|
-
*/
|
|
622
|
-
static Hue;
|
|
623
|
-
/**
|
|
624
|
-
* @group Characteristic Definitions
|
|
625
|
-
*/
|
|
626
|
-
static Identifier;
|
|
627
|
-
/**
|
|
628
|
-
* @group Characteristic Definitions
|
|
629
|
-
*/
|
|
630
|
-
static Identify;
|
|
631
|
-
/**
|
|
632
|
-
* @group Characteristic Definitions
|
|
633
|
-
*/
|
|
634
|
-
static ImageMirroring;
|
|
635
|
-
/**
|
|
636
|
-
* @group Characteristic Definitions
|
|
637
|
-
*/
|
|
638
|
-
static ImageRotation;
|
|
639
|
-
/**
|
|
640
|
-
* @group Characteristic Definitions
|
|
641
|
-
*/
|
|
642
|
-
static InputDeviceType;
|
|
643
|
-
/**
|
|
644
|
-
* @group Characteristic Definitions
|
|
645
|
-
*/
|
|
646
|
-
static InputSourceType;
|
|
647
|
-
/**
|
|
648
|
-
* @group Characteristic Definitions
|
|
649
|
-
*/
|
|
650
|
-
static InUse;
|
|
651
|
-
/**
|
|
652
|
-
* @group Characteristic Definitions
|
|
653
|
-
*/
|
|
654
|
-
static IsConfigured;
|
|
655
|
-
/**
|
|
656
|
-
* @group Characteristic Definitions
|
|
657
|
-
*/
|
|
658
|
-
static LeakDetected;
|
|
659
|
-
/**
|
|
660
|
-
* @group Characteristic Definitions
|
|
661
|
-
* @deprecated Removed and not used anymore
|
|
662
|
-
*/
|
|
663
|
-
static LinkQuality;
|
|
664
|
-
/**
|
|
665
|
-
* @group Characteristic Definitions
|
|
666
|
-
*/
|
|
667
|
-
static ListPairings;
|
|
668
|
-
/**
|
|
669
|
-
* @group Characteristic Definitions
|
|
670
|
-
*/
|
|
671
|
-
static LockControlPoint;
|
|
672
|
-
/**
|
|
673
|
-
* @group Characteristic Definitions
|
|
674
|
-
*/
|
|
675
|
-
static LockCurrentState;
|
|
676
|
-
/**
|
|
677
|
-
* @group Characteristic Definitions
|
|
678
|
-
*/
|
|
679
|
-
static LockLastKnownAction;
|
|
680
|
-
/**
|
|
681
|
-
* @group Characteristic Definitions
|
|
682
|
-
*/
|
|
683
|
-
static LockManagementAutoSecurityTimeout;
|
|
684
|
-
/**
|
|
685
|
-
* @group Characteristic Definitions
|
|
686
|
-
*/
|
|
687
|
-
static LockPhysicalControls;
|
|
688
|
-
/**
|
|
689
|
-
* @group Characteristic Definitions
|
|
690
|
-
*/
|
|
691
|
-
static LockTargetState;
|
|
692
|
-
/**
|
|
693
|
-
* @group Characteristic Definitions
|
|
694
|
-
*/
|
|
695
|
-
static Logs;
|
|
696
|
-
/**
|
|
697
|
-
* @group Characteristic Definitions
|
|
698
|
-
*/
|
|
699
|
-
static MACRetransmissionMaximum;
|
|
700
|
-
/**
|
|
701
|
-
* @group Characteristic Definitions
|
|
702
|
-
*/
|
|
703
|
-
static MACTransmissionCounters;
|
|
704
|
-
/**
|
|
705
|
-
* @group Characteristic Definitions
|
|
706
|
-
*/
|
|
707
|
-
static ManagedNetworkEnable;
|
|
708
|
-
/**
|
|
709
|
-
* @group Characteristic Definitions
|
|
710
|
-
*/
|
|
711
|
-
static ManuallyDisabled;
|
|
712
|
-
/**
|
|
713
|
-
* @group Characteristic Definitions
|
|
714
|
-
*/
|
|
715
|
-
static Manufacturer;
|
|
716
|
-
/**
|
|
717
|
-
* @group Characteristic Definitions
|
|
718
|
-
*/
|
|
719
|
-
static MaximumTransmitPower;
|
|
720
|
-
/**
|
|
721
|
-
* @group Characteristic Definitions
|
|
722
|
-
*/
|
|
723
|
-
static MetricsBufferFullState;
|
|
724
|
-
/**
|
|
725
|
-
* @group Characteristic Definitions
|
|
726
|
-
*/
|
|
727
|
-
static Model;
|
|
728
|
-
/**
|
|
729
|
-
* @group Characteristic Definitions
|
|
730
|
-
*/
|
|
731
|
-
static MotionDetected;
|
|
732
|
-
/**
|
|
733
|
-
* @group Characteristic Definitions
|
|
734
|
-
*/
|
|
735
|
-
static MultifunctionButton;
|
|
736
|
-
/**
|
|
737
|
-
* @group Characteristic Definitions
|
|
738
|
-
*/
|
|
739
|
-
static Mute;
|
|
740
|
-
/**
|
|
741
|
-
* @group Characteristic Definitions
|
|
742
|
-
*/
|
|
743
|
-
static Name;
|
|
744
|
-
/**
|
|
745
|
-
* @group Characteristic Definitions
|
|
746
|
-
*/
|
|
747
|
-
static NetworkAccessViolationControl;
|
|
748
|
-
/**
|
|
749
|
-
* @group Characteristic Definitions
|
|
750
|
-
*/
|
|
751
|
-
static NetworkClientProfileControl;
|
|
752
|
-
/**
|
|
753
|
-
* @group Characteristic Definitions
|
|
754
|
-
*/
|
|
755
|
-
static NetworkClientStatusControl;
|
|
756
|
-
/**
|
|
757
|
-
* @group Characteristic Definitions
|
|
758
|
-
*/
|
|
759
|
-
static NFCAccessControlPoint;
|
|
760
|
-
/**
|
|
761
|
-
* @group Characteristic Definitions
|
|
762
|
-
*/
|
|
763
|
-
static NFCAccessSupportedConfiguration;
|
|
764
|
-
/**
|
|
765
|
-
* @group Characteristic Definitions
|
|
766
|
-
*/
|
|
767
|
-
static NightVision;
|
|
768
|
-
/**
|
|
769
|
-
* @group Characteristic Definitions
|
|
770
|
-
*/
|
|
771
|
-
static NitrogenDioxideDensity;
|
|
772
|
-
/**
|
|
773
|
-
* @group Characteristic Definitions
|
|
774
|
-
*/
|
|
775
|
-
static ObstructionDetected;
|
|
776
|
-
/**
|
|
777
|
-
* @group Characteristic Definitions
|
|
778
|
-
*/
|
|
779
|
-
static OccupancyDetected;
|
|
780
|
-
/**
|
|
781
|
-
* @group Characteristic Definitions
|
|
782
|
-
*/
|
|
783
|
-
static On;
|
|
784
|
-
/**
|
|
785
|
-
* @group Characteristic Definitions
|
|
786
|
-
*/
|
|
787
|
-
static OperatingStateResponse;
|
|
788
|
-
/**
|
|
789
|
-
* @group Characteristic Definitions
|
|
790
|
-
*/
|
|
791
|
-
static OpticalZoom;
|
|
792
|
-
/**
|
|
793
|
-
* @group Characteristic Definitions
|
|
794
|
-
*/
|
|
795
|
-
static OutletInUse;
|
|
796
|
-
/**
|
|
797
|
-
* @group Characteristic Definitions
|
|
798
|
-
*/
|
|
799
|
-
static OzoneDensity;
|
|
800
|
-
/**
|
|
801
|
-
* @group Characteristic Definitions
|
|
802
|
-
*/
|
|
803
|
-
static PairingFeatures;
|
|
804
|
-
/**
|
|
805
|
-
* @group Characteristic Definitions
|
|
806
|
-
*/
|
|
807
|
-
static PairSetup;
|
|
808
|
-
/**
|
|
809
|
-
* @group Characteristic Definitions
|
|
810
|
-
*/
|
|
811
|
-
static PairVerify;
|
|
812
|
-
/**
|
|
813
|
-
* @group Characteristic Definitions
|
|
814
|
-
*/
|
|
815
|
-
static PasswordSetting;
|
|
816
|
-
/**
|
|
817
|
-
* @group Characteristic Definitions
|
|
818
|
-
*/
|
|
819
|
-
static PeriodicSnapshotsActive;
|
|
820
|
-
/**
|
|
821
|
-
* @group Characteristic Definitions
|
|
822
|
-
*/
|
|
823
|
-
static PictureMode;
|
|
824
|
-
/**
|
|
825
|
-
* @group Characteristic Definitions
|
|
826
|
-
*/
|
|
827
|
-
static Ping;
|
|
828
|
-
/**
|
|
829
|
-
* @group Characteristic Definitions
|
|
830
|
-
*/
|
|
831
|
-
static PM10Density;
|
|
832
|
-
/**
|
|
833
|
-
* @group Characteristic Definitions
|
|
834
|
-
*/
|
|
835
|
-
static PM2_5Density;
|
|
836
|
-
/**
|
|
837
|
-
* @group Characteristic Definitions
|
|
838
|
-
*/
|
|
839
|
-
static PositionState;
|
|
840
|
-
/**
|
|
841
|
-
* @group Characteristic Definitions
|
|
842
|
-
*/
|
|
843
|
-
static PowerModeSelection;
|
|
844
|
-
/**
|
|
845
|
-
* @group Characteristic Definitions
|
|
846
|
-
*/
|
|
847
|
-
static ProductData;
|
|
848
|
-
/**
|
|
849
|
-
* @group Characteristic Definitions
|
|
850
|
-
*/
|
|
851
|
-
static ProgrammableSwitchEvent;
|
|
852
|
-
/**
|
|
853
|
-
* @group Characteristic Definitions
|
|
854
|
-
*/
|
|
855
|
-
static ProgrammableSwitchOutputState;
|
|
856
|
-
/**
|
|
857
|
-
* @group Characteristic Definitions
|
|
858
|
-
*/
|
|
859
|
-
static ProgramMode;
|
|
860
|
-
/**
|
|
861
|
-
* @group Characteristic Definitions
|
|
862
|
-
* @deprecated Removed and not used anymore
|
|
863
|
-
*/
|
|
864
|
-
static Reachable;
|
|
865
|
-
/**
|
|
866
|
-
* @group Characteristic Definitions
|
|
867
|
-
*/
|
|
868
|
-
static ReceivedSignalStrengthIndication;
|
|
869
|
-
/**
|
|
870
|
-
* @group Characteristic Definitions
|
|
871
|
-
*/
|
|
872
|
-
static ReceiverSensitivity;
|
|
873
|
-
/**
|
|
874
|
-
* @group Characteristic Definitions
|
|
875
|
-
*/
|
|
876
|
-
static RecordingAudioActive;
|
|
877
|
-
/**
|
|
878
|
-
* @group Characteristic Definitions
|
|
879
|
-
*/
|
|
880
|
-
static RelativeHumidityDehumidifierThreshold;
|
|
881
|
-
/**
|
|
882
|
-
* @group Characteristic Definitions
|
|
883
|
-
*/
|
|
884
|
-
static RelativeHumidityHumidifierThreshold;
|
|
885
|
-
/**
|
|
886
|
-
* @group Characteristic Definitions
|
|
887
|
-
*/
|
|
888
|
-
static RelayControlPoint;
|
|
889
|
-
/**
|
|
890
|
-
* @group Characteristic Definitions
|
|
891
|
-
*/
|
|
892
|
-
static RelayEnabled;
|
|
893
|
-
/**
|
|
894
|
-
* @group Characteristic Definitions
|
|
895
|
-
*/
|
|
896
|
-
static RelayState;
|
|
897
|
-
/**
|
|
898
|
-
* @group Characteristic Definitions
|
|
899
|
-
*/
|
|
900
|
-
static RemainingDuration;
|
|
901
|
-
/**
|
|
902
|
-
* @group Characteristic Definitions
|
|
903
|
-
*/
|
|
904
|
-
static RemoteKey;
|
|
905
|
-
/**
|
|
906
|
-
* @group Characteristic Definitions
|
|
907
|
-
*/
|
|
908
|
-
static ResetFilterIndication;
|
|
909
|
-
/**
|
|
910
|
-
* @group Characteristic Definitions
|
|
911
|
-
*/
|
|
912
|
-
static RotationDirection;
|
|
913
|
-
/**
|
|
914
|
-
* @group Characteristic Definitions
|
|
915
|
-
*/
|
|
916
|
-
static RotationSpeed;
|
|
917
|
-
/**
|
|
918
|
-
* @group Characteristic Definitions
|
|
919
|
-
*/
|
|
920
|
-
static RouterStatus;
|
|
921
|
-
/**
|
|
922
|
-
* @group Characteristic Definitions
|
|
923
|
-
*/
|
|
924
|
-
static Saturation;
|
|
925
|
-
/**
|
|
926
|
-
* @group Characteristic Definitions
|
|
927
|
-
*/
|
|
928
|
-
static SecuritySystemAlarmType;
|
|
929
|
-
/**
|
|
930
|
-
* @group Characteristic Definitions
|
|
931
|
-
*/
|
|
932
|
-
static SecuritySystemCurrentState;
|
|
933
|
-
/**
|
|
934
|
-
* @group Characteristic Definitions
|
|
935
|
-
*/
|
|
936
|
-
static SecuritySystemTargetState;
|
|
937
|
-
/**
|
|
938
|
-
* @group Characteristic Definitions
|
|
939
|
-
*/
|
|
940
|
-
static SelectedAudioStreamConfiguration;
|
|
941
|
-
/**
|
|
942
|
-
* @group Characteristic Definitions
|
|
943
|
-
*/
|
|
944
|
-
static SelectedCameraRecordingConfiguration;
|
|
945
|
-
/**
|
|
946
|
-
* @group Characteristic Definitions
|
|
947
|
-
*/
|
|
948
|
-
static SelectedDiagnosticsModes;
|
|
949
|
-
/**
|
|
950
|
-
* @group Characteristic Definitions
|
|
951
|
-
*/
|
|
952
|
-
static SelectedRTPStreamConfiguration;
|
|
953
|
-
/**
|
|
954
|
-
* @group Characteristic Definitions
|
|
955
|
-
*/
|
|
956
|
-
static SelectedSleepConfiguration;
|
|
957
|
-
/**
|
|
958
|
-
* @group Characteristic Definitions
|
|
959
|
-
*/
|
|
960
|
-
static SerialNumber;
|
|
961
|
-
/**
|
|
962
|
-
* @group Characteristic Definitions
|
|
963
|
-
*/
|
|
964
|
-
static ServiceLabelIndex;
|
|
965
|
-
/**
|
|
966
|
-
* @group Characteristic Definitions
|
|
967
|
-
*/
|
|
968
|
-
static ServiceLabelNamespace;
|
|
969
|
-
/**
|
|
970
|
-
* @group Characteristic Definitions
|
|
971
|
-
*/
|
|
972
|
-
static SetDuration;
|
|
973
|
-
/**
|
|
974
|
-
* @group Characteristic Definitions
|
|
975
|
-
*/
|
|
976
|
-
static SetupDataStreamTransport;
|
|
977
|
-
/**
|
|
978
|
-
* @group Characteristic Definitions
|
|
979
|
-
*/
|
|
980
|
-
static SetupEndpoints;
|
|
981
|
-
/**
|
|
982
|
-
* @group Characteristic Definitions
|
|
983
|
-
*/
|
|
984
|
-
static SetupTransferTransport;
|
|
985
|
-
/**
|
|
986
|
-
* @group Characteristic Definitions
|
|
987
|
-
*/
|
|
988
|
-
static SignalToNoiseRatio;
|
|
989
|
-
/**
|
|
990
|
-
* @group Characteristic Definitions
|
|
991
|
-
*/
|
|
992
|
-
static SiriEnable;
|
|
993
|
-
/**
|
|
994
|
-
* @group Characteristic Definitions
|
|
995
|
-
*/
|
|
996
|
-
static SiriEndpointSessionStatus;
|
|
997
|
-
/**
|
|
998
|
-
* @group Characteristic Definitions
|
|
999
|
-
*/
|
|
1000
|
-
static SiriEngineVersion;
|
|
1001
|
-
/**
|
|
1002
|
-
* @group Characteristic Definitions
|
|
1003
|
-
*/
|
|
1004
|
-
static SiriInputType;
|
|
1005
|
-
/**
|
|
1006
|
-
* @group Characteristic Definitions
|
|
1007
|
-
*/
|
|
1008
|
-
static SiriLightOnUse;
|
|
1009
|
-
/**
|
|
1010
|
-
* @group Characteristic Definitions
|
|
1011
|
-
*/
|
|
1012
|
-
static SiriListening;
|
|
1013
|
-
/**
|
|
1014
|
-
* @group Characteristic Definitions
|
|
1015
|
-
*/
|
|
1016
|
-
static SiriTouchToUse;
|
|
1017
|
-
/**
|
|
1018
|
-
* @group Characteristic Definitions
|
|
1019
|
-
*/
|
|
1020
|
-
static SlatType;
|
|
1021
|
-
/**
|
|
1022
|
-
* @group Characteristic Definitions
|
|
1023
|
-
*/
|
|
1024
|
-
static SleepDiscoveryMode;
|
|
1025
|
-
/**
|
|
1026
|
-
* @group Characteristic Definitions
|
|
1027
|
-
*/
|
|
1028
|
-
static SleepInterval;
|
|
1029
|
-
/**
|
|
1030
|
-
* @group Characteristic Definitions
|
|
1031
|
-
*/
|
|
1032
|
-
static SmokeDetected;
|
|
1033
|
-
/**
|
|
1034
|
-
* @group Characteristic Definitions
|
|
1035
|
-
*/
|
|
1036
|
-
static SoftwareRevision;
|
|
1037
|
-
/**
|
|
1038
|
-
* @group Characteristic Definitions
|
|
1039
|
-
*/
|
|
1040
|
-
static StagedFirmwareVersion;
|
|
1041
|
-
/**
|
|
1042
|
-
* @group Characteristic Definitions
|
|
1043
|
-
*/
|
|
1044
|
-
static StatusActive;
|
|
1045
|
-
/**
|
|
1046
|
-
* @group Characteristic Definitions
|
|
1047
|
-
*/
|
|
1048
|
-
static StatusFault;
|
|
1049
|
-
/**
|
|
1050
|
-
* @group Characteristic Definitions
|
|
1051
|
-
*/
|
|
1052
|
-
static StatusJammed;
|
|
1053
|
-
/**
|
|
1054
|
-
* @group Characteristic Definitions
|
|
1055
|
-
*/
|
|
1056
|
-
static StatusLowBattery;
|
|
1057
|
-
/**
|
|
1058
|
-
* @group Characteristic Definitions
|
|
1059
|
-
*/
|
|
1060
|
-
static StatusTampered;
|
|
1061
|
-
/**
|
|
1062
|
-
* @group Characteristic Definitions
|
|
1063
|
-
*/
|
|
1064
|
-
static StreamingStatus;
|
|
1065
|
-
/**
|
|
1066
|
-
* @group Characteristic Definitions
|
|
1067
|
-
*/
|
|
1068
|
-
static SulphurDioxideDensity;
|
|
1069
|
-
/**
|
|
1070
|
-
* @group Characteristic Definitions
|
|
1071
|
-
*/
|
|
1072
|
-
static SupportedAssetTypes;
|
|
1073
|
-
/**
|
|
1074
|
-
* @group Characteristic Definitions
|
|
1075
|
-
*/
|
|
1076
|
-
static SupportedAudioRecordingConfiguration;
|
|
1077
|
-
/**
|
|
1078
|
-
* @group Characteristic Definitions
|
|
1079
|
-
*/
|
|
1080
|
-
static SupportedAudioStreamConfiguration;
|
|
1081
|
-
/**
|
|
1082
|
-
* @group Characteristic Definitions
|
|
1083
|
-
*/
|
|
1084
|
-
static SupportedCameraRecordingConfiguration;
|
|
1085
|
-
/**
|
|
1086
|
-
* @group Characteristic Definitions
|
|
1087
|
-
*/
|
|
1088
|
-
static SupportedCharacteristicValueTransitionConfiguration;
|
|
1089
|
-
/**
|
|
1090
|
-
* @group Characteristic Definitions
|
|
1091
|
-
*/
|
|
1092
|
-
static SupportedDataStreamTransportConfiguration;
|
|
1093
|
-
/**
|
|
1094
|
-
* @group Characteristic Definitions
|
|
1095
|
-
*/
|
|
1096
|
-
static SupportedDiagnosticsModes;
|
|
1097
|
-
/**
|
|
1098
|
-
* @group Characteristic Definitions
|
|
1099
|
-
*/
|
|
1100
|
-
static SupportedDiagnosticsSnapshot;
|
|
1101
|
-
/**
|
|
1102
|
-
* @group Characteristic Definitions
|
|
1103
|
-
*/
|
|
1104
|
-
static SupportedFirmwareUpdateConfiguration;
|
|
1105
|
-
/**
|
|
1106
|
-
* @group Characteristic Definitions
|
|
1107
|
-
*/
|
|
1108
|
-
static SupportedMetrics;
|
|
1109
|
-
/**
|
|
1110
|
-
* @group Characteristic Definitions
|
|
1111
|
-
*/
|
|
1112
|
-
static SupportedRouterConfiguration;
|
|
1113
|
-
/**
|
|
1114
|
-
* @group Characteristic Definitions
|
|
1115
|
-
*/
|
|
1116
|
-
static SupportedRTPConfiguration;
|
|
1117
|
-
/**
|
|
1118
|
-
* @group Characteristic Definitions
|
|
1119
|
-
*/
|
|
1120
|
-
static SupportedSleepConfiguration;
|
|
1121
|
-
/**
|
|
1122
|
-
* @group Characteristic Definitions
|
|
1123
|
-
*/
|
|
1124
|
-
static SupportedTransferTransportConfiguration;
|
|
1125
|
-
/**
|
|
1126
|
-
* @group Characteristic Definitions
|
|
1127
|
-
*/
|
|
1128
|
-
static SupportedVideoRecordingConfiguration;
|
|
1129
|
-
/**
|
|
1130
|
-
* @group Characteristic Definitions
|
|
1131
|
-
*/
|
|
1132
|
-
static SupportedVideoStreamConfiguration;
|
|
1133
|
-
/**
|
|
1134
|
-
* @group Characteristic Definitions
|
|
1135
|
-
*/
|
|
1136
|
-
static SwingMode;
|
|
1137
|
-
/**
|
|
1138
|
-
* @group Characteristic Definitions
|
|
1139
|
-
*/
|
|
1140
|
-
static TapType;
|
|
1141
|
-
/**
|
|
1142
|
-
* @group Characteristic Definitions
|
|
1143
|
-
*/
|
|
1144
|
-
static TargetAirPurifierState;
|
|
1145
|
-
/**
|
|
1146
|
-
* @group Characteristic Definitions
|
|
1147
|
-
* @deprecated Removed and not used anymore
|
|
1148
|
-
*/
|
|
1149
|
-
static TargetAirQuality;
|
|
1150
|
-
/**
|
|
1151
|
-
* @group Characteristic Definitions
|
|
1152
|
-
*/
|
|
1153
|
-
static TargetControlList;
|
|
1154
|
-
/**
|
|
1155
|
-
* @group Characteristic Definitions
|
|
1156
|
-
*/
|
|
1157
|
-
static TargetControlSupportedConfiguration;
|
|
1158
|
-
/**
|
|
1159
|
-
* @group Characteristic Definitions
|
|
1160
|
-
*/
|
|
1161
|
-
static TargetDoorState;
|
|
1162
|
-
/**
|
|
1163
|
-
* @group Characteristic Definitions
|
|
1164
|
-
*/
|
|
1165
|
-
static TargetFanState;
|
|
1166
|
-
/**
|
|
1167
|
-
* @group Characteristic Definitions
|
|
1168
|
-
*/
|
|
1169
|
-
static TargetHeaterCoolerState;
|
|
1170
|
-
/**
|
|
1171
|
-
* @group Characteristic Definitions
|
|
1172
|
-
*/
|
|
1173
|
-
static TargetHeatingCoolingState;
|
|
1174
|
-
/**
|
|
1175
|
-
* @group Characteristic Definitions
|
|
1176
|
-
*/
|
|
1177
|
-
static TargetHorizontalTiltAngle;
|
|
1178
|
-
/**
|
|
1179
|
-
* @group Characteristic Definitions
|
|
1180
|
-
*/
|
|
1181
|
-
static TargetHumidifierDehumidifierState;
|
|
1182
|
-
/**
|
|
1183
|
-
* @group Characteristic Definitions
|
|
1184
|
-
*/
|
|
1185
|
-
static TargetMediaState;
|
|
1186
|
-
/**
|
|
1187
|
-
* @group Characteristic Definitions
|
|
1188
|
-
*/
|
|
1189
|
-
static TargetPosition;
|
|
1190
|
-
/**
|
|
1191
|
-
* @group Characteristic Definitions
|
|
1192
|
-
*/
|
|
1193
|
-
static TargetRelativeHumidity;
|
|
1194
|
-
/**
|
|
1195
|
-
* @group Characteristic Definitions
|
|
1196
|
-
* @deprecated Removed and not used anymore
|
|
1197
|
-
*/
|
|
1198
|
-
static TargetSlatState;
|
|
1199
|
-
/**
|
|
1200
|
-
* @group Characteristic Definitions
|
|
1201
|
-
*/
|
|
1202
|
-
static TargetTemperature;
|
|
1203
|
-
/**
|
|
1204
|
-
* @group Characteristic Definitions
|
|
1205
|
-
*/
|
|
1206
|
-
static TargetTiltAngle;
|
|
1207
|
-
/**
|
|
1208
|
-
* @group Characteristic Definitions
|
|
1209
|
-
*/
|
|
1210
|
-
static TargetVerticalTiltAngle;
|
|
1211
|
-
/**
|
|
1212
|
-
* @group Characteristic Definitions
|
|
1213
|
-
*/
|
|
1214
|
-
static TargetVisibilityState;
|
|
1215
|
-
/**
|
|
1216
|
-
* @group Characteristic Definitions
|
|
1217
|
-
*/
|
|
1218
|
-
static TemperatureDisplayUnits;
|
|
1219
|
-
/**
|
|
1220
|
-
* @group Characteristic Definitions
|
|
1221
|
-
*/
|
|
1222
|
-
static ThirdPartyCameraActive;
|
|
1223
|
-
/**
|
|
1224
|
-
* @group Characteristic Definitions
|
|
1225
|
-
*/
|
|
1226
|
-
static ThreadControlPoint;
|
|
1227
|
-
/**
|
|
1228
|
-
* @group Characteristic Definitions
|
|
1229
|
-
*/
|
|
1230
|
-
static ThreadNodeCapabilities;
|
|
1231
|
-
/**
|
|
1232
|
-
* @group Characteristic Definitions
|
|
1233
|
-
*/
|
|
1234
|
-
static ThreadOpenThreadVersion;
|
|
1235
|
-
/**
|
|
1236
|
-
* @group Characteristic Definitions
|
|
1237
|
-
*/
|
|
1238
|
-
static ThreadStatus;
|
|
1239
|
-
/**
|
|
1240
|
-
* @group Characteristic Definitions
|
|
1241
|
-
* @deprecated Removed and not used anymore
|
|
1242
|
-
*/
|
|
1243
|
-
static TimeUpdate;
|
|
1244
|
-
/**
|
|
1245
|
-
* @group Characteristic Definitions
|
|
1246
|
-
*/
|
|
1247
|
-
static Token;
|
|
1248
|
-
/**
|
|
1249
|
-
* @group Characteristic Definitions
|
|
1250
|
-
*/
|
|
1251
|
-
static TransmitPower;
|
|
1252
|
-
/**
|
|
1253
|
-
* @group Characteristic Definitions
|
|
1254
|
-
*/
|
|
1255
|
-
static TunnelConnectionTimeout;
|
|
1256
|
-
/**
|
|
1257
|
-
* @group Characteristic Definitions
|
|
1258
|
-
*/
|
|
1259
|
-
static TunneledAccessoryAdvertising;
|
|
1260
|
-
/**
|
|
1261
|
-
* @group Characteristic Definitions
|
|
1262
|
-
*/
|
|
1263
|
-
static TunneledAccessoryConnected;
|
|
1264
|
-
/**
|
|
1265
|
-
* @group Characteristic Definitions
|
|
1266
|
-
*/
|
|
1267
|
-
static TunneledAccessoryStateNumber;
|
|
1268
|
-
/**
|
|
1269
|
-
* @group Characteristic Definitions
|
|
1270
|
-
*/
|
|
1271
|
-
static ValveType;
|
|
1272
|
-
/**
|
|
1273
|
-
* @group Characteristic Definitions
|
|
1274
|
-
*/
|
|
1275
|
-
static Version;
|
|
1276
|
-
/**
|
|
1277
|
-
* @group Characteristic Definitions
|
|
1278
|
-
*/
|
|
1279
|
-
static VideoAnalysisActive;
|
|
1280
|
-
/**
|
|
1281
|
-
* @group Characteristic Definitions
|
|
1282
|
-
*/
|
|
1283
|
-
static VOCDensity;
|
|
1284
|
-
/**
|
|
1285
|
-
* @group Characteristic Definitions
|
|
1286
|
-
*/
|
|
1287
|
-
static Volume;
|
|
1288
|
-
/**
|
|
1289
|
-
* @group Characteristic Definitions
|
|
1290
|
-
*/
|
|
1291
|
-
static VolumeControlType;
|
|
1292
|
-
/**
|
|
1293
|
-
* @group Characteristic Definitions
|
|
1294
|
-
*/
|
|
1295
|
-
static VolumeSelector;
|
|
1296
|
-
/**
|
|
1297
|
-
* @group Characteristic Definitions
|
|
1298
|
-
*/
|
|
1299
|
-
static WakeConfiguration;
|
|
1300
|
-
/**
|
|
1301
|
-
* @group Characteristic Definitions
|
|
1302
|
-
*/
|
|
1303
|
-
static WANConfigurationList;
|
|
1304
|
-
/**
|
|
1305
|
-
* @group Characteristic Definitions
|
|
1306
|
-
*/
|
|
1307
|
-
static WANStatusList;
|
|
1308
|
-
/**
|
|
1309
|
-
* @group Characteristic Definitions
|
|
1310
|
-
*/
|
|
1311
|
-
static WaterLevel;
|
|
1312
|
-
/**
|
|
1313
|
-
* @group Characteristic Definitions
|
|
1314
|
-
*/
|
|
1315
|
-
static WiFiCapabilities;
|
|
1316
|
-
/**
|
|
1317
|
-
* @group Characteristic Definitions
|
|
1318
|
-
*/
|
|
1319
|
-
static WiFiConfigurationControl;
|
|
1320
|
-
/**
|
|
1321
|
-
* @group Characteristic Definitions
|
|
1322
|
-
*/
|
|
1323
|
-
static WiFiSatelliteStatus;
|
|
1324
|
-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
1325
|
-
// NOTICE: when adding/changing properties, remember to possibly adjust the serialize/deserialize functions
|
|
1326
|
-
displayName;
|
|
1327
|
-
UUID;
|
|
1328
|
-
iid = null;
|
|
1329
|
-
value = null;
|
|
1330
|
-
/**
|
|
1331
|
-
* @deprecated replaced by {@link statusCode}
|
|
1332
|
-
* @private
|
|
1333
|
-
*/
|
|
1334
|
-
status = null;
|
|
1335
|
-
/**
|
|
1336
|
-
* @private
|
|
1337
|
-
*/
|
|
1338
|
-
statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1339
|
-
props;
|
|
1340
|
-
/**
|
|
1341
|
-
* The {@link Characteristic.onGet} handler
|
|
1342
|
-
*/
|
|
1343
|
-
getHandler;
|
|
1344
|
-
/**
|
|
1345
|
-
* The {@link Characteristic.onSet} handler
|
|
1346
|
-
*/
|
|
1347
|
-
setHandler;
|
|
1348
|
-
subscriptions = 0;
|
|
1349
|
-
/**
|
|
1350
|
-
* @private
|
|
1351
|
-
*/
|
|
1352
|
-
additionalAuthorizationHandler;
|
|
1353
|
-
constructor(displayName, UUID, props) {
|
|
1354
|
-
super();
|
|
1355
|
-
this.displayName = displayName;
|
|
1356
|
-
this.UUID = UUID;
|
|
1357
|
-
this.props = {
|
|
189
|
+
ValidValuesIterable.prototype[Symbol.iterator] = function () {
|
|
190
|
+
var _a, _b, value, e_1_1, min, max, stepValue, i;
|
|
191
|
+
var e_1, _c;
|
|
192
|
+
return tslib_1.__generator(this, function (_d) {
|
|
193
|
+
switch (_d.label) {
|
|
194
|
+
case 0:
|
|
195
|
+
if (!this.props.validValues) return [3 /*break*/, 9];
|
|
196
|
+
_d.label = 1;
|
|
197
|
+
case 1:
|
|
198
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
199
|
+
_a = tslib_1.__values(this.props.validValues), _b = _a.next();
|
|
200
|
+
_d.label = 2;
|
|
201
|
+
case 2:
|
|
202
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
203
|
+
value = _b.value;
|
|
204
|
+
return [4 /*yield*/, value];
|
|
205
|
+
case 3:
|
|
206
|
+
_d.sent();
|
|
207
|
+
_d.label = 4;
|
|
208
|
+
case 4:
|
|
209
|
+
_b = _a.next();
|
|
210
|
+
return [3 /*break*/, 2];
|
|
211
|
+
case 5: return [3 /*break*/, 8];
|
|
212
|
+
case 6:
|
|
213
|
+
e_1_1 = _d.sent();
|
|
214
|
+
e_1 = { error: e_1_1 };
|
|
215
|
+
return [3 /*break*/, 8];
|
|
216
|
+
case 7:
|
|
217
|
+
try {
|
|
218
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
219
|
+
}
|
|
220
|
+
finally { if (e_1) throw e_1.error; }
|
|
221
|
+
return [7 /*endfinally*/];
|
|
222
|
+
case 8: return [3 /*break*/, 13];
|
|
223
|
+
case 9:
|
|
224
|
+
min = 0;
|
|
225
|
+
max = void 0;
|
|
226
|
+
stepValue = 1;
|
|
227
|
+
if (this.props.validValueRanges) {
|
|
228
|
+
min = this.props.validValueRanges[0];
|
|
229
|
+
max = this.props.validValueRanges[1];
|
|
230
|
+
}
|
|
231
|
+
else if (this.props.minValue != null && this.props.maxValue != null) {
|
|
232
|
+
min = this.props.minValue;
|
|
233
|
+
max = this.props.maxValue;
|
|
234
|
+
if (this.props.minStep != null) {
|
|
235
|
+
stepValue = this.props.minStep;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
|
|
239
|
+
max = (0, request_util_1.numericUpperBound)(this.props.format);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
|
|
243
|
+
}
|
|
244
|
+
i = min;
|
|
245
|
+
_d.label = 10;
|
|
246
|
+
case 10:
|
|
247
|
+
if (!(i <= max)) return [3 /*break*/, 13];
|
|
248
|
+
return [4 /*yield*/, i];
|
|
249
|
+
case 11:
|
|
250
|
+
_d.sent();
|
|
251
|
+
_d.label = 12;
|
|
252
|
+
case 12:
|
|
253
|
+
i += stepValue;
|
|
254
|
+
return [3 /*break*/, 10];
|
|
255
|
+
case 13: return [2 /*return*/];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
return ValidValuesIterable;
|
|
260
|
+
}());
|
|
261
|
+
var numberPattern = /^-?\d+$/;
|
|
262
|
+
function extractHAPStatusFromError(error) {
|
|
263
|
+
var errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
264
|
+
if (numberPattern.test(error.message)) {
|
|
265
|
+
var value = parseInt(error.message, 10);
|
|
266
|
+
if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
|
|
267
|
+
errorValue = value;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return errorValue;
|
|
271
|
+
}
|
|
272
|
+
function maxWithUndefined(a, b) {
|
|
273
|
+
if (a == null) {
|
|
274
|
+
return b;
|
|
275
|
+
}
|
|
276
|
+
else if (b == null) {
|
|
277
|
+
return a;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
return Math.max(a, b);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function minWithUndefined(a, b) {
|
|
284
|
+
if (a == null) {
|
|
285
|
+
return b;
|
|
286
|
+
}
|
|
287
|
+
else if (b == null) {
|
|
288
|
+
return a;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
return Math.min(a, b);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a
|
|
296
|
+
* "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic
|
|
297
|
+
* to a {@link Service} in order to store that value. A particular Characteristic is distinguished from others by its
|
|
298
|
+
* UUID. HomeKit provides a set of known Characteristic UUIDs defined in HomeKit.ts along with a
|
|
299
|
+
* corresponding concrete subclass.
|
|
300
|
+
*
|
|
301
|
+
* You can also define custom Characteristics by providing your own UUID. Custom Characteristics can be added
|
|
302
|
+
* to any native or custom Services, but Siri will likely not be able to work with these.
|
|
303
|
+
*
|
|
304
|
+
* @group Characteristic
|
|
305
|
+
*/
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
307
|
+
var Characteristic = /** @class */ (function (_super) {
|
|
308
|
+
tslib_1.__extends(Characteristic, _super);
|
|
309
|
+
function Characteristic(displayName, UUID, props) {
|
|
310
|
+
var _this = _super.call(this) || this;
|
|
311
|
+
_this.iid = null;
|
|
312
|
+
_this.value = null;
|
|
313
|
+
/**
|
|
314
|
+
* @deprecated replaced by {@link statusCode}
|
|
315
|
+
* @private
|
|
316
|
+
*/
|
|
317
|
+
_this.status = null;
|
|
318
|
+
/**
|
|
319
|
+
* @private
|
|
320
|
+
*/
|
|
321
|
+
_this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
322
|
+
_this.subscriptions = 0;
|
|
323
|
+
_this.displayName = displayName;
|
|
324
|
+
_this.UUID = UUID;
|
|
325
|
+
_this.props = {
|
|
1358
326
|
format: "int" /* Formats.INT */,
|
|
1359
327
|
perms: ["ev" /* Perms.NOTIFY */],
|
|
1360
328
|
};
|
|
1361
|
-
|
|
329
|
+
_this.setProps(props || {}); // ensure sanity checks are called
|
|
330
|
+
return _this;
|
|
1362
331
|
}
|
|
1363
332
|
/**
|
|
1364
333
|
* Accepts a function that will be called to retrieve the current value of a Characteristic.
|
|
@@ -1373,21 +342,21 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1373
342
|
* ```
|
|
1374
343
|
* @param handler
|
|
1375
344
|
*/
|
|
1376
|
-
onGet(handler) {
|
|
345
|
+
Characteristic.prototype.onGet = function (handler) {
|
|
1377
346
|
if (typeof handler !== "function") {
|
|
1378
347
|
this.characteristicWarning(".onGet handler must be a function");
|
|
1379
348
|
return this;
|
|
1380
349
|
}
|
|
1381
350
|
this.getHandler = handler;
|
|
1382
351
|
return this;
|
|
1383
|
-
}
|
|
352
|
+
};
|
|
1384
353
|
/**
|
|
1385
354
|
* Removes the {@link CharacteristicGetHandler} handler which was configured using {@link onGet}.
|
|
1386
355
|
*/
|
|
1387
|
-
removeOnGet() {
|
|
356
|
+
Characteristic.prototype.removeOnGet = function () {
|
|
1388
357
|
this.getHandler = undefined;
|
|
1389
358
|
return this;
|
|
1390
|
-
}
|
|
359
|
+
};
|
|
1391
360
|
/**
|
|
1392
361
|
* Accepts a function that will be called when setting the value of a Characteristic.
|
|
1393
362
|
* If the characteristic supports {@link Perms.WRITE_RESPONSE} and the request requests a write-response value,
|
|
@@ -1402,21 +371,21 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1402
371
|
* ```
|
|
1403
372
|
* @param handler
|
|
1404
373
|
*/
|
|
1405
|
-
onSet(handler) {
|
|
374
|
+
Characteristic.prototype.onSet = function (handler) {
|
|
1406
375
|
if (typeof handler !== "function") {
|
|
1407
376
|
this.characteristicWarning(".onSet handler must be a function");
|
|
1408
377
|
return this;
|
|
1409
378
|
}
|
|
1410
379
|
this.setHandler = handler;
|
|
1411
380
|
return this;
|
|
1412
|
-
}
|
|
381
|
+
};
|
|
1413
382
|
/**
|
|
1414
383
|
* Removes the {@link CharacteristicSetHandler} which was configured using {@link onSet}.
|
|
1415
384
|
*/
|
|
1416
|
-
removeOnSet() {
|
|
385
|
+
Characteristic.prototype.removeOnSet = function () {
|
|
1417
386
|
this.setHandler = undefined;
|
|
1418
387
|
return this;
|
|
1419
|
-
}
|
|
388
|
+
};
|
|
1420
389
|
/**
|
|
1421
390
|
* Updates the properties of this characteristic.
|
|
1422
391
|
* Properties passed via the parameter will be set. Any parameter set to null will be deleted.
|
|
@@ -1424,10 +393,10 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1424
393
|
*
|
|
1425
394
|
* @param props - Partial properties object with the desired updates.
|
|
1426
395
|
*/
|
|
1427
|
-
setProps(props) {
|
|
396
|
+
Characteristic.prototype.setProps = function (props) {
|
|
1428
397
|
(0, assert_1.default)(props, "props cannot be undefined when setting props");
|
|
1429
398
|
// TODO calling setProps after publish doesn't lead to a increment in the current configuration number
|
|
1430
|
-
|
|
399
|
+
var formatDidChange = false;
|
|
1431
400
|
// for every value "null" can be used to reset props, except for required props
|
|
1432
401
|
if (props.format) {
|
|
1433
402
|
formatDidChange = this.props.format !== props.format;
|
|
@@ -1453,7 +422,7 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1453
422
|
props.minValue = undefined;
|
|
1454
423
|
}
|
|
1455
424
|
else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
|
|
1456
|
-
this.characteristicWarning(
|
|
425
|
+
this.characteristicWarning("Characteristic Property 'minValue' must be a finite number, received \"".concat(props.minValue, "\" (").concat(typeof props.minValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
1457
426
|
props.minValue = undefined;
|
|
1458
427
|
}
|
|
1459
428
|
else {
|
|
@@ -1480,7 +449,7 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1480
449
|
props.maxValue = undefined;
|
|
1481
450
|
}
|
|
1482
451
|
else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
|
|
1483
|
-
this.characteristicWarning(
|
|
452
|
+
this.characteristicWarning("Characteristic Property 'maxValue' must be a finite number, received \"".concat(props.maxValue, "\" (").concat(typeof props.maxValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
1484
453
|
props.maxValue = undefined;
|
|
1485
454
|
}
|
|
1486
455
|
else {
|
|
@@ -1584,14 +553,14 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1584
553
|
// - If the characteristic is marked as erroneous the value is not considered valid anyway, and we must not remove the `statusCode`.
|
|
1585
554
|
// - Special case for `ProgrammableSwitchEvent` where every change in value is considered an event which would result in ghost button presses
|
|
1586
555
|
// validateUserInput when called from setProps is intended to clamp value withing allowed range. It is why warnings should not be displayed.
|
|
1587
|
-
|
|
556
|
+
var correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
1588
557
|
if (correctedValue !== this.value) {
|
|
1589
558
|
// we don't want to emit a CHANGE event if the value didn't change at all!
|
|
1590
559
|
this.updateValue(correctedValue);
|
|
1591
560
|
}
|
|
1592
561
|
}
|
|
1593
562
|
return this;
|
|
1594
|
-
}
|
|
563
|
+
};
|
|
1595
564
|
/**
|
|
1596
565
|
* This method can be used to gain an Iterator to loop over all valid values defined for this characteristic.
|
|
1597
566
|
*
|
|
@@ -1620,9 +589,9 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1620
589
|
* const validValues = Array.from(characteristic.validValuesIterator());
|
|
1621
590
|
* ```
|
|
1622
591
|
*/
|
|
1623
|
-
validValuesIterator() {
|
|
592
|
+
Characteristic.prototype.validValuesIterator = function () {
|
|
1624
593
|
return new ValidValuesIterable(this.props);
|
|
1625
|
-
}
|
|
594
|
+
};
|
|
1626
595
|
// noinspection JSUnusedGlobalSymbols
|
|
1627
596
|
/**
|
|
1628
597
|
* This method can be used to set up additional authorization for a characteristic.
|
|
@@ -1640,12 +609,12 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1640
609
|
*
|
|
1641
610
|
* @param handler - Handler called to check additional authorization data.
|
|
1642
611
|
*/
|
|
1643
|
-
setupAdditionalAuthorization(handler) {
|
|
612
|
+
Characteristic.prototype.setupAdditionalAuthorization = function (handler) {
|
|
1644
613
|
if (!this.props.perms.includes("aa" /* Perms.ADDITIONAL_AUTHORIZATION */)) {
|
|
1645
614
|
this.props.perms.push("aa" /* Perms.ADDITIONAL_AUTHORIZATION */);
|
|
1646
615
|
}
|
|
1647
616
|
this.additionalAuthorizationHandler = handler;
|
|
1648
|
-
}
|
|
617
|
+
};
|
|
1649
618
|
/**
|
|
1650
619
|
* Updates the current value of the characteristic.
|
|
1651
620
|
*
|
|
@@ -1655,18 +624,18 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1655
624
|
*
|
|
1656
625
|
* @deprecated
|
|
1657
626
|
*/
|
|
1658
|
-
getValue(callback, context) {
|
|
1659
|
-
this.handleGetRequest(undefined, context).then(value
|
|
627
|
+
Characteristic.prototype.getValue = function (callback, context) {
|
|
628
|
+
this.handleGetRequest(undefined, context).then(function (value) {
|
|
1660
629
|
if (callback) {
|
|
1661
630
|
callback(null, value);
|
|
1662
631
|
}
|
|
1663
|
-
}, reason
|
|
632
|
+
}, function (reason) {
|
|
1664
633
|
if (callback) {
|
|
1665
634
|
callback(reason);
|
|
1666
635
|
}
|
|
1667
636
|
});
|
|
1668
|
-
}
|
|
1669
|
-
setValue(value, callback, context) {
|
|
637
|
+
};
|
|
638
|
+
Characteristic.prototype.setValue = function (value, callback, context) {
|
|
1670
639
|
if (value instanceof Error) {
|
|
1671
640
|
this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
|
|
1672
641
|
// noinspection JSDeprecatedSymbols
|
|
@@ -1684,13 +653,13 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1684
653
|
value = this.validateUserInput(value);
|
|
1685
654
|
}
|
|
1686
655
|
catch (error) {
|
|
1687
|
-
this.characteristicWarning(error
|
|
656
|
+
this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
1688
657
|
if (callback) {
|
|
1689
658
|
callback(error);
|
|
1690
659
|
}
|
|
1691
660
|
return this;
|
|
1692
661
|
}
|
|
1693
|
-
this.handleSetRequest(value, undefined, context).then(value
|
|
662
|
+
this.handleSetRequest(value, undefined, context).then(function (value) {
|
|
1694
663
|
if (callback) {
|
|
1695
664
|
if (value) { // possible write response
|
|
1696
665
|
callback(null, value);
|
|
@@ -1699,14 +668,14 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1699
668
|
callback(null);
|
|
1700
669
|
}
|
|
1701
670
|
}
|
|
1702
|
-
}, reason
|
|
671
|
+
}, function (reason) {
|
|
1703
672
|
if (callback) {
|
|
1704
673
|
callback(reason);
|
|
1705
674
|
}
|
|
1706
675
|
});
|
|
1707
676
|
return this;
|
|
1708
|
-
}
|
|
1709
|
-
updateValue(value, callback, context) {
|
|
677
|
+
};
|
|
678
|
+
Characteristic.prototype.updateValue = function (value, callback, context) {
|
|
1710
679
|
if (value instanceof Error) {
|
|
1711
680
|
this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
|
|
1712
681
|
// noinspection JSDeprecatedSymbols
|
|
@@ -1724,7 +693,7 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1724
693
|
value = this.validateUserInput(value);
|
|
1725
694
|
}
|
|
1726
695
|
catch (error) {
|
|
1727
|
-
this.characteristicWarning(error
|
|
696
|
+
this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
1728
697
|
if (callback) {
|
|
1729
698
|
callback();
|
|
1730
699
|
}
|
|
@@ -1733,14 +702,14 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1733
702
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1734
703
|
// noinspection JSDeprecatedSymbols
|
|
1735
704
|
this.status = null;
|
|
1736
|
-
|
|
705
|
+
var oldValue = this.value;
|
|
1737
706
|
this.value = value;
|
|
1738
707
|
if (callback) {
|
|
1739
708
|
callback();
|
|
1740
709
|
}
|
|
1741
710
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
|
|
1742
711
|
return this; // for chaining
|
|
1743
|
-
}
|
|
712
|
+
};
|
|
1744
713
|
/**
|
|
1745
714
|
* This method acts similarly to {@link updateValue} by setting the current value of the characteristic
|
|
1746
715
|
* without calling any {@link CharacteristicEventTypes.SET} or {@link onSet} handlers.
|
|
@@ -1750,16 +719,16 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1750
719
|
* @param value - The new value.
|
|
1751
720
|
* @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler.
|
|
1752
721
|
*/
|
|
1753
|
-
sendEventNotification(value, context) {
|
|
722
|
+
Characteristic.prototype.sendEventNotification = function (value, context) {
|
|
1754
723
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1755
724
|
// noinspection JSDeprecatedSymbols
|
|
1756
725
|
this.status = null;
|
|
1757
726
|
value = this.validateUserInput(value);
|
|
1758
|
-
|
|
727
|
+
var oldValue = this.value;
|
|
1759
728
|
this.value = value;
|
|
1760
729
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
|
|
1761
730
|
return this; // for chaining
|
|
1762
|
-
}
|
|
731
|
+
};
|
|
1763
732
|
/**
|
|
1764
733
|
* Called when a HAP requests wants to know the current value of the characteristic.
|
|
1765
734
|
*
|
|
@@ -1767,118 +736,130 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1767
736
|
* @param context - Deprecated parameter. There for backwards compatibility.
|
|
1768
737
|
* @private Used by the Accessory to load the characteristic value
|
|
1769
738
|
*/
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
1818
|
-
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
1819
|
-
// noinspection JSDeprecatedSymbols
|
|
1820
|
-
this.status = error;
|
|
1821
|
-
}
|
|
1822
|
-
throw this.statusCode;
|
|
1823
|
-
}
|
|
1824
|
-
}
|
|
1825
|
-
if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
|
|
1826
|
-
if (this.statusCode) {
|
|
1827
|
-
throw this.statusCode;
|
|
1828
|
-
}
|
|
1829
|
-
try {
|
|
1830
|
-
return this.validateUserInput(this.value);
|
|
1831
|
-
}
|
|
1832
|
-
catch (error) {
|
|
1833
|
-
this.characteristicWarning(`An illegal value was supplied by setting \`value\` for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
|
|
1834
|
-
return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
1835
|
-
}
|
|
1836
|
-
}
|
|
1837
|
-
return new Promise((resolve, reject) => {
|
|
1838
|
-
try {
|
|
1839
|
-
this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)((status, value) => {
|
|
1840
|
-
if (status) {
|
|
1841
|
-
if (typeof status === "number") {
|
|
1842
|
-
const hapStatusError = new hapStatusError_1.HapStatusError(status);
|
|
739
|
+
Characteristic.prototype.handleGetRequest = function (connection, context) {
|
|
740
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
741
|
+
var value, oldValue, error_1, hapStatusError;
|
|
742
|
+
var _this = this;
|
|
743
|
+
return tslib_1.__generator(this, function (_a) {
|
|
744
|
+
switch (_a.label) {
|
|
745
|
+
case 0:
|
|
746
|
+
if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
|
|
747
|
+
throw -70405 /* HAPStatus.WRITE_ONLY_CHARACTERISTIC */;
|
|
748
|
+
}
|
|
749
|
+
if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
|
|
750
|
+
// special workaround for event only programmable switch event, which must always return null
|
|
751
|
+
return [2 /*return*/, null];
|
|
752
|
+
}
|
|
753
|
+
if (!this.getHandler) return [3 /*break*/, 4];
|
|
754
|
+
if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
|
|
755
|
+
this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
|
|
756
|
+
}
|
|
757
|
+
_a.label = 1;
|
|
758
|
+
case 1:
|
|
759
|
+
_a.trys.push([1, 3, , 4]);
|
|
760
|
+
return [4 /*yield*/, this.getHandler(context, connection)];
|
|
761
|
+
case 2:
|
|
762
|
+
value = _a.sent();
|
|
763
|
+
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
764
|
+
// noinspection JSDeprecatedSymbols
|
|
765
|
+
this.status = null;
|
|
766
|
+
try {
|
|
767
|
+
value = this.validateUserInput(value);
|
|
768
|
+
}
|
|
769
|
+
catch (error) {
|
|
770
|
+
this.characteristicWarning("An illegal value was supplied by the read handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
771
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
772
|
+
// noinspection JSDeprecatedSymbols
|
|
773
|
+
this.status = error;
|
|
774
|
+
return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
|
|
775
|
+
}
|
|
776
|
+
oldValue = this.value;
|
|
777
|
+
this.value = value;
|
|
778
|
+
if (oldValue !== value) { // emit a change event if necessary
|
|
779
|
+
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
|
|
780
|
+
}
|
|
781
|
+
return [2 /*return*/, value];
|
|
782
|
+
case 3:
|
|
783
|
+
error_1 = _a.sent();
|
|
784
|
+
if (typeof error_1 === "number") {
|
|
785
|
+
hapStatusError = new hapStatusError_1.HapStatusError(error_1);
|
|
1843
786
|
this.statusCode = hapStatusError.hapStatus;
|
|
1844
787
|
// noinspection JSDeprecatedSymbols
|
|
1845
788
|
this.status = hapStatusError;
|
|
1846
789
|
}
|
|
1847
|
-
else if (
|
|
1848
|
-
this.statusCode =
|
|
790
|
+
else if (error_1 instanceof hapStatusError_1.HapStatusError) {
|
|
791
|
+
this.statusCode = error_1.hapStatus;
|
|
1849
792
|
// noinspection JSDeprecatedSymbols
|
|
1850
|
-
this.status =
|
|
793
|
+
this.status = error_1;
|
|
1851
794
|
}
|
|
1852
795
|
else {
|
|
1853
|
-
|
|
1854
|
-
this.statusCode =
|
|
796
|
+
this.characteristicWarning("Unhandled error thrown inside read handler for characteristic: ".concat(error_1 === null || error_1 === void 0 ? void 0 : error_1.message), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error_1 === null || error_1 === void 0 ? void 0 : error_1.stack);
|
|
797
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
1855
798
|
// noinspection JSDeprecatedSymbols
|
|
1856
|
-
this.status =
|
|
799
|
+
this.status = error_1;
|
|
1857
800
|
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
801
|
+
throw this.statusCode;
|
|
802
|
+
case 4:
|
|
803
|
+
if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
|
|
804
|
+
if (this.statusCode) {
|
|
805
|
+
throw this.statusCode;
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
return [2 /*return*/, this.validateUserInput(this.value)];
|
|
809
|
+
}
|
|
810
|
+
catch (error) {
|
|
811
|
+
this.characteristicWarning("An illegal value was supplied by setting `value` for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
812
|
+
return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
816
|
+
try {
|
|
817
|
+
_this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)(function (status, value) {
|
|
818
|
+
if (status) {
|
|
819
|
+
if (typeof status === "number") {
|
|
820
|
+
var hapStatusError = new hapStatusError_1.HapStatusError(status);
|
|
821
|
+
_this.statusCode = hapStatusError.hapStatus;
|
|
822
|
+
// noinspection JSDeprecatedSymbols
|
|
823
|
+
_this.status = hapStatusError;
|
|
824
|
+
}
|
|
825
|
+
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
826
|
+
_this.statusCode = status.hapStatus;
|
|
827
|
+
// noinspection JSDeprecatedSymbols
|
|
828
|
+
_this.status = status;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
debug("[%s] Received error from get handler %s", _this.displayName, status.stack);
|
|
832
|
+
_this.statusCode = extractHAPStatusFromError(status);
|
|
833
|
+
// noinspection JSDeprecatedSymbols
|
|
834
|
+
_this.status = status;
|
|
835
|
+
}
|
|
836
|
+
reject(_this.statusCode);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
_this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
840
|
+
// noinspection JSDeprecatedSymbols
|
|
841
|
+
_this.status = null;
|
|
842
|
+
value = _this.validateUserInput(value);
|
|
843
|
+
var oldValue = _this.value;
|
|
844
|
+
_this.value = value;
|
|
845
|
+
resolve(value);
|
|
846
|
+
if (oldValue !== value) { // emit a change event if necessary
|
|
847
|
+
_this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
|
|
848
|
+
}
|
|
849
|
+
}), context, connection);
|
|
850
|
+
}
|
|
851
|
+
catch (error) {
|
|
852
|
+
_this.characteristicWarning("Unhandled error thrown inside read handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
853
|
+
_this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
854
|
+
// noinspection JSDeprecatedSymbols
|
|
855
|
+
_this.status = error;
|
|
856
|
+
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
857
|
+
}
|
|
858
|
+
})];
|
|
859
|
+
}
|
|
860
|
+
});
|
|
1880
861
|
});
|
|
1881
|
-
}
|
|
862
|
+
};
|
|
1882
863
|
/**
|
|
1883
864
|
* Called when a HAP requests update the current value of the characteristic.
|
|
1884
865
|
*
|
|
@@ -1890,147 +871,162 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
1890
871
|
* write response value is resolved.
|
|
1891
872
|
* @private
|
|
1892
873
|
*/
|
|
1893
|
-
|
|
1894
|
-
this
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
const oldValue = this.value;
|
|
1909
|
-
if (this.setHandler) {
|
|
1910
|
-
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
|
|
1911
|
-
this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
|
|
1912
|
-
}
|
|
1913
|
-
try {
|
|
1914
|
-
const writeResponse = await this.setHandler(value, context, connection);
|
|
1915
|
-
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1916
|
-
// noinspection JSDeprecatedSymbols
|
|
1917
|
-
this.status = null;
|
|
1918
|
-
if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
|
|
1919
|
-
this.value = this.validateUserInput(writeResponse);
|
|
1920
|
-
return this.value;
|
|
1921
|
-
}
|
|
1922
|
-
else {
|
|
1923
|
-
if (writeResponse != null) {
|
|
1924
|
-
this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
1925
|
-
}
|
|
1926
|
-
this.value = value;
|
|
1927
|
-
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
1928
|
-
return;
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
catch (error) {
|
|
1932
|
-
if (typeof error === "number") {
|
|
1933
|
-
const hapStatusError = new hapStatusError_1.HapStatusError(error);
|
|
1934
|
-
this.statusCode = hapStatusError.hapStatus;
|
|
1935
|
-
// noinspection JSDeprecatedSymbols
|
|
1936
|
-
this.status = hapStatusError;
|
|
1937
|
-
}
|
|
1938
|
-
else if (error instanceof hapStatusError_1.HapStatusError) {
|
|
1939
|
-
this.statusCode = error.hapStatus;
|
|
1940
|
-
// noinspection JSDeprecatedSymbols
|
|
1941
|
-
this.status = error;
|
|
1942
|
-
}
|
|
1943
|
-
else {
|
|
1944
|
-
this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
1945
|
-
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
1946
|
-
// noinspection JSDeprecatedSymbols
|
|
1947
|
-
this.status = error;
|
|
1948
|
-
}
|
|
1949
|
-
throw this.statusCode;
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
|
|
1953
|
-
this.value = value;
|
|
1954
|
-
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
1955
|
-
return Promise.resolve();
|
|
1956
|
-
}
|
|
1957
|
-
else {
|
|
1958
|
-
return new Promise((resolve, reject) => {
|
|
1959
|
-
try {
|
|
1960
|
-
this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)((status, writeResponse) => {
|
|
1961
|
-
if (status) {
|
|
1962
|
-
if (typeof status === "number") {
|
|
1963
|
-
const hapStatusError = new hapStatusError_1.HapStatusError(status);
|
|
1964
|
-
this.statusCode = hapStatusError.hapStatus;
|
|
1965
|
-
// noinspection JSDeprecatedSymbols
|
|
1966
|
-
this.status = hapStatusError;
|
|
1967
|
-
}
|
|
1968
|
-
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
1969
|
-
this.statusCode = status.hapStatus;
|
|
1970
|
-
// noinspection JSDeprecatedSymbols
|
|
1971
|
-
this.status = status;
|
|
874
|
+
Characteristic.prototype.handleSetRequest = function (value, connection, context) {
|
|
875
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
876
|
+
var oldValue, writeResponse, error_2, hapStatusError;
|
|
877
|
+
var _this = this;
|
|
878
|
+
return tslib_1.__generator(this, function (_a) {
|
|
879
|
+
switch (_a.label) {
|
|
880
|
+
case 0:
|
|
881
|
+
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
882
|
+
// noinspection JSDeprecatedSymbols
|
|
883
|
+
this.status = null;
|
|
884
|
+
if (connection !== undefined) {
|
|
885
|
+
// if connection is undefined, the set "request" comes from the setValue method.
|
|
886
|
+
// for setValue a value of "null" is allowed and checked via validateUserInput.
|
|
887
|
+
try {
|
|
888
|
+
value = this.validateClientSuppliedValue(value);
|
|
1972
889
|
}
|
|
1973
|
-
|
|
1974
|
-
debug("[
|
|
1975
|
-
|
|
1976
|
-
// noinspection JSDeprecatedSymbols
|
|
1977
|
-
this.status = status;
|
|
890
|
+
catch (e) {
|
|
891
|
+
debug("[".concat(this.displayName, "]"), e.message);
|
|
892
|
+
return [2 /*return*/, Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */)];
|
|
1978
893
|
}
|
|
1979
|
-
reject(this.statusCode);
|
|
1980
|
-
return;
|
|
1981
894
|
}
|
|
895
|
+
oldValue = this.value;
|
|
896
|
+
if (!this.setHandler) return [3 /*break*/, 4];
|
|
897
|
+
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
|
|
898
|
+
this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
|
|
899
|
+
}
|
|
900
|
+
_a.label = 1;
|
|
901
|
+
case 1:
|
|
902
|
+
_a.trys.push([1, 3, , 4]);
|
|
903
|
+
return [4 /*yield*/, this.setHandler(value, context, connection)];
|
|
904
|
+
case 2:
|
|
905
|
+
writeResponse = _a.sent();
|
|
1982
906
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1983
907
|
// noinspection JSDeprecatedSymbols
|
|
1984
908
|
this.status = null;
|
|
1985
909
|
if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
|
|
1986
|
-
// support write response simply by letting the implementor pass the response as second argument to the callback
|
|
1987
910
|
this.value = this.validateUserInput(writeResponse);
|
|
1988
|
-
|
|
911
|
+
return [2 /*return*/, this.value];
|
|
1989
912
|
}
|
|
1990
913
|
else {
|
|
1991
914
|
if (writeResponse != null) {
|
|
1992
915
|
this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
1993
916
|
}
|
|
1994
917
|
this.value = value;
|
|
1995
|
-
resolve();
|
|
1996
918
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
919
|
+
return [2 /*return*/];
|
|
1997
920
|
}
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
921
|
+
return [3 /*break*/, 4];
|
|
922
|
+
case 3:
|
|
923
|
+
error_2 = _a.sent();
|
|
924
|
+
if (typeof error_2 === "number") {
|
|
925
|
+
hapStatusError = new hapStatusError_1.HapStatusError(error_2);
|
|
926
|
+
this.statusCode = hapStatusError.hapStatus;
|
|
927
|
+
// noinspection JSDeprecatedSymbols
|
|
928
|
+
this.status = hapStatusError;
|
|
929
|
+
}
|
|
930
|
+
else if (error_2 instanceof hapStatusError_1.HapStatusError) {
|
|
931
|
+
this.statusCode = error_2.hapStatus;
|
|
932
|
+
// noinspection JSDeprecatedSymbols
|
|
933
|
+
this.status = error_2;
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
this.characteristicWarning("Unhandled error thrown inside write handler for characteristic: ".concat(error_2 === null || error_2 === void 0 ? void 0 : error_2.message), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error_2 === null || error_2 === void 0 ? void 0 : error_2.stack);
|
|
937
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
938
|
+
// noinspection JSDeprecatedSymbols
|
|
939
|
+
this.status = error_2;
|
|
940
|
+
}
|
|
941
|
+
throw this.statusCode;
|
|
942
|
+
case 4:
|
|
943
|
+
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
|
|
944
|
+
this.value = value;
|
|
945
|
+
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
946
|
+
return [2 /*return*/, Promise.resolve()];
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
950
|
+
try {
|
|
951
|
+
_this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)(function (status, writeResponse) {
|
|
952
|
+
if (status) {
|
|
953
|
+
if (typeof status === "number") {
|
|
954
|
+
var hapStatusError = new hapStatusError_1.HapStatusError(status);
|
|
955
|
+
_this.statusCode = hapStatusError.hapStatus;
|
|
956
|
+
// noinspection JSDeprecatedSymbols
|
|
957
|
+
_this.status = hapStatusError;
|
|
958
|
+
}
|
|
959
|
+
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
960
|
+
_this.statusCode = status.hapStatus;
|
|
961
|
+
// noinspection JSDeprecatedSymbols
|
|
962
|
+
_this.status = status;
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
debug("[%s] Received error from set handler %s", _this.displayName, status.stack);
|
|
966
|
+
_this.statusCode = extractHAPStatusFromError(status);
|
|
967
|
+
// noinspection JSDeprecatedSymbols
|
|
968
|
+
_this.status = status;
|
|
969
|
+
}
|
|
970
|
+
reject(_this.statusCode);
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
_this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
974
|
+
// noinspection JSDeprecatedSymbols
|
|
975
|
+
_this.status = null;
|
|
976
|
+
if (writeResponse != null && _this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
|
|
977
|
+
// support write response simply by letting the implementor pass the response as second argument to the callback
|
|
978
|
+
_this.value = _this.validateUserInput(writeResponse);
|
|
979
|
+
resolve(_this.value);
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
if (writeResponse != null) {
|
|
983
|
+
_this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
984
|
+
}
|
|
985
|
+
_this.value = value;
|
|
986
|
+
resolve();
|
|
987
|
+
_this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
988
|
+
}
|
|
989
|
+
}), context, connection);
|
|
990
|
+
}
|
|
991
|
+
catch (error) {
|
|
992
|
+
_this.characteristicWarning("Unhandled error thrown inside write handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
|
|
993
|
+
_this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
994
|
+
// noinspection JSDeprecatedSymbols
|
|
995
|
+
_this.status = error;
|
|
996
|
+
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
997
|
+
}
|
|
998
|
+
})];
|
|
999
|
+
}
|
|
1000
|
+
return [2 /*return*/];
|
|
2006
1001
|
}
|
|
2007
1002
|
});
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
1003
|
+
});
|
|
1004
|
+
};
|
|
2010
1005
|
/**
|
|
2011
1006
|
* Called once a HomeKit controller subscribes to events of this characteristic.
|
|
2012
1007
|
* @private
|
|
2013
1008
|
*/
|
|
2014
|
-
subscribe() {
|
|
1009
|
+
Characteristic.prototype.subscribe = function () {
|
|
2015
1010
|
if (this.subscriptions === 0) {
|
|
2016
1011
|
this.emit("subscribe" /* CharacteristicEventTypes.SUBSCRIBE */);
|
|
2017
1012
|
}
|
|
2018
1013
|
this.subscriptions++;
|
|
2019
|
-
}
|
|
1014
|
+
};
|
|
2020
1015
|
/**
|
|
2021
1016
|
* Called once a HomeKit controller unsubscribe to events of this characteristic or a HomeKit controller
|
|
2022
1017
|
* which was subscribed to this characteristic disconnects.
|
|
2023
1018
|
* @private
|
|
2024
1019
|
*/
|
|
2025
|
-
unsubscribe() {
|
|
2026
|
-
|
|
1020
|
+
Characteristic.prototype.unsubscribe = function () {
|
|
1021
|
+
var wasOne = this.subscriptions === 1;
|
|
2027
1022
|
this.subscriptions--;
|
|
2028
1023
|
this.subscriptions = Math.max(this.subscriptions, 0);
|
|
2029
1024
|
if (wasOne) {
|
|
2030
1025
|
this.emit("unsubscribe" /* CharacteristicEventTypes.UNSUBSCRIBE */);
|
|
2031
1026
|
}
|
|
2032
|
-
}
|
|
2033
|
-
getDefaultValue() {
|
|
1027
|
+
};
|
|
1028
|
+
Characteristic.prototype.getDefaultValue = function () {
|
|
1029
|
+
var _a;
|
|
2034
1030
|
// noinspection JSDeprecatedSymbols
|
|
2035
1031
|
switch (this.props.format) {
|
|
2036
1032
|
case "bool" /* Formats.BOOL */:
|
|
@@ -2066,7 +1062,7 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2066
1062
|
case Characteristic.CurrentTemperature.UUID:
|
|
2067
1063
|
return 0; // some existing integrations expect this to be 0 by default
|
|
2068
1064
|
default: {
|
|
2069
|
-
if (this.props.validValues
|
|
1065
|
+
if (((_a = this.props.validValues) === null || _a === void 0 ? void 0 : _a.length) && typeof this.props.validValues[0] === "number") {
|
|
2070
1066
|
return this.props.validValues[0];
|
|
2071
1067
|
}
|
|
2072
1068
|
if (typeof this.props.minValue === "number" && Number.isFinite(this.props.minValue)) {
|
|
@@ -2078,16 +1074,16 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2078
1074
|
default:
|
|
2079
1075
|
return 0;
|
|
2080
1076
|
}
|
|
2081
|
-
}
|
|
1077
|
+
};
|
|
2082
1078
|
/**
|
|
2083
1079
|
* Checks if the value received from the HAP request is valid.
|
|
2084
1080
|
* If returned false the received value is not valid and {@link HAPStatus.INVALID_VALUE_IN_REQUEST}
|
|
2085
1081
|
* must be returned.
|
|
2086
1082
|
* @param value - Value supplied by the HomeKit controller
|
|
2087
1083
|
*/
|
|
2088
|
-
validateClientSuppliedValue(value) {
|
|
1084
|
+
Characteristic.prototype.validateClientSuppliedValue = function (value) {
|
|
2089
1085
|
if (value == null) {
|
|
2090
|
-
throw new Error(
|
|
1086
|
+
throw new Error("Client supplied invalid value for ".concat(this.props.format, ": ").concat(value));
|
|
2091
1087
|
}
|
|
2092
1088
|
switch (this.props.format) {
|
|
2093
1089
|
case "bool" /* Formats.BOOL */: {
|
|
@@ -2097,7 +1093,7 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2097
1093
|
if (typeof value === "number" && (value === 1 || value === 0)) {
|
|
2098
1094
|
return Boolean(value);
|
|
2099
1095
|
}
|
|
2100
|
-
throw new Error(
|
|
1096
|
+
throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
|
|
2101
1097
|
}
|
|
2102
1098
|
case "int" /* Formats.INT */:
|
|
2103
1099
|
case "float" /* Formats.FLOAT */:
|
|
@@ -2109,58 +1105,58 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2109
1105
|
value = value ? 1 : 0;
|
|
2110
1106
|
}
|
|
2111
1107
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
2112
|
-
throw new Error(
|
|
1108
|
+
throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
|
|
2113
1109
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
1110
|
+
var numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
|
|
1111
|
+
var numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
|
|
2116
1112
|
if (typeof numericMin === "number" && value < numericMin) {
|
|
2117
|
-
throw new Error(
|
|
1113
|
+
throw new Error("Client supplied value of ".concat(value, " is less than the minimum allowed value of ").concat(numericMin));
|
|
2118
1114
|
}
|
|
2119
1115
|
if (typeof numericMax === "number" && value > numericMax) {
|
|
2120
|
-
throw new Error(
|
|
1116
|
+
throw new Error("Client supplied value of ".concat(value, " is greater than the maximum allowed value of ").concat(numericMax));
|
|
2121
1117
|
}
|
|
2122
1118
|
if (this.props.validValues && !this.props.validValues.includes(value)) {
|
|
2123
|
-
throw new Error(
|
|
1119
|
+
throw new Error("Client supplied value of ".concat(value, " is not in ").concat(this.props.validValues.toString()));
|
|
2124
1120
|
}
|
|
2125
1121
|
if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
|
|
2126
1122
|
if (value < this.props.validValueRanges[0]) {
|
|
2127
|
-
throw new Error(
|
|
1123
|
+
throw new Error("Client supplied value of ".concat(value, " is less than the minimum allowed value of ").concat(this.props.validValueRanges[0]));
|
|
2128
1124
|
}
|
|
2129
1125
|
if (value > this.props.validValueRanges[1]) {
|
|
2130
|
-
throw new Error(
|
|
1126
|
+
throw new Error("Client supplied value of ".concat(value, " is greater than the maximum allowed value of ").concat(this.props.validValueRanges[1]));
|
|
2131
1127
|
}
|
|
2132
1128
|
}
|
|
2133
1129
|
return value;
|
|
2134
1130
|
}
|
|
2135
1131
|
case "string" /* Formats.STRING */: {
|
|
2136
1132
|
if (typeof value !== "string") {
|
|
2137
|
-
throw new Error(
|
|
1133
|
+
throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
|
|
2138
1134
|
}
|
|
2139
|
-
|
|
1135
|
+
var maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
|
|
2140
1136
|
if (value.length > maxLength) {
|
|
2141
|
-
throw new Error(
|
|
1137
|
+
throw new Error("Client supplied value length of ".concat(value.length, " exceeds maximum length allowed of ").concat(maxLength));
|
|
2142
1138
|
}
|
|
2143
1139
|
return value;
|
|
2144
1140
|
}
|
|
2145
1141
|
case "data" /* Formats.DATA */: {
|
|
2146
1142
|
if (typeof value !== "string") {
|
|
2147
|
-
throw new Error(
|
|
1143
|
+
throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
|
|
2148
1144
|
}
|
|
2149
1145
|
// we don't validate base64 here
|
|
2150
|
-
|
|
1146
|
+
var maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
|
|
2151
1147
|
if (value.length > maxLength) {
|
|
2152
|
-
throw new Error(
|
|
1148
|
+
throw new Error("Client supplied value length of ".concat(value.length, " exceeds maximum length allowed of ").concat(maxLength));
|
|
2153
1149
|
}
|
|
2154
1150
|
return value;
|
|
2155
1151
|
}
|
|
2156
1152
|
case "tlv8" /* Formats.TLV8 */:
|
|
2157
1153
|
if (typeof value !== "string") {
|
|
2158
|
-
throw new Error(
|
|
1154
|
+
throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
|
|
2159
1155
|
}
|
|
2160
1156
|
return value;
|
|
2161
1157
|
}
|
|
2162
1158
|
return value;
|
|
2163
|
-
}
|
|
1159
|
+
};
|
|
2164
1160
|
/**
|
|
2165
1161
|
* Checks if the value received from the API call is valid.
|
|
2166
1162
|
* It adjusts the value where it makes sense, prints a warning where values may be rejected with an error
|
|
@@ -2169,7 +1165,9 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2169
1165
|
* @param value - The value received from the API call
|
|
2170
1166
|
* @param warningType - Optionally defines the warning type to use when raising a {@link CharacteristicEventTypes.CHARACTERISTIC_WARNING}.
|
|
2171
1167
|
*/
|
|
2172
|
-
validateUserInput(value, warningType
|
|
1168
|
+
Characteristic.prototype.validateUserInput = function (value, warningType) {
|
|
1169
|
+
var _a;
|
|
1170
|
+
if (warningType === void 0) { warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
|
|
2173
1171
|
if (value === null) {
|
|
2174
1172
|
if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
|
|
2175
1173
|
this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
@@ -2230,12 +1228,12 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2230
1228
|
value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
|
|
2231
1229
|
}
|
|
2232
1230
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
2233
|
-
this.characteristicWarning(
|
|
1231
|
+
this.characteristicWarning("characteristic value expected valid finite number and received \"".concat(value, "\" (").concat(typeof value, ")"), warningType);
|
|
2234
1232
|
value = typeof this.value === "number" ? this.value : this.props.minValue || 0;
|
|
2235
1233
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
1234
|
+
var numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
|
|
1235
|
+
var numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
|
|
1236
|
+
var stepValue = undefined;
|
|
2239
1237
|
if (this.props.format === "float" /* Formats.FLOAT */) {
|
|
2240
1238
|
stepValue = this.props.minStep;
|
|
2241
1239
|
}
|
|
@@ -2243,30 +1241,28 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2243
1241
|
stepValue = maxWithUndefined(this.props.minStep, 1);
|
|
2244
1242
|
}
|
|
2245
1243
|
if (stepValue != null && stepValue > 0) {
|
|
2246
|
-
|
|
1244
|
+
var minValue = this.props.minValue != null ? this.props.minValue : 0;
|
|
2247
1245
|
value = stepValue * Math.round((value - minValue) / stepValue) + minValue;
|
|
2248
1246
|
}
|
|
2249
1247
|
if (numericMin != null && value < numericMin) {
|
|
2250
|
-
this.characteristicWarning(
|
|
1248
|
+
this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " exceeded minimum of ").concat(numericMin), warningType);
|
|
2251
1249
|
value = numericMin;
|
|
2252
1250
|
}
|
|
2253
1251
|
if (numericMax != null && value > numericMax) {
|
|
2254
|
-
this.characteristicWarning(
|
|
1252
|
+
this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " exceeded maximum of ").concat(numericMax), warningType);
|
|
2255
1253
|
value = numericMax;
|
|
2256
1254
|
}
|
|
2257
1255
|
if (this.props.validValues && !this.props.validValues.includes(value)) {
|
|
2258
|
-
this.characteristicWarning(
|
|
1256
|
+
this.characteristicWarning("characteristic value ".concat(value, " is not contained in valid values array"), warningType);
|
|
2259
1257
|
return this.props.validValues.includes(this.value) ? this.value : (this.props.validValues[0] || 0);
|
|
2260
1258
|
}
|
|
2261
1259
|
if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
|
|
2262
1260
|
if (value < this.props.validValueRanges[0]) {
|
|
2263
|
-
this.characteristicWarning(
|
|
2264
|
-
+ `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
|
|
1261
|
+
this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " not contained in valid value range of ").concat(this.props.validValueRanges, ", supplying illegal values will throw errors in the future"), warningType);
|
|
2265
1262
|
value = this.props.validValueRanges[0];
|
|
2266
1263
|
}
|
|
2267
1264
|
else if (value > this.props.validValueRanges[1]) {
|
|
2268
|
-
this.characteristicWarning(
|
|
2269
|
-
+ `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
|
|
1265
|
+
this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " not contained in valid value range of ").concat(this.props.validValueRanges, ", supplying illegal values will throw errors in the future"), warningType);
|
|
2270
1266
|
value = this.props.validValueRanges[1];
|
|
2271
1267
|
}
|
|
2272
1268
|
}
|
|
@@ -2284,18 +1280,14 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2284
1280
|
}
|
|
2285
1281
|
// mirrors the case value = null at the beginning
|
|
2286
1282
|
if (value.length <= 1 && (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID)) {
|
|
2287
|
-
this.characteristicWarning(
|
|
2288
|
-
+ ` HomeKit will reject this accessory, ignoring new value ${warningType}`);
|
|
1283
|
+
this.characteristicWarning("[".concat(this.displayName, "] characteristic must have a length of more than 1 character otherwise HomeKit will reject this accessory, ignoring new value"), warningType);
|
|
2289
1284
|
return this.value; // just return the current value
|
|
2290
1285
|
}
|
|
2291
|
-
|
|
1286
|
+
var maxLength = (_a = this.props.maxLen) !== null && _a !== void 0 ? _a : 64; // default is 64 (max is 256 which is set in setProps)
|
|
2292
1287
|
if (value.length > maxLength) {
|
|
2293
|
-
this.characteristicWarning(
|
|
1288
|
+
this.characteristicWarning("characteristic was supplied illegal value: string '".concat(value, "' exceeded max length of ").concat(maxLength), warningType);
|
|
2294
1289
|
value = value.substring(0, maxLength);
|
|
2295
1290
|
}
|
|
2296
|
-
if (value.length > 0 && this.UUID === Characteristic.ConfiguredName.UUID) {
|
|
2297
|
-
(0, checkName_1.checkName)(this.displayName, "ConfiguredName", value);
|
|
2298
|
-
}
|
|
2299
1291
|
return value;
|
|
2300
1292
|
}
|
|
2301
1293
|
case "data" /* Formats.DATA */:
|
|
@@ -2320,88 +1312,109 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2320
1312
|
return this.value;
|
|
2321
1313
|
}
|
|
2322
1314
|
return value;
|
|
2323
|
-
}
|
|
1315
|
+
};
|
|
2324
1316
|
/**
|
|
2325
1317
|
* @private used to assign iid to characteristic
|
|
2326
1318
|
*/
|
|
2327
|
-
_assignID(identifierCache, accessoryName, serviceUUID, serviceSubtype) {
|
|
1319
|
+
Characteristic.prototype._assignID = function (identifierCache, accessoryName, serviceUUID, serviceSubtype) {
|
|
2328
1320
|
// generate our IID based on our UUID
|
|
2329
1321
|
this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
|
|
2330
|
-
}
|
|
2331
|
-
characteristicWarning(message, type
|
|
1322
|
+
};
|
|
1323
|
+
Characteristic.prototype.characteristicWarning = function (message, type, stack) {
|
|
1324
|
+
if (type === void 0) { type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
|
|
1325
|
+
if (stack === void 0) { stack = new Error().stack; }
|
|
2332
1326
|
this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
|
|
2333
|
-
}
|
|
1327
|
+
};
|
|
2334
1328
|
/**
|
|
2335
1329
|
* @param event
|
|
2336
1330
|
* @private
|
|
2337
1331
|
*/
|
|
2338
|
-
removeAllListeners(event) {
|
|
1332
|
+
Characteristic.prototype.removeAllListeners = function (event) {
|
|
2339
1333
|
if (!event) {
|
|
2340
1334
|
this.removeOnGet();
|
|
2341
1335
|
this.removeOnSet();
|
|
2342
1336
|
}
|
|
2343
|
-
return
|
|
2344
|
-
}
|
|
1337
|
+
return _super.prototype.removeAllListeners.call(this, event);
|
|
1338
|
+
};
|
|
2345
1339
|
/**
|
|
2346
1340
|
* @param characteristic
|
|
2347
1341
|
* @private
|
|
2348
1342
|
*/
|
|
2349
|
-
replaceBy(characteristic) {
|
|
1343
|
+
Characteristic.prototype.replaceBy = function (characteristic) {
|
|
1344
|
+
var _this = this;
|
|
2350
1345
|
this.props = characteristic.props;
|
|
2351
1346
|
this.updateValue(characteristic.value);
|
|
2352
|
-
|
|
1347
|
+
var getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
|
|
2353
1348
|
if (getListeners.length) {
|
|
2354
1349
|
// the callback can only be called once, so we remove all old listeners
|
|
2355
1350
|
this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
|
|
2356
1351
|
// @ts-expect-error: force type
|
|
2357
|
-
getListeners.forEach(listener
|
|
1352
|
+
getListeners.forEach(function (listener) { return _this.addListener("get" /* CharacteristicEventTypes.GET */, listener); });
|
|
2358
1353
|
}
|
|
2359
1354
|
this.removeOnGet();
|
|
2360
1355
|
if (characteristic.getHandler) {
|
|
2361
1356
|
this.onGet(characteristic.getHandler);
|
|
2362
1357
|
}
|
|
2363
|
-
|
|
1358
|
+
var setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
|
|
2364
1359
|
if (setListeners.length) {
|
|
2365
1360
|
// the callback can only be called once, so we remove all old listeners
|
|
2366
1361
|
this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
|
|
2367
1362
|
// @ts-expect-error: force type
|
|
2368
|
-
setListeners.forEach(listener
|
|
1363
|
+
setListeners.forEach(function (listener) { return _this.addListener("set" /* CharacteristicEventTypes.SET */, listener); });
|
|
2369
1364
|
}
|
|
2370
1365
|
this.removeOnSet();
|
|
2371
1366
|
if (characteristic.setHandler) {
|
|
2372
1367
|
this.onSet(characteristic.setHandler);
|
|
2373
1368
|
}
|
|
2374
|
-
}
|
|
1369
|
+
};
|
|
2375
1370
|
/**
|
|
2376
1371
|
* Returns a JSON representation of this characteristic suitable for delivering to HAP clients.
|
|
2377
1372
|
* @private used to generate response to /accessories query
|
|
2378
1373
|
*/
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
1374
|
+
Characteristic.prototype.toHAP = function (connection_1) {
|
|
1375
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (connection, contactGetHandlers) {
|
|
1376
|
+
var object, value, _a;
|
|
1377
|
+
var _this = this;
|
|
1378
|
+
if (contactGetHandlers === void 0) { contactGetHandlers = true; }
|
|
1379
|
+
return tslib_1.__generator(this, function (_b) {
|
|
1380
|
+
switch (_b.label) {
|
|
1381
|
+
case 0:
|
|
1382
|
+
object = this.internalHAPRepresentation();
|
|
1383
|
+
if (!!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) return [3 /*break*/, 1];
|
|
1384
|
+
object.value = undefined;
|
|
1385
|
+
return [3 /*break*/, 6];
|
|
1386
|
+
case 1:
|
|
1387
|
+
if (!(this.UUID === Characteristic.ProgrammableSwitchEvent.UUID)) return [3 /*break*/, 2];
|
|
1388
|
+
// special workaround for event only programmable switch event, which must always return null
|
|
1389
|
+
object.value = null;
|
|
1390
|
+
return [3 /*break*/, 6];
|
|
1391
|
+
case 2:
|
|
1392
|
+
if (!contactGetHandlers) return [3 /*break*/, 4];
|
|
1393
|
+
return [4 /*yield*/, this.handleGetRequest(connection).catch(function () {
|
|
1394
|
+
var value = _this.getDefaultValue();
|
|
1395
|
+
debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", _this.displayName, "".concat(value));
|
|
1396
|
+
return value; // use default value
|
|
1397
|
+
})];
|
|
1398
|
+
case 3:
|
|
1399
|
+
_a = _b.sent();
|
|
1400
|
+
return [3 /*break*/, 5];
|
|
1401
|
+
case 4:
|
|
1402
|
+
_a = this.value;
|
|
1403
|
+
_b.label = 5;
|
|
1404
|
+
case 5:
|
|
1405
|
+
value = _a;
|
|
1406
|
+
object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
|
|
1407
|
+
_b.label = 6;
|
|
1408
|
+
case 6: return [2 /*return*/, object];
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
});
|
|
1412
|
+
};
|
|
2400
1413
|
/**
|
|
2401
1414
|
* Returns a JSON representation of this characteristic without the value.
|
|
2402
1415
|
* @private used to generate the config hash
|
|
2403
1416
|
*/
|
|
2404
|
-
internalHAPRepresentation() {
|
|
1417
|
+
Characteristic.prototype.internalHAPRepresentation = function () {
|
|
2405
1418
|
(0, assert_1.default)(this.iid, "iid cannot be undefined for characteristic '" + this.displayName + "'");
|
|
2406
1419
|
// TODO include the value for characteristics of the AccessoryInformation service
|
|
2407
1420
|
return {
|
|
@@ -2420,15 +1433,15 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2420
1433
|
"valid-values": this.props.validValues,
|
|
2421
1434
|
"valid-values-range": this.props.validValueRanges,
|
|
2422
1435
|
};
|
|
2423
|
-
}
|
|
1436
|
+
};
|
|
2424
1437
|
/**
|
|
2425
1438
|
* Serialize characteristic into json string.
|
|
2426
1439
|
*
|
|
2427
1440
|
* @param characteristic - Characteristic object.
|
|
2428
1441
|
* @private used to store characteristic on disk
|
|
2429
1442
|
*/
|
|
2430
|
-
|
|
2431
|
-
|
|
1443
|
+
Characteristic.serialize = function (characteristic) {
|
|
1444
|
+
var constructorName;
|
|
2432
1445
|
if (characteristic.constructor.name !== "Characteristic") {
|
|
2433
1446
|
constructorName = characteristic.constructor.name;
|
|
2434
1447
|
}
|
|
@@ -2440,18 +1453,18 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2440
1453
|
value: characteristic.value,
|
|
2441
1454
|
props: (0, clone_1.clone)({}, characteristic.props),
|
|
2442
1455
|
};
|
|
2443
|
-
}
|
|
1456
|
+
};
|
|
2444
1457
|
/**
|
|
2445
1458
|
* Deserialize characteristic from json string.
|
|
2446
1459
|
*
|
|
2447
1460
|
* @param json - Json string representing a characteristic.
|
|
2448
1461
|
* @private used to recreate characteristic from disk
|
|
2449
1462
|
*/
|
|
2450
|
-
|
|
2451
|
-
|
|
1463
|
+
Characteristic.deserialize = function (json) {
|
|
1464
|
+
var characteristic;
|
|
2452
1465
|
if (json.constructorName && json.constructorName.charAt(0).toUpperCase() === json.constructorName.charAt(0)
|
|
2453
1466
|
&& Characteristic[json.constructorName]) { // MUST start with uppercase character and must exist on Characteristic object
|
|
2454
|
-
|
|
1467
|
+
var constructor = Characteristic[json.constructorName];
|
|
2455
1468
|
characteristic = new constructor();
|
|
2456
1469
|
characteristic.displayName = json.displayName;
|
|
2457
1470
|
characteristic.setProps(json.props);
|
|
@@ -2461,8 +1474,24 @@ class Characteristic extends events_1.EventEmitter {
|
|
|
2461
1474
|
}
|
|
2462
1475
|
characteristic.value = json.value;
|
|
2463
1476
|
return characteristic;
|
|
2464
|
-
}
|
|
2465
|
-
|
|
1477
|
+
};
|
|
1478
|
+
/**
|
|
1479
|
+
* @deprecated Please use the Formats const enum above.
|
|
1480
|
+
*/
|
|
1481
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1482
|
+
Characteristic.Formats = Formats;
|
|
1483
|
+
/**
|
|
1484
|
+
* @deprecated Please use the Units const enum above.
|
|
1485
|
+
*/
|
|
1486
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1487
|
+
Characteristic.Units = Units;
|
|
1488
|
+
/**
|
|
1489
|
+
* @deprecated Please use the Perms const enum above.
|
|
1490
|
+
*/
|
|
1491
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1492
|
+
Characteristic.Perms = Perms;
|
|
1493
|
+
return Characteristic;
|
|
1494
|
+
}(events_1.EventEmitter));
|
|
2466
1495
|
exports.Characteristic = Characteristic;
|
|
2467
1496
|
// We have a cyclic dependency problem. Within this file we have the definitions of "./definitions" as
|
|
2468
1497
|
// type imports only (in order to define the static properties). Setting those properties is done outside
|