hap-nodejs 1.0.0-beta.7 → 1.0.0

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 (203) hide show
  1. package/README.md +7 -3
  2. package/dist/accessories/AirConditioner_accessory.js +24 -24
  3. package/dist/accessories/AirConditioner_accessory.js.map +1 -1
  4. package/dist/accessories/AppleTVRemote_accessory.js +23 -23
  5. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
  6. package/dist/accessories/Camera_accessory.js +295 -380
  7. package/dist/accessories/Camera_accessory.js.map +1 -1
  8. package/dist/accessories/Fan_accessory.js +15 -21
  9. package/dist/accessories/Fan_accessory.js.map +1 -1
  10. package/dist/accessories/GarageDoorOpener_accessory.js +12 -12
  11. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
  12. package/dist/accessories/Light-AdaptiveLighting_accessory.js +31 -21
  13. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
  14. package/dist/accessories/Light_accessory.js +45 -48
  15. package/dist/accessories/Light_accessory.js.map +1 -1
  16. package/dist/accessories/Lock_accessory.js +11 -11
  17. package/dist/accessories/Lock_accessory.js.map +1 -1
  18. package/dist/accessories/MotionSensor_accessory.js +8 -8
  19. package/dist/accessories/MotionSensor_accessory.js.map +1 -1
  20. package/dist/accessories/Outlet_accessory.js +10 -10
  21. package/dist/accessories/Outlet_accessory.js.map +1 -1
  22. package/dist/accessories/SmartSpeaker_accessory.js +11 -11
  23. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
  24. package/dist/accessories/Sprinkler_accessory.js +19 -19
  25. package/dist/accessories/Sprinkler_accessory.js.map +1 -1
  26. package/dist/accessories/TV_accessory.js +17 -17
  27. package/dist/accessories/TV_accessory.js.map +1 -1
  28. package/dist/accessories/TemperatureSensor_accessory.js +6 -6
  29. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
  30. package/dist/accessories/Wi-FiRouter_accessory.js +3 -3
  31. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
  32. package/dist/accessories/Wi-FiSatellite_accessory.js +4 -4
  33. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
  34. package/dist/accessories/gstreamer-audioProducer.js +45 -55
  35. package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
  36. package/dist/accessories/types.js +2 -2
  37. package/dist/accessories/types.js.map +1 -1
  38. package/dist/index.d.ts +0 -14
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +6 -31
  41. package/dist/index.js.map +1 -1
  42. package/dist/internal-types.d.ts +4 -4
  43. package/dist/internal-types.d.ts.map +1 -1
  44. package/dist/internal-types.js +10 -6
  45. package/dist/internal-types.js.map +1 -1
  46. package/dist/lib/Accessory.d.ts +19 -74
  47. package/dist/lib/Accessory.d.ts.map +1 -1
  48. package/dist/lib/Accessory.js +775 -1155
  49. package/dist/lib/Accessory.js.map +1 -1
  50. package/dist/lib/Advertiser.d.ts +5 -6
  51. package/dist/lib/Advertiser.d.ts.map +1 -1
  52. package/dist/lib/Advertiser.js +402 -521
  53. package/dist/lib/Advertiser.js.map +1 -1
  54. package/dist/lib/Bridge.js +6 -10
  55. package/dist/lib/Bridge.js.map +1 -1
  56. package/dist/lib/Characteristic.d.ts +31 -93
  57. package/dist/lib/Characteristic.d.ts.map +1 -1
  58. package/dist/lib/Characteristic.js +1474 -668
  59. package/dist/lib/Characteristic.js.map +1 -1
  60. package/dist/lib/HAPServer.d.ts +10 -22
  61. package/dist/lib/HAPServer.d.ts.map +1 -1
  62. package/dist/lib/HAPServer.js +224 -286
  63. package/dist/lib/HAPServer.js.map +1 -1
  64. package/dist/lib/Service.d.ts +9 -27
  65. package/dist/lib/Service.d.ts.map +1 -1
  66. package/dist/lib/Service.js +476 -314
  67. package/dist/lib/Service.js.map +1 -1
  68. package/dist/lib/camera/RTPProxy.d.ts +0 -2
  69. package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
  70. package/dist/lib/camera/RTPProxy.js +112 -104
  71. package/dist/lib/camera/RTPProxy.js.map +1 -1
  72. package/dist/lib/camera/RTPStreamManagement.d.ts +2 -67
  73. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
  74. package/dist/lib/camera/RTPStreamManagement.js +272 -292
  75. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  76. package/dist/lib/camera/RecordingManagement.d.ts +0 -1
  77. package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
  78. package/dist/lib/camera/RecordingManagement.js +325 -392
  79. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  80. package/dist/lib/camera/index.d.ts +0 -1
  81. package/dist/lib/camera/index.d.ts.map +1 -1
  82. package/dist/lib/camera/index.js +1 -2
  83. package/dist/lib/camera/index.js.map +1 -1
  84. package/dist/lib/controller/AdaptiveLightingController.d.ts +19 -4
  85. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
  86. package/dist/lib/controller/AdaptiveLightingController.js +220 -221
  87. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  88. package/dist/lib/controller/CameraController.d.ts +0 -6
  89. package/dist/lib/controller/CameraController.d.ts.map +1 -1
  90. package/dist/lib/controller/CameraController.js +192 -258
  91. package/dist/lib/controller/CameraController.js.map +1 -1
  92. package/dist/lib/controller/Controller.d.ts +1 -1
  93. package/dist/lib/controller/Controller.d.ts.map +1 -1
  94. package/dist/lib/controller/Controller.js +3 -3
  95. package/dist/lib/controller/Controller.js.map +1 -1
  96. package/dist/lib/controller/DoorbellController.js +38 -39
  97. package/dist/lib/controller/DoorbellController.js.map +1 -1
  98. package/dist/lib/controller/RemoteController.d.ts +4 -20
  99. package/dist/lib/controller/RemoteController.d.ts.map +1 -1
  100. package/dist/lib/controller/RemoteController.js +351 -424
  101. package/dist/lib/controller/RemoteController.js.map +1 -1
  102. package/dist/lib/controller/index.js +1 -1
  103. package/dist/lib/datastream/DataStreamManagement.js +57 -58
  104. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  105. package/dist/lib/datastream/DataStreamParser.d.ts +0 -1
  106. package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
  107. package/dist/lib/datastream/DataStreamParser.js +261 -306
  108. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  109. package/dist/lib/datastream/DataStreamServer.d.ts +0 -8
  110. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
  111. package/dist/lib/datastream/DataStreamServer.js +262 -275
  112. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  113. package/dist/lib/datastream/index.js +1 -1
  114. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +50 -40
  115. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
  116. package/dist/lib/definitions/CharacteristicDefinitions.js +2059 -2754
  117. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  118. package/dist/lib/definitions/ServiceDefinitions.d.ts +14 -8
  119. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
  120. package/dist/lib/definitions/ServiceDefinitions.js +834 -1053
  121. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  122. package/dist/lib/definitions/generate-definitions.js +383 -679
  123. package/dist/lib/definitions/generate-definitions.js.map +1 -1
  124. package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
  125. package/dist/lib/definitions/generator-configuration.js +163 -35
  126. package/dist/lib/definitions/generator-configuration.js.map +1 -1
  127. package/dist/lib/definitions/index.js +1 -1
  128. package/dist/lib/model/AccessoryInfo.d.ts +0 -1
  129. package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
  130. package/dist/lib/model/AccessoryInfo.js +102 -137
  131. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  132. package/dist/lib/model/ControllerStorage.js +86 -89
  133. package/dist/lib/model/ControllerStorage.js.map +1 -1
  134. package/dist/lib/model/HAPStorage.js +15 -16
  135. package/dist/lib/model/HAPStorage.js.map +1 -1
  136. package/dist/lib/model/IdentifierCache.js +49 -49
  137. package/dist/lib/model/IdentifierCache.js.map +1 -1
  138. package/dist/lib/tv/AccessControlManagement.d.ts +0 -1
  139. package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
  140. package/dist/lib/tv/AccessControlManagement.js +43 -46
  141. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  142. package/dist/lib/util/checkName.d.ts +8 -0
  143. package/dist/lib/util/checkName.d.ts.map +1 -0
  144. package/dist/lib/util/checkName.js +17 -0
  145. package/dist/lib/util/checkName.js.map +1 -0
  146. package/dist/lib/util/clone.js +6 -29
  147. package/dist/lib/util/clone.js.map +1 -1
  148. package/dist/lib/util/color-utils.js +8 -12
  149. package/dist/lib/util/color-utils.js.map +1 -1
  150. package/dist/lib/util/eventedhttp.d.ts +5 -9
  151. package/dist/lib/util/eventedhttp.d.ts.map +1 -1
  152. package/dist/lib/util/eventedhttp.js +306 -405
  153. package/dist/lib/util/eventedhttp.js.map +1 -1
  154. package/dist/lib/util/hapCrypto.d.ts +0 -1
  155. package/dist/lib/util/hapCrypto.d.ts.map +1 -1
  156. package/dist/lib/util/hapCrypto.js +39 -41
  157. package/dist/lib/util/hapCrypto.js.map +1 -1
  158. package/dist/lib/util/hapStatusError.js +9 -12
  159. package/dist/lib/util/hapStatusError.js.map +1 -1
  160. package/dist/lib/util/net-utils.d.ts.map +1 -1
  161. package/dist/lib/util/net-utils.js +34 -54
  162. package/dist/lib/util/net-utils.js.map +1 -1
  163. package/dist/lib/util/once.js +4 -10
  164. package/dist/lib/util/once.js.map +1 -1
  165. package/dist/lib/util/promise-utils.d.ts +0 -1
  166. package/dist/lib/util/promise-utils.d.ts.map +1 -1
  167. package/dist/lib/util/promise-utils.js +10 -16
  168. package/dist/lib/util/promise-utils.js.map +1 -1
  169. package/dist/lib/util/request-util.js +8 -10
  170. package/dist/lib/util/request-util.js.map +1 -1
  171. package/dist/lib/util/time.d.ts +0 -1
  172. package/dist/lib/util/time.d.ts.map +1 -1
  173. package/dist/lib/util/time.js +7 -8
  174. package/dist/lib/util/time.js.map +1 -1
  175. package/dist/lib/util/tlv.d.ts +0 -28
  176. package/dist/lib/util/tlv.d.ts.map +1 -1
  177. package/dist/lib/util/tlv.js +83 -126
  178. package/dist/lib/util/tlv.js.map +1 -1
  179. package/dist/lib/util/uuid.d.ts +0 -10
  180. package/dist/lib/util/uuid.d.ts.map +1 -1
  181. package/dist/lib/util/uuid.js +22 -40
  182. package/dist/lib/util/uuid.js.map +1 -1
  183. package/dist/types.d.ts +0 -35
  184. package/dist/types.d.ts.map +1 -1
  185. package/dist/types.js +1 -1
  186. package/dist/types.js.map +1 -1
  187. package/package.json +29 -28
  188. package/dist/BridgedCore.d.ts +0 -2
  189. package/dist/BridgedCore.d.ts.map +0 -1
  190. package/dist/BridgedCore.js +0 -43
  191. package/dist/BridgedCore.js.map +0 -1
  192. package/dist/Core.d.ts +0 -2
  193. package/dist/Core.d.ts.map +0 -1
  194. package/dist/Core.js +0 -52
  195. package/dist/Core.js.map +0 -1
  196. package/dist/lib/AccessoryLoader.d.ts +0 -28
  197. package/dist/lib/AccessoryLoader.d.ts.map +0 -1
  198. package/dist/lib/AccessoryLoader.js +0 -167
  199. package/dist/lib/AccessoryLoader.js.map +0 -1
  200. package/dist/lib/camera/Camera.d.ts +0 -44
  201. package/dist/lib/camera/Camera.d.ts.map +0 -1
  202. package/dist/lib/camera/Camera.js +0 -36
  203. package/dist/lib/camera/Camera.js.map +0 -1
@@ -1,17 +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
- var tslib_1 = require("tslib");
5
- var assert_1 = tslib_1.__importDefault(require("assert"));
6
- var debug_1 = tslib_1.__importDefault(require("debug"));
7
- var events_1 = require("events");
8
- var HAPServer_1 = require("./HAPServer");
9
- var clone_1 = require("./util/clone");
10
- var hapStatusError_1 = require("./util/hapStatusError");
11
- var once_1 = require("./util/once");
12
- var request_util_1 = require("./util/request-util");
13
- var uuid_1 = require("./util/uuid");
14
- var debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
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");
15
16
  /**
16
17
  * @group Characteristic
17
18
  */
@@ -54,276 +55,1213 @@ var Formats;
54
55
  * Base64 encoded tlv8 string.
55
56
  */
56
57
  Formats["TLV8"] = "tlv8";
