hap-nodejs 0.12.3-beta.11 → 0.12.3-beta.12
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/dist/BridgedCore.js +14 -14
- package/dist/BridgedCore.js.map +1 -1
- package/dist/Core.js +14 -14
- 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 +292 -373
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +15 -21
- 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 +26 -26
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +45 -48
- 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 +36 -47
- 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 +780 -1093
- 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 +392 -524
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.js +6 -10
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.js +1465 -501
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.js +215 -265
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.js +519 -322
- 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 +112 -104
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +284 -257
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +318 -381
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.js +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +198 -209
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.js +190 -249
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/DoorbellController.js +38 -39
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.js +343 -401
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.js +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +56 -57
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +259 -304
- 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 +252 -269
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.js +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +2089 -2858
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +864 -1096
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +383 -679
- 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 +101 -136
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.js +86 -89
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.js +15 -16
- 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 +40 -44
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +2 -1
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +7 -11
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.js +5 -27
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.js +8 -12
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.js +288 -384
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.js +31 -32
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.js +9 -12
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.js +32 -53
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.js +3 -8
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.js +8 -13
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.js +2 -3
- 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 +57 -76
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.js +15 -19
- package/dist/lib/util/uuid.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const HAPServer_1 = require("./HAPServer");
|
|
9
|
+
const clone_1 = require("./util/clone");
|
|
10
|
+
const hapStatusError_1 = require("./util/hapStatusError");
|
|
11
|
+
const once_1 = require("./util/once");
|
|
12
|
+
const request_util_1 = require("./util/request-util");
|
|
13
|
+
const uuid_1 = require("./util/uuid");
|
|
14
|
+
const checkName_1 = require("./util/checkName");
|
|
15
|
+
const debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
|
|
16
16
|
/**
|
|
17
17
|
* @group Characteristic
|
|
18
18
|
*/
|
|
@@ -182,88 +182,50 @@ var CharacteristicEventTypes;
|
|
|
182
182
|
/**
|
|
183
183
|
* @group Characteristic
|
|
184
184
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
class ValidValuesIterable {
|
|
186
|
+
props;
|
|
187
|
+
constructor(props) {
|
|
187
188
|
(0, assert_1.default)((0, request_util_1.isNumericFormat)(props.format), "Cannot instantiate valid values iterable when format is not numeric. Found " + props.format);
|
|
188
189
|
this.props = props;
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
switch (_d.label) {
|
|
195
|
-
case 0:
|
|
196
|
-
if (!this.props.validValues) return [3 /*break*/, 9];
|
|
197
|
-
_d.label = 1;
|
|
198
|
-
case 1:
|
|
199
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
200
|
-
_a = tslib_1.__values(this.props.validValues), _b = _a.next();
|
|
201
|
-
_d.label = 2;
|
|
202
|
-
case 2:
|
|
203
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
204
|
-
value = _b.value;
|
|
205
|
-
return [4 /*yield*/, value];
|
|
206
|
-
case 3:
|
|
207
|
-
_d.sent();
|
|
208
|
-
_d.label = 4;
|
|
209
|
-
case 4:
|
|
210
|
-
_b = _a.next();
|
|
211
|
-
return [3 /*break*/, 2];
|
|
212
|
-
case 5: return [3 /*break*/, 8];
|
|
213
|
-
case 6:
|
|
214
|
-
e_1_1 = _d.sent();
|
|
215
|
-
e_1 = { error: e_1_1 };
|
|
216
|
-
return [3 /*break*/, 8];
|
|
217
|
-
case 7:
|
|
218
|
-
try {
|
|
219
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
220
|
-
}
|
|
221
|
-
finally { if (e_1) throw e_1.error; }
|
|
222
|
-
return [7 /*endfinally*/];
|
|
223
|
-
case 8: return [3 /*break*/, 13];
|
|
224
|
-
case 9:
|
|
225
|
-
min = 0;
|
|
226
|
-
max = void 0;
|
|
227
|
-
stepValue = 1;
|
|
228
|
-
if (this.props.validValueRanges) {
|
|
229
|
-
min = this.props.validValueRanges[0];
|
|
230
|
-
max = this.props.validValueRanges[1];
|
|
231
|
-
}
|
|
232
|
-
else if (this.props.minValue != null && this.props.maxValue != null) {
|
|
233
|
-
min = this.props.minValue;
|
|
234
|
-
max = this.props.maxValue;
|
|
235
|
-
if (this.props.minStep != null) {
|
|
236
|
-
stepValue = this.props.minStep;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
|
|
240
|
-
max = (0, request_util_1.numericUpperBound)(this.props.format);
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
|
|
244
|
-
}
|
|
245
|
-
i = min;
|
|
246
|
-
_d.label = 10;
|
|
247
|
-
case 10:
|
|
248
|
-
if (!(i <= max)) return [3 /*break*/, 13];
|
|
249
|
-
return [4 /*yield*/, i];
|
|
250
|
-
case 11:
|
|
251
|
-
_d.sent();
|
|
252
|
-
_d.label = 12;
|
|
253
|
-
case 12:
|
|
254
|
-
i += stepValue;
|
|
255
|
-
return [3 /*break*/, 10];
|
|
256
|
-
case 13: return [2 /*return*/];
|
|
191
|
+
*[Symbol.iterator]() {
|
|
192
|
+
if (this.props.validValues) {
|
|
193
|
+
for (const value of this.props.validValues) {
|
|
194
|
+
yield value;
|
|
257
195
|
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
let min = 0; // default is zero for all the uint types
|
|
199
|
+
let max;
|
|
200
|
+
let stepValue = 1;
|
|
201
|
+
if (this.props.validValueRanges) {
|
|
202
|
+
min = this.props.validValueRanges[0];
|
|
203
|
+
max = this.props.validValueRanges[1];
|
|
204
|
+
}
|
|
205
|
+
else if (this.props.minValue != null && this.props.maxValue != null) {
|
|
206
|
+
min = this.props.minValue;
|
|
207
|
+
max = this.props.maxValue;
|
|
208
|
+
if (this.props.minStep != null) {
|
|
209
|
+
stepValue = this.props.minStep;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
|
|
213
|
+
max = (0, request_util_1.numericUpperBound)(this.props.format);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
|
|
217
|
+
}
|
|
218
|
+
for (let i = min; i <= max; i += stepValue) {
|
|
219
|
+
yield i;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const numberPattern = /^-?\d+$/;
|
|
263
225
|
function extractHAPStatusFromError(error) {
|
|
264
|
-
|
|
226
|
+
let errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
265
227
|
if (numberPattern.test(error.message)) {
|
|
266
|
-
|
|
228
|
+
const value = parseInt(error.message, 10);
|
|
267
229
|
if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
|
|
268
230
|
errorValue = value;
|
|
269
231
|
}
|
|
@@ -305,30 +267,1098 @@ function minWithUndefined(a, b) {
|
|
|
305
267
|
* @group Characteristic
|
|
306
268
|
*/
|
|
307
269
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
270
|
+
class Characteristic extends events_1.EventEmitter {
|
|
271
|
+
/**
|
|
272
|
+
* @deprecated Please use the Formats const enum above.
|
|
273
|
+
*/
|
|
274
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
275
|
+
static Formats = Formats;
|
|
276
|
+
/**
|
|
277
|
+
* @deprecated Please use the Units const enum above.
|
|
278
|
+
*/
|
|
279
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
280
|
+
static Units = Units;
|
|
281
|
+
/**
|
|
282
|
+
* @deprecated Please use the Perms const enum above.
|
|
283
|
+
*/
|
|
284
|
+
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
285
|
+
static Perms = Perms;
|
|
286
|
+
// Pattern below is for automatic detection of the section of defined characteristics. Used by the generator
|
|
287
|
+
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
|
288
|
+
/**
|
|
289
|
+
* @group Characteristic Definitions
|
|
290
|
+
*/
|
|
291
|
+
static AccessCodeControlPoint;
|
|
292
|
+
/**
|
|
293
|
+
* @group Characteristic Definitions
|
|
294
|
+
*/
|
|
295
|
+
static AccessCodeSupportedConfiguration;
|
|
296
|
+
/**
|
|
297
|
+
* @group Characteristic Definitions
|
|
298
|
+
*/
|
|
299
|
+
static AccessControlLevel;
|
|
300
|
+
/**
|
|
301
|
+
* @group Characteristic Definitions
|
|
302
|
+
*/
|
|
303
|
+
static AccessoryFlags;
|
|
304
|
+
/**
|
|
305
|
+
* @group Characteristic Definitions
|
|
306
|
+
*/
|
|
307
|
+
static AccessoryIdentifier;
|
|
308
|
+
/**
|
|
309
|
+
* @group Characteristic Definitions
|
|
310
|
+
*/
|
|
311
|
+
static Active;
|
|
312
|
+
/**
|
|
313
|
+
* @group Characteristic Definitions
|
|
314
|
+
*/
|
|
315
|
+
static ActiveIdentifier;
|
|
316
|
+
/**
|
|
317
|
+
* @group Characteristic Definitions
|
|
318
|
+
*/
|
|
319
|
+
static ActivityInterval;
|
|
320
|
+
/**
|
|
321
|
+
* @group Characteristic Definitions
|
|
322
|
+
*/
|
|
323
|
+
static AdministratorOnlyAccess;
|
|
324
|
+
/**
|
|
325
|
+
* @group Characteristic Definitions
|
|
326
|
+
*/
|
|
327
|
+
static AirParticulateDensity;
|
|
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 = {
|
|
327
1358
|
format: "int" /* Formats.INT */,
|
|
328
1359
|
perms: ["ev" /* Perms.NOTIFY */],
|
|
329
1360
|
};
|
|
330
|
-
|
|
331
|
-
return _this;
|
|
1361
|
+
this.setProps(props || {}); // ensure sanity checks are called
|
|
332
1362
|
}
|
|
333
1363
|
/**
|
|
334
1364
|
* Accepts a function that will be called to retrieve the current value of a Characteristic.
|
|
@@ -343,21 +1373,21 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
343
1373
|
* ```
|
|
344
1374
|
* @param handler
|
|
345
1375
|
*/
|
|
346
|
-
|
|
1376
|
+
onGet(handler) {
|
|
347
1377
|
if (typeof handler !== "function") {
|
|
348
1378
|
this.characteristicWarning(".onGet handler must be a function");
|
|
349
1379
|
return this;
|
|
350
1380
|
}
|
|
351
1381
|
this.getHandler = handler;
|
|
352
1382
|
return this;
|
|
353
|
-
}
|
|
1383
|
+
}
|
|
354
1384
|
/**
|
|
355
1385
|
* Removes the {@link CharacteristicGetHandler} handler which was configured using {@link onGet}.
|
|
356
1386
|
*/
|
|
357
|
-
|
|
1387
|
+
removeOnGet() {
|
|
358
1388
|
this.getHandler = undefined;
|
|
359
1389
|
return this;
|
|
360
|
-
}
|
|
1390
|
+
}
|
|
361
1391
|
/**
|
|
362
1392
|
* Accepts a function that will be called when setting the value of a Characteristic.
|
|
363
1393
|
* If the characteristic supports {@link Perms.WRITE_RESPONSE} and the request requests a write-response value,
|
|
@@ -372,21 +1402,21 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
372
1402
|
* ```
|
|
373
1403
|
* @param handler
|
|
374
1404
|
*/
|
|
375
|
-
|
|
1405
|
+
onSet(handler) {
|
|
376
1406
|
if (typeof handler !== "function") {
|
|
377
1407
|
this.characteristicWarning(".onSet handler must be a function");
|
|
378
1408
|
return this;
|
|
379
1409
|
}
|
|
380
1410
|
this.setHandler = handler;
|
|
381
1411
|
return this;
|
|
382
|
-
}
|
|
1412
|
+
}
|
|
383
1413
|
/**
|
|
384
1414
|
* Removes the {@link CharacteristicSetHandler} which was configured using {@link onSet}.
|
|
385
1415
|
*/
|
|
386
|
-
|
|
1416
|
+
removeOnSet() {
|
|
387
1417
|
this.setHandler = undefined;
|
|
388
1418
|
return this;
|
|
389
|
-
}
|
|
1419
|
+
}
|
|
390
1420
|
/**
|
|
391
1421
|
* Updates the properties of this characteristic.
|
|
392
1422
|
* Properties passed via the parameter will be set. Any parameter set to null will be deleted.
|
|
@@ -394,10 +1424,10 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
394
1424
|
*
|
|
395
1425
|
* @param props - Partial properties object with the desired updates.
|
|
396
1426
|
*/
|
|
397
|
-
|
|
1427
|
+
setProps(props) {
|
|
398
1428
|
(0, assert_1.default)(props, "props cannot be undefined when setting props");
|
|
399
1429
|
// TODO calling setProps after publish doesn't lead to a increment in the current configuration number
|
|
400
|
-
|
|
1430
|
+
let formatDidChange = false;
|
|
401
1431
|
// for every value "null" can be used to reset props, except for required props
|
|
402
1432
|
if (props.format) {
|
|
403
1433
|
formatDidChange = this.props.format !== props.format;
|
|
@@ -423,7 +1453,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
423
1453
|
props.minValue = undefined;
|
|
424
1454
|
}
|
|
425
1455
|
else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
|
|
426
|
-
this.characteristicWarning(
|
|
1456
|
+
this.characteristicWarning(`Characteristic Property 'minValue' must be a finite number, received "${props.minValue}" (${typeof props.minValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
427
1457
|
props.minValue = undefined;
|
|
428
1458
|
}
|
|
429
1459
|
else {
|
|
@@ -450,7 +1480,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
450
1480
|
props.maxValue = undefined;
|
|
451
1481
|
}
|
|
452
1482
|
else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
|
|
453
|
-
this.characteristicWarning(
|
|
1483
|
+
this.characteristicWarning(`Characteristic Property 'maxValue' must be a finite number, received "${props.maxValue}" (${typeof props.maxValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
454
1484
|
props.maxValue = undefined;
|
|
455
1485
|
}
|
|
456
1486
|
else {
|
|
@@ -554,14 +1584,14 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
554
1584
|
// - If the characteristic is marked as erroneous the value is not considered valid anyway, and we must not remove the `statusCode`.
|
|
555
1585
|
// - Special case for `ProgrammableSwitchEvent` where every change in value is considered an event which would result in ghost button presses
|
|
556
1586
|
// validateUserInput when called from setProps is intended to clamp value withing allowed range. It is why warnings should not be displayed.
|
|
557
|
-
|
|
1587
|
+
const correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
558
1588
|
if (correctedValue !== this.value) {
|
|
559
1589
|
// we don't want to emit a CHANGE event if the value didn't change at all!
|
|
560
1590
|
this.updateValue(correctedValue);
|
|
561
1591
|
}
|
|
562
1592
|
}
|
|
563
1593
|
return this;
|
|
564
|
-
}
|
|
1594
|
+
}
|
|
565
1595
|
/**
|
|
566
1596
|
* This method can be used to gain an Iterator to loop over all valid values defined for this characteristic.
|
|
567
1597
|
*
|
|
@@ -590,9 +1620,9 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
590
1620
|
* const validValues = Array.from(characteristic.validValuesIterator());
|
|
591
1621
|
* ```
|
|
592
1622
|
*/
|
|
593
|
-
|
|
1623
|
+
validValuesIterator() {
|
|
594
1624
|
return new ValidValuesIterable(this.props);
|
|
595
|
-
}
|
|
1625
|
+
}
|
|
596
1626
|
// noinspection JSUnusedGlobalSymbols
|
|
597
1627
|
/**
|
|
598
1628
|
* This method can be used to set up additional authorization for a characteristic.
|
|
@@ -610,12 +1640,12 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
610
1640
|
*
|
|
611
1641
|
* @param handler - Handler called to check additional authorization data.
|
|
612
1642
|
*/
|
|
613
|
-
|
|
1643
|
+
setupAdditionalAuthorization(handler) {
|
|
614
1644
|
if (!this.props.perms.includes("aa" /* Perms.ADDITIONAL_AUTHORIZATION */)) {
|
|
615
1645
|
this.props.perms.push("aa" /* Perms.ADDITIONAL_AUTHORIZATION */);
|
|
616
1646
|
}
|
|
617
1647
|
this.additionalAuthorizationHandler = handler;
|
|
618
|
-
}
|
|
1648
|
+
}
|
|
619
1649
|
/**
|
|
620
1650
|
* Updates the current value of the characteristic.
|
|
621
1651
|
*
|
|
@@ -625,18 +1655,18 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
625
1655
|
*
|
|
626
1656
|
* @deprecated
|
|
627
1657
|
*/
|
|
628
|
-
|
|
629
|
-
this.handleGetRequest(undefined, context).then(
|
|
1658
|
+
getValue(callback, context) {
|
|
1659
|
+
this.handleGetRequest(undefined, context).then(value => {
|
|
630
1660
|
if (callback) {
|
|
631
1661
|
callback(null, value);
|
|
632
1662
|
}
|
|
633
|
-
},
|
|
1663
|
+
}, reason => {
|
|
634
1664
|
if (callback) {
|
|
635
1665
|
callback(reason);
|
|
636
1666
|
}
|
|
637
1667
|
});
|
|
638
|
-
}
|
|
639
|
-
|
|
1668
|
+
}
|
|
1669
|
+
setValue(value, callback, context) {
|
|
640
1670
|
if (value instanceof Error) {
|
|
641
1671
|
this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
|
|
642
1672
|
// noinspection JSDeprecatedSymbols
|
|
@@ -654,13 +1684,13 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
654
1684
|
value = this.validateUserInput(value);
|
|
655
1685
|
}
|
|
656
1686
|
catch (error) {
|
|
657
|
-
this.characteristicWarning(
|
|
1687
|
+
this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
658
1688
|
if (callback) {
|
|
659
1689
|
callback(error);
|
|
660
1690
|
}
|
|
661
1691
|
return this;
|
|
662
1692
|
}
|
|
663
|
-
this.handleSetRequest(value, undefined, context).then(
|
|
1693
|
+
this.handleSetRequest(value, undefined, context).then(value => {
|
|
664
1694
|
if (callback) {
|
|
665
1695
|
if (value) { // possible write response
|
|
666
1696
|
callback(null, value);
|
|
@@ -669,14 +1699,14 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
669
1699
|
callback(null);
|
|
670
1700
|
}
|
|
671
1701
|
}
|
|
672
|
-
},
|
|
1702
|
+
}, reason => {
|
|
673
1703
|
if (callback) {
|
|
674
1704
|
callback(reason);
|
|
675
1705
|
}
|
|
676
1706
|
});
|
|
677
1707
|
return this;
|
|
678
|
-
}
|
|
679
|
-
|
|
1708
|
+
}
|
|
1709
|
+
updateValue(value, callback, context) {
|
|
680
1710
|
if (value instanceof Error) {
|
|
681
1711
|
this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
|
|
682
1712
|
// noinspection JSDeprecatedSymbols
|
|
@@ -694,7 +1724,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
694
1724
|
value = this.validateUserInput(value);
|
|
695
1725
|
}
|
|
696
1726
|
catch (error) {
|
|
697
|
-
this.characteristicWarning(
|
|
1727
|
+
this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
698
1728
|
if (callback) {
|
|
699
1729
|
callback();
|
|
700
1730
|
}
|
|
@@ -703,14 +1733,14 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
703
1733
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
704
1734
|
// noinspection JSDeprecatedSymbols
|
|
705
1735
|
this.status = null;
|
|
706
|
-
|
|
1736
|
+
const oldValue = this.value;
|
|
707
1737
|
this.value = value;
|
|
708
1738
|
if (callback) {
|
|
709
1739
|
callback();
|
|
710
1740
|
}
|
|
711
1741
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
|
|
712
1742
|
return this; // for chaining
|
|
713
|
-
}
|
|
1743
|
+
}
|
|
714
1744
|
/**
|
|
715
1745
|
* This method acts similarly to {@link updateValue} by setting the current value of the characteristic
|
|
716
1746
|
* without calling any {@link CharacteristicEventTypes.SET} or {@link onSet} handlers.
|
|
@@ -720,16 +1750,16 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
720
1750
|
* @param value - The new value.
|
|
721
1751
|
* @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler.
|
|
722
1752
|
*/
|
|
723
|
-
|
|
1753
|
+
sendEventNotification(value, context) {
|
|
724
1754
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
725
1755
|
// noinspection JSDeprecatedSymbols
|
|
726
1756
|
this.status = null;
|
|
727
1757
|
value = this.validateUserInput(value);
|
|
728
|
-
|
|
1758
|
+
const oldValue = this.value;
|
|
729
1759
|
this.value = value;
|
|
730
1760
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
|
|
731
1761
|
return this; // for chaining
|
|
732
|
-
}
|
|
1762
|
+
}
|
|
733
1763
|
/**
|
|
734
1764
|
* Called when a HAP requests wants to know the current value of the characteristic.
|
|
735
1765
|
*
|
|
@@ -737,130 +1767,118 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
737
1767
|
* @param context - Deprecated parameter. There for backwards compatibility.
|
|
738
1768
|
* @private Used by the Accessory to load the characteristic value
|
|
739
1769
|
*/
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1770
|
+
async handleGetRequest(connection, context) {
|
|
1771
|
+
if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
|
|
1772
|
+
throw -70405 /* HAPStatus.WRITE_ONLY_CHARACTERISTIC */;
|
|
1773
|
+
}
|
|
1774
|
+
if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
|
|
1775
|
+
// special workaround for event only programmable switch event, which must always return null
|
|
1776
|
+
return null;
|
|
1777
|
+
}
|
|
1778
|
+
if (this.getHandler) {
|
|
1779
|
+
if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
|
|
1780
|
+
this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
|
|
1781
|
+
}
|
|
1782
|
+
try {
|
|
1783
|
+
let value = await this.getHandler(context, connection);
|
|
1784
|
+
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1785
|
+
// noinspection JSDeprecatedSymbols
|
|
1786
|
+
this.status = null;
|
|
1787
|
+
try {
|
|
1788
|
+
value = this.validateUserInput(value);
|
|
1789
|
+
}
|
|
1790
|
+
catch (error) {
|
|
1791
|
+
this.characteristicWarning(`An illegal value was supplied by the read handler for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
|
|
1792
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
1793
|
+
// noinspection JSDeprecatedSymbols
|
|
1794
|
+
this.status = error;
|
|
1795
|
+
return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
1796
|
+
}
|
|
1797
|
+
const oldValue = this.value;
|
|
1798
|
+
this.value = value;
|
|
1799
|
+
if (oldValue !== value) { // emit a change event if necessary
|
|
1800
|
+
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
|
|
1801
|
+
}
|
|
1802
|
+
return value;
|
|
1803
|
+
}
|
|
1804
|
+
catch (error) {
|
|
1805
|
+
if (typeof error === "number") {
|
|
1806
|
+
const hapStatusError = new hapStatusError_1.HapStatusError(error);
|
|
1807
|
+
this.statusCode = hapStatusError.hapStatus;
|
|
1808
|
+
// noinspection JSDeprecatedSymbols
|
|
1809
|
+
this.status = hapStatusError;
|
|
1810
|
+
}
|
|
1811
|
+
else if (error instanceof hapStatusError_1.HapStatusError) {
|
|
1812
|
+
this.statusCode = error.hapStatus;
|
|
1813
|
+
// noinspection JSDeprecatedSymbols
|
|
1814
|
+
this.status = error;
|
|
1815
|
+
}
|
|
1816
|
+
else {
|
|
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);
|
|
787
1843
|
this.statusCode = hapStatusError.hapStatus;
|
|
788
1844
|
// noinspection JSDeprecatedSymbols
|
|
789
1845
|
this.status = hapStatusError;
|
|
790
1846
|
}
|
|
791
|
-
else if (
|
|
792
|
-
this.statusCode =
|
|
1847
|
+
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
1848
|
+
this.statusCode = status.hapStatus;
|
|
793
1849
|
// noinspection JSDeprecatedSymbols
|
|
794
|
-
this.status =
|
|
1850
|
+
this.status = status;
|
|
795
1851
|
}
|
|
796
1852
|
else {
|
|
797
|
-
|
|
798
|
-
this.statusCode =
|
|
1853
|
+
debug("[%s] Received error from get handler %s", this.displayName, status.stack);
|
|
1854
|
+
this.statusCode = extractHAPStatusFromError(status);
|
|
799
1855
|
// noinspection JSDeprecatedSymbols
|
|
800
|
-
this.status =
|
|
801
|
-
}
|
|
802
|
-
throw this.statusCode;
|
|
803
|
-
case 4:
|
|
804
|
-
if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
|
|
805
|
-
if (this.statusCode) {
|
|
806
|
-
throw this.statusCode;
|
|
807
|
-
}
|
|
808
|
-
try {
|
|
809
|
-
return [2 /*return*/, this.validateUserInput(this.value)];
|
|
810
|
-
}
|
|
811
|
-
catch (error) {
|
|
812
|
-
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);
|
|
813
|
-
return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
|
|
814
|
-
}
|
|
1856
|
+
this.status = status;
|
|
815
1857
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
_this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
841
|
-
// noinspection JSDeprecatedSymbols
|
|
842
|
-
_this.status = null;
|
|
843
|
-
value = _this.validateUserInput(value);
|
|
844
|
-
var oldValue = _this.value;
|
|
845
|
-
_this.value = value;
|
|
846
|
-
resolve(value);
|
|
847
|
-
if (oldValue !== value) { // emit a change event if necessary
|
|
848
|
-
_this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
|
|
849
|
-
}
|
|
850
|
-
}), context, connection);
|
|
851
|
-
}
|
|
852
|
-
catch (error) {
|
|
853
|
-
_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);
|
|
854
|
-
_this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
855
|
-
// noinspection JSDeprecatedSymbols
|
|
856
|
-
_this.status = error;
|
|
857
|
-
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
858
|
-
}
|
|
859
|
-
})];
|
|
860
|
-
}
|
|
861
|
-
});
|
|
1858
|
+
reject(this.statusCode);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1862
|
+
// noinspection JSDeprecatedSymbols
|
|
1863
|
+
this.status = null;
|
|
1864
|
+
value = this.validateUserInput(value);
|
|
1865
|
+
const oldValue = this.value;
|
|
1866
|
+
this.value = value;
|
|
1867
|
+
resolve(value);
|
|
1868
|
+
if (oldValue !== value) { // emit a change event if necessary
|
|
1869
|
+
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
|
|
1870
|
+
}
|
|
1871
|
+
}), context, connection);
|
|
1872
|
+
}
|
|
1873
|
+
catch (error) {
|
|
1874
|
+
this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
1875
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
1876
|
+
// noinspection JSDeprecatedSymbols
|
|
1877
|
+
this.status = error;
|
|
1878
|
+
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
1879
|
+
}
|
|
862
1880
|
});
|
|
863
|
-
}
|
|
1881
|
+
}
|
|
864
1882
|
/**
|
|
865
1883
|
* Called when a HAP requests update the current value of the characteristic.
|
|
866
1884
|
*
|
|
@@ -872,162 +1890,147 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
872
1890
|
* write response value is resolved.
|
|
873
1891
|
* @private
|
|
874
1892
|
*/
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1893
|
+
async handleSetRequest(value, connection, context) {
|
|
1894
|
+
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
1895
|
+
// noinspection JSDeprecatedSymbols
|
|
1896
|
+
this.status = null;
|
|
1897
|
+
if (connection !== undefined) {
|
|
1898
|
+
// if connection is undefined, the set "request" comes from the setValue method.
|
|
1899
|
+
// for setValue a value of "null" is allowed and checked via validateUserInput.
|
|
1900
|
+
try {
|
|
1901
|
+
value = this.validateClientSuppliedValue(value);
|
|
1902
|
+
}
|
|
1903
|
+
catch (e) {
|
|
1904
|
+
debug(`[${this.displayName}]`, e.message);
|
|
1905
|
+
return Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
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;
|
|
890
1967
|
}
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1968
|
+
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
1969
|
+
this.statusCode = status.hapStatus;
|
|
1970
|
+
// noinspection JSDeprecatedSymbols
|
|
1971
|
+
this.status = status;
|
|
894
1972
|
}
|
|
1973
|
+
else {
|
|
1974
|
+
debug("[%s] Received error from set handler %s", this.displayName, status.stack);
|
|
1975
|
+
this.statusCode = extractHAPStatusFromError(status);
|
|
1976
|
+
// noinspection JSDeprecatedSymbols
|
|
1977
|
+
this.status = status;
|
|
1978
|
+
}
|
|
1979
|
+
reject(this.statusCode);
|
|
1980
|
+
return;
|
|
895
1981
|
}
|
|
896
|
-
oldValue = this.value;
|
|
897
|
-
if (!this.setHandler) return [3 /*break*/, 4];
|
|
898
|
-
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
|
|
899
|
-
this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
|
|
900
|
-
}
|
|
901
|
-
_a.label = 1;
|
|
902
|
-
case 1:
|
|
903
|
-
_a.trys.push([1, 3, , 4]);
|
|
904
|
-
return [4 /*yield*/, this.setHandler(value, context, connection)];
|
|
905
|
-
case 2:
|
|
906
|
-
writeResponse = _a.sent();
|
|
907
1982
|
this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
908
1983
|
// noinspection JSDeprecatedSymbols
|
|
909
1984
|
this.status = null;
|
|
910
1985
|
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
|
|
911
1987
|
this.value = this.validateUserInput(writeResponse);
|
|
912
|
-
|
|
1988
|
+
resolve(this.value);
|
|
913
1989
|
}
|
|
914
1990
|
else {
|
|
915
1991
|
if (writeResponse != null) {
|
|
916
1992
|
this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
917
1993
|
}
|
|
918
1994
|
this.value = value;
|
|
1995
|
+
resolve();
|
|
919
1996
|
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
920
|
-
return [2 /*return*/];
|
|
921
|
-
}
|
|
922
|
-
return [3 /*break*/, 4];
|
|
923
|
-
case 3:
|
|
924
|
-
error_2 = _a.sent();
|
|
925
|
-
if (typeof error_2 === "number") {
|
|
926
|
-
hapStatusError = new hapStatusError_1.HapStatusError(error_2);
|
|
927
|
-
this.statusCode = hapStatusError.hapStatus;
|
|
928
|
-
// noinspection JSDeprecatedSymbols
|
|
929
|
-
this.status = hapStatusError;
|
|
930
|
-
}
|
|
931
|
-
else if (error_2 instanceof hapStatusError_1.HapStatusError) {
|
|
932
|
-
this.statusCode = error_2.hapStatus;
|
|
933
|
-
// noinspection JSDeprecatedSymbols
|
|
934
|
-
this.status = error_2;
|
|
935
|
-
}
|
|
936
|
-
else {
|
|
937
|
-
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);
|
|
938
|
-
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
939
|
-
// noinspection JSDeprecatedSymbols
|
|
940
|
-
this.status = error_2;
|
|
941
|
-
}
|
|
942
|
-
throw this.statusCode;
|
|
943
|
-
case 4:
|
|
944
|
-
if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
|
|
945
|
-
this.value = value;
|
|
946
|
-
this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
947
|
-
return [2 /*return*/, Promise.resolve()];
|
|
948
|
-
}
|
|
949
|
-
else {
|
|
950
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
951
|
-
try {
|
|
952
|
-
_this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)(function (status, writeResponse) {
|
|
953
|
-
if (status) {
|
|
954
|
-
if (typeof status === "number") {
|
|
955
|
-
var hapStatusError = new hapStatusError_1.HapStatusError(status);
|
|
956
|
-
_this.statusCode = hapStatusError.hapStatus;
|
|
957
|
-
// noinspection JSDeprecatedSymbols
|
|
958
|
-
_this.status = hapStatusError;
|
|
959
|
-
}
|
|
960
|
-
else if (status instanceof hapStatusError_1.HapStatusError) {
|
|
961
|
-
_this.statusCode = status.hapStatus;
|
|
962
|
-
// noinspection JSDeprecatedSymbols
|
|
963
|
-
_this.status = status;
|
|
964
|
-
}
|
|
965
|
-
else {
|
|
966
|
-
debug("[%s] Received error from set handler %s", _this.displayName, status.stack);
|
|
967
|
-
_this.statusCode = extractHAPStatusFromError(status);
|
|
968
|
-
// noinspection JSDeprecatedSymbols
|
|
969
|
-
_this.status = status;
|
|
970
|
-
}
|
|
971
|
-
reject(_this.statusCode);
|
|
972
|
-
return;
|
|
973
|
-
}
|
|
974
|
-
_this.statusCode = 0 /* HAPStatus.SUCCESS */;
|
|
975
|
-
// noinspection JSDeprecatedSymbols
|
|
976
|
-
_this.status = null;
|
|
977
|
-
if (writeResponse != null && _this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
|
|
978
|
-
// support write response simply by letting the implementor pass the response as second argument to the callback
|
|
979
|
-
_this.value = _this.validateUserInput(writeResponse);
|
|
980
|
-
resolve(_this.value);
|
|
981
|
-
}
|
|
982
|
-
else {
|
|
983
|
-
if (writeResponse != null) {
|
|
984
|
-
_this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
|
|
985
|
-
}
|
|
986
|
-
_this.value = value;
|
|
987
|
-
resolve();
|
|
988
|
-
_this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
|
|
989
|
-
}
|
|
990
|
-
}), context, connection);
|
|
991
|
-
}
|
|
992
|
-
catch (error) {
|
|
993
|
-
_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);
|
|
994
|
-
_this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
995
|
-
// noinspection JSDeprecatedSymbols
|
|
996
|
-
_this.status = error;
|
|
997
|
-
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
998
|
-
}
|
|
999
|
-
})];
|
|
1000
1997
|
}
|
|
1001
|
-
|
|
1998
|
+
}), context, connection);
|
|
1999
|
+
}
|
|
2000
|
+
catch (error) {
|
|
2001
|
+
this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
|
|
2002
|
+
this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
|
|
2003
|
+
// noinspection JSDeprecatedSymbols
|
|
2004
|
+
this.status = error;
|
|
2005
|
+
reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
1002
2006
|
}
|
|
1003
2007
|
});
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
1006
2010
|
/**
|
|
1007
2011
|
* Called once a HomeKit controller subscribes to events of this characteristic.
|
|
1008
2012
|
* @private
|
|
1009
2013
|
*/
|
|
1010
|
-
|
|
2014
|
+
subscribe() {
|
|
1011
2015
|
if (this.subscriptions === 0) {
|
|
1012
2016
|
this.emit("subscribe" /* CharacteristicEventTypes.SUBSCRIBE */);
|
|
1013
2017
|
}
|
|
1014
2018
|
this.subscriptions++;
|
|
1015
|
-
}
|
|
2019
|
+
}
|
|
1016
2020
|
/**
|
|
1017
2021
|
* Called once a HomeKit controller unsubscribe to events of this characteristic or a HomeKit controller
|
|
1018
2022
|
* which was subscribed to this characteristic disconnects.
|
|
1019
2023
|
* @private
|
|
1020
2024
|
*/
|
|
1021
|
-
|
|
1022
|
-
|
|
2025
|
+
unsubscribe() {
|
|
2026
|
+
const wasOne = this.subscriptions === 1;
|
|
1023
2027
|
this.subscriptions--;
|
|
1024
2028
|
this.subscriptions = Math.max(this.subscriptions, 0);
|
|
1025
2029
|
if (wasOne) {
|
|
1026
2030
|
this.emit("unsubscribe" /* CharacteristicEventTypes.UNSUBSCRIBE */);
|
|
1027
2031
|
}
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
var _a;
|
|
2032
|
+
}
|
|
2033
|
+
getDefaultValue() {
|
|
1031
2034
|
// noinspection JSDeprecatedSymbols
|
|
1032
2035
|
switch (this.props.format) {
|
|
1033
2036
|
case "bool" /* Formats.BOOL */:
|
|
@@ -1063,7 +2066,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1063
2066
|
case Characteristic.CurrentTemperature.UUID:
|
|
1064
2067
|
return 0; // some existing integrations expect this to be 0 by default
|
|
1065
2068
|
default: {
|
|
1066
|
-
if (
|
|
2069
|
+
if (this.props.validValues?.length && typeof this.props.validValues[0] === "number") {
|
|
1067
2070
|
return this.props.validValues[0];
|
|
1068
2071
|
}
|
|
1069
2072
|
if (typeof this.props.minValue === "number" && Number.isFinite(this.props.minValue)) {
|
|
@@ -1075,16 +2078,16 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1075
2078
|
default:
|
|
1076
2079
|
return 0;
|
|
1077
2080
|
}
|
|
1078
|
-
}
|
|
2081
|
+
}
|
|
1079
2082
|
/**
|
|
1080
2083
|
* Checks if the value received from the HAP request is valid.
|
|
1081
2084
|
* If returned false the received value is not valid and {@link HAPStatus.INVALID_VALUE_IN_REQUEST}
|
|
1082
2085
|
* must be returned.
|
|
1083
2086
|
* @param value - Value supplied by the HomeKit controller
|
|
1084
2087
|
*/
|
|
1085
|
-
|
|
2088
|
+
validateClientSuppliedValue(value) {
|
|
1086
2089
|
if (value == null) {
|
|
1087
|
-
throw new Error(
|
|
2090
|
+
throw new Error(`Client supplied invalid value for ${this.props.format}: ${value}`);
|
|
1088
2091
|
}
|
|
1089
2092
|
switch (this.props.format) {
|
|
1090
2093
|
case "bool" /* Formats.BOOL */: {
|
|
@@ -1094,7 +2097,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1094
2097
|
if (typeof value === "number" && (value === 1 || value === 0)) {
|
|
1095
2098
|
return Boolean(value);
|
|
1096
2099
|
}
|
|
1097
|
-
throw new Error(
|
|
2100
|
+
throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
|
|
1098
2101
|
}
|
|
1099
2102
|
case "int" /* Formats.INT */:
|
|
1100
2103
|
case "float" /* Formats.FLOAT */:
|
|
@@ -1106,58 +2109,58 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1106
2109
|
value = value ? 1 : 0;
|
|
1107
2110
|
}
|
|
1108
2111
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1109
|
-
throw new Error(
|
|
2112
|
+
throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
|
|
1110
2113
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
2114
|
+
const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
|
|
2115
|
+
const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
|
|
1113
2116
|
if (typeof numericMin === "number" && value < numericMin) {
|
|
1114
|
-
throw new Error(
|
|
2117
|
+
throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${numericMin}`);
|
|
1115
2118
|
}
|
|
1116
2119
|
if (typeof numericMax === "number" && value > numericMax) {
|
|
1117
|
-
throw new Error(
|
|
2120
|
+
throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${numericMax}`);
|
|
1118
2121
|
}
|
|
1119
2122
|
if (this.props.validValues && !this.props.validValues.includes(value)) {
|
|
1120
|
-
throw new Error(
|
|
2123
|
+
throw new Error(`Client supplied value of ${value} is not in ${this.props.validValues.toString()}`);
|
|
1121
2124
|
}
|
|
1122
2125
|
if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
|
|
1123
2126
|
if (value < this.props.validValueRanges[0]) {
|
|
1124
|
-
throw new Error(
|
|
2127
|
+
throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${this.props.validValueRanges[0]}`);
|
|
1125
2128
|
}
|
|
1126
2129
|
if (value > this.props.validValueRanges[1]) {
|
|
1127
|
-
throw new Error(
|
|
2130
|
+
throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${this.props.validValueRanges[1]}`);
|
|
1128
2131
|
}
|
|
1129
2132
|
}
|
|
1130
2133
|
return value;
|
|
1131
2134
|
}
|
|
1132
2135
|
case "string" /* Formats.STRING */: {
|
|
1133
2136
|
if (typeof value !== "string") {
|
|
1134
|
-
throw new Error(
|
|
2137
|
+
throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
|
|
1135
2138
|
}
|
|
1136
|
-
|
|
2139
|
+
const maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
|
|
1137
2140
|
if (value.length > maxLength) {
|
|
1138
|
-
throw new Error(
|
|
2141
|
+
throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
|
|
1139
2142
|
}
|
|
1140
2143
|
return value;
|
|
1141
2144
|
}
|
|
1142
2145
|
case "data" /* Formats.DATA */: {
|
|
1143
2146
|
if (typeof value !== "string") {
|
|
1144
|
-
throw new Error(
|
|
2147
|
+
throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
|
|
1145
2148
|
}
|
|
1146
2149
|
// we don't validate base64 here
|
|
1147
|
-
|
|
2150
|
+
const maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
|
|
1148
2151
|
if (value.length > maxLength) {
|
|
1149
|
-
throw new Error(
|
|
2152
|
+
throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
|
|
1150
2153
|
}
|
|
1151
2154
|
return value;
|
|
1152
2155
|
}
|
|
1153
2156
|
case "tlv8" /* Formats.TLV8 */:
|
|
1154
2157
|
if (typeof value !== "string") {
|
|
1155
|
-
throw new Error(
|
|
2158
|
+
throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
|
|
1156
2159
|
}
|
|
1157
2160
|
return value;
|
|
1158
2161
|
}
|
|
1159
2162
|
return value;
|
|
1160
|
-
}
|
|
2163
|
+
}
|
|
1161
2164
|
/**
|
|
1162
2165
|
* Checks if the value received from the API call is valid.
|
|
1163
2166
|
* It adjusts the value where it makes sense, prints a warning where values may be rejected with an error
|
|
@@ -1166,9 +2169,7 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1166
2169
|
* @param value - The value received from the API call
|
|
1167
2170
|
* @param warningType - Optionally defines the warning type to use when raising a {@link CharacteristicEventTypes.CHARACTERISTIC_WARNING}.
|
|
1168
2171
|
*/
|
|
1169
|
-
|
|
1170
|
-
var _a;
|
|
1171
|
-
if (warningType === void 0) { warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
|
|
2172
|
+
validateUserInput(value, warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */) {
|
|
1172
2173
|
if (value === null) {
|
|
1173
2174
|
if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
|
|
1174
2175
|
this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
|
|
@@ -1229,12 +2230,12 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1229
2230
|
value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
|
|
1230
2231
|
}
|
|
1231
2232
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1232
|
-
this.characteristicWarning(
|
|
2233
|
+
this.characteristicWarning(`characteristic value expected valid finite number and received "${value}" (${typeof value})`, warningType);
|
|
1233
2234
|
value = typeof this.value === "number" ? this.value : this.props.minValue || 0;
|
|
1234
2235
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
2236
|
+
const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
|
|
2237
|
+
const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
|
|
2238
|
+
let stepValue = undefined;
|
|
1238
2239
|
if (this.props.format === "float" /* Formats.FLOAT */) {
|
|
1239
2240
|
stepValue = this.props.minStep;
|
|
1240
2241
|
}
|
|
@@ -1242,30 +2243,30 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1242
2243
|
stepValue = maxWithUndefined(this.props.minStep, 1);
|
|
1243
2244
|
}
|
|
1244
2245
|
if (stepValue != null && stepValue > 0) {
|
|
1245
|
-
|
|
2246
|
+
const minValue = this.props.minValue != null ? this.props.minValue : 0;
|
|
1246
2247
|
value = stepValue * Math.round((value - minValue) / stepValue) + minValue;
|
|
1247
2248
|
}
|
|
1248
2249
|
if (numericMin != null && value < numericMin) {
|
|
1249
|
-
this.characteristicWarning(
|
|
2250
|
+
this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded minimum of ${numericMin}`, warningType);
|
|
1250
2251
|
value = numericMin;
|
|
1251
2252
|
}
|
|
1252
2253
|
if (numericMax != null && value > numericMax) {
|
|
1253
|
-
this.characteristicWarning(
|
|
2254
|
+
this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded maximum of ${numericMax}`, warningType);
|
|
1254
2255
|
value = numericMax;
|
|
1255
2256
|
}
|
|
1256
2257
|
if (this.props.validValues && !this.props.validValues.includes(value)) {
|
|
1257
|
-
this.characteristicWarning(
|
|
2258
|
+
this.characteristicWarning(`characteristic value ${value} is not contained in valid values array`, warningType);
|
|
1258
2259
|
return this.props.validValues.includes(this.value) ? this.value : (this.props.validValues[0] || 0);
|
|
1259
2260
|
}
|
|
1260
2261
|
if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
|
|
1261
2262
|
if (value < this.props.validValueRanges[0]) {
|
|
1262
|
-
this.characteristicWarning(
|
|
1263
|
-
+
|
|
2263
|
+
this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
|
|
2264
|
+
+ `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
|
|
1264
2265
|
value = this.props.validValueRanges[0];
|
|
1265
2266
|
}
|
|
1266
2267
|
else if (value > this.props.validValueRanges[1]) {
|
|
1267
|
-
this.characteristicWarning(
|
|
1268
|
-
+
|
|
2268
|
+
this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
|
|
2269
|
+
+ `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
|
|
1269
2270
|
value = this.props.validValueRanges[1];
|
|
1270
2271
|
}
|
|
1271
2272
|
}
|
|
@@ -1283,17 +2284,17 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1283
2284
|
}
|
|
1284
2285
|
// mirrors the case value = null at the beginning
|
|
1285
2286
|
if (value.length <= 1 && (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID)) {
|
|
1286
|
-
this.characteristicWarning(
|
|
1287
|
-
+
|
|
2287
|
+
this.characteristicWarning(`[${this.displayName}] characteristic must have a length of more than 1 character otherwise`
|
|
2288
|
+
+ ` HomeKit will reject this accessory, ignoring new value ${warningType}`);
|
|
1288
2289
|
return this.value; // just return the current value
|
|
1289
2290
|
}
|
|
1290
|
-
|
|
2291
|
+
const maxLength = this.props.maxLen ?? 64; // default is 64 (max is 256 which is set in setProps)
|
|
1291
2292
|
if (value.length > maxLength) {
|
|
1292
|
-
this.characteristicWarning(
|
|
2293
|
+
this.characteristicWarning(`characteristic was supplied illegal value: string '${value}' exceeded max length of ${maxLength}`, warningType);
|
|
1293
2294
|
value = value.substring(0, maxLength);
|
|
1294
2295
|
}
|
|
1295
|
-
if (this.UUID ===
|
|
1296
|
-
(0, checkName_1.checkName)(
|
|
2296
|
+
if (value.length > 0 && this.UUID === Characteristic.ConfiguredName.UUID) {
|
|
2297
|
+
(0, checkName_1.checkName)(this.displayName, "ConfiguredName", value);
|
|
1297
2298
|
}
|
|
1298
2299
|
return value;
|
|
1299
2300
|
}
|
|
@@ -1319,109 +2320,88 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1319
2320
|
return this.value;
|
|
1320
2321
|
}
|
|
1321
2322
|
return value;
|
|
1322
|
-
}
|
|
2323
|
+
}
|
|
1323
2324
|
/**
|
|
1324
2325
|
* @private used to assign iid to characteristic
|
|
1325
2326
|
*/
|
|
1326
|
-
|
|
2327
|
+
_assignID(identifierCache, accessoryName, serviceUUID, serviceSubtype) {
|
|
1327
2328
|
// generate our IID based on our UUID
|
|
1328
2329
|
this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
if (type === void 0) { type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
|
|
1332
|
-
if (stack === void 0) { stack = new Error().stack; }
|
|
2330
|
+
}
|
|
2331
|
+
characteristicWarning(message, type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, stack = new Error().stack) {
|
|
1333
2332
|
this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
|
|
1334
|
-
}
|
|
2333
|
+
}
|
|
1335
2334
|
/**
|
|
1336
2335
|
* @param event
|
|
1337
2336
|
* @private
|
|
1338
2337
|
*/
|
|
1339
|
-
|
|
2338
|
+
removeAllListeners(event) {
|
|
1340
2339
|
if (!event) {
|
|
1341
2340
|
this.removeOnGet();
|
|
1342
2341
|
this.removeOnSet();
|
|
1343
2342
|
}
|
|
1344
|
-
return
|
|
1345
|
-
}
|
|
2343
|
+
return super.removeAllListeners(event);
|
|
2344
|
+
}
|
|
1346
2345
|
/**
|
|
1347
2346
|
* @param characteristic
|
|
1348
2347
|
* @private
|
|
1349
2348
|
*/
|
|
1350
|
-
|
|
1351
|
-
var _this = this;
|
|
2349
|
+
replaceBy(characteristic) {
|
|
1352
2350
|
this.props = characteristic.props;
|
|
1353
2351
|
this.updateValue(characteristic.value);
|
|
1354
|
-
|
|
2352
|
+
const getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
|
|
1355
2353
|
if (getListeners.length) {
|
|
1356
2354
|
// the callback can only be called once, so we remove all old listeners
|
|
1357
2355
|
this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
|
|
1358
2356
|
// @ts-expect-error: force type
|
|
1359
|
-
getListeners.forEach(
|
|
2357
|
+
getListeners.forEach(listener => this.addListener("get" /* CharacteristicEventTypes.GET */, listener));
|
|
1360
2358
|
}
|
|
1361
2359
|
this.removeOnGet();
|
|
1362
2360
|
if (characteristic.getHandler) {
|
|
1363
2361
|
this.onGet(characteristic.getHandler);
|
|
1364
2362
|
}
|
|
1365
|
-
|
|
2363
|
+
const setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
|
|
1366
2364
|
if (setListeners.length) {
|
|
1367
2365
|
// the callback can only be called once, so we remove all old listeners
|
|
1368
2366
|
this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
|
|
1369
2367
|
// @ts-expect-error: force type
|
|
1370
|
-
setListeners.forEach(
|
|
2368
|
+
setListeners.forEach(listener => this.addListener("set" /* CharacteristicEventTypes.SET */, listener));
|
|
1371
2369
|
}
|
|
1372
2370
|
this.removeOnSet();
|
|
1373
2371
|
if (characteristic.setHandler) {
|
|
1374
2372
|
this.onSet(characteristic.setHandler);
|
|
1375
2373
|
}
|
|
1376
|
-
}
|
|
2374
|
+
}
|
|
1377
2375
|
/**
|
|
1378
2376
|
* Returns a JSON representation of this characteristic suitable for delivering to HAP clients.
|
|
1379
2377
|
* @private used to generate response to /accessories query
|
|
1380
2378
|
*/
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", _this.displayName, "".concat(value));
|
|
1403
|
-
return value; // use default value
|
|
1404
|
-
})];
|
|
1405
|
-
case 3:
|
|
1406
|
-
_a = _b.sent();
|
|
1407
|
-
return [3 /*break*/, 5];
|
|
1408
|
-
case 4:
|
|
1409
|
-
_a = this.value;
|
|
1410
|
-
_b.label = 5;
|
|
1411
|
-
case 5:
|
|
1412
|
-
value = _a;
|
|
1413
|
-
object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
|
|
1414
|
-
_b.label = 6;
|
|
1415
|
-
case 6: return [2 /*return*/, object];
|
|
1416
|
-
}
|
|
1417
|
-
});
|
|
1418
|
-
});
|
|
1419
|
-
};
|
|
2379
|
+
async toHAP(connection, contactGetHandlers = true) {
|
|
2380
|
+
const object = this.internalHAPRepresentation();
|
|
2381
|
+
if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) {
|
|
2382
|
+
object.value = undefined;
|
|
2383
|
+
}
|
|
2384
|
+
else if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
|
|
2385
|
+
// special workaround for event only programmable switch event, which must always return null
|
|
2386
|
+
object.value = null;
|
|
2387
|
+
}
|
|
2388
|
+
else { // query the current value
|
|
2389
|
+
const value = contactGetHandlers
|
|
2390
|
+
? await this.handleGetRequest(connection).catch(() => {
|
|
2391
|
+
const value = this.getDefaultValue();
|
|
2392
|
+
debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", this.displayName, `${value}`);
|
|
2393
|
+
return value; // use default value
|
|
2394
|
+
})
|
|
2395
|
+
: this.value;
|
|
2396
|
+
object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
|
|
2397
|
+
}
|
|
2398
|
+
return object;
|
|
2399
|
+
}
|
|
1420
2400
|
/**
|
|
1421
2401
|
* Returns a JSON representation of this characteristic without the value.
|
|
1422
2402
|
* @private used to generate the config hash
|
|
1423
2403
|
*/
|
|
1424
|
-
|
|
2404
|
+
internalHAPRepresentation() {
|
|
1425
2405
|
(0, assert_1.default)(this.iid, "iid cannot be undefined for characteristic '" + this.displayName + "'");
|
|
1426
2406
|
// TODO include the value for characteristics of the AccessoryInformation service
|
|
1427
2407
|
return {
|
|
@@ -1440,15 +2420,15 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1440
2420
|
"valid-values": this.props.validValues,
|
|
1441
2421
|
"valid-values-range": this.props.validValueRanges,
|
|
1442
2422
|
};
|
|
1443
|
-
}
|
|
2423
|
+
}
|
|
1444
2424
|
/**
|
|
1445
2425
|
* Serialize characteristic into json string.
|
|
1446
2426
|
*
|
|
1447
2427
|
* @param characteristic - Characteristic object.
|
|
1448
2428
|
* @private used to store characteristic on disk
|
|
1449
2429
|
*/
|
|
1450
|
-
|
|
1451
|
-
|
|
2430
|
+
static serialize(characteristic) {
|
|
2431
|
+
let constructorName;
|
|
1452
2432
|
if (characteristic.constructor.name !== "Characteristic") {
|
|
1453
2433
|
constructorName = characteristic.constructor.name;
|
|
1454
2434
|
}
|
|
@@ -1460,18 +2440,18 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1460
2440
|
value: characteristic.value,
|
|
1461
2441
|
props: (0, clone_1.clone)({}, characteristic.props),
|
|
1462
2442
|
};
|
|
1463
|
-
}
|
|
2443
|
+
}
|
|
1464
2444
|
/**
|
|
1465
2445
|
* Deserialize characteristic from json string.
|
|
1466
2446
|
*
|
|
1467
2447
|
* @param json - Json string representing a characteristic.
|
|
1468
2448
|
* @private used to recreate characteristic from disk
|
|
1469
2449
|
*/
|
|
1470
|
-
|
|
1471
|
-
|
|
2450
|
+
static deserialize(json) {
|
|
2451
|
+
let characteristic;
|
|
1472
2452
|
if (json.constructorName && json.constructorName.charAt(0).toUpperCase() === json.constructorName.charAt(0)
|
|
1473
2453
|
&& Characteristic[json.constructorName]) { // MUST start with uppercase character and must exist on Characteristic object
|
|
1474
|
-
|
|
2454
|
+
const constructor = Characteristic[json.constructorName];
|
|
1475
2455
|
characteristic = new constructor();
|
|
1476
2456
|
characteristic.displayName = json.displayName;
|
|
1477
2457
|
characteristic.setProps(json.props);
|
|
@@ -1481,24 +2461,8 @@ var Characteristic = /** @class */ (function (_super) {
|
|
|
1481
2461
|
}
|
|
1482
2462
|
characteristic.value = json.value;
|
|
1483
2463
|
return characteristic;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
* @deprecated Please use the Formats const enum above.
|
|
1487
|
-
*/
|
|
1488
|
-
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1489
|
-
Characteristic.Formats = Formats;
|
|
1490
|
-
/**
|
|
1491
|
-
* @deprecated Please use the Units const enum above.
|
|
1492
|
-
*/
|
|
1493
|
-
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1494
|
-
Characteristic.Units = Units;
|
|
1495
|
-
/**
|
|
1496
|
-
* @deprecated Please use the Perms const enum above.
|
|
1497
|
-
*/
|
|
1498
|
-
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
1499
|
-
Characteristic.Perms = Perms;
|
|
1500
|
-
return Characteristic;
|
|
1501
|
-
}(events_1.EventEmitter));
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
1502
2466
|
exports.Characteristic = Characteristic;
|
|
1503
2467
|
// We have a cyclic dependency problem. Within this file we have the definitions of "./definitions" as
|
|
1504
2468
|
// type imports only (in order to define the static properties). Setting those properties is done outside
|