hap-nodejs 0.11.0-beta.12 → 0.11.0-beta.14

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.
Files changed (221) hide show
  1. package/dist/BridgedCore.js +4 -4
  2. package/dist/BridgedCore.js.map +1 -1
  3. package/dist/Core.js +2 -2
  4. package/dist/Core.js.map +1 -1
  5. package/dist/accessories/AirConditioner_accessory.js +18 -18
  6. package/dist/accessories/AirConditioner_accessory.js.map +1 -1
  7. package/dist/accessories/AppleTVRemote_accessory.js +6 -6
  8. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
  9. package/dist/accessories/Camera_accessory.js +96 -87
  10. package/dist/accessories/Camera_accessory.js.map +1 -1
  11. package/dist/accessories/Fan_accessory.js +6 -6
  12. package/dist/accessories/Fan_accessory.js.map +1 -1
  13. package/dist/accessories/GarageDoorOpener_accessory.js +4 -4
  14. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
  15. package/dist/accessories/Light-AdaptiveLighting_accessory.js +2 -2
  16. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
  17. package/dist/accessories/Light_accessory.js +10 -10
  18. package/dist/accessories/Light_accessory.js.map +1 -1
  19. package/dist/accessories/Lock_accessory.js +4 -4
  20. package/dist/accessories/Lock_accessory.js.map +1 -1
  21. package/dist/accessories/MotionSensor_accessory.js +3 -3
  22. package/dist/accessories/MotionSensor_accessory.js.map +1 -1
  23. package/dist/accessories/Outlet_accessory.js +4 -4
  24. package/dist/accessories/Outlet_accessory.js.map +1 -1
  25. package/dist/accessories/SmartSpeaker_accessory.js +5 -5
  26. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
  27. package/dist/accessories/Sprinkler_accessory.js +7 -7
  28. package/dist/accessories/Sprinkler_accessory.js.map +1 -1
  29. package/dist/accessories/TV_accessory.js +9 -9
  30. package/dist/accessories/TV_accessory.js.map +1 -1
  31. package/dist/accessories/TemperatureSensor_accessory.js +2 -2
  32. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
  33. package/dist/accessories/Wi-FiRouter_accessory.js +2 -2
  34. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
  35. package/dist/accessories/Wi-FiSatellite_accessory.js +2 -2
  36. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
  37. package/dist/accessories/gstreamer-audioProducer.d.ts +2 -2
  38. package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
  39. package/dist/accessories/gstreamer-audioProducer.js +20 -20
  40. package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
  41. package/dist/index.d.ts +30 -6
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +39 -25
  44. package/dist/index.js.map +1 -1
  45. package/dist/internal-types.d.ts +20 -125
  46. package/dist/internal-types.d.ts.map +1 -1
  47. package/dist/internal-types.js +15 -5
  48. package/dist/internal-types.js.map +1 -1
  49. package/dist/lib/Accessory.d.ts +73 -14
  50. package/dist/lib/Accessory.d.ts.map +1 -1
  51. package/dist/lib/Accessory.js +168 -148
  52. package/dist/lib/Accessory.js.map +1 -1
  53. package/dist/lib/AccessoryLoader.d.ts +12 -0
  54. package/dist/lib/AccessoryLoader.d.ts.map +1 -1
  55. package/dist/lib/AccessoryLoader.js +18 -6
  56. package/dist/lib/AccessoryLoader.js.map +1 -1
  57. package/dist/lib/Advertiser.d.ts +26 -0
  58. package/dist/lib/Advertiser.d.ts.map +1 -1
  59. package/dist/lib/Advertiser.js +59 -39
  60. package/dist/lib/Advertiser.js.map +1 -1
  61. package/dist/lib/Bridge.d.ts +2 -0
  62. package/dist/lib/Bridge.d.ts.map +1 -1
  63. package/dist/lib/Bridge.js +3 -1
  64. package/dist/lib/Bridge.js.map +1 -1
  65. package/dist/lib/Characteristic.d.ts +818 -13
  66. package/dist/lib/Characteristic.d.ts.map +1 -1
  67. package/dist/lib/Characteristic.js +155 -127
  68. package/dist/lib/Characteristic.js.map +1 -1
  69. package/dist/lib/HAPServer.d.ts +72 -18
  70. package/dist/lib/HAPServer.d.ts.map +1 -1
  71. package/dist/lib/HAPServer.js +178 -160
  72. package/dist/lib/HAPServer.js.map +1 -1
  73. package/dist/lib/Service.d.ts +266 -14
  74. package/dist/lib/Service.d.ts.map +1 -1
  75. package/dist/lib/Service.js +36 -35
  76. package/dist/lib/Service.js.map +1 -1
  77. package/dist/lib/camera/Camera.d.ts +13 -4
  78. package/dist/lib/camera/Camera.d.ts.map +1 -1
  79. package/dist/lib/camera/Camera.js +3 -0
  80. package/dist/lib/camera/Camera.js.map +1 -1
  81. package/dist/lib/camera/RTPProxy.d.ts +5 -0
  82. package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
  83. package/dist/lib/camera/RTPProxy.js +2 -1
  84. package/dist/lib/camera/RTPProxy.js.map +1 -1
  85. package/dist/lib/camera/RTPStreamManagement.d.ts +154 -31
  86. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
  87. package/dist/lib/camera/RTPStreamManagement.js +198 -161
  88. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  89. package/dist/lib/camera/RecordingManagement.d.ts +61 -11
  90. package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
  91. package/dist/lib/camera/RecordingManagement.js +171 -138
  92. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  93. package/dist/lib/camera/index.js +4 -4
  94. package/dist/lib/camera/index.js.map +1 -1
  95. package/dist/lib/controller/AdaptiveLightingController.d.ts +28 -2
  96. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
  97. package/dist/lib/controller/AdaptiveLightingController.js +72 -65
  98. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  99. package/dist/lib/controller/CameraController.d.ts +44 -13
  100. package/dist/lib/controller/CameraController.d.ts.map +1 -1
  101. package/dist/lib/controller/CameraController.js +42 -34
  102. package/dist/lib/controller/CameraController.js.map +1 -1
  103. package/dist/lib/controller/Controller.d.ts +28 -7
  104. package/dist/lib/controller/Controller.d.ts.map +1 -1
  105. package/dist/lib/controller/Controller.js +7 -0
  106. package/dist/lib/controller/Controller.js.map +1 -1
  107. package/dist/lib/controller/DoorbellController.d.ts +5 -1
  108. package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
  109. package/dist/lib/controller/DoorbellController.js +5 -3
  110. package/dist/lib/controller/DoorbellController.js.map +1 -1
  111. package/dist/lib/controller/RemoteController.d.ts +108 -39
  112. package/dist/lib/controller/RemoteController.d.ts.map +1 -1
  113. package/dist/lib/controller/RemoteController.js +190 -175
  114. package/dist/lib/controller/RemoteController.js.map +1 -1
  115. package/dist/lib/controller/index.js +5 -5
  116. package/dist/lib/controller/index.js.map +1 -1
  117. package/dist/lib/datastream/DataStreamManagement.d.ts +25 -19
  118. package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
  119. package/dist/lib/datastream/DataStreamManagement.js +36 -30
  120. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  121. package/dist/lib/datastream/DataStreamParser.d.ts +39 -0
  122. package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
  123. package/dist/lib/datastream/DataStreamParser.js +125 -88
  124. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  125. package/dist/lib/datastream/DataStreamServer.d.ts +121 -46
  126. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
  127. package/dist/lib/datastream/DataStreamServer.js +134 -100
  128. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  129. package/dist/lib/datastream/index.js +3 -3
  130. package/dist/lib/datastream/index.js.map +1 -1
  131. package/dist/lib/definitions/CharacteristicDefinitions.js +799 -799
  132. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  133. package/dist/lib/definitions/ServiceDefinitions.js +77 -77
  134. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  135. package/dist/lib/definitions/generate-definitions.js +60 -59
  136. package/dist/lib/definitions/generate-definitions.js.map +1 -1
  137. package/dist/lib/definitions/generator-configuration.js +15 -15
  138. package/dist/lib/definitions/generator-configuration.js.map +1 -1
  139. package/dist/lib/definitions/index.js +2 -2
  140. package/dist/lib/definitions/index.js.map +1 -1
  141. package/dist/lib/model/AccessoryInfo.d.ts +10 -4
  142. package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
  143. package/dist/lib/model/AccessoryInfo.js +21 -17
  144. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  145. package/dist/lib/model/ControllerStorage.d.ts +3 -0
  146. package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
  147. package/dist/lib/model/ControllerStorage.js +8 -5
  148. package/dist/lib/model/ControllerStorage.js.map +1 -1
  149. package/dist/lib/model/HAPStorage.d.ts +3 -0
  150. package/dist/lib/model/HAPStorage.d.ts.map +1 -1
  151. package/dist/lib/model/HAPStorage.js +4 -1
  152. package/dist/lib/model/HAPStorage.js.map +1 -1
  153. package/dist/lib/model/IdentifierCache.d.ts +1 -0
  154. package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
  155. package/dist/lib/model/IdentifierCache.js +3 -2
  156. package/dist/lib/model/IdentifierCache.js.map +1 -1
  157. package/dist/lib/tv/AccessControlManagement.d.ts +11 -0
  158. package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
  159. package/dist/lib/tv/AccessControlManagement.js +15 -7
  160. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  161. package/dist/lib/util/clone.d.ts +2 -1
  162. package/dist/lib/util/clone.d.ts.map +1 -1
  163. package/dist/lib/util/clone.js +5 -4
  164. package/dist/lib/util/clone.js.map +1 -1
  165. package/dist/lib/util/color-utils.d.ts +3 -0
  166. package/dist/lib/util/color-utils.d.ts.map +1 -1
  167. package/dist/lib/util/color-utils.js +4 -1
  168. package/dist/lib/util/color-utils.js.map +1 -1
  169. package/dist/lib/util/eventedhttp.d.ts +34 -5
  170. package/dist/lib/util/eventedhttp.d.ts.map +1 -1
  171. package/dist/lib/util/eventedhttp.js +62 -51
  172. package/dist/lib/util/eventedhttp.js.map +1 -1
  173. package/dist/lib/util/hapCrypto.d.ts +27 -0
  174. package/dist/lib/util/hapCrypto.d.ts.map +1 -1
  175. package/dist/lib/util/hapCrypto.js +28 -4
  176. package/dist/lib/util/hapCrypto.js.map +1 -1
  177. package/dist/lib/util/hapStatusError.d.ts +2 -0
  178. package/dist/lib/util/hapStatusError.d.ts.map +1 -1
  179. package/dist/lib/util/hapStatusError.js +4 -2
  180. package/dist/lib/util/hapStatusError.js.map +1 -1
  181. package/dist/lib/util/net-utils.d.ts +7 -0
  182. package/dist/lib/util/net-utils.d.ts.map +1 -1
  183. package/dist/lib/util/net-utils.js +11 -4
  184. package/dist/lib/util/net-utils.js.map +1 -1
  185. package/dist/lib/util/once.d.ts +5 -0
  186. package/dist/lib/util/once.d.ts.map +1 -1
  187. package/dist/lib/util/once.js +6 -1
  188. package/dist/lib/util/once.js.map +1 -1
  189. package/dist/lib/util/promise-utils.d.ts +9 -0
  190. package/dist/lib/util/promise-utils.d.ts.map +1 -1
  191. package/dist/lib/util/promise-utils.js +3 -0
  192. package/dist/lib/util/promise-utils.js.map +1 -1
  193. package/dist/lib/util/request-util.d.ts +16 -0
  194. package/dist/lib/util/request-util.d.ts.map +1 -1
  195. package/dist/lib/util/request-util.js +42 -27
  196. package/dist/lib/util/request-util.js.map +1 -1
  197. package/dist/lib/util/time.d.ts +6 -0
  198. package/dist/lib/util/time.d.ts.map +1 -1
  199. package/dist/lib/util/time.js +7 -1
  200. package/dist/lib/util/time.js.map +1 -1
  201. package/dist/lib/util/tlv.d.ts +33 -2
  202. package/dist/lib/util/tlv.d.ts.map +1 -1
  203. package/dist/lib/util/tlv.js +29 -5
  204. package/dist/lib/util/tlv.js.map +1 -1
  205. package/dist/lib/util/uuid.d.ts +2 -3
  206. package/dist/lib/util/uuid.d.ts.map +1 -1
  207. package/dist/lib/util/uuid.js +1 -1
  208. package/dist/lib/util/uuid.js.map +1 -1
  209. package/dist/types.d.ts +267 -19
  210. package/dist/types.d.ts.map +1 -1
  211. package/dist/types.js +8 -0
  212. package/dist/types.js.map +1 -1
  213. package/package.json +5 -4
  214. package/dist/lib/util/HAPHTTPError.d.ts +0 -16
  215. package/dist/lib/util/HAPHTTPError.d.ts.map +0 -1
  216. package/dist/lib/util/HAPHTTPError.js +0 -26
  217. package/dist/lib/util/HAPHTTPError.js.map +0 -1
  218. package/dist/lib/util/tlvError.d.ts +0 -14
  219. package/dist/lib/util/tlvError.d.ts.map +0 -1
  220. package/dist/lib/util/tlvError.js +0 -24
  221. package/dist/lib/util/tlvError.js.map +0 -1