58
+ })(Formats || (exports.Formats = Formats = {}));
59
+ /**
60
+ * @group Characteristic
61
+ */
62
+ var Units;
63
+ (function (Units) {
64
+ /**
65
+ * Celsius is the only temperature unit in the HomeKit Accessory Protocol.
66
+ * Unit conversion is always done on the client side e.g. on the iPhone in the Home App depending on
67
+ * the configured unit on the device itself.
68
+ */
69
+ Units["CELSIUS"] = "celsius";
70
+ Units["PERCENTAGE"] = "percentage";
71
+ Units["ARC_DEGREE"] = "arcdegrees";
72
+ Units["LUX"] = "lux";
73
+ Units["SECONDS"] = "seconds";
74
+ })(Units || (exports.Units = Units = {}));
75
+ /**
76
+ * @group Characteristic
77
+ */
78
+ var Perms;
79
+ (function (Perms) {
80
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
81
+ Perms["PAIRED_READ"] = "pr";
82
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
83
+ Perms["PAIRED_WRITE"] = "pw";
84
+ Perms["NOTIFY"] = "ev";
85
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
86
+ Perms["EVENTS"] = "ev";
87
+ Perms["ADDITIONAL_AUTHORIZATION"] = "aa";
88
+ Perms["TIMED_WRITE"] = "tw";
89
+ Perms["HIDDEN"] = "hd";
90
+ Perms["WRITE_RESPONSE"] = "wr";
91
+ })(Perms || (exports.Perms = Perms = {}));
92
+ /**
93
+ * Describes the abstract access to a {@link Characteristic}.
94
+ * It abstracts the more granular access described by {@link Perms}.
95
+ *
96
+ * It is used in {@link CharacteristicProps.adminOnlyAccess}.
97
+ *
98
+ * @group Characteristic
99
+ */
100
+ var Access;
101
+ (function (Access) {
102
+ Access[Access["READ"] = 0] = "READ";
103
+ Access[Access["WRITE"] = 1] = "WRITE";
104
+ Access[Access["NOTIFY"] = 2] = "NOTIFY";
105
+ })(Access || (exports.Access = Access = {}));
106
+ /**
107
+ * @group Characteristic
108
+ */
109
+ var ChangeReason;
110
+ (function (ChangeReason) {
111
+ /**
112
+ * Reason used when HomeKit writes a value or the API user calls {@link Characteristic.setValue}.
113
+ */
114
+ ChangeReason["WRITE"] = "write";
115
+ /**
116
+ * Reason used when the API user calls the method {@link Characteristic.updateValue}.
117
+ */
118
+ ChangeReason["UPDATE"] = "update";
119
+ /**
120
+ * Used when HomeKit reads a value or the API user calls the deprecated method `Characteristic.getValue`.
121
+ */
122
+ ChangeReason["READ"] = "read";
123
+ /**
124
+ * Used when call to {@link Characteristic.sendEventNotification} was made.
125
+ */
126
+ ChangeReason["EVENT"] = "event";
127
+ })(ChangeReason || (exports.ChangeReason = ChangeReason = {}));
128
+ /**
129
+ * @group Characteristic
130
+ */
131
+ var CharacteristicEventTypes;
132
+ (function (CharacteristicEventTypes) {
133
+ /**
134
+ * This event is thrown when a HomeKit controller wants to read the current value of the characteristic.
135
+ * The event handler should call the supplied callback as fast as possible.
136
+ *
137
+ * HAP-NodeJS will complain about slow running get handlers after 3 seconds and terminate the request after 10 seconds.
138
+ */
139
+ CharacteristicEventTypes["GET"] = "get";
140
+ /**
141
+ * This event is thrown when a HomeKit controller wants to write a new value to the characteristic.
142
+ * The event handler should call the supplied callback as fast as possible.
143
+ *
144
+ * HAP-NodeJS will complain about slow running set handlers after 3 seconds and terminate the request after 10 seconds.
145
+ */
146
+ CharacteristicEventTypes["SET"] = "set";
147
+ /**
148
+ * Emitted after a new value is set for the characteristic.
149
+ * The new value can be set via a request by a HomeKit controller or via an API call.
150
+ */
151
+ CharacteristicEventTypes["CHANGE"] = "change";
152
+ /**
153
+ * @private
154
+ */
155
+ CharacteristicEventTypes["SUBSCRIBE"] = "subscribe";
156
+ /**
157
+ * @private
158
+ */
159
+ CharacteristicEventTypes["UNSUBSCRIBE"] = "unsubscribe";
160
+ /**
161
+ * @private
162
+ */
163
+ CharacteristicEventTypes["CHARACTERISTIC_WARNING"] = "characteristic-warning";
164
+ })(CharacteristicEventTypes || (exports.CharacteristicEventTypes = CharacteristicEventTypes = {}));
165
+ /**
166
+ * @group Characteristic
167
+ */
168
+ class ValidValuesIterable {
169
+ props;
170
+ constructor(props) {
171
+ (0, assert_1.default)((0, request_util_1.isNumericFormat)(props.format), "Cannot instantiate valid values iterable when format is not numeric. Found " + props.format);
172
+ this.props = props;
173
+ }
174
+ *[Symbol.iterator]() {
175
+ if (this.props.validValues) {
176
+ for (const value of this.props.validValues) {
177
+ yield value;
178
+ }
179
+ }
180
+ else {
181
+ let min = 0; // default is zero for all the uint types
182
+ let max;
183
+ let stepValue = 1;
184
+ if (this.props.validValueRanges) {
185
+ min = this.props.validValueRanges[0];
186
+ max = this.props.validValueRanges[1];
187
+ }
188
+ else if (this.props.minValue != null && this.props.maxValue != null) {
189
+ min = this.props.minValue;
190
+ max = this.props.maxValue;
191
+ if (this.props.minStep != null) {
192
+ stepValue = this.props.minStep;
193
+ }
194
+ }
195
+ else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
196
+ max = (0, request_util_1.numericUpperBound)(this.props.format);
197
+ }
198
+ else {
199
+ throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
200
+ }
201
+ for (let i = min; i <= max; i += stepValue) {
202
+ yield i;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ const numberPattern = /^-?\d+$/;
208
+ function extractHAPStatusFromError(error) {
209
+ let errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
210
+ if (numberPattern.test(error.message)) {
211
+ const value = parseInt(error.message, 10);
212
+ if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
213
+ errorValue = value;
214
+ }
215
+ }
216
+ return errorValue;
217
+ }
218
+ function maxWithUndefined(a, b) {
219
+ if (a == null) {
220
+ return b;
221
+ }
222
+ else if (b == null) {
223
+ return a;
224
+ }
225
+ else {
226
+ return Math.max(a, b);
227
+ }
228
+ }
229
+ function minWithUndefined(a, b) {
230
+ if (a == null) {
231
+ return b;
232
+ }
233
+ else if (b == null) {
234
+ return a;
235
+ }
236
+ else {
237
+ return Math.min(a, b);
238
+ }
239
+ }
240
+ /**
241
+ * Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a
242
+ * "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic
243
+ * to a {@link Service} in order to store that value. A particular Characteristic is distinguished from others by its
244
+ * UUID. HomeKit provides a set of known Characteristic UUIDs defined in HomeKit.ts along with a
245
+ * corresponding concrete subclass.
246
+ *
247
+ * You can also define custom Characteristics by providing your own UUID. Custom Characteristics can be added
248
+ * to any native or custom Services, but Siri will likely not be able to work with these.
249
+ *
250
+ * @group Characteristic
251
+ */
252
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
253
+ class Characteristic extends events_1.EventEmitter {
254
+ // Pattern below is for automatic detection of the section of defined characteristics. Used by the generator
255
+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
256
+ /**
257
+ * @group Characteristic Definitions
258
+ */
259
+ static AccessCodeControlPoint;
260
+ /**
261
+ * @group Characteristic Definitions
262
+ */
263
+ static AccessCodeSupportedConfiguration;
264
+ /**
265
+ * @group Characteristic Definitions
266
+ */
267
+ static AccessControlLevel;
268
+ /**
269
+ * @group Characteristic Definitions
270
+ */
271
+ static AccessoryFlags;
272
+ /**
273
+ * @group Characteristic Definitions
274
+ */
275
+ static AccessoryIdentifier;
276
+ /**
277
+ * @group Characteristic Definitions
278
+ */
279
+ static Active;
280
+ /**
281
+ * @group Characteristic Definitions
282
+ */
283
+ static ActiveIdentifier;
284
+ /**
285
+ * @group Characteristic Definitions
286
+ */
287
+ static ActivityInterval;
288
+ /**
289
+ * @group Characteristic Definitions
290
+ */
291
+ static AdministratorOnlyAccess;
292
+ /**
293
+ * @group Characteristic Definitions
294
+ */
295
+ static AirParticulateDensity;
296
+ /**
297
+ * @group Characteristic Definitions
298
+ */
299
+ static AirParticulateSize;
300
+ /**
301
+ * @group Characteristic Definitions
302
+ */
303
+ static AirPlayEnable;
304
+ /**
305
+ * @group Characteristic Definitions
306
+ */
307
+ static AirQuality;
308
+ /**
309
+ * @group Characteristic Definitions
310
+ */
311
+ static AppMatchingIdentifier;
312
+ /**
313
+ * @group Characteristic Definitions
314
+ */
315
+ static AssetUpdateReadiness;
316
+ /**
317
+ * @group Characteristic Definitions
318
+ */
319
+ static AudioFeedback;
320
+ /**
321
+ * @group Characteristic Definitions
322
+ */
323
+ static BatteryLevel;
324
+ /**
325
+ * @group Characteristic Definitions
326
+ */
327
+ static Brightness;
328
+ /**
329
+ * @group Characteristic Definitions
330
+ */
331
+ static ButtonEvent;
332
+ /**
333
+ * @group Characteristic Definitions
334
+ */
335
+ static CameraOperatingModeIndicator;
336
+ /**
337
+ * @group Characteristic Definitions
338
+ */
339
+ static CarbonDioxideDetected;
340
+ /**
341
+ * @group Characteristic Definitions
342
+ */
343
+ static CarbonDioxideLevel;
344
+ /**
345
+ * @group Characteristic Definitions
346
+ */
347
+ static CarbonDioxidePeakLevel;
348
+ /**
349
+ * @group Characteristic Definitions
350
+ */
351
+ static CarbonMonoxideDetected;
352
+ /**
353
+ * @group Characteristic Definitions
354
+ */
355
+ static CarbonMonoxideLevel;
356
+ /**
357
+ * @group Characteristic Definitions
358
+ */
359
+ static CarbonMonoxidePeakLevel;
360
+ /**
361
+ * @group Characteristic Definitions
362
+ */
363
+ static CCAEnergyDetectThreshold;
364
+ /**
365
+ * @group Characteristic Definitions
366
+ */
367
+ static CCASignalDetectThreshold;
368
+ /**
369
+ * @group Characteristic Definitions
370
+ */
371
+ static CharacteristicValueActiveTransitionCount;
372
+ /**
373
+ * @group Characteristic Definitions
374
+ */
375
+ static CharacteristicValueTransitionControl;
376
+ /**
377
+ * @group Characteristic Definitions
378
+ */
379
+ static ChargingState;
380
+ /**
381
+ * @group Characteristic Definitions
382
+ */
383
+ static ClosedCaptions;
384
+ /**
385
+ * @group Characteristic Definitions
386
+ */
387
+ static ColorTemperature;
388
+ /**
389
+ * @group Characteristic Definitions
390
+ */
391
+ static ConfigurationState;
392
+ /**
393
+ * @group Characteristic Definitions
394
+ */
395
+ static ConfiguredName;
396
+ /**
397
+ * @group Characteristic Definitions
398
+ */
399
+ static ContactSensorState;
400
+ /**
401
+ * @group Characteristic Definitions
402
+ */
403
+ static CoolingThresholdTemperature;
404
+ /**
405
+ * @group Characteristic Definitions
406
+ */
407
+ static CryptoHash;
408
+ /**
409
+ * @group Characteristic Definitions
410
+ */
411
+ static CurrentAirPurifierState;
412
+ /**
413
+ * @group Characteristic Definitions
414
+ */
415
+ static CurrentAmbientLightLevel;
416
+ /**
417
+ * @group Characteristic Definitions
418
+ */
419
+ static CurrentDoorState;
420
+ /**
421
+ * @group Characteristic Definitions
422
+ */
423
+ static CurrentFanState;
424
+ /**
425
+ * @group Characteristic Definitions
426
+ */
427
+ static CurrentHeaterCoolerState;
428
+ /**
429
+ * @group Characteristic Definitions
430
+ */
431
+ static CurrentHeatingCoolingState;
432
+ /**
433
+ * @group Characteristic Definitions
434
+ */
435
+ static CurrentHorizontalTiltAngle;
436
+ /**
437
+ * @group Characteristic Definitions
438
+ */
439
+ static CurrentHumidifierDehumidifierState;
440
+ /**
441
+ * @group Characteristic Definitions
442
+ */
443
+ static CurrentMediaState;
444
+ /**
445
+ * @group Characteristic Definitions
446
+ */
447
+ static CurrentPosition;
448
+ /**
449
+ * @group Characteristic Definitions
450
+ */
451
+ static CurrentRelativeHumidity;
452
+ /**
453
+ * @group Characteristic Definitions
454
+ */
455
+ static CurrentSlatState;
456
+ /**
457
+ * @group Characteristic Definitions
458
+ */
459
+ static CurrentTemperature;
460
+ /**
461
+ * @group Characteristic Definitions
462
+ */
463
+ static CurrentTiltAngle;
464
+ /**
465
+ * @group Characteristic Definitions
466
+ */
467
+ static CurrentTransport;
468
+ /**
469
+ * @group Characteristic Definitions
470
+ */
471
+ static CurrentVerticalTiltAngle;
472
+ /**
473
+ * @group Characteristic Definitions
474
+ */
475
+ static CurrentVisibilityState;
476
+ /**
477
+ * @group Characteristic Definitions
478
+ */
479
+ static DataStreamHAPTransport;
480
+ /**
481
+ * @group Characteristic Definitions
482
+ */
483
+ static DataStreamHAPTransportInterrupt;
484
+ /**
485
+ * @group Characteristic Definitions
486
+ */
487
+ static DiagonalFieldOfView;
488
+ /**
489
+ * @group Characteristic Definitions
490
+ */
491
+ static DigitalZoom;
492
+ /**
493
+ * @group Characteristic Definitions
494
+ */
495
+ static DisplayOrder;
496
+ /**
497
+ * @group Characteristic Definitions
498
+ */
499
+ static EventRetransmissionMaximum;
500
+ /**
501
+ * @group Characteristic Definitions
502
+ */
503
+ static EventSnapshotsActive;
504
+ /**
505
+ * @group Characteristic Definitions
506
+ */
507
+ static EventTransmissionCounters;
508
+ /**
509
+ * @group Characteristic Definitions
510
+ */
511
+ static FilterChangeIndication;
512
+ /**
513
+ * @group Characteristic Definitions
514
+ */
515
+ static FilterLifeLevel;
516
+ /**
517
+ * @group Characteristic Definitions
518
+ */
519
+ static FirmwareRevision;
520
+ /**
521
+ * @group Characteristic Definitions
522
+ */
523
+ static FirmwareUpdateReadiness;
524
+ /**
525
+ * @group Characteristic Definitions
526
+ */
527
+ static FirmwareUpdateStatus;
528
+ /**
529
+ * @group Characteristic Definitions
530
+ */
531
+ static HardwareFinish;
532
+ /**
533
+ * @group Characteristic Definitions
534
+ */
535
+ static HardwareRevision;
536
+ /**
537
+ * @group Characteristic Definitions
538
+ */
539
+ static HeartBeat;
540
+ /**
541
+ * @group Characteristic Definitions
542
+ */
543
+ static HeatingThresholdTemperature;
544
+ /**
545
+ * @group Characteristic Definitions
546
+ */
547
+ static HoldPosition;
548
+ /**
549
+ * @group Characteristic Definitions
550
+ */
551
+ static HomeKitCameraActive;
552
+ /**
553
+ * @group Characteristic Definitions
554
+ */
555
+ static Hue;
556
+ /**
557
+ * @group Characteristic Definitions
558
+ */
559
+ static Identifier;
560
+ /**
561
+ * @group Characteristic Definitions
562
+ */
563
+ static Identify;
564
+ /**
565
+ * @group Characteristic Definitions
566
+ */
567
+ static ImageMirroring;
568
+ /**
569
+ * @group Characteristic Definitions
570
+ */
571
+ static ImageRotation;
572
+ /**
573
+ * @group Characteristic Definitions
574
+ */
575
+ static InputDeviceType;
576
+ /**
577
+ * @group Characteristic Definitions
578
+ */
579
+ static InputSourceType;
580
+ /**
581
+ * @group Characteristic Definitions
582
+ */
583
+ static InUse;
584
+ /**
585
+ * @group Characteristic Definitions
586
+ */
587
+ static IsConfigured;
588
+ /**
589
+ * @group Characteristic Definitions
590
+ */
591
+ static LeakDetected;
592
+ /**
593
+ * @group Characteristic Definitions
594
+ */
595
+ static ListPairings;
596
+ /**
597
+ * @group Characteristic Definitions
598
+ */
599
+ static LockControlPoint;
600
+ /**
601
+ * @group Characteristic Definitions
602
+ */
603
+ static LockCurrentState;
604
+ /**
605
+ * @group Characteristic Definitions
606
+ */
607
+ static LockLastKnownAction;
608
+ /**
609
+ * @group Characteristic Definitions
610
+ */
611
+ static LockManagementAutoSecurityTimeout;
612
+ /**
613
+ * @group Characteristic Definitions
614
+ */
615
+ static LockPhysicalControls;
616
+ /**
617
+ * @group Characteristic Definitions
618
+ */
619
+ static LockTargetState;
620
+ /**
621
+ * @group Characteristic Definitions
622
+ */
623
+ static Logs;
624
+ /**
625
+ * @group Characteristic Definitions
626
+ */
627
+ static MACRetransmissionMaximum;
628
+ /**
629
+ * @group Characteristic Definitions
630
+ */
631
+ static MACTransmissionCounters;
632
+ /**
633
+ * @group Characteristic Definitions
634
+ */
635
+ static ManagedNetworkEnable;
636
+ /**
637
+ * @group Characteristic Definitions
638
+ */
639
+ static ManuallyDisabled;
640
+ /**
641
+ * @group Characteristic Definitions
642
+ */
643
+ static Manufacturer;
644
+ /**
645
+ * @group Characteristic Definitions
646
+ */
647
+ static MaximumTransmitPower;
648
+ /**
649
+ * @group Characteristic Definitions
650
+ */
651
+ static MetricsBufferFullState;
652
+ /**
653
+ * @group Characteristic Definitions
654
+ */
655
+ static Model;
656
+ /**
657
+ * @group Characteristic Definitions
658
+ */
659
+ static MotionDetected;
660
+ /**
661
+ * @group Characteristic Definitions
662
+ */
663
+ static MultifunctionButton;
664
+ /**
665
+ * @group Characteristic Definitions
666
+ */
667
+ static Mute;
668
+ /**
669
+ * @group Characteristic Definitions
670
+ */
671
+ static Name;
672
+ /**
673
+ * @group Characteristic Definitions
674
+ */
675
+ static NetworkAccessViolationControl;
676
+ /**
677
+ * @group Characteristic Definitions
678
+ */
679
+ static NetworkClientProfileControl;
680
+ /**
681
+ * @group Characteristic Definitions
682
+ */
683
+ static NetworkClientStatusControl;
684
+ /**
685
+ * @group Characteristic Definitions
686
+ */
687
+ static NFCAccessControlPoint;
688
+ /**
689
+ * @group Characteristic Definitions
690
+ */
691
+ static NFCAccessSupportedConfiguration;
692
+ /**
693
+ * @group Characteristic Definitions
694
+ */
695
+ static NightVision;
696
+ /**
697
+ * @group Characteristic Definitions
698
+ */
699
+ static NitrogenDioxideDensity;
700
+ /**
701
+ * @group Characteristic Definitions
702
+ */
703
+ static ObstructionDetected;
704
+ /**
705
+ * @group Characteristic Definitions
706
+ */
707
+ static OccupancyDetected;
708
+ /**
709
+ * @group Characteristic Definitions
710
+ */
711
+ static On;
712
+ /**
713
+ * @group Characteristic Definitions
714
+ */
715
+ static OperatingStateResponse;
716
+ /**
717
+ * @group Characteristic Definitions
718
+ */
719
+ static OpticalZoom;
720
+ /**
721
+ * @group Characteristic Definitions
722
+ */
723
+ static OutletInUse;
724
+ /**
725
+ * @group Characteristic Definitions
726
+ */
727
+ static OzoneDensity;
728
+ /**
729
+ * @group Characteristic Definitions
730
+ */
731
+ static PairingFeatures;
732
+ /**
733
+ * @group Characteristic Definitions
734
+ */
735
+ static PairSetup;
736
+ /**
737
+ * @group Characteristic Definitions
738
+ */
739
+ static PairVerify;
740
+ /**
741
+ * @group Characteristic Definitions
742
+ */
743
+ static PasswordSetting;
744
+ /**
745
+ * @group Characteristic Definitions
746
+ */
747
+ static PeriodicSnapshotsActive;
748
+ /**
749
+ * @group Characteristic Definitions
750
+ */
751
+ static PictureMode;
752
+ /**
753
+ * @group Characteristic Definitions
754
+ */
755
+ static Ping;
756
+ /**
757
+ * @group Characteristic Definitions
758
+ */
759
+ static PM10Density;
760
+ /**
761
+ * @group Characteristic Definitions
762
+ */
763
+ static PM2_5Density;
764
+ /**
765
+ * @group Characteristic Definitions
766
+ */
767
+ static PositionState;
768
+ /**
769
+ * @group Characteristic Definitions
770
+ */
771
+ static PowerModeSelection;
772
+ /**
773
+ * @group Characteristic Definitions
774
+ */
775
+ static ProductData;
776
+ /**
777
+ * @group Characteristic Definitions
778
+ */
779
+ static ProgrammableSwitchEvent;
780
+ /**
781
+ * @group Characteristic Definitions
782
+ */
783
+ static ProgrammableSwitchOutputState;
784
+ /**
785
+ * @group Characteristic Definitions
786
+ */
787
+ static ProgramMode;
788
+ /**
789
+ * @group Characteristic Definitions
790
+ */
791
+ static ReceivedSignalStrengthIndication;
792
+ /**
793
+ * @group Characteristic Definitions
794
+ */
795
+ static ReceiverSensitivity;
796
+ /**
797
+ * @group Characteristic Definitions
798
+ */
799
+ static RecordingAudioActive;
800
+ /**
801
+ * @group Characteristic Definitions
802
+ */
803
+ static RelativeHumidityDehumidifierThreshold;
804
+ /**
805
+ * @group Characteristic Definitions
806
+ */
807
+ static RelativeHumidityHumidifierThreshold;
808
+ /**
809
+ * @group Characteristic Definitions
810
+ */
811
+ static RelayControlPoint;
812
+ /**
813
+ * @group Characteristic Definitions
814
+ */
815
+ static RelayEnabled;
816
+ /**
817
+ * @group Characteristic Definitions
818
+ */
819
+ static RelayState;
820
+ /**
821
+ * @group Characteristic Definitions
822
+ */
823
+ static RemainingDuration;
824
+ /**
825
+ * @group Characteristic Definitions
826
+ */
827
+ static RemoteKey;
828
+ /**
829
+ * @group Characteristic Definitions
830
+ */
831
+ static ResetFilterIndication;
832
+ /**
833
+ * @group Characteristic Definitions
834
+ */
835
+ static RotationDirection;
836
+ /**
837
+ * @group Characteristic Definitions
838
+ */
839
+ static RotationSpeed;
840
+ /**
841
+ * @group Characteristic Definitions
842
+ */
843
+ static RouterStatus;
844
+ /**
845
+ * @group Characteristic Definitions
846
+ */
847
+ static Saturation;
848
+ /**
849
+ * @group Characteristic Definitions
850
+ */
851
+ static SecuritySystemAlarmType;
852
+ /**
853
+ * @group Characteristic Definitions
854
+ */
855
+ static SecuritySystemCurrentState;
856
+ /**
857
+ * @group Characteristic Definitions
858
+ */
859
+ static SecuritySystemTargetState;
860
+ /**
861
+ * @group Characteristic Definitions
862
+ */
863
+ static SelectedAudioStreamConfiguration;
864
+ /**
865
+ * @group Characteristic Definitions
866
+ */
867
+ static SelectedCameraRecordingConfiguration;
868
+ /**
869
+ * @group Characteristic Definitions
870
+ */
871
+ static SelectedDiagnosticsModes;
872
+ /**
873
+ * @group Characteristic Definitions
874
+ */
875
+ static SelectedRTPStreamConfiguration;
876
+ /**
877
+ * @group Characteristic Definitions
878
+ */
879
+ static SelectedSleepConfiguration;
880
+ /**
881
+ * @group Characteristic Definitions
882
+ */
883
+ static SerialNumber;
884
+ /**
885
+ * @group Characteristic Definitions
886
+ */
887
+ static ServiceLabelIndex;
888
+ /**
889
+ * @group Characteristic Definitions
890
+ */
891
+ static ServiceLabelNamespace;
892
+ /**
893
+ * @group Characteristic Definitions
894
+ */
895
+ static SetDuration;
896
+ /**
897
+ * @group Characteristic Definitions
898
+ */
899
+ static SetupDataStreamTransport;
900
+ /**
901
+ * @group Characteristic Definitions
902
+ */
903
+ static SetupEndpoints;
904
+ /**
905
+ * @group Characteristic Definitions
906
+ */
907
+ static SetupTransferTransport;
908
+ /**
909
+ * @group Characteristic Definitions
910
+ */
911
+ static SignalToNoiseRatio;
912
+ /**
913
+ * @group Characteristic Definitions
914
+ */
915
+ static SiriEnable;
916
+ /**
917
+ * @group Characteristic Definitions
918
+ */
919
+ static SiriEndpointSessionStatus;
920
+ /**
921
+ * @group Characteristic Definitions
922
+ */
923
+ static SiriEngineVersion;
924
+ /**
925
+ * @group Characteristic Definitions
926
+ */
927
+ static SiriInputType;
928
+ /**
929
+ * @group Characteristic Definitions
930
+ */
931
+ static SiriLightOnUse;
932
+ /**
933
+ * @group Characteristic Definitions
934
+ */
935
+ static SiriListening;
936
+ /**
937
+ * @group Characteristic Definitions
938
+ */
939
+ static SiriTouchToUse;
940
+ /**
941
+ * @group Characteristic Definitions
942
+ */
943
+ static SlatType;
944
+ /**
945
+ * @group Characteristic Definitions
946
+ */
947
+ static SleepDiscoveryMode;
948
+ /**
949
+ * @group Characteristic Definitions
950
+ */
951
+ static SleepInterval;
952
+ /**
953
+ * @group Characteristic Definitions
954
+ */
955
+ static SmokeDetected;
956
+ /**
957
+ * @group Characteristic Definitions
958
+ */
959
+ static SoftwareRevision;
960
+ /**
961
+ * @group Characteristic Definitions
962
+ */
963
+ static StagedFirmwareVersion;
964
+ /**
965
+ * @group Characteristic Definitions
966
+ */
967
+ static StatusActive;
968
+ /**
969
+ * @group Characteristic Definitions
970
+ */
971
+ static StatusFault;
972
+ /**
973
+ * @group Characteristic Definitions
974
+ */
975
+ static StatusJammed;
976
+ /**
977
+ * @group Characteristic Definitions
978
+ */
979
+ static StatusLowBattery;
980
+ /**
981
+ * @group Characteristic Definitions
982
+ */
983
+ static StatusTampered;
984
+ /**
985
+ * @group Characteristic Definitions
986
+ */
987
+ static StreamingStatus;
988
+ /**
989
+ * @group Characteristic Definitions
990
+ */
991
+ static SulphurDioxideDensity;
992
+ /**
993
+ * @group Characteristic Definitions
994
+ */
995
+ static SupportedAssetTypes;
996
+ /**
997
+ * @group Characteristic Definitions
998
+ */
999
+ static SupportedAudioRecordingConfiguration;
1000
+ /**
1001
+ * @group Characteristic Definitions
1002
+ */
1003
+ static SupportedAudioStreamConfiguration;
1004
+ /**
1005
+ * @group Characteristic Definitions
1006
+ */
1007
+ static SupportedCameraRecordingConfiguration;
1008
+ /**
1009
+ * @group Characteristic Definitions
1010
+ */
1011
+ static SupportedCharacteristicValueTransitionConfiguration;
1012
+ /**
1013
+ * @group Characteristic Definitions
1014
+ */
1015
+ static SupportedDataStreamTransportConfiguration;
1016
+ /**
1017
+ * @group Characteristic Definitions
1018
+ */
1019
+ static SupportedDiagnosticsModes;
1020
+ /**
1021
+ * @group Characteristic Definitions
1022
+ */
1023
+ static SupportedDiagnosticsSnapshot;
1024
+ /**
1025
+ * @group Characteristic Definitions
1026
+ */
1027
+ static SupportedFirmwareUpdateConfiguration;
1028
+ /**
1029
+ * @group Characteristic Definitions
1030
+ */
1031
+ static SupportedMetrics;
1032
+ /**
1033
+ * @group Characteristic Definitions
1034
+ */
1035
+ static SupportedRouterConfiguration;
1036
+ /**
1037
+ * @group Characteristic Definitions
1038
+ */
1039
+ static SupportedRTPConfiguration;
1040
+ /**
1041
+ * @group Characteristic Definitions
1042
+ */
1043
+ static SupportedSleepConfiguration;
1044
+ /**
1045
+ * @group Characteristic Definitions
1046
+ */
1047
+ static SupportedTransferTransportConfiguration;
1048
+ /**
1049
+ * @group Characteristic Definitions
1050
+ */
1051
+ static SupportedVideoRecordingConfiguration;
1052
+ /**
1053
+ * @group Characteristic Definitions
1054
+ */
1055
+ static SupportedVideoStreamConfiguration;
1056
+ /**
1057
+ * @group Characteristic Definitions
1058
+ */
1059
+ static SwingMode;
1060
+ /**
1061
+ * @group Characteristic Definitions
1062
+ */
1063
+ static TapType;
1064
+ /**
1065
+ * @group Characteristic Definitions
1066
+ */
1067
+ static TargetAirPurifierState;
1068
+ /**
1069
+ * @group Characteristic Definitions
1070
+ */
1071
+ static TargetControlList;
1072
+ /**
1073
+ * @group Characteristic Definitions
1074
+ */
1075
+ static TargetControlSupportedConfiguration;
1076
+ /**
1077
+ * @group Characteristic Definitions
1078
+ */
1079
+ static TargetDoorState;
1080
+ /**
1081
+ * @group Characteristic Definitions
1082
+ */
1083
+ static TargetFanState;
1084
+ /**
1085
+ * @group Characteristic Definitions
1086
+ */
1087
+ static TargetHeaterCoolerState;
1088
+ /**
1089
+ * @group Characteristic Definitions
1090
+ */
1091
+ static TargetHeatingCoolingState;
1092
+ /**
1093
+ * @group Characteristic Definitions
1094
+ */
1095
+ static TargetHorizontalTiltAngle;
1096
+ /**
1097
+ * @group Characteristic Definitions
1098
+ */
1099
+ static TargetHumidifierDehumidifierState;
1100
+ /**
1101
+ * @group Characteristic Definitions
1102
+ */
1103
+ static TargetMediaState;
1104
+ /**
1105
+ * @group Characteristic Definitions
1106
+ */
1107
+ static TargetPosition;
1108
+ /**
1109
+ * @group Characteristic Definitions
1110
+ */
1111
+ static TargetRelativeHumidity;
1112
+ /**
1113
+ * @group Characteristic Definitions
1114
+ */
1115
+ static TargetTemperature;
1116
+ /**
1117
+ * @group Characteristic Definitions
1118
+ */
1119
+ static TargetTiltAngle;
1120
+ /**
1121
+ * @group Characteristic Definitions
1122
+ */
1123
+ static TargetVerticalTiltAngle;
1124
+ /**
1125
+ * @group Characteristic Definitions
1126
+ */
1127
+ static TargetVisibilityState;
1128
+ /**
1129
+ * @group Characteristic Definitions
1130
+ */
1131
+ static TemperatureDisplayUnits;
1132
+ /**
1133
+ * @group Characteristic Definitions
1134
+ */
1135
+ static ThirdPartyCameraActive;
1136
+ /**
1137
+ * @group Characteristic Definitions
1138
+ */
1139
+ static ThreadControlPoint;
1140
+ /**
1141
+ * @group Characteristic Definitions
1142
+ */
1143
+ static ThreadNodeCapabilities;
1144
+ /**
1145
+ * @group Characteristic Definitions
1146
+ */
1147
+ static ThreadOpenThreadVersion;
1148
+ /**
1149
+ * @group Characteristic Definitions
1150
+ */
1151
+ static ThreadStatus;
1152
+ /**
1153
+ * @group Characteristic Definitions
1154
+ */
1155
+ static Token;
1156
+ /**
1157
+ * @group Characteristic Definitions
1158
+ */
1159
+ static TransmitPower;
1160
+ /**
1161
+ * @group Characteristic Definitions
1162
+ */
1163
+ static TunnelConnectionTimeout;
1164
+ /**
1165
+ * @group Characteristic Definitions
1166
+ */
1167
+ static TunneledAccessoryAdvertising;
1168
+ /**
1169
+ * @group Characteristic Definitions
1170
+ */
1171
+ static TunneledAccessoryConnected;
1172
+ /**
1173
+ * @group Characteristic Definitions
1174
+ */
1175
+ static TunneledAccessoryStateNumber;
1176
+ /**
1177
+ * @group Characteristic Definitions
1178
+ */
1179
+ static ValveType;
57
1180
  /**
58
- * @deprecated Not contained in the HAP spec
1181
+ * @group Characteristic Definitions
59
1182
  */
60
- Formats["ARRAY"] = "array";
1183
+ static Version;
61
1184
  /**
62
- * @deprecated Not contained in the HAP spec
1185
+ * @group Characteristic Definitions
63
1186
  */
64
- Formats["DICTIONARY"] = "dict";
65
- })(Formats = exports.Formats || (exports.Formats = {}));
66
- /**
67
- * @group Characteristic
68
- */
69
- var Units;
70
- (function (Units) {
1187
+ static VideoAnalysisActive;
71
1188
  /**
72
- * Celsius is the only temperature unit in the HomeKit Accessory Protocol.
73
- * Unit conversion is always done on the client side e.g. on the iPhone in the Home App depending on
74
- * the configured unit on the device itself.
1189
+ * @group Characteristic Definitions
75
1190
  */
76
- Units["CELSIUS"] = "celsius";
77
- Units["PERCENTAGE"] = "percentage";
78
- Units["ARC_DEGREE"] = "arcdegrees";
79
- Units["LUX"] = "lux";
80
- Units["SECONDS"] = "seconds";
81
- })(Units = exports.Units || (exports.Units = {}));
82
- /**
83
- * @group Characteristic
84
- */
85
- var Perms;
86
- (function (Perms) {
87
- // noinspection JSUnusedGlobalSymbols
1191
+ static VOCDensity;
88
1192
  /**
89
- * @deprecated replaced by {@link PAIRED_READ}. Kept for backwards compatibility.
1193
+ * @group Characteristic Definitions
90
1194
  */
91
- Perms["READ"] = "pr";
1195
+ static Volume;
92
1196
  /**
93
- * @deprecated replaced by {@link PAIRED_WRITE}. Kept for backwards compatibility.
1197
+ * @group Characteristic Definitions
94
1198
  */
95
- Perms["WRITE"] = "pw";
96
- Perms["PAIRED_READ"] = "pr";
97
- Perms["PAIRED_WRITE"] = "pw";
98
- Perms["NOTIFY"] = "ev";
99
- Perms["EVENTS"] = "ev";
100
- Perms["ADDITIONAL_AUTHORIZATION"] = "aa";
101
- Perms["TIMED_WRITE"] = "tw";
102
- Perms["HIDDEN"] = "hd";
103
- Perms["WRITE_RESPONSE"] = "wr";
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
- */
113
- var Access;
114
- (function (Access) {
115
- Access[Access["READ"] = 0] = "READ";
116
- Access[Access["WRITE"] = 1] = "WRITE";
117
- Access[Access["NOTIFY"] = 2] = "NOTIFY";
118
- })(Access = exports.Access || (exports.Access = {}));
119
- /**
120
- * @group Characteristic
121
- */
122
- var ChangeReason;
123
- (function (ChangeReason) {
1199
+ static VolumeControlType;
124
1200
  /**
125
- * Reason used when HomeKit writes a value or the API user calls {@link Characteristic.setValue}.
1201
+ * @group Characteristic Definitions
126
1202
  */
127
- ChangeReason["WRITE"] = "write";
1203
+ static VolumeSelector;
128
1204
  /**
129
- * Reason used when the API user calls the method {@link Characteristic.updateValue}.
1205
+ * @group Characteristic Definitions
130
1206
  */
131
- ChangeReason["UPDATE"] = "update";
1207
+ static WakeConfiguration;
132
1208
  /**
133
- * Used when HomeKit reads a value or the API user calls the deprecated method `Characteristic.getValue`.
1209
+ * @group Characteristic Definitions
134
1210
  */
135
- ChangeReason["READ"] = "read";
1211
+ static WANConfigurationList;
136
1212
  /**
137
- * Used when call to {@link Characteristic.sendEventNotification} was made.
1213
+ * @group Characteristic Definitions
138
1214
  */
139
- ChangeReason["EVENT"] = "event";
140
- })(ChangeReason = exports.ChangeReason || (exports.ChangeReason = {}));
141
- /**
142
- * @group Characteristic
143
- */
144
- var CharacteristicEventTypes;
145
- (function (CharacteristicEventTypes) {
1215
+ static WANStatusList;
146
1216
  /**
147
- * This event is thrown when a HomeKit controller wants to read the current value of the characteristic.
148
- * The event handler should call the supplied callback as fast as possible.
149
- *
150
- * HAP-NodeJS will complain about slow running get handlers after 3 seconds and terminate the request after 10 seconds.
1217
+ * @group Characteristic Definitions
151
1218
  */
152
- CharacteristicEventTypes["GET"] = "get";
1219
+ static WaterLevel;
153
1220
  /**
154
- * This event is thrown when a HomeKit controller wants to write a new value to the characteristic.
155
- * The event handler should call the supplied callback as fast as possible.
156
- *
157
- * HAP-NodeJS will complain about slow running set handlers after 3 seconds and terminate the request after 10 seconds.
1221
+ * @group Characteristic Definitions
158
1222
  */
159
- CharacteristicEventTypes["SET"] = "set";
1223
+ static WiFiCapabilities;
160
1224
  /**
161
- * Emitted after a new value is set for the characteristic.
162
- * The new value can be set via a request by a HomeKit controller or via an API call.
1225
+ * @group Characteristic Definitions
163
1226
  */
164
- CharacteristicEventTypes["CHANGE"] = "change";
1227
+ static WiFiConfigurationControl;
165
1228
  /**
166
- * @private
1229
+ * @group Characteristic Definitions
167
1230
  */
168
- CharacteristicEventTypes["SUBSCRIBE"] = "subscribe";
1231
+ static WiFiSatelliteStatus;
1232
+ // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1233
+ // NOTICE: when adding/changing properties, remember to possibly adjust the serialize/deserialize functions
1234
+ displayName;
1235
+ UUID;
1236
+ iid = null;
1237
+ value = null;
169
1238
  /**
170
1239
  * @private
171
1240
  */
172
- CharacteristicEventTypes["UNSUBSCRIBE"] = "unsubscribe";
1241
+ statusCode = 0 /* HAPStatus.SUCCESS */;
1242
+ props;
1243
+ /**
1244
+ * The {@link Characteristic.onGet} handler
1245
+ */
1246
+ getHandler;
1247
+ /**
1248
+ * The {@link Characteristic.onSet} handler
1249
+ */
1250
+ setHandler;
1251
+ subscriptions = 0;
173
1252
  /**
174
1253
  * @private
175
1254
  */
176
- CharacteristicEventTypes["CHARACTERISTIC_WARNING"] = "characteristic-warning";
177
- })(CharacteristicEventTypes = exports.CharacteristicEventTypes || (exports.CharacteristicEventTypes = {}));
178
- /**
179
- * @group Characteristic
180
- */
181
- var ValidValuesIterable = /** @class */ (function () {
182
- function ValidValuesIterable(props) {
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);
184
- this.props = props;
185
- }
186
- ValidValuesIterable.prototype[Symbol.iterator] = function () {
187
- var _a, _b, value, e_1_1, min, max, stepValue, i;
188
- var e_1, _c;
189
- return tslib_1.__generator(this, function (_d) {
190
- switch (_d.label) {
191
- case 0:
192
- if (!this.props.validValues) return [3 /*break*/, 9];
193
- _d.label = 1;
194
- case 1:
195
- _d.trys.push([1, 6, 7, 8]);
196
- _a = tslib_1.__values(this.props.validValues), _b = _a.next();
197
- _d.label = 2;
198
- case 2:
199
- if (!!_b.done) return [3 /*break*/, 5];
200
- value = _b.value;
201
- return [4 /*yield*/, value];
202
- case 3:
203
- _d.sent();
204
- _d.label = 4;
205
- case 4:
206
- _b = _a.next();
207
- return [3 /*break*/, 2];
208
- case 5: return [3 /*break*/, 8];
209
- case 6:
210
- e_1_1 = _d.sent();
211
- e_1 = { error: e_1_1 };
212
- return [3 /*break*/, 8];
213
- case 7:
214
- try {
215
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
216
- }
217
- finally { if (e_1) throw e_1.error; }
218
- return [7 /*endfinally*/];
219
- case 8: return [3 /*break*/, 13];
220
- case 9:
221
- min = 0;
222
- max = void 0;
223
- stepValue = 1;
224
- if (this.props.validValueRanges) {
225
- min = this.props.validValueRanges[0];
226
- max = this.props.validValueRanges[1];
227
- }
228
- else if (this.props.minValue != null && this.props.maxValue != null) {
229
- min = this.props.minValue;
230
- max = this.props.maxValue;
231
- if (this.props.minStep != null) {
232
- stepValue = this.props.minStep;
233
- }
234
- }
235
- else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
236
- max = (0, request_util_1.numericUpperBound)(this.props.format);
237
- }
238
- else {
239
- throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
240
- }
241
- i = min;
242
- _d.label = 10;
243
- case 10:
244
- if (!(i <= max)) return [3 /*break*/, 13];
245
- return [4 /*yield*/, i];
246
- case 11:
247
- _d.sent();
248
- _d.label = 12;
249
- case 12:
250
- i += stepValue;
251
- return [3 /*break*/, 10];
252
- case 13: return [2 /*return*/];
253
- }
254
- });
255
- };
256
- return ValidValuesIterable;
257
- }());
258
- var numberPattern = /^-?\d+$/;
259
- function extractHAPStatusFromError(error) {
260
- var errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
261
- if (numberPattern.test(error.message)) {
262
- var value = parseInt(error.message, 10);
263
- if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
264
- errorValue = value;
265
- }
266
- }
267
- return errorValue;
268
- }
269
- function maxWithUndefined(a, b) {
270
- if (a == null) {
271
- return b;
272
- }
273
- else if (b == null) {
274
- return a;
275
- }
276
- else {
277
- return Math.max(a, b);
278
- }
279
- }
280
- function minWithUndefined(a, b) {
281
- if (a == null) {
282
- return b;
283
- }
284
- else if (b == null) {
285
- return a;
286
- }
287
- else {
288
- return Math.min(a, b);
289
- }
290
- }
291
- /**
292
- * Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a
293
- * "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic
294
- * to a {@link Service} in order to store that value. A particular Characteristic is distinguished from others by its
295
- * UUID. HomeKit provides a set of known Characteristic UUIDs defined in HomeKit.ts along with a
296
- * corresponding concrete subclass.
297
- *
298
- * You can also define custom Characteristics by providing your own UUID. Custom Characteristics can be added
299
- * to any native or custom Services, but Siri will likely not be able to work with these.
300
- *
301
- * @group Characteristic
302
- */
303
- var Characteristic = /** @class */ (function (_super) {
304
- tslib_1.__extends(Characteristic, _super);
305
- function Characteristic(displayName, UUID, props) {
306
- var _this = _super.call(this) || this;
307
- _this.iid = null;
308
- _this.value = null;
309
- /**
310
- * @deprecated replaced by {@link statusCode}
311
- * @private
312
- */
313
- _this.status = null;
314
- /**
315
- * @private
316
- */
317
- _this.statusCode = 0 /* HAPStatus.SUCCESS */;
318
- _this.subscriptions = 0;
319
- _this.displayName = displayName;
320
- _this.UUID = UUID;
321
- _this.props = {
1255
+ additionalAuthorizationHandler;
1256
+ constructor(displayName, UUID, props) {
1257
+ super();
1258
+ this.displayName = displayName;
1259
+ this.UUID = UUID;
1260
+ this.props = {
322
1261
  format: "int" /* Formats.INT */,
323
1262
  perms: ["ev" /* Perms.NOTIFY */],
324
1263
  };
325
- _this.setProps(props || {}); // ensure sanity checks are called
326
- return _this;
1264
+ this.setProps(props || {}); // ensure sanity checks are called
327
1265
  }
328
1266
  /**
329
1267
  * Accepts a function that will be called to retrieve the current value of a Characteristic.
@@ -338,21 +1276,21 @@ var Characteristic = /** @class */ (function (_super) {
338
1276
  * ```
339
1277
  * @param handler
340
1278
  */
341
- Characteristic.prototype.onGet = function (handler) {
1279
+ onGet(handler) {
342
1280
  if (typeof handler !== "function") {
343
1281
  this.characteristicWarning(".onGet handler must be a function");
344
1282
  return this;
345
1283
  }
346
1284
  this.getHandler = handler;
347
1285
  return this;
348
- };
1286
+ }
349
1287
  /**
350
1288
  * Removes the {@link CharacteristicGetHandler} handler which was configured using {@link onGet}.
351
1289
  */
352
- Characteristic.prototype.removeOnGet = function () {
1290
+ removeOnGet() {
353
1291
  this.getHandler = undefined;
354
1292
  return this;
355
- };
1293
+ }
356
1294
  /**
357
1295
  * Accepts a function that will be called when setting the value of a Characteristic.
358
1296
  * If the characteristic supports {@link Perms.WRITE_RESPONSE} and the request requests a write-response value,
@@ -367,21 +1305,21 @@ var Characteristic = /** @class */ (function (_super) {
367
1305
  * ```
368
1306
  * @param handler
369
1307
  */
370
- Characteristic.prototype.onSet = function (handler) {
1308
+ onSet(handler) {
371
1309
  if (typeof handler !== "function") {
372
1310
  this.characteristicWarning(".onSet handler must be a function");
373
1311
  return this;
374
1312
  }
375
1313
  this.setHandler = handler;
376
1314
  return this;
377
- };
1315
+ }
378
1316
  /**
379
1317
  * Removes the {@link CharacteristicSetHandler} which was configured using {@link onSet}.
380
1318
  */
381
- Characteristic.prototype.removeOnSet = function () {
1319
+ removeOnSet() {
382
1320
  this.setHandler = undefined;
383
1321
  return this;
384
- };
1322
+ }
385
1323
  /**
386
1324
  * Updates the properties of this characteristic.
387
1325
  * Properties passed via the parameter will be set. Any parameter set to null will be deleted.
@@ -389,10 +1327,10 @@ var Characteristic = /** @class */ (function (_super) {
389
1327
  *
390
1328
  * @param props - Partial properties object with the desired updates.
391
1329
  */
392
- Characteristic.prototype.setProps = function (props) {
1330
+ setProps(props) {
393
1331
  (0, assert_1.default)(props, "props cannot be undefined when setting props");
394
1332
  // TODO calling setProps after publish doesn't lead to a increment in the current configuration number
395
- var formatDidChange = false;
1333
+ let formatDidChange = false;
396
1334
  // for every value "null" can be used to reset props, except for required props
397
1335
  if (props.format) {
398
1336
  formatDidChange = this.props.format !== props.format;
@@ -418,7 +1356,7 @@ var Characteristic = /** @class */ (function (_super) {
418
1356
  props.minValue = undefined;
419
1357
  }
420
1358
  else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
421
- this.characteristicWarning("Characteristic Property 'minValue' must be a finite number, received \"".concat(props.minValue, "\" (").concat(typeof props.minValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1359
+ this.characteristicWarning(`Characteristic Property 'minValue' must be a finite number, received "${props.minValue}" (${typeof props.minValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
422
1360
  props.minValue = undefined;
423
1361
  }
424
1362
  else {
@@ -445,7 +1383,7 @@ var Characteristic = /** @class */ (function (_super) {
445
1383
  props.maxValue = undefined;
446
1384
  }
447
1385
  else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
448
- this.characteristicWarning("Characteristic Property 'maxValue' must be a finite number, received \"".concat(props.maxValue, "\" (").concat(typeof props.maxValue, ")"), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1386
+ this.characteristicWarning(`Characteristic Property 'maxValue' must be a finite number, received "${props.maxValue}" (${typeof props.maxValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
449
1387
  props.maxValue = undefined;
450
1388
  }
451
1389
  else {
@@ -549,14 +1487,14 @@ var Characteristic = /** @class */ (function (_super) {
549
1487
  // - If the characteristic is marked as erroneous the value is not considered valid anyway, and we must not remove the `statusCode`.
550
1488
  // - Special case for `ProgrammableSwitchEvent` where every change in value is considered an event which would result in ghost button presses
551
1489
  // validateUserInput when called from setProps is intended to clamp value withing allowed range. It is why warnings should not be displayed.
552
- var correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1490
+ const correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
553
1491
  if (correctedValue !== this.value) {
554
1492
  // we don't want to emit a CHANGE event if the value didn't change at all!
555
1493
  this.updateValue(correctedValue);
556
1494
  }
557
1495
  }
558
1496
  return this;
559
- };
1497
+ }
560
1498
  /**
561
1499
  * This method can be used to gain an Iterator to loop over all valid values defined for this characteristic.
562
1500
  *
@@ -585,9 +1523,9 @@ var Characteristic = /** @class */ (function (_super) {
585
1523
  * const validValues = Array.from(characteristic.validValuesIterator());
586
1524
  * ```
587
1525
  */
588
- Characteristic.prototype.validValuesIterator = function () {
1526
+ validValuesIterator() {
589
1527
  return new ValidValuesIterable(this.props);
590
- };
1528
+ }
591
1529
  // noinspection JSUnusedGlobalSymbols
592
1530
  /**
593
1531
  * This method can be used to set up additional authorization for a characteristic.
@@ -605,37 +1543,15 @@ var Characteristic = /** @class */ (function (_super) {
605
1543
  *
606
1544
  * @param handler - Handler called to check additional authorization data.
607
1545
  */
608
- Characteristic.prototype.setupAdditionalAuthorization = function (handler) {
1546
+ setupAdditionalAuthorization(handler) {
609
1547
  if (!this.props.perms.includes("aa" /* Perms.ADDITIONAL_AUTHORIZATION */)) {
610
1548
  this.props.perms.push("aa" /* Perms.ADDITIONAL_AUTHORIZATION */);
611
1549
  }
612
1550
  this.additionalAuthorizationHandler = handler;
613
- };
614
- /**
615
- * Updates the current value of the characteristic.
616
- *
617
- * @param callback
618
- * @param context
619
- * @private use to return the current value on HAP requests
620
- *
621
- * @deprecated
622
- */
623
- Characteristic.prototype.getValue = function (callback, context) {
624
- this.handleGetRequest(undefined, context).then(function (value) {
625
- if (callback) {
626
- callback(null, value);
627
- }
628
- }, function (reason) {
629
- if (callback) {
630
- callback(reason);
631
- }
632
- });
633
- };
634
- Characteristic.prototype.setValue = function (value, callback, context) {
1551
+ }
1552
+ setValue(value, callback, context) {
635
1553
  if (value instanceof Error) {
636
1554
  this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
637
- // noinspection JSDeprecatedSymbols
638
- this.status = value;
639
1555
  if (callback) {
640
1556
  callback();
641
1557
  }
@@ -649,13 +1565,13 @@ var Characteristic = /** @class */ (function (_super) {
649
1565
  value = this.validateUserInput(value);
650
1566
  }
651
1567
  catch (error) {
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);
1568
+ this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
653
1569
  if (callback) {
654
1570
  callback(error);
655
1571
  }
656
1572
  return this;
657
1573
  }
658
- this.handleSetRequest(value, undefined, context).then(function (value) {
1574
+ this.handleSetRequest(value, undefined, context).then(value => {
659
1575
  if (callback) {
660
1576
  if (value) { // possible write response
661
1577
  callback(null, value);
@@ -664,18 +1580,16 @@ var Characteristic = /** @class */ (function (_super) {
664
1580
  callback(null);
665
1581
  }
666
1582
  }
667
- }, function (reason) {
1583
+ }, reason => {
668
1584
  if (callback) {
669
1585
  callback(reason);
670
1586
  }
671
1587
  });
672
1588
  return this;
673
- };
674
- Characteristic.prototype.updateValue = function (value, callback, context) {
1589
+ }
1590
+ updateValue(value, callback, context) {
675
1591
  if (value instanceof Error) {
676
1592
  this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
677
- // noinspection JSDeprecatedSymbols
678
- this.status = value;
679
1593
  if (callback) {
680
1594
  callback();
681
1595
  }
@@ -689,23 +1603,21 @@ var Characteristic = /** @class */ (function (_super) {
689
1603
  value = this.validateUserInput(value);
690
1604
  }
691
1605
  catch (error) {
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);
1606
+ this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
693
1607
  if (callback) {
694
1608
  callback();
695
1609
  }
696
1610
  return this;
697
1611
  }
698
1612
  this.statusCode = 0 /* HAPStatus.SUCCESS */;
699
- // noinspection JSDeprecatedSymbols
700
- this.status = null;
701
- var oldValue = this.value;
1613
+ const oldValue = this.value;
702
1614
  this.value = value;
703
1615
  if (callback) {
704
1616
  callback();
705
1617
  }
706
1618
  this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
707
1619
  return this; // for chaining
708
- };
1620
+ }
709
1621
  /**
710
1622
  * This method acts similarly to {@link updateValue} by setting the current value of the characteristic
711
1623
  * without calling any {@link CharacteristicEventTypes.SET} or {@link onSet} handlers.
@@ -715,16 +1627,14 @@ var Characteristic = /** @class */ (function (_super) {
715
1627
  * @param value - The new value.
716
1628
  * @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler.
717
1629
  */
718
- Characteristic.prototype.sendEventNotification = function (value, context) {
1630
+ sendEventNotification(value, context) {
719
1631
  this.statusCode = 0 /* HAPStatus.SUCCESS */;
720
- // noinspection JSDeprecatedSymbols
721
- this.status = null;
722
1632
  value = this.validateUserInput(value);
723
- var oldValue = this.value;
1633
+ const oldValue = this.value;
724
1634
  this.value = value;
725
1635
  this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
726
1636
  return this; // for chaining
727
- };
1637
+ }
728
1638
  /**
729
1639
  * Called when a HAP requests wants to know the current value of the characteristic.
730
1640
  *
@@ -732,130 +1642,98 @@ var Characteristic = /** @class */ (function (_super) {
732
1642
  * @param context - Deprecated parameter. There for backwards compatibility.
733
1643
  * @private Used by the Accessory to load the characteristic value
734
1644
  */
735
- Characteristic.prototype.handleGetRequest = function (connection, context) {
736
- return tslib_1.__awaiter(this, void 0, void 0, function () {
737
- var value, oldValue, error_1, hapStatusError;
738
- var _this = this;
739
- return tslib_1.__generator(this, function (_a) {
740
- switch (_a.label) {
741
- case 0:
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 */;
744
- }
745
- if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
746
- // special workaround for event only programmable switch event, which must always return null
747
- return [2 /*return*/, null];
748
- }
749
- if (!this.getHandler) return [3 /*break*/, 4];
750
- if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
751
- this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
752
- }
753
- _a.label = 1;
754
- case 1:
755
- _a.trys.push([1, 3, , 4]);
756
- return [4 /*yield*/, this.getHandler(context, connection)];
757
- case 2:
758
- value = _a.sent();
759
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
760
- // noinspection JSDeprecatedSymbols
761
- this.status = null;
762
- try {
763
- value = this.validateUserInput(value);
764
- }
765
- catch (error) {
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 */;
768
- // noinspection JSDeprecatedSymbols
769
- this.status = error;
770
- return [2 /*return*/, Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */)];
771
- }
772
- oldValue = this.value;
773
- this.value = value;
774
- if (oldValue !== value) { // emit a change event if necessary
775
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
776
- }
777
- return [2 /*return*/, value];
778
- case 3:
779
- error_1 = _a.sent();
780
- if (typeof error_1 === "number") {
781
- hapStatusError = new hapStatusError_1.HapStatusError(error_1);
1645
+ async handleGetRequest(connection, context) {
1646
+ if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
1647
+ throw -70405 /* HAPStatus.WRITE_ONLY_CHARACTERISTIC */;
1648
+ }
1649
+ if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
1650
+ // special workaround for event only programmable switch event, which must always return null
1651
+ return null;
1652
+ }
1653
+ if (this.getHandler) {
1654
+ if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
1655
+ this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
1656
+ }
1657
+ try {
1658
+ let value = await this.getHandler(context, connection);
1659
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
1660
+ try {
1661
+ value = this.validateUserInput(value);
1662
+ }
1663
+ catch (error) {
1664
+ this.characteristicWarning(`An illegal value was supplied by the read handler for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
1665
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1666
+ return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1667
+ }
1668
+ const oldValue = this.value;
1669
+ this.value = value;
1670
+ if (oldValue !== value) { // emit a change event if necessary
1671
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1672
+ }
1673
+ return value;
1674
+ }
1675
+ catch (error) {
1676
+ if (typeof error === "number") {
1677
+ const hapStatusError = new hapStatusError_1.HapStatusError(error);
1678
+ this.statusCode = hapStatusError.hapStatus;
1679
+ }
1680
+ else if (error instanceof hapStatusError_1.HapStatusError) {
1681
+ this.statusCode = error.hapStatus;
1682
+ }
1683
+ else {
1684
+ this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1685
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1686
+ }
1687
+ throw this.statusCode;
1688
+ }
1689
+ }
1690
+ if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
1691
+ if (this.statusCode) {
1692
+ throw this.statusCode;
1693
+ }
1694
+ try {
1695
+ return this.validateUserInput(this.value);
1696
+ }
1697
+ catch (error) {
1698
+ this.characteristicWarning(`An illegal value was supplied by setting \`value\` for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
1699
+ return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1700
+ }
1701
+ }
1702
+ return new Promise((resolve, reject) => {
1703
+ try {
1704
+ this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)((status, value) => {
1705
+ if (status) {
1706
+ if (typeof status === "number") {
1707
+ const hapStatusError = new hapStatusError_1.HapStatusError(status);
782
1708
  this.statusCode = hapStatusError.hapStatus;
783
- // noinspection JSDeprecatedSymbols
784
- this.status = hapStatusError;
785
1709
  }
786
- else if (error_1 instanceof hapStatusError_1.HapStatusError) {
787
- this.statusCode = error_1.hapStatus;
788
- // noinspection JSDeprecatedSymbols
789
- this.status = error_1;
1710
+ else if (status instanceof hapStatusError_1.HapStatusError) {
1711
+ this.statusCode = status.hapStatus;
790
1712
  }
791
1713
  else {
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 */;
794
- // noinspection JSDeprecatedSymbols
795
- this.status = error_1;
796
- }
797
- throw this.statusCode;
798
- case 4:
799
- if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
800
- if (this.statusCode) {
801
- throw this.statusCode;
802
- }
803
- try {
804
- return [2 /*return*/, this.validateUserInput(this.value)];
805
- }
806
- catch (error) {
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 */)];
809
- }
1714
+ debug("[%s] Received error from get handler %s", this.displayName, status.stack);
1715
+ this.statusCode = extractHAPStatusFromError(status);
810
1716
  }
811
- return [2 /*return*/, new Promise(function (resolve, reject) {
812
- try {
813
- _this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)(function (status, value) {
814
- if (status) {
815
- if (typeof status === "number") {
816
- var hapStatusError = new hapStatusError_1.HapStatusError(status);
817
- _this.statusCode = hapStatusError.hapStatus;
818
- // noinspection JSDeprecatedSymbols
819
- _this.status = hapStatusError;
820
- }
821
- else if (status instanceof hapStatusError_1.HapStatusError) {
822
- _this.statusCode = status.hapStatus;
823
- // noinspection JSDeprecatedSymbols
824
- _this.status = status;
825
- }
826
- else {
827
- debug("[%s] Received error from get handler %s", _this.displayName, status.stack);
828
- _this.statusCode = extractHAPStatusFromError(status);
829
- // noinspection JSDeprecatedSymbols
830
- _this.status = status;
831
- }
832
- reject(_this.statusCode);
833
- return;
834
- }
835
- _this.statusCode = 0 /* HAPStatus.SUCCESS */;
836
- // noinspection JSDeprecatedSymbols
837
- _this.status = null;
838
- value = _this.validateUserInput(value);
839
- var oldValue = _this.value;
840
- _this.value = value;
841
- resolve(value);
842
- if (oldValue !== value) { // emit a change event if necessary
843
- _this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
844
- }
845
- }), context, connection);
846
- }
847
- catch (error) {
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 */;
850
- // noinspection JSDeprecatedSymbols
851
- _this.status = error;
852
- reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
853
- }
854
- })];
855
- }
856
- });
1717
+ reject(this.statusCode);
1718
+ return;
1719
+ }
1720
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
1721
+ value = this.validateUserInput(value);
1722
+ const oldValue = this.value;
1723
+ this.value = value;
1724
+ resolve(value);
1725
+ if (oldValue !== value) { // emit a change event if necessary
1726
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1727
+ }
1728
+ }), context, connection);
1729
+ }
1730
+ catch (error) {
1731
+ this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1732
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1733
+ reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1734
+ }
857
1735
  });
858
- };
1736
+ }
859
1737
  /**
860
1738
  * Called when a HAP requests update the current value of the characteristic.
861
1739
  *
@@ -867,162 +1745,127 @@ var Characteristic = /** @class */ (function (_super) {
867
1745
  * write response value is resolved.
868
1746
  * @private
869
1747
  */
870
- Characteristic.prototype.handleSetRequest = function (value, connection, context) {
871
- return tslib_1.__awaiter(this, void 0, void 0, function () {
872
- var oldValue, writeResponse, error_2, hapStatusError;
873
- var _this = this;
874
- return tslib_1.__generator(this, function (_a) {
875
- switch (_a.label) {
876
- case 0:
877
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
878
- // noinspection JSDeprecatedSymbols
879
- this.status = null;
880
- if (connection !== undefined) {
881
- // if connection is undefined, the set "request" comes from the setValue method.
882
- // for setValue a value of "null" is allowed and checked via validateUserInput.
883
- try {
884
- value = this.validateClientSuppliedValue(value);
1748
+ async handleSetRequest(value, connection, context) {
1749
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
1750
+ if (connection !== undefined) {
1751
+ // if connection is undefined, the set "request" comes from the setValue method.
1752
+ // for setValue a value of "null" is allowed and checked via validateUserInput.
1753
+ try {
1754
+ value = this.validateClientSuppliedValue(value);
1755
+ }
1756
+ catch (e) {
1757
+ debug(`[${this.displayName}]`, e.message);
1758
+ return Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
1759
+ }
1760
+ }
1761
+ const oldValue = this.value;
1762
+ if (this.setHandler) {
1763
+ if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
1764
+ this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
1765
+ }
1766
+ try {
1767
+ const writeResponse = await this.setHandler(value, context, connection);
1768
+ this.statusCode = 0 /* HAPStatus.SUCCESS */;
1769
+ if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
1770
+ this.value = this.validateUserInput(writeResponse);
1771
+ return this.value;
1772
+ }
1773
+ else {
1774
+ if (writeResponse != null) {
1775
+ this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1776
+ }
1777
+ this.value = value;
1778
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1779
+ return;
1780
+ }
1781
+ }
1782
+ catch (error) {
1783
+ if (typeof error === "number") {
1784
+ const hapStatusError = new hapStatusError_1.HapStatusError(error);
1785
+ this.statusCode = hapStatusError.hapStatus;
1786
+ }
1787
+ else if (error instanceof hapStatusError_1.HapStatusError) {
1788
+ this.statusCode = error.hapStatus;
1789
+ }
1790
+ else {
1791
+ this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1792
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1793
+ }
1794
+ throw this.statusCode;
1795
+ }
1796
+ }
1797
+ if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
1798
+ this.value = value;
1799
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1800
+ return Promise.resolve();
1801
+ }
1802
+ else {
1803
+ return new Promise((resolve, reject) => {
1804
+ try {
1805
+ this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)((status, writeResponse) => {
1806
+ if (status) {
1807
+ if (typeof status === "number") {
1808
+ const hapStatusError = new hapStatusError_1.HapStatusError(status);
1809
+ this.statusCode = hapStatusError.hapStatus;
885
1810
  }
886
- catch (e) {
887
- debug("[".concat(this.displayName, "]"), e.message);
888
- return [2 /*return*/, Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */)];
1811
+ else if (status instanceof hapStatusError_1.HapStatusError) {
1812
+ this.statusCode = status.hapStatus;
889
1813
  }
1814
+ else {
1815
+ debug("[%s] Received error from set handler %s", this.displayName, status.stack);
1816
+ this.statusCode = extractHAPStatusFromError(status);
1817
+ }
1818
+ reject(this.statusCode);
1819
+ return;
890
1820
  }
891
- oldValue = this.value;
892
- if (!this.setHandler) return [3 /*break*/, 4];
893
- if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
894
- this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
895
- }
896
- _a.label = 1;
897
- case 1:
898
- _a.trys.push([1, 3, , 4]);
899
- return [4 /*yield*/, this.setHandler(value, context, connection)];
900
- case 2:
901
- writeResponse = _a.sent();
902
1821
  this.statusCode = 0 /* HAPStatus.SUCCESS */;
903
- // noinspection JSDeprecatedSymbols
904
- this.status = null;
905
1822
  if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
1823
+ // support write response simply by letting the implementor pass the response as second argument to the callback
906
1824
  this.value = this.validateUserInput(writeResponse);
907
- return [2 /*return*/, this.value];
1825
+ resolve(this.value);
908
1826
  }
909
1827
  else {
910
1828
  if (writeResponse != null) {
911
1829
  this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
912
1830
  }
913
1831
  this.value = value;
1832
+ resolve();
914
1833
  this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
915
- return [2 /*return*/];
916
- }
917
- return [3 /*break*/, 4];
918
- case 3:
919
- error_2 = _a.sent();
920
- if (typeof error_2 === "number") {
921
- hapStatusError = new hapStatusError_1.HapStatusError(error_2);
922
- this.statusCode = hapStatusError.hapStatus;
923
- // noinspection JSDeprecatedSymbols
924
- this.status = hapStatusError;
925
- }
926
- else if (error_2 instanceof hapStatusError_1.HapStatusError) {
927
- this.statusCode = error_2.hapStatus;
928
- // noinspection JSDeprecatedSymbols
929
- this.status = error_2;
930
- }
931
- else {
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 */;
934
- // noinspection JSDeprecatedSymbols
935
- this.status = error_2;
936
- }
937
- throw this.statusCode;
938
- case 4:
939
- if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
940
- this.value = value;
941
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
942
- return [2 /*return*/, Promise.resolve()];
943
- }
944
- else {
945
- return [2 /*return*/, new Promise(function (resolve, reject) {
946
- try {
947
- _this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)(function (status, writeResponse) {
948
- if (status) {
949
- if (typeof status === "number") {
950
- var hapStatusError = new hapStatusError_1.HapStatusError(status);
951
- _this.statusCode = hapStatusError.hapStatus;
952
- // noinspection JSDeprecatedSymbols
953
- _this.status = hapStatusError;
954
- }
955
- else if (status instanceof hapStatusError_1.HapStatusError) {
956
- _this.statusCode = status.hapStatus;
957
- // noinspection JSDeprecatedSymbols
958
- _this.status = status;
959
- }
960
- else {
961
- debug("[%s] Received error from set handler %s", _this.displayName, status.stack);
962
- _this.statusCode = extractHAPStatusFromError(status);
963
- // noinspection JSDeprecatedSymbols
964
- _this.status = status;
965
- }
966
- reject(_this.statusCode);
967
- return;
968
- }
969
- _this.statusCode = 0 /* HAPStatus.SUCCESS */;
970
- // noinspection JSDeprecatedSymbols
971
- _this.status = null;
972
- if (writeResponse != null && _this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
973
- // support write response simply by letting the implementor pass the response as second argument to the callback
974
- _this.value = _this.validateUserInput(writeResponse);
975
- resolve(_this.value);
976
- }
977
- else {
978
- if (writeResponse != null) {
979
- _this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
980
- }
981
- _this.value = value;
982
- resolve();
983
- _this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
984
- }
985
- }), context, connection);
986
- }
987
- catch (error) {
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 */;
990
- // noinspection JSDeprecatedSymbols
991
- _this.status = error;
992
- reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
993
- }
994
- })];
995
1834
  }
996
- return [2 /*return*/];
1835
+ }), context, connection);
1836
+ }
1837
+ catch (error) {
1838
+ this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1839
+ this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1840
+ reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
997
1841
  }
998
1842
  });
999
- });
1000
- };
1843
+ }
1844
+ }
1001
1845
  /**
1002
1846
  * Called once a HomeKit controller subscribes to events of this characteristic.
1003
1847
  * @private
1004
1848
  */
1005
- Characteristic.prototype.subscribe = function () {
1849
+ subscribe() {
1006
1850
  if (this.subscriptions === 0) {
1007
1851
  this.emit("subscribe" /* CharacteristicEventTypes.SUBSCRIBE */);
1008
1852
  }
1009
1853
  this.subscriptions++;
1010
- };
1854
+ }
1011
1855
  /**
1012
1856
  * Called once a HomeKit controller unsubscribe to events of this characteristic or a HomeKit controller
1013
1857
  * which was subscribed to this characteristic disconnects.
1014
1858
  * @private
1015
1859
  */
1016
- Characteristic.prototype.unsubscribe = function () {
1017
- var wasOne = this.subscriptions === 1;
1860
+ unsubscribe() {
1861
+ const wasOne = this.subscriptions === 1;
1018
1862
  this.subscriptions--;
1019
1863
  this.subscriptions = Math.max(this.subscriptions, 0);
1020
1864
  if (wasOne) {
1021
1865
  this.emit("unsubscribe" /* CharacteristicEventTypes.UNSUBSCRIBE */);
1022
1866
  }
1023
- };
1024
- Characteristic.prototype.getDefaultValue = function () {
1025
- var _a;
1867
+ }
1868
+ getDefaultValue() {
1026
1869
  // noinspection JSDeprecatedSymbols
1027
1870
  switch (this.props.format) {
1028
1871
  case "bool" /* Formats.BOOL */:
@@ -1044,10 +1887,6 @@ var Characteristic = /** @class */ (function (_super) {
1044
1887
  return ""; // who knows!
1045
1888
  case "tlv8" /* Formats.TLV8 */:
1046
1889
  return ""; // who knows!
1047
- case "dict" /* Formats.DICTIONARY */:
1048
- return {};
1049
- case "array" /* Formats.ARRAY */:
1050
- return [];
1051
1890
  case "int" /* Formats.INT */:
1052
1891
  case "float" /* Formats.FLOAT */:
1053
1892
  case "uint8" /* Formats.UINT8 */:
@@ -1058,7 +1897,7 @@ var Characteristic = /** @class */ (function (_super) {
1058
1897
  case Characteristic.CurrentTemperature.UUID:
1059
1898
  return 0; // some existing integrations expect this to be 0 by default
1060
1899
  default: {
1061
- if (((_a = this.props.validValues) === null || _a === void 0 ? void 0 : _a.length) && typeof this.props.validValues[0] === "number") {
1900
+ if (this.props.validValues?.length && typeof this.props.validValues[0] === "number") {
1062
1901
  return this.props.validValues[0];
1063
1902
  }
1064
1903
  if (typeof this.props.minValue === "number" && Number.isFinite(this.props.minValue)) {
@@ -1070,16 +1909,16 @@ var Characteristic = /** @class */ (function (_super) {
1070
1909
  default:
1071
1910
  return 0;
1072
1911
  }
1073
- };
1912
+ }
1074
1913
  /**
1075
1914
  * Checks if the value received from the HAP request is valid.
1076
1915
  * If returned false the received value is not valid and {@link HAPStatus.INVALID_VALUE_IN_REQUEST}
1077
1916
  * must be returned.
1078
1917
  * @param value - Value supplied by the HomeKit controller
1079
1918
  */
1080
- Characteristic.prototype.validateClientSuppliedValue = function (value) {
1919
+ validateClientSuppliedValue(value) {
1081
1920
  if (value == null) {
1082
- throw new Error("Client supplied invalid value for ".concat(this.props.format, ": ").concat(value));
1921
+ throw new Error(`Client supplied invalid value for ${this.props.format}: ${value}`);
1083
1922
  }
1084
1923
  switch (this.props.format) {
1085
1924
  case "bool" /* Formats.BOOL */: {
@@ -1089,7 +1928,7 @@ var Characteristic = /** @class */ (function (_super) {
1089
1928
  if (typeof value === "number" && (value === 1 || value === 0)) {
1090
1929
  return Boolean(value);
1091
1930
  }
1092
- throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1931
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1093
1932
  }
1094
1933
  case "int" /* Formats.INT */:
1095
1934
  case "float" /* Formats.FLOAT */:
@@ -1101,58 +1940,58 @@ var Characteristic = /** @class */ (function (_super) {
1101
1940
  value = value ? 1 : 0;
1102
1941
  }
1103
1942
  if (typeof value !== "number" || !Number.isFinite(value)) {
1104
- throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1943
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1105
1944
  }
1106
- var numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
1107
- var numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
1945
+ const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
1946
+ const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
1108
1947
  if (typeof numericMin === "number" && value < numericMin) {
1109
- throw new Error("Client supplied value of ".concat(value, " is less than the minimum allowed value of ").concat(numericMin));
1948
+ throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${numericMin}`);
1110
1949
  }
1111
1950
  if (typeof numericMax === "number" && value > numericMax) {
1112
- throw new Error("Client supplied value of ".concat(value, " is greater than the maximum allowed value of ").concat(numericMax));
1951
+ throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${numericMax}`);
1113
1952
  }
1114
1953
  if (this.props.validValues && !this.props.validValues.includes(value)) {
1115
- throw new Error("Client supplied value of ".concat(value, " is not in ").concat(this.props.validValues.toString()));
1954
+ throw new Error(`Client supplied value of ${value} is not in ${this.props.validValues.toString()}`);
1116
1955
  }
1117
1956
  if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
1118
1957
  if (value < this.props.validValueRanges[0]) {
1119
- throw new Error("Client supplied value of ".concat(value, " is less than the minimum allowed value of ").concat(this.props.validValueRanges[0]));
1958
+ throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${this.props.validValueRanges[0]}`);
1120
1959
  }
1121
1960
  if (value > this.props.validValueRanges[1]) {
1122
- throw new Error("Client supplied value of ".concat(value, " is greater than the maximum allowed value of ").concat(this.props.validValueRanges[1]));
1961
+ throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${this.props.validValueRanges[1]}`);
1123
1962
  }
1124
1963
  }
1125
1964
  return value;
1126
1965
  }
1127
1966
  case "string" /* Formats.STRING */: {
1128
1967
  if (typeof value !== "string") {
1129
- throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1968
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1130
1969
  }
1131
- var maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
1970
+ const maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
1132
1971
  if (value.length > maxLength) {
1133
- throw new Error("Client supplied value length of ".concat(value.length, " exceeds maximum length allowed of ").concat(maxLength));
1972
+ throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
1134
1973
  }
1135
1974
  return value;
1136
1975
  }
1137
1976
  case "data" /* Formats.DATA */: {
1138
1977
  if (typeof value !== "string") {
1139
- throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1978
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1140
1979
  }
1141
1980
  // we don't validate base64 here
1142
- var maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
1981
+ const maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
1143
1982
  if (value.length > maxLength) {
1144
- throw new Error("Client supplied value length of ".concat(value.length, " exceeds maximum length allowed of ").concat(maxLength));
1983
+ throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
1145
1984
  }
1146
1985
  return value;
1147
1986
  }
1148
1987
  case "tlv8" /* Formats.TLV8 */:
1149
1988
  if (typeof value !== "string") {
1150
- throw new Error("Client supplied invalid type for ".concat(this.props.format, ": \"").concat(value, "\" (").concat(typeof value, ")"));
1989
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1151
1990
  }
1152
1991
  return value;
1153
1992
  }
1154
1993
  return value;
1155
- };
1994
+ }
1156
1995
  /**
1157
1996
  * Checks if the value received from the API call is valid.
1158
1997
  * It adjusts the value where it makes sense, prints a warning where values may be rejected with an error
@@ -1161,9 +2000,7 @@ var Characteristic = /** @class */ (function (_super) {
1161
2000
  * @param value - The value received from the API call
1162
2001
  * @param warningType - Optionally defines the warning type to use when raising a {@link CharacteristicEventTypes.CHARACTERISTIC_WARNING}.
1163
2002
  */
1164
- Characteristic.prototype.validateUserInput = function (value, warningType) {
1165
- var _a;
1166
- if (warningType === void 0) { warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
2003
+ validateUserInput(value, warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */) {
1167
2004
  if (value === null) {
1168
2005
  if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
1169
2006
  this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
@@ -1224,12 +2061,12 @@ var Characteristic = /** @class */ (function (_super) {
1224
2061
  value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
1225
2062
  }
1226
2063
  if (typeof value !== "number" || !Number.isFinite(value)) {
1227
- this.characteristicWarning("characteristic value expected valid finite number and received \"".concat(value, "\" (").concat(typeof value, ")"), warningType);
2064
+ this.characteristicWarning(`characteristic value expected valid finite number and received "${value}" (${typeof value})`, warningType);
1228
2065
  value = typeof this.value === "number" ? this.value : this.props.minValue || 0;
1229
2066
  }
1230
- var numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
1231
- var numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
1232
- var stepValue = undefined;
2067
+ const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
2068
+ const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
2069
+ let stepValue = undefined;
1233
2070
  if (this.props.format === "float" /* Formats.FLOAT */) {
1234
2071
  stepValue = this.props.minStep;
1235
2072
  }
@@ -1237,28 +2074,30 @@ var Characteristic = /** @class */ (function (_super) {
1237
2074
  stepValue = maxWithUndefined(this.props.minStep, 1);
1238
2075
  }
1239
2076
  if (stepValue != null && stepValue > 0) {
1240
- var minValue = this.props.minValue != null ? this.props.minValue : 0;
2077
+ const minValue = this.props.minValue != null ? this.props.minValue : 0;
1241
2078
  value = stepValue * Math.round((value - minValue) / stepValue) + minValue;
1242
2079
  }
1243
2080
  if (numericMin != null && value < numericMin) {
1244
- this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " exceeded minimum of ").concat(numericMin), warningType);
2081
+ this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded minimum of ${numericMin}`, warningType);
1245
2082
  value = numericMin;
1246
2083
  }
1247
2084
  if (numericMax != null && value > numericMax) {
1248
- this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " exceeded maximum of ").concat(numericMax), warningType);
2085
+ this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded maximum of ${numericMax}`, warningType);
1249
2086
  value = numericMax;
1250
2087
  }
1251
2088
  if (this.props.validValues && !this.props.validValues.includes(value)) {
1252
- this.characteristicWarning("characteristic value ".concat(value, " is not contained in valid values array"), warningType);
2089
+ this.characteristicWarning(`characteristic value ${value} is not contained in valid values array`, warningType);
1253
2090
  return this.props.validValues.includes(this.value) ? this.value : (this.props.validValues[0] || 0);
1254
2091
  }
1255
2092
  if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
1256
2093
  if (value < this.props.validValueRanges[0]) {
1257
- this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " not contained in valid value range of ").concat(this.props.validValueRanges, ", supplying illegal values will throw errors in the future"), warningType);
2094
+ this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
2095
+ + `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
1258
2096
  value = this.props.validValueRanges[0];
1259
2097
  }
1260
2098
  else if (value > this.props.validValueRanges[1]) {
1261
- this.characteristicWarning("characteristic was supplied illegal value: number ".concat(value, " not contained in valid value range of ").concat(this.props.validValueRanges, ", supplying illegal values will throw errors in the future"), warningType);
2099
+ this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
2100
+ + `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
1262
2101
  value = this.props.validValueRanges[1];
1263
2102
  }
1264
2103
  }
@@ -1276,14 +2115,18 @@ var Characteristic = /** @class */ (function (_super) {
1276
2115
  }
1277
2116
  // mirrors the case value = null at the beginning
1278
2117
  if (value.length <= 1 && (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID)) {
1279
- this.characteristicWarning("[".concat(this.displayName, "] characteristic must have a length of more than 1 character otherwise HomeKit will reject this accessory, ignoring new value"), warningType);
2118
+ this.characteristicWarning(`[${this.displayName}] characteristic must have a length of more than 1 character otherwise`
2119
+ + ` HomeKit will reject this accessory, ignoring new value ${warningType}`);
1280
2120
  return this.value; // just return the current value
1281
2121
  }
1282
- var maxLength = (_a = this.props.maxLen) !== null && _a !== void 0 ? _a : 64; // default is 64 (max is 256 which is set in setProps)
2122
+ const maxLength = this.props.maxLen ?? 64; // default is 64 (max is 256 which is set in setProps)
1283
2123
  if (value.length > maxLength) {
1284
- this.characteristicWarning("characteristic was supplied illegal value: string '".concat(value, "' exceeded max length of ").concat(maxLength), warningType);
2124
+ this.characteristicWarning(`characteristic was supplied illegal value: string '${value}' exceeded max length of ${maxLength}`, warningType);
1285
2125
  value = value.substring(0, maxLength);
1286
2126
  }
2127
+ if (value.length > 0 && this.UUID === Characteristic.ConfiguredName.UUID) {
2128
+ (0, checkName_1.checkName)(this.displayName, "ConfiguredName", value);
2129
+ }
1287
2130
  return value;
1288
2131
  }
1289
2132
  case "data" /* Formats.DATA */:
@@ -1308,109 +2151,88 @@ var Characteristic = /** @class */ (function (_super) {
1308
2151
  return this.value;
1309
2152
  }
1310
2153
  return value;
1311
- };
2154
+ }
1312
2155
  /**
1313
2156
  * @private used to assign iid to characteristic
1314
2157
  */
1315
- Characteristic.prototype._assignID = function (identifierCache, accessoryName, serviceUUID, serviceSubtype) {
2158
+ _assignID(identifierCache, accessoryName, serviceUUID, serviceSubtype) {
1316
2159
  // generate our IID based on our UUID
1317
2160
  this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
1318
- };
1319
- Characteristic.prototype.characteristicWarning = function (message, type, stack) {
1320
- if (type === void 0) { type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */; }
1321
- if (stack === void 0) { stack = new Error().stack; }
2161
+ }
2162
+ characteristicWarning(message, type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, stack = new Error().stack) {
1322
2163
  this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
1323
- };
2164
+ }
1324
2165
  /**
1325
2166
  * @param event
1326
2167
  * @private
1327
2168
  */
1328
- Characteristic.prototype.removeAllListeners = function (event) {
2169
+ removeAllListeners(event) {
1329
2170
  if (!event) {
1330
2171
  this.removeOnGet();
1331
2172
  this.removeOnSet();
1332
2173
  }
1333
- return _super.prototype.removeAllListeners.call(this, event);
1334
- };
2174
+ return super.removeAllListeners(event);
2175
+ }
1335
2176
  /**
1336
2177
  * @param characteristic
1337
2178
  * @private
1338
2179
  */
1339
- Characteristic.prototype.replaceBy = function (characteristic) {
1340
- var _this = this;
2180
+ replaceBy(characteristic) {
1341
2181
  this.props = characteristic.props;
1342
2182
  this.updateValue(characteristic.value);
1343
- var getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
2183
+ const getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
1344
2184
  if (getListeners.length) {
1345
2185
  // the callback can only be called once, so we remove all old listeners
1346
2186
  this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
1347
2187
  // @ts-expect-error: force type
1348
- getListeners.forEach(function (listener) { return _this.addListener("get" /* CharacteristicEventTypes.GET */, listener); });
2188
+ getListeners.forEach(listener => this.addListener("get" /* CharacteristicEventTypes.GET */, listener));
1349
2189
  }
1350
2190
  this.removeOnGet();
1351
2191
  if (characteristic.getHandler) {
1352
2192
  this.onGet(characteristic.getHandler);
1353
2193
  }
1354
- var setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
2194
+ const setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
1355
2195
  if (setListeners.length) {
1356
2196
  // the callback can only be called once, so we remove all old listeners
1357
2197
  this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
1358
2198
  // @ts-expect-error: force type
1359
- setListeners.forEach(function (listener) { return _this.addListener("set" /* CharacteristicEventTypes.SET */, listener); });
2199
+ setListeners.forEach(listener => this.addListener("set" /* CharacteristicEventTypes.SET */, listener));
1360
2200
  }
1361
2201
  this.removeOnSet();
1362
2202
  if (characteristic.setHandler) {
1363
2203
  this.onSet(characteristic.setHandler);
1364
2204
  }
1365
- };
2205
+ }
1366
2206
  /**
1367
2207
  * Returns a JSON representation of this characteristic suitable for delivering to HAP clients.
1368
2208
  * @private used to generate response to /accessories query
1369
2209
  */
1370
- Characteristic.prototype.toHAP = function (connection, contactGetHandlers) {
1371
- if (contactGetHandlers === void 0) { contactGetHandlers = true; }
1372
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1373
- var object, value, _a;
1374
- var _this = this;
1375
- return tslib_1.__generator(this, function (_b) {
1376
- switch (_b.label) {
1377
- case 0:
1378
- object = this.internalHAPRepresentation();
1379
- if (!!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) return [3 /*break*/, 1];
1380
- object.value = undefined;
1381
- return [3 /*break*/, 6];
1382
- case 1:
1383
- if (!(this.UUID === Characteristic.ProgrammableSwitchEvent.UUID)) return [3 /*break*/, 2];
1384
- // special workaround for event only programmable switch event, which must always return null
1385
- object.value = null;
1386
- return [3 /*break*/, 6];
1387
- case 2:
1388
- if (!contactGetHandlers) return [3 /*break*/, 4];
1389
- return [4 /*yield*/, this.handleGetRequest(connection).catch(function () {
1390
- var value = _this.getDefaultValue();
1391
- debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", _this.displayName, "".concat(value));
1392
- return value; // use default value
1393
- })];
1394
- case 3:
1395
- _a = _b.sent();
1396
- return [3 /*break*/, 5];
1397
- case 4:
1398
- _a = this.value;
1399
- _b.label = 5;
1400
- case 5:
1401
- value = _a;
1402
- object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
1403
- _b.label = 6;
1404
- case 6: return [2 /*return*/, object];
1405
- }
1406
- });
1407
- });
1408
- };
2210
+ async toHAP(connection, contactGetHandlers = true) {
2211
+ const object = this.internalHAPRepresentation();
2212
+ if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) {
2213
+ object.value = undefined;
2214
+ }
2215
+ else if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
2216
+ // special workaround for event only programmable switch event, which must always return null
2217
+ object.value = null;
2218
+ }
2219
+ else { // query the current value
2220
+ const value = contactGetHandlers
2221
+ ? await this.handleGetRequest(connection).catch(() => {
2222
+ const value = this.getDefaultValue();
2223
+ debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", this.displayName, `${value}`);
2224
+ return value; // use default value
2225
+ })
2226
+ : this.value;
2227
+ object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
2228
+ }
2229
+ return object;
2230
+ }
1409
2231
  /**
1410
2232
  * Returns a JSON representation of this characteristic without the value.
1411
2233
  * @private used to generate the config hash
1412
2234
  */
1413
- Characteristic.prototype.internalHAPRepresentation = function () {
2235
+ internalHAPRepresentation() {
1414
2236
  (0, assert_1.default)(this.iid, "iid cannot be undefined for characteristic '" + this.displayName + "'");
1415
2237
  // TODO include the value for characteristics of the AccessoryInformation service
1416
2238
  return {
@@ -1429,38 +2251,38 @@ var Characteristic = /** @class */ (function (_super) {
1429
2251
  "valid-values": this.props.validValues,
1430
2252
  "valid-values-range": this.props.validValueRanges,
1431
2253
  };
1432
- };
2254
+ }
1433
2255
  /**
1434
2256
  * Serialize characteristic into json string.
1435
2257
  *
1436
2258
  * @param characteristic - Characteristic object.
1437
2259
  * @private used to store characteristic on disk
1438
2260
  */
1439
- Characteristic.serialize = function (characteristic) {
1440
- var constructorName;
2261
+ static serialize(characteristic) {
2262
+ let constructorName;
1441
2263
  if (characteristic.constructor.name !== "Characteristic") {
1442
2264
  constructorName = characteristic.constructor.name;
1443
2265
  }
1444
2266
  return {
1445
2267
  displayName: characteristic.displayName,
1446
2268
  UUID: characteristic.UUID,
1447
- eventOnlyCharacteristic: characteristic.UUID === Characteristic.ProgrammableSwitchEvent.UUID,
2269
+ eventOnlyCharacteristic: characteristic.UUID === Characteristic.ProgrammableSwitchEvent.UUID, // support downgrades for now
1448
2270
  constructorName: constructorName,
1449
2271
  value: characteristic.value,
1450
2272
  props: (0, clone_1.clone)({}, characteristic.props),
1451
2273
  };
1452
- };
2274
+ }
1453
2275
  /**
1454
2276
  * Deserialize characteristic from json string.
1455
2277
  *
1456
2278
  * @param json - Json string representing a characteristic.
1457
2279
  * @private used to recreate characteristic from disk
1458
2280
  */
1459
- Characteristic.deserialize = function (json) {
1460
- var characteristic;
2281
+ static deserialize(json) {
2282
+ let characteristic;
1461
2283
  if (json.constructorName && json.constructorName.charAt(0).toUpperCase() === json.constructorName.charAt(0)
1462
2284
  && Characteristic[json.constructorName]) { // MUST start with uppercase character and must exist on Characteristic object
1463
- var constructor = Characteristic[json.constructorName];
2285
+ const constructor = Characteristic[json.constructorName];
1464
2286
  characteristic = new constructor();
1465
2287
  characteristic.displayName = json.displayName;
1466
2288
  characteristic.setProps(json.props);
@@ -1470,24 +2292,8 @@ var Characteristic = /** @class */ (function (_super) {
1470
2292
  }
1471
2293
  characteristic.value = json.value;
1472
2294
  return characteristic;
1473
- };
1474
- /**
1475
- * @deprecated Please use the Formats const enum above.
1476
- */
1477
- // @ts-expect-error: forceConsistentCasingInFileNames compiler option
1478
- Characteristic.Formats = Formats;
1479
- /**
1480
- * @deprecated Please use the Units const enum above.
1481
- */
1482
- // @ts-expect-error: forceConsistentCasingInFileNames compiler option
1483
- Characteristic.Units = Units;
1484
- /**
1485
- * @deprecated Please use the Perms const enum above.
1486
- */
1487
- // @ts-expect-error: forceConsistentCasingInFileNames compiler option
1488
- Characteristic.Perms = Perms;
1489
- return Characteristic;
1490
- }(events_1.EventEmitter));
2295
+ }
2296
+ }
1491
2297
  exports.Characteristic = Characteristic;
1492
2298
  // We have a cyclic dependency problem. Within this file we have the definitions of "./definitions" as
1493
2299
  // type imports only (in order to define the static properties). Setting those properties is done outside