@@ -2,8 +2,8 @@
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
4
  var tslib_1 = require("tslib");
5
- var assert_1 = (0, tslib_1.__importDefault)(require("assert"));
6
- var debug_1 = (0, tslib_1.__importDefault)(require("debug"));
5
+ var assert_1 = tslib_1.__importDefault(require("assert"));
6
+ var debug_1 = tslib_1.__importDefault(require("debug"));
7
7
  var events_1 = require("events");
8
8
  var HAPServer_1 = require("./HAPServer");
9
9
  var clone_1 = require("./util/clone");
@@ -12,6 +12,9 @@ var once_1 = require("./util/once");
12
12
  var request_util_1 = require("./util/request-util");
13
13
  var uuid_1 = require("./util/uuid");
14
14
  var debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
15
+ /**
16
+ * @group Characteristic
17
+ */
15
18
  var Formats;
16
19
  (function (Formats) {
17
20
  Formats["BOOL"] = "bool";
@@ -60,6 +63,9 @@ var Formats;
60
63
  */
61
64
  Formats["DICTIONARY"] = "dict";
62
65
  })(Formats = exports.Formats || (exports.Formats = {}));
66
+ /**
67
+ * @group Characteristic
68
+ */
63
69
  var Units;
64
70
  (function (Units) {
65
71
  /**
@@ -73,6 +79,9 @@ var Units;
73
79
  Units["LUX"] = "lux";
74
80
  Units["SECONDS"] = "seconds";
75
81
  })(Units = exports.Units || (exports.Units = {}));
82
+ /**
83
+ * @group Characteristic
84
+ */
76
85
  var Perms;
77
86
  (function (Perms) {
78
87
  // noinspection JSUnusedGlobalSymbols
@@ -93,12 +102,23 @@ var Perms;
93
102
  Perms["HIDDEN"] = "hd";
94
103
  Perms["WRITE_RESPONSE"] = "wr";
95
104
  })(Perms = exports.Perms || (exports.Perms = {}));
105
+ /**
106
+ * Describes the abstract access to a {@link Characteristic}.
107
+ * It abstracts the more granular access described by {@link Perms}.
108
+ *
109
+ * It is used in {@link CharacteristicProps.adminOnlyAccess}.
110
+ *
111
+ * @group Characteristic
112
+ */
96
113
  var Access;
97
114
  (function (Access) {
98
115
  Access[Access["READ"] = 0] = "READ";
99
116
  Access[Access["WRITE"] = 1] = "WRITE";
100
117
  Access[Access["NOTIFY"] = 2] = "NOTIFY";
101
118
  })(Access = exports.Access || (exports.Access = {}));
119
+ /**
120
+ * @group Characteristic
121
+ */
102
122
  var ChangeReason;
103
123
  (function (ChangeReason) {
104
124
  /**
@@ -110,7 +130,7 @@ var ChangeReason;
110
130
  */
111
131
  ChangeReason["UPDATE"] = "update";
112
132
  /**
113
- * Used when HomeKit reads a value or the API user calls the deprecated method {@link Characteristic.getValue}.
133
+ * Used when HomeKit reads a value or the API user calls the deprecated method `Characteristic.getValue`.
114
134
  */
115
135
  ChangeReason["READ"] = "read";
116
136
  /**
@@ -118,6 +138,9 @@ var ChangeReason;
118
138
  */
119
139
  ChangeReason["EVENT"] = "event";
120
140
  })(ChangeReason = exports.ChangeReason || (exports.ChangeReason = {}));
141
+ /**
142
+ * @group Characteristic
143
+ */
121
144
  var CharacteristicEventTypes;
122
145
  (function (CharacteristicEventTypes) {
123
146
  /**
@@ -152,6 +175,9 @@ var CharacteristicEventTypes;
152
175
  */
153
176
  CharacteristicEventTypes["CHARACTERISTIC_WARNING"] = "characteristic-warning";
154
177
  })(CharacteristicEventTypes = exports.CharacteristicEventTypes || (exports.CharacteristicEventTypes = {}));
178
+ /**
179
+ * @group Characteristic
180
+ */
155
181
  var ValidValuesIterable = /** @class */ (function () {
156
182
  function ValidValuesIterable(props) {
157
183
  (0, assert_1.default)((0, request_util_1.isNumericFormat)(props.format), "Cannot instantiate valid values iterable when format is not numeric. Found " + props.format);
@@ -160,14 +186,14 @@ var ValidValuesIterable = /** @class */ (function () {
160
186
  ValidValuesIterable.prototype[Symbol.iterator] = function () {
161
187
  var _a, _b, value, e_1_1, min, max, stepValue, i;
162
188
  var e_1, _c;
163
- return (0, tslib_1.__generator)(this, function (_d) {
189
+ return tslib_1.__generator(this, function (_d) {
164
190
  switch (_d.label) {
165
191
  case 0:
166
192
  if (!this.props.validValues) return [3 /*break*/, 9];
167
193
  _d.label = 1;
168
194
  case 1:
169
195
  _d.trys.push([1, 6, 7, 8]);
170
- _a = (0, tslib_1.__values)(this.props.validValues), _b = _a.next();
196
+ _a = tslib_1.__values(this.props.validValues), _b = _a.next();
171
197
  _d.label = 2;
172
198
  case 2:
173
199
  if (!!_b.done) return [3 /*break*/, 5];
@@ -231,7 +257,7 @@ var ValidValuesIterable = /** @class */ (function () {
231
257
  }());
232
258
  var numberPattern = /^-?\d+$/;
233
259
  function extractHAPStatusFromError(error) {
234
- var errorValue = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
260
+ var errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
235
261
  if (numberPattern.test(error.message)) {
236
262
  var value = parseInt(error.message, 10);
237
263
  if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
@@ -271,9 +297,11 @@ function minWithUndefined(a, b) {
271
297
  *
272
298
  * You can also define custom Characteristics by providing your own UUID. Custom Characteristics can be added
273
299
  * to any native or custom Services, but Siri will likely not be able to work with these.
300
+ *
301
+ * @group Characteristic
274
302
  */
275
303
  var Characteristic = /** @class */ (function (_super) {
276
- (0, tslib_1.__extends)(Characteristic, _super);
304
+ tslib_1.__extends(Characteristic, _super);
277
305
  function Characteristic(displayName, UUID, props) {
278
306
  var _this = _super.call(this) || this;
279
307
  _this.iid = null;
@@ -286,13 +314,13 @@ var Characteristic = /** @class */ (function (_super) {
286
314
  /**
287
315
  * @private
288
316
  */
289
- _this.statusCode = 0 /* SUCCESS */;
317
+ _this.statusCode = 0 /* HAPStatus.SUCCESS */;
290
318
  _this.subscriptions = 0;
291
319
  _this.displayName = displayName;
292
320
  _this.UUID = UUID;
293
321
  _this.props = {
294
- format: "int" /* INT */,
295
- perms: ["ev" /* NOTIFY */],
322
+ format: "int" /* Formats.INT */,
323
+ perms: ["ev" /* Perms.NOTIFY */],
296
324
  };
297
325
  _this.setProps(props || {}); // ensure sanity checks are called
298
326
  return _this;
@@ -386,22 +414,22 @@ var Characteristic = /** @class */ (function (_super) {
386
414
  props.minValue = undefined;
387
415
  }
388
416
  else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
389
- this.characteristicWarning("Characteristic Property 'minValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* ERROR_MESSAGE */);
417
+ this.characteristicWarning("Characteristic Property 'minValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
390
418
  props.minValue = undefined;
391
419
  }
392
420
  else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
393
- this.characteristicWarning("Characteristic Property 'minValue' must be a finite number, received \"".concat(props.minValue, "\" (").concat(typeof props.minValue, ")"), "error-message" /* ERROR_MESSAGE */);
421
+ this.characteristicWarning("Characteristic Property 'minValue' must be a finite number, received \"".concat(props.minValue, "\" (").concat(typeof props.minValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
394
422
  props.minValue = undefined;
395
423
  }
396
424
  else {
397
425
  if (props.minValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
398
426
  this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
399
- this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* ERROR_MESSAGE */);
427
+ this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
400
428
  props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
401
429
  }
402
430
  else if (props.minValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
403
431
  this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
404
- this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* ERROR_MESSAGE */);
432
+ this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
405
433
  props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
406
434
  }
407
435
  }
@@ -413,22 +441,22 @@ var Characteristic = /** @class */ (function (_super) {
413
441
  props.maxValue = undefined;
414
442
  }
415
443
  else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
416
- this.characteristicWarning("Characteristic Property 'maxValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* ERROR_MESSAGE */);
444
+ this.characteristicWarning("Characteristic Property 'maxValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
417
445
  props.maxValue = undefined;
418
446
  }
419
447
  else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
420
- this.characteristicWarning("Characteristic Property 'maxValue' must be a finite number, received \"".concat(props.maxValue, "\" (").concat(typeof props.maxValue, ")"), "error-message" /* ERROR_MESSAGE */);
448
+ this.characteristicWarning("Characteristic Property 'maxValue' must be a finite number, received \"".concat(props.maxValue, "\" (").concat(typeof props.maxValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
421
449
  props.maxValue = undefined;
422
450
  }
423
451
  else {
424
452
  if (props.maxValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
425
453
  this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
426
- this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* ERROR_MESSAGE */);
454
+ this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
427
455
  props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
428
456
  }
429
457
  else if (props.maxValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
430
458
  this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
431
- this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* ERROR_MESSAGE */);
459
+ this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
432
460
  props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
433
461
  }
434
462
  }
@@ -439,7 +467,7 @@ var Characteristic = /** @class */ (function (_super) {
439
467
  this.props.minStep = undefined;
440
468
  }
441
469
  else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
442
- this.characteristicWarning("Characteristic Property `minStep` can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* ERROR_MESSAGE */);
470
+ this.characteristicWarning("Characteristic Property `minStep` can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
443
471
  }
444
472
  else {
445
473
  if (props.minStep < 1 && (0, request_util_1.isIntegerNumericFormat)(this.props.format)) {
@@ -453,8 +481,8 @@ var Characteristic = /** @class */ (function (_super) {
453
481
  if (props.maxLen === null) {
454
482
  this.props.maxLen = undefined;
455
483
  }
456
- else if (this.props.format !== "string" /* STRING */) {
457
- this.characteristicWarning("Characteristic Property `maxLen` can only be set for characteristics with format `STRING`, but not for " + this.props.format, "error-message" /* ERROR_MESSAGE */);
484
+ else if (this.props.format !== "string" /* Formats.STRING */) {
485
+ this.characteristicWarning("Characteristic Property `maxLen` can only be set for characteristics with format `STRING`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
458
486
  }
459
487
  else {
460
488
  if (props.maxLen > 256) {
@@ -468,8 +496,8 @@ var Characteristic = /** @class */ (function (_super) {
468
496
  if (props.maxDataLen === null) {
469
497
  this.props.maxDataLen = undefined;
470
498
  }
471
- else if (this.props.format !== "data" /* DATA */) {
472
- this.characteristicWarning("Characteristic Property `maxDataLen` can only be set for characteristics with format `DATA`, but not for " + this.props.format, "error-message" /* ERROR_MESSAGE */);
499
+ else if (this.props.format !== "data" /* Formats.DATA */) {
500
+ this.characteristicWarning("Characteristic Property `maxDataLen` can only be set for characteristics with format `DATA`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
473
501
  }
474
502
  else {
475
503
  this.props.maxDataLen = props.maxDataLen;
@@ -509,10 +537,10 @@ var Characteristic = /** @class */ (function (_super) {
509
537
  throw new Error("Error setting CharacteristicsProps for '" + this.displayName + "': 'minValue' cannot be greater or equal the 'maxValue'!");
510
538
  }
511
539
  }
512
- if (((0, request_util_1.isNumericFormat)(this.props.format) || this.props.format === "string" /* STRING */)
540
+ if (((0, request_util_1.isNumericFormat)(this.props.format) || this.props.format === "string" /* Formats.STRING */)
513
541
  && this.value != null
514
542
  && !formatDidChange
515
- && this.statusCode === 0 /* SUCCESS */
543
+ && this.statusCode === 0 /* HAPStatus.SUCCESS */
516
544
  && this.UUID !== Characteristic.ProgrammableSwitchEvent.UUID) {
517
545
  // explaining the if statement above:
518
546
  // - We only do a check for numeric and string formats as they are the only ones affected by characteristic property restrictions.
@@ -521,7 +549,7 @@ var Characteristic = /** @class */ (function (_super) {
521
549
  // - If the characteristic is marked as erroneous the value is not considered valid anyway, and we must not remove the `statusCode`.
522
550
  // - Special case for `ProgrammableSwitchEvent` where every change in value is considered an event which would result in ghost button presses
523
551
  // validateUserInput when called from setProps is intended to clamp value withing allowed range. It is why warnings should not be displayed.
524
- var correctedValue = this.validateUserInput(this.value, "debug-message" /* DEBUG_MESSAGE */);
552
+ var correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
525
553
  if (correctedValue !== this.value) {
526
554
  // we don't want to emit a CHANGE event if the value didn't change at all!
527
555
  this.updateValue(correctedValue);
@@ -578,8 +606,8 @@ var Characteristic = /** @class */ (function (_super) {
578
606
  * @param handler - Handler called to check additional authorization data.
579
607
  */
580
608
  Characteristic.prototype.setupAdditionalAuthorization = function (handler) {
581
- if (!this.props.perms.includes("aa" /* ADDITIONAL_AUTHORIZATION */)) {
582
- this.props.perms.push("aa" /* ADDITIONAL_AUTHORIZATION */);
609
+ if (!this.props.perms.includes("aa" /* Perms.ADDITIONAL_AUTHORIZATION */)) {
610
+ this.props.perms.push("aa" /* Perms.ADDITIONAL_AUTHORIZATION */);
583
611
  }
584
612
  this.additionalAuthorizationHandler = handler;
585
613
  };
@@ -621,7 +649,7 @@ var Characteristic = /** @class */ (function (_super) {
621
649
  value = this.validateUserInput(value);
622
650
  }
623
651
  catch (error) {
624
- this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
652
+ this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
625
653
  if (callback) {
626
654
  callback(error);
627
655
  }
@@ -661,13 +689,13 @@ var Characteristic = /** @class */ (function (_super) {
661
689
  value = this.validateUserInput(value);
662
690
  }
663
691
  catch (error) {
664
- this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
692
+ this.characteristicWarning((error === null || error === void 0 ? void 0 : error.message) + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
665
693
  if (callback) {
666
694
  callback();
667
695
  }
668
696
  return this;
669
697
  }
670
- this.statusCode = 0 /* SUCCESS */;
698
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
671
699
  // noinspection JSDeprecatedSymbols
672
700
  this.status = null;
673
701
  var oldValue = this.value;
@@ -675,7 +703,7 @@ var Characteristic = /** @class */ (function (_super) {
675
703
  if (callback) {
676
704
  callback();
677
705
  }
678
- this.emit("change" /* CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* UPDATE */, context: context });
706
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
679
707
  return this; // for chaining
680
708
  };
681
709
  /**
@@ -688,13 +716,13 @@ var Characteristic = /** @class */ (function (_super) {
688
716
  * @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler.
689
717
  */
690
718
  Characteristic.prototype.sendEventNotification = function (value, context) {
691
- this.statusCode = 0 /* SUCCESS */;
719
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
692
720
  // noinspection JSDeprecatedSymbols
693
721
  this.status = null;
694
722
  value = this.validateUserInput(value);
695
723
  var oldValue = this.value;
696
724
  this.value = value;
697
- this.emit("change" /* CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* EVENT */, context: context });
725
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
698
726
  return this; // for chaining
699
727
  };
700
728
  /**
@@ -705,21 +733,21 @@ var Characteristic = /** @class */ (function (_super) {
705
733
  * @private Used by the Accessory to load the characteristic value
706
734
  */
707
735
  Characteristic.prototype.handleGetRequest = function (connection, context) {
708
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
736
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
709
737
  var value, oldValue, error_1, hapStatusError;
710
738
  var _this = this;
711
- return (0, tslib_1.__generator)(this, function (_a) {
739
+ return tslib_1.__generator(this, function (_a) {
712
740
  switch (_a.label) {
713
741
  case 0:
714
- if (!this.props.perms.includes("pr" /* PAIRED_READ */)) { // check if we are allowed to read from this characteristic
715
- throw -70405 /* WRITE_ONLY_CHARACTERISTIC */;
742
+ if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
743
+ throw -70405 /* HAPStatus.WRITE_ONLY_CHARACTERISTIC */;
716
744
  }
717
745
  if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
718
746
  // special workaround for event only programmable switch event, which must always return null
719
747
  return [2 /*return*/, null];
720
748
  }
721
749
  if (!this.getHandler) return [3 /*break*/, 4];
722
- if (this.listeners("get" /* GET */).length > 0) {
750
+ if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
723
751
  this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
724
752
  }
725
753
  _a.label = 1;
@@ -728,23 +756,23 @@ var Characteristic = /** @class */ (function (_super) {
728
756
  return [4 /*yield*/, this.getHandler(context, connection)];
729
757
  case 2:
730
758
  value = _a.sent();
731
- this.statusCode = 0 /* SUCCESS */;
759
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
732
760
  // noinspection JSDeprecatedSymbols
733
761
  this.status = null;
734
762
  try {
735
763
  value = this.validateUserInput(value);
736
764
  }
737
765
  catch (error) {
738
- this.characteristicWarning("An illegal value was supplied by the read handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "warn-message" /* WARN_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
739
- this.statusCode = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
766
+ this.characteristicWarning("An illegal value was supplied by the read handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
767
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
740
768
  // noinspection JSDeprecatedSymbols
741
769
  this.status = error;
742
- return [2 /*return*/, Promise.reject(-70402 /* SERVICE_COMMUNICATION_FAILURE */)];
770
+ return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
743
771
  }
744
772
  oldValue = this.value;
745
773
  this.value = value;
746
774
  if (oldValue !== value) { // emit a change event if necessary
747
- this.emit("change" /* CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* READ */, context: context });
775
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
748
776
  }
749
777
  return [2 /*return*/, value];
750
778
  case 3:
@@ -761,14 +789,14 @@ var Characteristic = /** @class */ (function (_super) {
761
789
  this.status = error_1;
762
790
  }
763
791
  else {
764
- this.characteristicWarning("Unhandled error thrown inside read handler for characteristic: ".concat(error_1 === null || error_1 === void 0 ? void 0 : error_1.message), "error-message" /* ERROR_MESSAGE */, error_1 === null || error_1 === void 0 ? void 0 : error_1.stack);
765
- this.statusCode = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
792
+ this.characteristicWarning("Unhandled error thrown inside read handler for characteristic: ".concat(error_1 === null || error_1 === void 0 ? void 0 : error_1.message), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error_1 === null || error_1 === void 0 ? void 0 : error_1.stack);
793
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
766
794
  // noinspection JSDeprecatedSymbols
767
795
  this.status = error_1;
768
796
  }
769
797
  throw this.statusCode;
770
798
  case 4:
771
- if (this.listeners("get" /* GET */).length === 0) {
799
+ if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
772
800
  if (this.statusCode) {
773
801
  throw this.statusCode;
774
802
  }
@@ -776,13 +804,13 @@ var Characteristic = /** @class */ (function (_super) {
776
804
  return [2 /*return*/, this.validateUserInput(this.value)];
777
805
  }
778
806
  catch (error) {
779
- this.characteristicWarning("An illegal value was supplied by setting `value` for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "warn-message" /* WARN_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
780
- return [2 /*return*/, Promise.reject(-70402 /* SERVICE_COMMUNICATION_FAILURE */)];
807
+ 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);
808
+ return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
781
809
  }
782
810
  }
783
811
  return [2 /*return*/, new Promise(function (resolve, reject) {
784
812
  try {
785
- _this.emit("get" /* GET */, (0, once_1.once)(function (status, value) {
813
+ _this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)(function (status, value) {
786
814
  if (status) {
787
815
  if (typeof status === "number") {
788
816
  var hapStatusError = new hapStatusError_1.HapStatusError(status);
@@ -804,7 +832,7 @@ var Characteristic = /** @class */ (function (_super) {
804
832
  reject(_this.statusCode);
805
833
  return;
806
834
  }
807
- _this.statusCode = 0 /* SUCCESS */;
835
+ _this.statusCode = 0 /* HAPStatus.SUCCESS */;
808
836
  // noinspection JSDeprecatedSymbols
809
837
  _this.status = null;
810
838
  value = _this.validateUserInput(value);
@@ -812,16 +840,16 @@ var Characteristic = /** @class */ (function (_super) {
812
840
  _this.value = value;
813
841
  resolve(value);
814
842
  if (oldValue !== value) { // emit a change event if necessary
815
- _this.emit("change" /* CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* READ */, context: context });
843
+ _this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
816
844
  }
817
845
  }), context, connection);
818
846
  }
819
847
  catch (error) {
820
- _this.characteristicWarning("Unhandled error thrown inside read handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "error-message" /* ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
821
- _this.statusCode = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
848
+ _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);
849
+ _this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
822
850
  // noinspection JSDeprecatedSymbols
823
851
  _this.status = error;
824
- reject(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
852
+ reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
825
853
  }
826
854
  })];
827
855
  }
@@ -840,13 +868,13 @@ var Characteristic = /** @class */ (function (_super) {
840
868
  * @private
841
869
  */
842
870
  Characteristic.prototype.handleSetRequest = function (value, connection, context) {
843
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
871
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
844
872
  var oldValue, writeResponse, error_2, hapStatusError;
845
873
  var _this = this;
846
- return (0, tslib_1.__generator)(this, function (_a) {
874
+ return tslib_1.__generator(this, function (_a) {
847
875
  switch (_a.label) {
848
876
  case 0:
849
- this.statusCode = 0 /* SUCCESS */;
877
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
850
878
  // noinspection JSDeprecatedSymbols
851
879
  this.status = null;
852
880
  if (connection !== undefined) {
@@ -857,12 +885,12 @@ var Characteristic = /** @class */ (function (_super) {
857
885
  }
858
886
  catch (e) {
859
887
  debug("[".concat(this.displayName, "]"), e.message);
860
- return [2 /*return*/, Promise.reject(-70410 /* INVALID_VALUE_IN_REQUEST */)];
888
+ return [2 /*return*/, Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */)];
861
889
  }
862
890
  }
863
891
  oldValue = this.value;
864
892
  if (!this.setHandler) return [3 /*break*/, 4];
865
- if (this.listeners("set" /* SET */).length > 0) {
893
+ if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
866
894
  this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
867
895
  }
868
896
  _a.label = 1;
@@ -871,19 +899,19 @@ var Characteristic = /** @class */ (function (_super) {
871
899
  return [4 /*yield*/, this.setHandler(value, context, connection)];
872
900
  case 2:
873
901
  writeResponse = _a.sent();
874
- this.statusCode = 0 /* SUCCESS */;
902
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
875
903
  // noinspection JSDeprecatedSymbols
876
904
  this.status = null;
877
- if (writeResponse != null && this.props.perms.includes("wr" /* WRITE_RESPONSE */)) {
905
+ if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
878
906
  this.value = this.validateUserInput(writeResponse);
879
907
  return [2 /*return*/, this.value];
880
908
  }
881
909
  else {
882
910
  if (writeResponse != null) {
883
- this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* DEBUG_MESSAGE */);
911
+ this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
884
912
  }
885
913
  this.value = value;
886
- this.emit("change" /* CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* WRITE */, context: context });
914
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
887
915
  return [2 /*return*/];
888
916
  }
889
917
  return [3 /*break*/, 4];
@@ -901,22 +929,22 @@ var Characteristic = /** @class */ (function (_super) {
901
929
  this.status = error_2;
902
930
  }
903
931
  else {
904
- 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" /* ERROR_MESSAGE */, error_2 === null || error_2 === void 0 ? void 0 : error_2.stack);
905
- this.statusCode = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
932
+ 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);
933
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
906
934
  // noinspection JSDeprecatedSymbols
907
935
  this.status = error_2;
908
936
  }
909
937
  throw this.statusCode;
910
938
  case 4:
911
- if (this.listeners("set" /* SET */).length === 0) {
939
+ if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
912
940
  this.value = value;
913
- this.emit("change" /* CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* WRITE */, context: context });
941
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
914
942
  return [2 /*return*/, Promise.resolve()];
915
943
  }
916
944
  else {
917
945
  return [2 /*return*/, new Promise(function (resolve, reject) {
918
946
  try {
919
- _this.emit("set" /* SET */, value, (0, once_1.once)(function (status, writeResponse) {
947
+ _this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)(function (status, writeResponse) {
920
948
  if (status) {
921
949
  if (typeof status === "number") {
922
950
  var hapStatusError = new hapStatusError_1.HapStatusError(status);
@@ -938,30 +966,30 @@ var Characteristic = /** @class */ (function (_super) {
938
966
  reject(_this.statusCode);
939
967
  return;
940
968
  }
941
- _this.statusCode = 0 /* SUCCESS */;
969
+ _this.statusCode = 0 /* HAPStatus.SUCCESS */;
942
970
  // noinspection JSDeprecatedSymbols
943
971
  _this.status = null;
944
- if (writeResponse != null && _this.props.perms.includes("wr" /* WRITE_RESPONSE */)) {
972
+ if (writeResponse != null && _this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
945
973
  // support write response simply by letting the implementor pass the response as second argument to the callback
946
974
  _this.value = _this.validateUserInput(writeResponse);
947
975
  resolve(_this.value);
948
976
  }
949
977
  else {
950
978
  if (writeResponse != null) {
951
- _this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* DEBUG_MESSAGE */);
979
+ _this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
952
980
  }
953
981
  _this.value = value;
954
982
  resolve();
955
- _this.emit("change" /* CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* WRITE */, context: context });
983
+ _this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
956
984
  }
957
985
  }), context, connection);
958
986
  }
959
987
  catch (error) {
960
- _this.characteristicWarning("Unhandled error thrown inside write handler for characteristic: ".concat(error === null || error === void 0 ? void 0 : error.message), "error-message" /* ERROR_MESSAGE */, error === null || error === void 0 ? void 0 : error.stack);
961
- _this.statusCode = -70402 /* SERVICE_COMMUNICATION_FAILURE */;
988
+ _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);
989
+ _this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
962
990
  // noinspection JSDeprecatedSymbols
963
991
  _this.status = error;
964
- reject(-70402 /* SERVICE_COMMUNICATION_FAILURE */);
992
+ reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
965
993
  }
966
994
  })];
967
995
  }
@@ -976,7 +1004,7 @@ var Characteristic = /** @class */ (function (_super) {
976
1004
  */
977
1005
  Characteristic.prototype.subscribe = function () {
978
1006
  if (this.subscriptions === 0) {
979
- this.emit("subscribe" /* SUBSCRIBE */);
1007
+ this.emit("subscribe" /* CharacteristicEventTypes.SUBSCRIBE */);
980
1008
  }
981
1009
  this.subscriptions++;
982
1010
  };
@@ -990,16 +1018,16 @@ var Characteristic = /** @class */ (function (_super) {
990
1018
  this.subscriptions--;
991
1019
  this.subscriptions = Math.max(this.subscriptions, 0);
992
1020
  if (wasOne) {
993
- this.emit("unsubscribe" /* UNSUBSCRIBE */);
1021
+ this.emit("unsubscribe" /* CharacteristicEventTypes.UNSUBSCRIBE */);
994
1022
  }
995
1023
  };
996
1024
  Characteristic.prototype.getDefaultValue = function () {
997
1025
  var _a;
998
1026
  // noinspection JSDeprecatedSymbols
999
1027
  switch (this.props.format) {
1000
- case "bool" /* BOOL */:
1028
+ case "bool" /* Formats.BOOL */:
1001
1029
  return false;
1002
- case "string" /* STRING */:
1030
+ case "string" /* Formats.STRING */:
1003
1031
  switch (this.UUID) {
1004
1032
  case Characteristic.Manufacturer.UUID:
1005
1033
  return "Default-Manufacturer";
@@ -1012,20 +1040,20 @@ var Characteristic = /** @class */ (function (_super) {
1012
1040
  default:
1013
1041
  return "";
1014
1042
  }
1015
- case "data" /* DATA */:
1043
+ case "data" /* Formats.DATA */:
1016
1044
  return ""; // who knows!
1017
- case "tlv8" /* TLV8 */:
1045
+ case "tlv8" /* Formats.TLV8 */:
1018
1046
  return ""; // who knows!
1019
- case "dict" /* DICTIONARY */:
1047
+ case "dict" /* Formats.DICTIONARY */:
1020
1048
  return {};
1021
- case "array" /* ARRAY */:
1049
+ case "array" /* Formats.ARRAY */:
1022
1050
  return [];
1023
- case "int" /* INT */:
1024
- case "float" /* FLOAT */:
1025
- case "uint8" /* UINT8 */:
1026
- case "uint16" /* UINT16 */:
1027
- case "uint32" /* UINT32 */:
1028
- case "uint64" /* UINT64 */:
1051
+ case "int" /* Formats.INT */:
1052
+ case "float" /* Formats.FLOAT */:
1053
+ case "uint8" /* Formats.UINT8 */:
1054
+ case "uint16" /* Formats.UINT16 */:
1055
+ case "uint32" /* Formats.UINT32 */:
1056
+ case "uint64" /* Formats.UINT64 */:
1029
1057
  switch (this.UUID) {
1030
1058
  case Characteristic.CurrentTemperature.UUID:
1031
1059
  return 0; // some existing integrations expect this to be 0 by default
@@ -1054,7 +1082,7 @@ var Characteristic = /** @class */ (function (_super) {
1054
1082
  throw new Error("Client supplied invalid value for ".concat(this.props.format, ": ").concat(value));
1055
1083
  }
1056
1084
  switch (this.props.format) {
1057
- case "bool" /* BOOL */: {
1085
+ case "bool" /* Formats.BOOL */: {
1058
1086
  if (typeof value === "boolean") {
1059
1087
  return value;
1060
1088
  }
@@ -1063,12 +1091,12 @@ var Characteristic = /** @class */ (function (_super) {
1063
1091
  }
1064
1092
  throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1065
1093
  }
1066
- case "int" /* INT */:
1067
- case "float" /* FLOAT */:
1068
- case "uint8" /* UINT8 */:
1069
- case "uint16" /* UINT16 */:
1070
- case "uint32" /* UINT32 */:
1071
- case "uint64" /* UINT64 */: {
1094
+ case "int" /* Formats.INT */:
1095
+ case "float" /* Formats.FLOAT */:
1096
+ case "uint8" /* Formats.UINT8 */:
1097
+ case "uint16" /* Formats.UINT16 */:
1098
+ case "uint32" /* Formats.UINT32 */:
1099
+ case "uint64" /* Formats.UINT64 */: {
1072
1100
  if (typeof value === "boolean") {
1073
1101
  value = value ? 1 : 0;
1074
1102
  }
@@ -1096,7 +1124,7 @@ var Characteristic = /** @class */ (function (_super) {
1096
1124
  }
1097
1125
  return value;
1098
1126
  }
1099
- case "string" /* STRING */: {
1127
+ case "string" /* Formats.STRING */: {
1100
1128
  if (typeof value !== "string") {
1101
1129
  throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1102
1130
  }
@@ -1106,7 +1134,7 @@ var Characteristic = /** @class */ (function (_super) {
1106
1134
  }
1107
1135
  return value;
1108
1136
  }
1109
- case "data" /* DATA */: {
1137
+ case "data" /* Formats.DATA */: {
1110
1138
  if (typeof value !== "string") {
1111
1139
  throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1112
1140
  }
@@ -1117,7 +1145,7 @@ var Characteristic = /** @class */ (function (_super) {
1117
1145
  }
1118
1146
  return value;
1119
1147
  }
1120
- case "tlv8" /* TLV8 */:
1148
+ case "tlv8" /* Formats.TLV8 */:
1121
1149
  if (typeof value !== "string") {
1122
1150
  throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1123
1151
  }
@@ -1135,13 +1163,13 @@ var Characteristic = /** @class */ (function (_super) {
1135
1163
  */
1136
1164
  Characteristic.prototype.validateUserInput = function (value, warningType) {
1137
1165
  var _a;
1138
- if (warningType === void 0) { warningType = "warn-message" /* WARN_MESSAGE */; }
1166
+ if (warningType === void 0) { warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
1139
1167
  if (value === null) {
1140
1168
  if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
1141
- this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* ERROR_MESSAGE */);
1169
+ this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1142
1170
  return this.value; // don't change the value
1143
1171
  }
1144
- if (this.props.format === "data" /* DATA */ || this.props.format === "tlv8" /* TLV8 */) {
1172
+ if (this.props.format === "data" /* Formats.DATA */ || this.props.format === "tlv8" /* Formats.TLV8 */) {
1145
1173
  return value; // TLV8 and DATA formats are allowed to have null as a value
1146
1174
  }
1147
1175
  /**
@@ -1170,7 +1198,7 @@ var Characteristic = /** @class */ (function (_super) {
1170
1198
  }
1171
1199
  }
1172
1200
  switch (this.props.format) {
1173
- case "bool" /* BOOL */: {
1201
+ case "bool" /* Formats.BOOL */: {
1174
1202
  if (typeof value === "boolean") {
1175
1203
  return value;
1176
1204
  }
@@ -1183,17 +1211,17 @@ var Characteristic = /** @class */ (function (_super) {
1183
1211
  this.characteristicWarning("characteristic value expected boolean and received " + typeof value, warningType);
1184
1212
  return false;
1185
1213
  }
1186
- case "int" /* INT */:
1187
- case "float" /* FLOAT */:
1188
- case "uint8" /* UINT8 */:
1189
- case "uint16" /* UINT16 */:
1190
- case "uint32" /* UINT32 */:
1191
- case "uint64" /* UINT64 */: {
1214
+ case "int" /* Formats.INT */:
1215
+ case "float" /* Formats.FLOAT */:
1216
+ case "uint8" /* Formats.UINT8 */:
1217
+ case "uint16" /* Formats.UINT16 */:
1218
+ case "uint32" /* Formats.UINT32 */:
1219
+ case "uint64" /* Formats.UINT64 */: {
1192
1220
  if (typeof value === "boolean") {
1193
1221
  value = value ? 1 : 0;
1194
1222
  }
1195
1223
  if (typeof value === "string") {
1196
- value = this.props.format === "float" /* FLOAT */ ? parseFloat(value) : parseInt(value, 10);
1224
+ value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
1197
1225
  }
1198
1226
  if (typeof value !== "number" || !Number.isFinite(value)) {
1199
1227
  this.characteristicWarning("characteristic value expected valid finite number and received \"".concat(value, "\" (").concat(typeof value, ")"), warningType);
@@ -1202,7 +1230,7 @@ var Characteristic = /** @class */ (function (_super) {
1202
1230
  var numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
1203
1231
  var numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
1204
1232
  var stepValue = undefined;
1205
- if (this.props.format === "float" /* FLOAT */) {
1233
+ if (this.props.format === "float" /* Formats.FLOAT */) {
1206
1234
  stepValue = this.props.minStep;
1207
1235
  }
1208
1236
  else {
@@ -1236,7 +1264,7 @@ var Characteristic = /** @class */ (function (_super) {
1236
1264
  }
1237
1265
  return value;
1238
1266
  }
1239
- case "string" /* STRING */: {
1267
+ case "string" /* Formats.STRING */: {
1240
1268
  if (typeof value === "number") {
1241
1269
  this.characteristicWarning("characteristic was supplied illegal value: number instead of string, " +
1242
1270
  "supplying illegal values will throw errors in the future", warningType);
@@ -1258,7 +1286,7 @@ var Characteristic = /** @class */ (function (_super) {
1258
1286
  }
1259
1287
  return value;
1260
1288
  }
1261
- case "data" /* DATA */:
1289
+ case "data" /* Formats.DATA */:
1262
1290
  if (typeof value !== "string") {
1263
1291
  throw new Error("characteristic with DATA format must have string value");
1264
1292
  }
@@ -1267,7 +1295,7 @@ var Characteristic = /** @class */ (function (_super) {
1267
1295
  throw new Error("characteristic with DATA format exceeds specified maxDataLen");
1268
1296
  }
1269
1297
  return value;
1270
- case "tlv8" /* TLV8 */:
1298
+ case "tlv8" /* Formats.TLV8 */:
1271
1299
  if (value === undefined) {
1272
1300
  this.characteristicWarning("characteristic was supplied illegal value: undefined", warningType);
1273
1301
  return this.value;
@@ -1276,7 +1304,7 @@ var Characteristic = /** @class */ (function (_super) {
1276
1304
  }
1277
1305
  // hopefully it shouldn't get to this point
1278
1306
  if (value === undefined) {
1279
- this.characteristicWarning("characteristic was supplied illegal value: undefined", "error-message" /* ERROR_MESSAGE */);
1307
+ this.characteristicWarning("characteristic was supplied illegal value: undefined", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1280
1308
  return this.value;
1281
1309
  }
1282
1310
  return value;
@@ -1289,9 +1317,9 @@ var Characteristic = /** @class */ (function (_super) {
1289
1317
  this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
1290
1318
  };
1291
1319
  Characteristic.prototype.characteristicWarning = function (message, type, stack) {
1292
- if (type === void 0) { type = "warn-message" /* WARN_MESSAGE */; }
1320
+ if (type === void 0) { type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
1293
1321
  if (stack === void 0) { stack = new Error().stack; }
1294
- this.emit("characteristic-warning" /* CHARACTERISTIC_WARNING */, type, message, stack);
1322
+ this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
1295
1323
  };
1296
1324
  /**
1297
1325
  * @param event
@@ -1312,23 +1340,23 @@ var Characteristic = /** @class */ (function (_super) {
1312
1340
  var _this = this;
1313
1341
  this.props = characteristic.props;
1314
1342
  this.updateValue(characteristic.value);
1315
- var getListeners = characteristic.listeners("get" /* GET */);
1343
+ var getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
1316
1344
  if (getListeners.length) {
1317
1345
  // the callback can only be called once, so we remove all old listeners
1318
- this.removeAllListeners("get" /* GET */);
1346
+ this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
1319
1347
  // @ts-expect-error: force type
1320
- getListeners.forEach(function (listener) { return _this.addListener("get" /* GET */, listener); });
1348
+ getListeners.forEach(function (listener) { return _this.addListener("get" /* CharacteristicEventTypes.GET */, listener); });
1321
1349
  }
1322
1350
  this.removeOnGet();
1323
1351
  if (characteristic.getHandler) {
1324
1352
  this.onGet(characteristic.getHandler);
1325
1353
  }
1326
- var setListeners = characteristic.listeners("set" /* SET */);
1354
+ var setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
1327
1355
  if (setListeners.length) {
1328
1356
  // the callback can only be called once, so we remove all old listeners
1329
- this.removeAllListeners("set" /* SET */);
1357
+ this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
1330
1358
  // @ts-expect-error: force type
1331
- setListeners.forEach(function (listener) { return _this.addListener("set" /* SET */, listener); });
1359
+ setListeners.forEach(function (listener) { return _this.addListener("set" /* CharacteristicEventTypes.SET */, listener); });
1332
1360
  }
1333
1361
  this.removeOnSet();
1334
1362
  if (characteristic.setHandler) {
@@ -1341,14 +1369,14 @@ var Characteristic = /** @class */ (function (_super) {
1341
1369
  */
1342
1370
  Characteristic.prototype.toHAP = function (connection, contactGetHandlers) {
1343
1371
  if (contactGetHandlers === void 0) { contactGetHandlers = true; }
1344
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
1372
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1345
1373
  var object, value, _a;
1346
1374
  var _this = this;
1347
- return (0, tslib_1.__generator)(this, function (_b) {
1375
+ return tslib_1.__generator(this, function (_b) {
1348
1376
  switch (_b.label) {
1349
1377
  case 0:
1350
1378
  object = this.internalHAPRepresentation();
1351
- if (!!this.props.perms.includes("pr" /* PAIRED_READ */)) return [3 /*break*/, 1];
1379
+ if (!!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) return [3 /*break*/, 1];
1352
1380
  object.value = undefined;
1353
1381
  return [3 /*break*/, 6];
1354
1382
  case 1: