hap-nodejs 1.1.1-beta.5 → 1.1.1-beta.7

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 (289) hide show
  1. package/@types/bonjour-hap.d.ts +53 -50
  2. package/@types/simple-plist.d.ts +4 -0
  3. package/README.md +19 -16
  4. package/dist/accessories/AirConditioner_accessory.js +32 -30
  5. package/dist/accessories/AirConditioner_accessory.js.map +1 -1
  6. package/dist/accessories/AppleTVRemote_accessory.js +86 -74
  7. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
  8. package/dist/accessories/Camera_accessory.js +138 -143
  9. package/dist/accessories/Camera_accessory.js.map +1 -1
  10. package/dist/accessories/Fan_accessory.js +24 -20
  11. package/dist/accessories/Fan_accessory.js.map +1 -1
  12. package/dist/accessories/GarageDoorOpener_accessory.js +37 -35
  13. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
  14. package/dist/accessories/Light-AdaptiveLighting_accessory.js +46 -44
  15. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
  16. package/dist/accessories/Light_accessory.js +36 -34
  17. package/dist/accessories/Light_accessory.js.map +1 -1
  18. package/dist/accessories/Lock_accessory.js +28 -27
  19. package/dist/accessories/Lock_accessory.js.map +1 -1
  20. package/dist/accessories/MotionSensor_accessory.js +18 -15
  21. package/dist/accessories/MotionSensor_accessory.js.map +1 -1
  22. package/dist/accessories/Outlet_accessory.js +24 -22
  23. package/dist/accessories/Outlet_accessory.js.map +1 -1
  24. package/dist/accessories/SmartSpeaker_accessory.js +22 -20
  25. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
  26. package/dist/accessories/Sprinkler_accessory.js +39 -36
  27. package/dist/accessories/Sprinkler_accessory.js.map +1 -1
  28. package/dist/accessories/TV_accessory.js +47 -45
  29. package/dist/accessories/TV_accessory.js.map +1 -1
  30. package/dist/accessories/TemperatureSensor_accessory.js +17 -14
  31. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
  32. package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
  33. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
  34. package/dist/accessories/Wi-FiRouter_accessory.js +14 -11
  35. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
  36. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
  37. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
  38. package/dist/accessories/Wi-FiSatellite_accessory.js +16 -13
  39. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
  40. package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
  41. package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
  42. package/dist/accessories/gstreamer-audioProducer.js +39 -38
  43. package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
  44. package/dist/accessories/types.d.ts +63 -63
  45. package/dist/accessories/types.d.ts.map +1 -1
  46. package/dist/accessories/types.js +87 -83
  47. package/dist/accessories/types.js.map +1 -1
  48. package/dist/index.d.ts +28 -26
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +34 -40
  51. package/dist/index.js.map +1 -1
  52. package/dist/internal-types.d.ts +1 -1
  53. package/dist/internal-types.d.ts.map +1 -1
  54. package/dist/internal-types.js +21 -19
  55. package/dist/internal-types.js.map +1 -1
  56. package/dist/lib/Accessory.d.ts +37 -38
  57. package/dist/lib/Accessory.d.ts.map +1 -1
  58. package/dist/lib/Accessory.js +299 -289
  59. package/dist/lib/Accessory.js.map +1 -1
  60. package/dist/lib/Advertiser.d.ts +7 -7
  61. package/dist/lib/Advertiser.d.ts.map +1 -1
  62. package/dist/lib/Advertiser.js +136 -128
  63. package/dist/lib/Advertiser.js.map +1 -1
  64. package/dist/lib/Bridge.d.ts +1 -1
  65. package/dist/lib/Bridge.d.ts.map +1 -1
  66. package/dist/lib/Bridge.js +6 -2
  67. package/dist/lib/Bridge.js.map +1 -1
  68. package/dist/lib/Characteristic.d.ts +41 -40
  69. package/dist/lib/Characteristic.d.ts.map +1 -1
  70. package/dist/lib/Characteristic.js +210 -206
  71. package/dist/lib/Characteristic.js.map +1 -1
  72. package/dist/lib/HAPServer.d.ts +30 -35
  73. package/dist/lib/HAPServer.d.ts.map +1 -1
  74. package/dist/lib/HAPServer.js +229 -225
  75. package/dist/lib/HAPServer.js.map +1 -1
  76. package/dist/lib/Service.d.ts +22 -22
  77. package/dist/lib/Service.d.ts.map +1 -1
  78. package/dist/lib/Service.js +71 -67
  79. package/dist/lib/Service.js.map +1 -1
  80. package/dist/lib/camera/RTPProxy.d.ts +1 -2
  81. package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
  82. package/dist/lib/camera/RTPProxy.js +44 -28
  83. package/dist/lib/camera/RTPProxy.js.map +1 -1
  84. package/dist/lib/camera/RTPStreamManagement.d.ts +33 -34
  85. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
  86. package/dist/lib/camera/RTPStreamManagement.js +149 -181
  87. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  88. package/dist/lib/camera/RecordingManagement.d.ts +17 -19
  89. package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
  90. package/dist/lib/camera/RecordingManagement.js +153 -162
  91. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  92. package/dist/lib/camera/index.d.ts +3 -3
  93. package/dist/lib/camera/index.d.ts.map +1 -1
  94. package/dist/lib/camera/index.js +6 -3
  95. package/dist/lib/camera/index.js.map +1 -1
  96. package/dist/lib/controller/AdaptiveLightingController.d.ts +33 -33
  97. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
  98. package/dist/lib/controller/AdaptiveLightingController.js +146 -154
  99. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  100. package/dist/lib/controller/CameraController.d.ts +20 -22
  101. package/dist/lib/controller/CameraController.d.ts.map +1 -1
  102. package/dist/lib/controller/CameraController.js +78 -74
  103. package/dist/lib/controller/CameraController.js.map +1 -1
  104. package/dist/lib/controller/Controller.d.ts +4 -4
  105. package/dist/lib/controller/Controller.d.ts.map +1 -1
  106. package/dist/lib/controller/Controller.js +8 -5
  107. package/dist/lib/controller/Controller.js.map +1 -1
  108. package/dist/lib/controller/DoorbellController.d.ts +4 -5
  109. package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
  110. package/dist/lib/controller/DoorbellController.js +13 -9
  111. package/dist/lib/controller/DoorbellController.js.map +1 -1
  112. package/dist/lib/controller/RemoteController.d.ts +37 -39
  113. package/dist/lib/controller/RemoteController.d.ts.map +1 -1
  114. package/dist/lib/controller/RemoteController.js +199 -210
  115. package/dist/lib/controller/RemoteController.js.map +1 -1
  116. package/dist/lib/controller/index.d.ts +5 -5
  117. package/dist/lib/controller/index.d.ts.map +1 -1
  118. package/dist/lib/controller/index.js +8 -5
  119. package/dist/lib/controller/index.js.map +1 -1
  120. package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
  121. package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
  122. package/dist/lib/datastream/DataStreamManagement.js +40 -40
  123. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  124. package/dist/lib/datastream/DataStreamParser.d.ts +0 -1
  125. package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
  126. package/dist/lib/datastream/DataStreamParser.js +77 -57
  127. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  128. package/dist/lib/datastream/DataStreamServer.d.ts +22 -27
  129. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
  130. package/dist/lib/datastream/DataStreamServer.js +164 -159
  131. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  132. package/dist/lib/datastream/index.d.ts +3 -3
  133. package/dist/lib/datastream/index.d.ts.map +1 -1
  134. package/dist/lib/datastream/index.js +6 -3
  135. package/dist/lib/datastream/index.js.map +1 -1
  136. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -1
  137. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
  138. package/dist/lib/definitions/CharacteristicDefinitions.js +1203 -957
  139. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  140. package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
  141. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
  142. package/dist/lib/definitions/ServiceDefinitions.js +695 -620
  143. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
  144. package/dist/lib/definitions/generate-definitions.d.ts +3 -3
  145. package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
  146. package/dist/lib/definitions/generate-definitions.js +259 -247
  147. package/dist/lib/definitions/generate-definitions.js.map +1 -1
  148. package/dist/lib/definitions/generator-configuration.d.ts +1 -1
  149. package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
  150. package/dist/lib/definitions/generator-configuration.js +181 -176
  151. package/dist/lib/definitions/generator-configuration.js.map +1 -1
  152. package/dist/lib/definitions/index.d.ts +2 -2
  153. package/dist/lib/definitions/index.d.ts.map +1 -1
  154. package/dist/lib/definitions/index.js +5 -2
  155. package/dist/lib/definitions/index.js.map +1 -1
  156. package/dist/lib/gen/HomeKit.d.ts +7 -0
  157. package/dist/lib/gen/HomeKit.d.ts.map +1 -0
  158. package/dist/lib/gen/HomeKit.js +8 -0
  159. package/dist/lib/gen/HomeKit.js.map +1 -0
  160. package/dist/lib/model/AccessoryInfo.d.ts +3 -4
  161. package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
  162. package/dist/lib/model/AccessoryInfo.js +55 -52
  163. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  164. package/dist/lib/model/ControllerStorage.d.ts +3 -3
  165. package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
  166. package/dist/lib/model/ControllerStorage.js +23 -18
  167. package/dist/lib/model/ControllerStorage.js.map +1 -1
  168. package/dist/lib/model/HAPStorage.d.ts +2 -2
  169. package/dist/lib/model/HAPStorage.d.ts.map +1 -1
  170. package/dist/lib/model/HAPStorage.js +11 -4
  171. package/dist/lib/model/HAPStorage.js.map +1 -1
  172. package/dist/lib/model/IdentifierCache.d.ts +1 -1
  173. package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
  174. package/dist/lib/model/IdentifierCache.js +27 -19
  175. package/dist/lib/model/IdentifierCache.js.map +1 -1
  176. package/dist/lib/tv/AccessControlManagement.d.ts +9 -9
  177. package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
  178. package/dist/lib/tv/AccessControlManagement.js +29 -27
  179. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  180. package/dist/lib/util/checkName.d.ts +2 -2
  181. package/dist/lib/util/checkName.d.ts.map +1 -1
  182. package/dist/lib/util/checkName.js +9 -6
  183. package/dist/lib/util/checkName.js.map +1 -1
  184. package/dist/lib/util/clone.d.ts.map +1 -1
  185. package/dist/lib/util/clone.js +5 -1
  186. package/dist/lib/util/clone.js.map +1 -1
  187. package/dist/lib/util/color-utils.d.ts +1 -1
  188. package/dist/lib/util/color-utils.d.ts.map +1 -1
  189. package/dist/lib/util/color-utils.js +9 -4
  190. package/dist/lib/util/color-utils.js.map +1 -1
  191. package/dist/lib/util/eventedhttp.d.ts +22 -23
  192. package/dist/lib/util/eventedhttp.d.ts.map +1 -1
  193. package/dist/lib/util/eventedhttp.js +116 -109
  194. package/dist/lib/util/eventedhttp.js.map +1 -1
  195. package/dist/lib/util/hapCrypto.d.ts +2 -3
  196. package/dist/lib/util/hapCrypto.d.ts.map +1 -1
  197. package/dist/lib/util/hapCrypto.js +40 -31
  198. package/dist/lib/util/hapCrypto.js.map +1 -1
  199. package/dist/lib/util/hapStatusError.d.ts +1 -1
  200. package/dist/lib/util/hapStatusError.d.ts.map +1 -1
  201. package/dist/lib/util/hapStatusError.js +8 -4
  202. package/dist/lib/util/hapStatusError.js.map +1 -1
  203. package/dist/lib/util/net-utils.d.ts +1 -1
  204. package/dist/lib/util/net-utils.js +23 -17
  205. package/dist/lib/util/net-utils.js.map +1 -1
  206. package/dist/lib/util/once.d.ts.map +1 -1
  207. package/dist/lib/util/once.js +6 -2
  208. package/dist/lib/util/once.js.map +1 -1
  209. package/dist/lib/util/promise-utils.d.ts +1 -1
  210. package/dist/lib/util/promise-utils.d.ts.map +1 -1
  211. package/dist/lib/util/promise-utils.js +10 -3
  212. package/dist/lib/util/promise-utils.js.map +1 -1
  213. package/dist/lib/util/request-util.d.ts +2 -3
  214. package/dist/lib/util/request-util.d.ts.map +1 -1
  215. package/dist/lib/util/request-util.js +19 -11
  216. package/dist/lib/util/request-util.js.map +1 -1
  217. package/dist/lib/util/time.d.ts +0 -1
  218. package/dist/lib/util/time.d.ts.map +1 -1
  219. package/dist/lib/util/time.js +11 -6
  220. package/dist/lib/util/time.js.map +1 -1
  221. package/dist/lib/util/tlv.d.ts +0 -1
  222. package/dist/lib/util/tlv.d.ts.map +1 -1
  223. package/dist/lib/util/tlv.js +43 -28
  224. package/dist/lib/util/tlv.js.map +1 -1
  225. package/dist/lib/util/uuid.d.ts +0 -1
  226. package/dist/lib/util/uuid.d.ts.map +1 -1
  227. package/dist/lib/util/uuid.js +38 -26
  228. package/dist/lib/util/uuid.js.map +1 -1
  229. package/dist/types.d.ts +24 -24
  230. package/dist/types.d.ts.map +1 -1
  231. package/dist/types.js +5 -3
  232. package/dist/types.js.map +1 -1
  233. package/package.json +47 -52
  234. package/dist/lib/dbus/align.d.ts +0 -2
  235. package/dist/lib/dbus/align.d.ts.map +0 -1
  236. package/dist/lib/dbus/align.js +0 -12
  237. package/dist/lib/dbus/align.js.map +0 -1
  238. package/dist/lib/dbus/bus.d.ts +0 -38
  239. package/dist/lib/dbus/bus.d.ts.map +0 -1
  240. package/dist/lib/dbus/bus.js +0 -222
  241. package/dist/lib/dbus/bus.js.map +0 -1
  242. package/dist/lib/dbus/constants.d.ts +0 -43
  243. package/dist/lib/dbus/constants.d.ts.map +0 -1
  244. package/dist/lib/dbus/constants.js +0 -53
  245. package/dist/lib/dbus/constants.js.map +0 -1
  246. package/dist/lib/dbus/dbus-buffer.d.ts +0 -30
  247. package/dist/lib/dbus/dbus-buffer.d.ts.map +0 -1
  248. package/dist/lib/dbus/dbus-buffer.js +0 -175
  249. package/dist/lib/dbus/dbus-buffer.js.map +0 -1
  250. package/dist/lib/dbus/handshake.d.ts +0 -2
  251. package/dist/lib/dbus/handshake.d.ts.map +0 -1
  252. package/dist/lib/dbus/handshake.js +0 -130
  253. package/dist/lib/dbus/handshake.js.map +0 -1
  254. package/dist/lib/dbus/index.d.ts +0 -3
  255. package/dist/lib/dbus/index.d.ts.map +0 -1
  256. package/dist/lib/dbus/index.js +0 -123
  257. package/dist/lib/dbus/index.js.map +0 -1
  258. package/dist/lib/dbus/introspect.d.ts +0 -30
  259. package/dist/lib/dbus/introspect.d.ts.map +0 -1
  260. package/dist/lib/dbus/introspect.js +0 -208
  261. package/dist/lib/dbus/introspect.js.map +0 -1
  262. package/dist/lib/dbus/marshall.d.ts +0 -2
  263. package/dist/lib/dbus/marshall.d.ts.map +0 -1
  264. package/dist/lib/dbus/marshall.js +0 -97
  265. package/dist/lib/dbus/marshall.js.map +0 -1
  266. package/dist/lib/dbus/marshallers.d.ts +0 -10
  267. package/dist/lib/dbus/marshallers.d.ts.map +0 -1
  268. package/dist/lib/dbus/marshallers.js +0 -329
  269. package/dist/lib/dbus/marshallers.js.map +0 -1
  270. package/dist/lib/dbus/message.d.ts +0 -4
  271. package/dist/lib/dbus/message.d.ts.map +0 -1
  272. package/dist/lib/dbus/message.js +0 -116
  273. package/dist/lib/dbus/message.js.map +0 -1
  274. package/dist/lib/dbus/put.d.ts +0 -21
  275. package/dist/lib/dbus/put.d.ts.map +0 -1
  276. package/dist/lib/dbus/put.js +0 -120
  277. package/dist/lib/dbus/put.js.map +0 -1
  278. package/dist/lib/dbus/readline.d.ts +0 -2
  279. package/dist/lib/dbus/readline.d.ts.map +0 -1
  280. package/dist/lib/dbus/readline.js +0 -27
  281. package/dist/lib/dbus/readline.js.map +0 -1
  282. package/dist/lib/dbus/signature.d.ts +0 -2
  283. package/dist/lib/dbus/signature.d.ts.map +0 -1
  284. package/dist/lib/dbus/signature.js +0 -59
  285. package/dist/lib/dbus/signature.js.map +0 -1
  286. package/dist/lib/dbus/stdifaces.d.ts +0 -3
  287. package/dist/lib/dbus/stdifaces.d.ts.map +0 -1
  288. package/dist/lib/dbus/stdifaces.js +0 -206
  289. package/dist/lib/dbus/stdifaces.js.map +0 -1
@@ -1,19 +1,22 @@
1
- import assert from 'node:assert';
2
- import { EventEmitter } from 'node:events';
3
- import createDebug from 'debug';
4
- import { isKnownHAPStatusError } from './HAPServer.js';
5
- import { checkName } from './util/checkName.js';
6
- import { clone } from './util/clone.js';
7
- import { HapStatusError } from './util/hapStatusError.js';
8
- import { once } from './util/once.js';
9
- import { formatOutgoingCharacteristicValue, isIntegerNumericFormat, isNumericFormat, isUnsignedNumericFormat, numericLowerBound, numericUpperBound, } from './util/request-util.js';
10
- import { BASE_UUID, toShortForm } from './util/uuid.js';
11
- const debug = createDebug('HAP-NodeJS:Characteristic');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Characteristic = exports.CharacteristicEventTypes = exports.ChangeReason = exports.Access = exports.Perms = exports.Units = exports.Formats = void 0;
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");
12
16
  /**
13
17
  * @group Characteristic
14
18
  */
15
- // eslint-disable-next-line no-restricted-syntax
16
- export var Formats;
19
+ var Formats;
17
20
  (function (Formats) {
18
21
  Formats["BOOL"] = "bool";
19
22
  /**
@@ -52,12 +55,11 @@ export var Formats;
52
55
  * Base64 encoded tlv8 string.
53
56
  */
54
57
  Formats["TLV8"] = "tlv8";
55
- })(Formats || (Formats = {}));
58
+ })(Formats || (exports.Formats = Formats = {}));
56
59
  /**
57
60
  * @group Characteristic
58
61
  */
59
- // eslint-disable-next-line no-restricted-syntax
60
- export var Units;
62
+ var Units;
61
63
  (function (Units) {
62
64
  /**
63
65
  * Celsius is the only temperature unit in the HomeKit Accessory Protocol.
@@ -69,23 +71,24 @@ export var Units;
69
71
  Units["ARC_DEGREE"] = "arcdegrees";
70
72
  Units["LUX"] = "lux";
71
73
  Units["SECONDS"] = "seconds";
72
- })(Units || (Units = {}));
74
+ })(Units || (exports.Units = Units = {}));
73
75
  /**
74
76
  * @group Characteristic
75
77
  */
76
- // eslint-disable-next-line no-restricted-syntax
77
- export var Perms;
78
+ var Perms;
78
79
  (function (Perms) {
80
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
79
81
  Perms["PAIRED_READ"] = "pr";
82
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
80
83
  Perms["PAIRED_WRITE"] = "pw";
81
84
  Perms["NOTIFY"] = "ev";
82
- // eslint-disable-next-line ts/no-duplicate-enum-values
85
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
83
86
  Perms["EVENTS"] = "ev";
84
87
  Perms["ADDITIONAL_AUTHORIZATION"] = "aa";
85
88
  Perms["TIMED_WRITE"] = "tw";
86
89
  Perms["HIDDEN"] = "hd";
87
90
  Perms["WRITE_RESPONSE"] = "wr";
88
- })(Perms || (Perms = {}));
91
+ })(Perms || (exports.Perms = Perms = {}));
89
92
  /**
90
93
  * Describes the abstract access to a {@link Characteristic}.
91
94
  * It abstracts the more granular access described by {@link Perms}.
@@ -94,18 +97,16 @@ export var Perms;
94
97
  *
95
98
  * @group Characteristic
96
99
  */
97
- // eslint-disable-next-line no-restricted-syntax
98
- export var Access;
100
+ var Access;
99
101
  (function (Access) {
100
102
  Access[Access["READ"] = 0] = "READ";
101
103
  Access[Access["WRITE"] = 1] = "WRITE";
102
104
  Access[Access["NOTIFY"] = 2] = "NOTIFY";
103
- })(Access || (Access = {}));
105
+ })(Access || (exports.Access = Access = {}));
104
106
  /**
105
107
  * @group Characteristic
106
108
  */
107
- // eslint-disable-next-line no-restricted-syntax
108
- export var ChangeReason;
109
+ var ChangeReason;
109
110
  (function (ChangeReason) {
110
111
  /**
111
112
  * Reason used when HomeKit writes a value or the API user calls {@link Characteristic.setValue}.
@@ -123,12 +124,11 @@ export var ChangeReason;
123
124
  * Used when call to {@link Characteristic.sendEventNotification} was made.
124
125
  */
125
126
  ChangeReason["EVENT"] = "event";
126
- })(ChangeReason || (ChangeReason = {}));
127
+ })(ChangeReason || (exports.ChangeReason = ChangeReason = {}));
127
128
  /**
128
129
  * @group Characteristic
129
130
  */
130
- // eslint-disable-next-line no-restricted-syntax
131
- export var CharacteristicEventTypes;
131
+ var CharacteristicEventTypes;
132
132
  (function (CharacteristicEventTypes) {
133
133
  /**
134
134
  * This event is thrown when a HomeKit controller wants to read the current value of the characteristic.
@@ -161,14 +161,14 @@ export var CharacteristicEventTypes;
161
161
  * @private
162
162
  */
163
163
  CharacteristicEventTypes["CHARACTERISTIC_WARNING"] = "characteristic-warning";
164
- })(CharacteristicEventTypes || (CharacteristicEventTypes = {}));
164
+ })(CharacteristicEventTypes || (exports.CharacteristicEventTypes = CharacteristicEventTypes = {}));
165
165
  /**
166
166
  * @group Characteristic
167
167
  */
168
168
  class ValidValuesIterable {
169
169
  props;
170
170
  constructor(props) {
171
- assert(isNumericFormat(props.format), `Cannot instantiate valid values iterable when format is not numeric. Found ${props.format}`);
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
172
  this.props = props;
173
173
  }
174
174
  *[Symbol.iterator]() {
@@ -192,11 +192,11 @@ class ValidValuesIterable {
192
192
  stepValue = this.props.minStep;
193
193
  }
194
194
  }
195
- else if (isUnsignedNumericFormat(this.props.format)) {
196
- max = numericUpperBound(this.props.format);
195
+ else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
196
+ max = (0, request_util_1.numericUpperBound)(this.props.format);
197
197
  }
198
198
  else {
199
- throw new Error(`Could not find valid iterator strategy for props: ${JSON.stringify(this.props)}`);
199
+ throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
200
200
  }
201
201
  for (let i = min; i <= max; i += stepValue) {
202
202
  yield i;
@@ -208,8 +208,8 @@ const numberPattern = /^-?\d+$/;
208
208
  function extractHAPStatusFromError(error) {
209
209
  let errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
210
210
  if (numberPattern.test(error.message)) {
211
- const value = Number.parseInt(error.message, 10);
212
- if (isKnownHAPStatusError(value)) {
211
+ const value = parseInt(error.message, 10);
212
+ if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
213
213
  errorValue = value;
214
214
  }
215
215
  }
@@ -249,8 +249,8 @@ function minWithUndefined(a, b) {
249
249
  *
250
250
  * @group Characteristic
251
251
  */
252
- // eslint-disable-next-line ts/no-unsafe-declaration-merging
253
- export class Characteristic extends EventEmitter {
252
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
253
+ class Characteristic extends events_1.EventEmitter {
254
254
  // Pattern below is for automatic detection of the section of defined characteristics. Used by the generator
255
255
  // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
256
256
  /**
@@ -1257,8 +1257,8 @@ export class Characteristic extends EventEmitter {
1257
1257
  * @param handler
1258
1258
  */
1259
1259
  onGet(handler) {
1260
- if (typeof handler !== 'function') {
1261
- this.characteristicWarning('.onGet handler must be a function');
1260
+ if (typeof handler !== "function") {
1261
+ this.characteristicWarning(".onGet handler must be a function");
1262
1262
  return this;
1263
1263
  }
1264
1264
  this.getHandler = handler;
@@ -1286,8 +1286,8 @@ export class Characteristic extends EventEmitter {
1286
1286
  * @param handler
1287
1287
  */
1288
1288
  onSet(handler) {
1289
- if (typeof handler !== 'function') {
1290
- this.characteristicWarning('.onSet handler must be a function');
1289
+ if (typeof handler !== "function") {
1290
+ this.characteristicWarning(".onSet handler must be a function");
1291
1291
  return this;
1292
1292
  }
1293
1293
  this.setHandler = handler;
@@ -1308,7 +1308,7 @@ export class Characteristic extends EventEmitter {
1308
1308
  * @param props - Partial properties object with the desired updates.
1309
1309
  */
1310
1310
  setProps(props) {
1311
- assert(props, 'props cannot be undefined when setting props');
1311
+ (0, assert_1.default)(props, "props cannot be undefined when setting props");
1312
1312
  // TODO calling setProps after publish doesn't lead to a increment in the current configuration number
1313
1313
  let formatDidChange = false;
1314
1314
  // for every value "null" can be used to reset props, except for required props
@@ -1317,7 +1317,7 @@ export class Characteristic extends EventEmitter {
1317
1317
  this.props.format = props.format;
1318
1318
  }
1319
1319
  if (props.perms) {
1320
- assert(props.perms.length > 0, 'characteristic prop perms cannot be empty array');
1320
+ (0, assert_1.default)(props.perms.length > 0, "characteristic prop perms cannot be empty array");
1321
1321
  this.props.perms = props.perms;
1322
1322
  }
1323
1323
  if (props.unit !== undefined) {
@@ -1331,22 +1331,24 @@ export class Characteristic extends EventEmitter {
1331
1331
  if (props.minValue === null) {
1332
1332
  props.minValue = undefined;
1333
1333
  }
1334
- else if (!isNumericFormat(this.props.format)) {
1335
- this.characteristicWarning(`Characteristic Property 'minValue' can only be set for characteristics with numeric format, but not for ${this.props.format}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1334
+ else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1335
+ this.characteristicWarning("Characteristic Property 'minValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1336
1336
  props.minValue = undefined;
1337
1337
  }
1338
- else if (typeof props.minValue !== 'number' || !Number.isFinite(props.minValue)) {
1338
+ else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
1339
1339
  this.characteristicWarning(`Characteristic Property 'minValue' must be a finite number, received "${props.minValue}" (${typeof props.minValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1340
1340
  props.minValue = undefined;
1341
1341
  }
1342
1342
  else {
1343
- if (props.minValue < numericLowerBound(this.props.format)) {
1344
- this.characteristicWarning(`Characteristic Property 'minValue' was set to ${props.minValue}, but for numeric format ${this.props.format} minimum possible is ${numericLowerBound(this.props.format)}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1345
- props.minValue = numericLowerBound(this.props.format);
1343
+ if (props.minValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
1344
+ this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
1345
+ this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1346
+ props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
1346
1347
  }
1347
- else if (props.minValue > numericUpperBound(this.props.format)) {
1348
- this.characteristicWarning(`Characteristic Property 'minValue' was set to ${props.minValue}, but for numeric format ${this.props.format} maximum possible is ${numericUpperBound(this.props.format)}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1349
- props.minValue = numericLowerBound(this.props.format);
1348
+ else if (props.minValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
1349
+ this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
1350
+ this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1351
+ props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
1350
1352
  }
1351
1353
  }
1352
1354
  this.props.minValue = props.minValue;
@@ -1356,22 +1358,24 @@ export class Characteristic extends EventEmitter {
1356
1358
  if (props.maxValue === null) {
1357
1359
  props.maxValue = undefined;
1358
1360
  }
1359
- else if (!isNumericFormat(this.props.format)) {
1360
- this.characteristicWarning(`Characteristic Property 'maxValue' can only be set for characteristics with numeric format, but not for ${this.props.format}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1361
+ else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1362
+ this.characteristicWarning("Characteristic Property 'maxValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1361
1363
  props.maxValue = undefined;
1362
1364
  }
1363
- else if (typeof props.maxValue !== 'number' || !Number.isFinite(props.maxValue)) {
1365
+ else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
1364
1366
  this.characteristicWarning(`Characteristic Property 'maxValue' must be a finite number, received "${props.maxValue}" (${typeof props.maxValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1365
1367
  props.maxValue = undefined;
1366
1368
  }
1367
1369
  else {
1368
- if (props.maxValue > numericUpperBound(this.props.format)) {
1369
- this.characteristicWarning(`Characteristic Property 'maxValue' was set to ${props.maxValue}, but for numeric format ${this.props.format} maximum possible is ${numericUpperBound(this.props.format)}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1370
- props.maxValue = numericUpperBound(this.props.format);
1370
+ if (props.maxValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
1371
+ this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
1372
+ this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1373
+ props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
1371
1374
  }
1372
- else if (props.maxValue < numericLowerBound(this.props.format)) {
1373
- this.characteristicWarning(`Characteristic Property 'maxValue' was set to ${props.maxValue}, but for numeric format ${this.props.format} minimum possible is ${numericLowerBound(this.props.format)}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1374
- props.maxValue = numericUpperBound(this.props.format);
1375
+ else if (props.maxValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
1376
+ this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
1377
+ this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1378
+ props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
1375
1379
  }
1376
1380
  }
1377
1381
  this.props.maxValue = props.maxValue;
@@ -1380,13 +1384,13 @@ export class Characteristic extends EventEmitter {
1380
1384
  if (props.minStep === null) {
1381
1385
  this.props.minStep = undefined;
1382
1386
  }
1383
- else if (!isNumericFormat(this.props.format)) {
1384
- this.characteristicWarning(`Characteristic Property \`minStep\` can only be set for characteristics with numeric format, but not for ${this.props.format}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1387
+ else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1388
+ this.characteristicWarning("Characteristic Property `minStep` can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1385
1389
  }
1386
1390
  else {
1387
- if (props.minStep < 1 && isIntegerNumericFormat(this.props.format)) {
1388
- this.characteristicWarning(`Characteristic Property \`minStep\` was set to a value lower than 1, `
1389
- + `this will have no effect on format \`${this.props.format}`);
1391
+ if (props.minStep < 1 && (0, request_util_1.isIntegerNumericFormat)(this.props.format)) {
1392
+ this.characteristicWarning("Characteristic Property `minStep` was set to a value lower than 1, " +
1393
+ "this will have no effect on format `" + this.props.format);
1390
1394
  }
1391
1395
  this.props.minStep = props.minStep;
1392
1396
  }
@@ -1396,11 +1400,11 @@ export class Characteristic extends EventEmitter {
1396
1400
  this.props.maxLen = undefined;
1397
1401
  }
1398
1402
  else if (this.props.format !== "string" /* Formats.STRING */) {
1399
- this.characteristicWarning(`Characteristic Property \`maxLen\` can only be set for characteristics with format \`STRING\`, but not for ${this.props.format}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1403
+ this.characteristicWarning("Characteristic Property `maxLen` can only be set for characteristics with format `STRING`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1400
1404
  }
1401
1405
  else {
1402
1406
  if (props.maxLen > 256) {
1403
- this.characteristicWarning('Characteristic Property string `maxLen` cannot be bigger than 256');
1407
+ this.characteristicWarning("Characteristic Property string `maxLen` cannot be bigger than 256");
1404
1408
  props.maxLen = 256;
1405
1409
  }
1406
1410
  this.props.maxLen = props.maxLen;
@@ -1411,7 +1415,7 @@ export class Characteristic extends EventEmitter {
1411
1415
  this.props.maxDataLen = undefined;
1412
1416
  }
1413
1417
  else if (this.props.format !== "data" /* Formats.DATA */) {
1414
- this.characteristicWarning(`Characteristic Property \`maxDataLen\` can only be set for characteristics with format \`DATA\`, but not for ${this.props.format}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1418
+ this.characteristicWarning("Characteristic Property `maxDataLen` can only be set for characteristics with format `DATA`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1415
1419
  }
1416
1420
  else {
1417
1421
  this.props.maxDataLen = props.maxDataLen;
@@ -1421,11 +1425,11 @@ export class Characteristic extends EventEmitter {
1421
1425
  if (props.validValues === null) {
1422
1426
  this.props.validValues = undefined;
1423
1427
  }
1424
- else if (!isNumericFormat(this.props.format)) {
1425
- this.characteristicWarning(`Characteristic Property \`validValues\` was supplied for non numeric format ${this.props.format}`);
1428
+ else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1429
+ this.characteristicWarning("Characteristic Property `validValues` was supplied for non numeric format " + this.props.format);
1426
1430
  }
1427
1431
  else {
1428
- assert(props.validValues.length, 'characteristic prop validValues cannot be empty array');
1432
+ (0, assert_1.default)(props.validValues.length, "characteristic prop validValues cannot be empty array");
1429
1433
  this.props.validValues = props.validValues;
1430
1434
  }
1431
1435
  }
@@ -1433,11 +1437,11 @@ export class Characteristic extends EventEmitter {
1433
1437
  if (props.validValueRanges === null) {
1434
1438
  this.props.validValueRanges = undefined;
1435
1439
  }
1436
- else if (!isNumericFormat(this.props.format)) {
1437
- this.characteristicWarning(`Characteristic Property \`validValueRanges\` was supplied for non numeric format ${this.props.format}`);
1440
+ else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1441
+ this.characteristicWarning("Characteristic Property `validValueRanges` was supplied for non numeric format " + this.props.format);
1438
1442
  }
1439
1443
  else {
1440
- assert(props.validValueRanges.length === 2, 'characteristic prop validValueRanges must have a length of 2');
1444
+ (0, assert_1.default)(props.validValueRanges.length === 2, "characteristic prop validValueRanges must have a length of 2");
1441
1445
  this.props.validValueRanges = props.validValueRanges;
1442
1446
  }
1443
1447
  }
@@ -1448,10 +1452,10 @@ export class Characteristic extends EventEmitter {
1448
1452
  if (this.props.minValue > this.props.maxValue) { // see https://github.com/homebridge/HAP-NodeJS/issues/690
1449
1453
  this.props.minValue = undefined;
1450
1454
  this.props.maxValue = undefined;
1451
- throw new Error(`Error setting CharacteristicsProps for '${this.displayName}': 'minValue' cannot be greater or equal the 'maxValue'!`);
1455
+ throw new Error("Error setting CharacteristicsProps for '" + this.displayName + "': 'minValue' cannot be greater or equal the 'maxValue'!");
1452
1456
  }
1453
1457
  }
1454
- if ((isNumericFormat(this.props.format) || this.props.format === "string" /* Formats.STRING */)
1458
+ if (((0, request_util_1.isNumericFormat)(this.props.format) || this.props.format === "string" /* Formats.STRING */)
1455
1459
  && this.value != null
1456
1460
  && !formatDidChange
1457
1461
  && this.statusCode === 0 /* HAPStatus.SUCCESS */
@@ -1476,11 +1480,11 @@ export class Characteristic extends EventEmitter {
1476
1480
  *
1477
1481
  * The range of valid values can be defined using three different ways via the {@link CharacteristicProps} object
1478
1482
  * (set via the {@link setProps} method):
1479
- * First method is to specifically list every valid value inside {@link CharacteristicProps.validValues}
1480
- * Second you can specify a range via {@link CharacteristicProps.minValue} and {@link CharacteristicProps.maxValue} (with optionally defining
1483
+ * * First method is to specifically list every valid value inside {@link CharacteristicProps.validValues}
1484
+ * * Second you can specify a range via {@link CharacteristicProps.minValue} and {@link CharacteristicProps.maxValue} (with optionally defining
1481
1485
  * {@link CharacteristicProps.minStep})
1482
- * And lastly you can specify a range via {@link CharacteristicProps.validValueRanges}
1483
- * Implicitly a valid value range is predefined for characteristics with Format {@link Formats.UINT8}, {@link Formats.UINT16},
1486
+ * * And lastly you can specify a range via {@link CharacteristicProps.validValueRanges}
1487
+ * * Implicitly a valid value range is predefined for characteristics with Format {@link Formats.UINT8}, {@link Formats.UINT16},
1484
1488
  * {@link Formats.UINT32} and {@link Formats.UINT64}: starting by zero to their respective maximum number
1485
1489
  *
1486
1490
  * The method will automatically detect which type of valid values definition is used and provide
@@ -1502,6 +1506,7 @@ export class Characteristic extends EventEmitter {
1502
1506
  validValuesIterator() {
1503
1507
  return new ValidValuesIterable(this.props);
1504
1508
  }
1509
+ // noinspection JSUnusedGlobalSymbols
1505
1510
  /**
1506
1511
  * This method can be used to set up additional authorization for a characteristic.
1507
1512
  * For one, it adds the {@link Perms.ADDITIONAL_AUTHORIZATION} permission to the characteristic
@@ -1526,13 +1531,13 @@ export class Characteristic extends EventEmitter {
1526
1531
  }
1527
1532
  setValue(value, callback, context) {
1528
1533
  if (value instanceof Error) {
1529
- this.statusCode = value instanceof HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1534
+ this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1530
1535
  if (callback) {
1531
1536
  callback();
1532
1537
  }
1533
1538
  return this;
1534
1539
  }
1535
- if (callback && !context && typeof callback !== 'function') {
1540
+ if (callback && !context && typeof callback !== "function") {
1536
1541
  context = callback;
1537
1542
  callback = undefined;
1538
1543
  }
@@ -1540,13 +1545,13 @@ export class Characteristic extends EventEmitter {
1540
1545
  value = this.validateUserInput(value);
1541
1546
  }
1542
1547
  catch (error) {
1543
- this.characteristicWarning(`${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1548
+ this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1544
1549
  if (callback) {
1545
1550
  callback(error);
1546
1551
  }
1547
1552
  return this;
1548
1553
  }
1549
- this.handleSetRequest(value, undefined, context).then((value) => {
1554
+ this.handleSetRequest(value, undefined, context).then(value => {
1550
1555
  if (callback) {
1551
1556
  if (value) { // possible write response
1552
1557
  callback(null, value);
@@ -1555,7 +1560,7 @@ export class Characteristic extends EventEmitter {
1555
1560
  callback(null);
1556
1561
  }
1557
1562
  }
1558
- }, (reason) => {
1563
+ }, reason => {
1559
1564
  if (callback) {
1560
1565
  callback(reason);
1561
1566
  }
@@ -1564,13 +1569,13 @@ export class Characteristic extends EventEmitter {
1564
1569
  }
1565
1570
  updateValue(value, callback, context) {
1566
1571
  if (value instanceof Error) {
1567
- this.statusCode = value instanceof HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1572
+ this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1568
1573
  if (callback) {
1569
1574
  callback();
1570
1575
  }
1571
1576
  return this;
1572
1577
  }
1573
- if (callback && !context && typeof callback !== 'function') {
1578
+ if (callback && !context && typeof callback !== "function") {
1574
1579
  context = callback;
1575
1580
  callback = undefined;
1576
1581
  }
@@ -1578,7 +1583,7 @@ export class Characteristic extends EventEmitter {
1578
1583
  value = this.validateUserInput(value);
1579
1584
  }
1580
1585
  catch (error) {
1581
- this.characteristicWarning(`${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1586
+ this.characteristicWarning(error?.message + "", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1582
1587
  if (callback) {
1583
1588
  callback();
1584
1589
  }
@@ -1590,7 +1595,7 @@ export class Characteristic extends EventEmitter {
1590
1595
  if (callback) {
1591
1596
  callback();
1592
1597
  }
1593
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context });
1598
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
1594
1599
  return this; // for chaining
1595
1600
  }
1596
1601
  /**
@@ -1607,15 +1612,15 @@ export class Characteristic extends EventEmitter {
1607
1612
  value = this.validateUserInput(value);
1608
1613
  const oldValue = this.value;
1609
1614
  this.value = value;
1610
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context });
1615
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
1611
1616
  return this; // for chaining
1612
1617
  }
1613
1618
  /**
1614
1619
  * Called when a HAP requests wants to know the current value of the characteristic.
1615
1620
  *
1616
1621
  * @param connection - The HAP connection from which the request originated from.
1617
- * @param context - Deprecated parameter, is there for backwards compatibility.
1618
- * @private
1622
+ * @param context - Deprecated parameter. There for backwards compatibility.
1623
+ * @private Used by the Accessory to load the characteristic value
1619
1624
  */
1620
1625
  async handleGetRequest(connection, context) {
1621
1626
  if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
@@ -1627,7 +1632,7 @@ export class Characteristic extends EventEmitter {
1627
1632
  }
1628
1633
  if (this.getHandler) {
1629
1634
  if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
1630
- this.characteristicWarning('Ignoring on(\'get\') handler as onGet handler was defined instead');
1635
+ this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
1631
1636
  }
1632
1637
  try {
1633
1638
  let value = await this.getHandler(context, connection);
@@ -1643,16 +1648,16 @@ export class Characteristic extends EventEmitter {
1643
1648
  const oldValue = this.value;
1644
1649
  this.value = value;
1645
1650
  if (oldValue !== value) { // emit a change event if necessary
1646
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context });
1651
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1647
1652
  }
1648
1653
  return value;
1649
1654
  }
1650
1655
  catch (error) {
1651
- if (typeof error === 'number') {
1652
- const hapStatusError = new HapStatusError(error);
1656
+ if (typeof error === "number") {
1657
+ const hapStatusError = new hapStatusError_1.HapStatusError(error);
1653
1658
  this.statusCode = hapStatusError.hapStatus;
1654
1659
  }
1655
- else if (error instanceof HapStatusError) {
1660
+ else if (error instanceof hapStatusError_1.HapStatusError) {
1656
1661
  this.statusCode = error.hapStatus;
1657
1662
  }
1658
1663
  else {
@@ -1676,17 +1681,17 @@ export class Characteristic extends EventEmitter {
1676
1681
  }
1677
1682
  return new Promise((resolve, reject) => {
1678
1683
  try {
1679
- this.emit("get" /* CharacteristicEventTypes.GET */, once((status, value) => {
1684
+ this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)((status, value) => {
1680
1685
  if (status) {
1681
- if (typeof status === 'number') {
1682
- const hapStatusError = new HapStatusError(status);
1686
+ if (typeof status === "number") {
1687
+ const hapStatusError = new hapStatusError_1.HapStatusError(status);
1683
1688
  this.statusCode = hapStatusError.hapStatus;
1684
1689
  }
1685
- else if (status instanceof HapStatusError) {
1690
+ else if (status instanceof hapStatusError_1.HapStatusError) {
1686
1691
  this.statusCode = status.hapStatus;
1687
1692
  }
1688
1693
  else {
1689
- debug('[%s] Received error from get handler %s', this.displayName, status.stack);
1694
+ debug("[%s] Received error from get handler %s", this.displayName, status.stack);
1690
1695
  this.statusCode = extractHAPStatusFromError(status);
1691
1696
  }
1692
1697
  reject(this.statusCode);
@@ -1698,7 +1703,7 @@ export class Characteristic extends EventEmitter {
1698
1703
  this.value = value;
1699
1704
  resolve(value);
1700
1705
  if (oldValue !== value) { // emit a change event if necessary
1701
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context });
1706
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1702
1707
  }
1703
1708
  }), context, connection);
1704
1709
  }
@@ -1714,10 +1719,10 @@ export class Characteristic extends EventEmitter {
1714
1719
  *
1715
1720
  * @param value - The updated value
1716
1721
  * @param connection - The connection from which the request originated from
1717
- * @param context - Deprecated parameter, is there for backwards compatibility.
1722
+ * @param context - Deprecated parameter. There for backwards compatibility.
1718
1723
  * @returns Promise resolve to void in normal operation. When characteristic supports write-response, HAP
1719
- * requests a write-response and the set handler returns a write-response value, the respective
1720
- * write response value is resolved.
1724
+ * requests a write-response and the set handler returns a write-response value, the respective
1725
+ * write response value is resolved.
1721
1726
  * @private
1722
1727
  */
1723
1728
  async handleSetRequest(value, connection, context) {
@@ -1736,7 +1741,7 @@ export class Characteristic extends EventEmitter {
1736
1741
  const oldValue = this.value;
1737
1742
  if (this.setHandler) {
1738
1743
  if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
1739
- this.characteristicWarning('Ignoring on(\'set\') handler as onSet handler was defined instead');
1744
+ this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
1740
1745
  }
1741
1746
  try {
1742
1747
  const writeResponse = await this.setHandler(value, context, connection);
@@ -1747,19 +1752,19 @@ export class Characteristic extends EventEmitter {
1747
1752
  }
1748
1753
  else {
1749
1754
  if (writeResponse != null) {
1750
- this.characteristicWarning('SET handler returned write response value, though the characteristic doesn\'t support write response', "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1755
+ this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1751
1756
  }
1752
1757
  this.value = value;
1753
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context });
1758
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1754
1759
  return;
1755
1760
  }
1756
1761
  }
1757
1762
  catch (error) {
1758
- if (typeof error === 'number') {
1759
- const hapStatusError = new HapStatusError(error);
1763
+ if (typeof error === "number") {
1764
+ const hapStatusError = new hapStatusError_1.HapStatusError(error);
1760
1765
  this.statusCode = hapStatusError.hapStatus;
1761
1766
  }
1762
- else if (error instanceof HapStatusError) {
1767
+ else if (error instanceof hapStatusError_1.HapStatusError) {
1763
1768
  this.statusCode = error.hapStatus;
1764
1769
  }
1765
1770
  else {
@@ -1771,23 +1776,23 @@ export class Characteristic extends EventEmitter {
1771
1776
  }
1772
1777
  if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
1773
1778
  this.value = value;
1774
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context });
1779
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1775
1780
  return Promise.resolve();
1776
1781
  }
1777
1782
  else {
1778
1783
  return new Promise((resolve, reject) => {
1779
1784
  try {
1780
- this.emit("set" /* CharacteristicEventTypes.SET */, value, once((status, writeResponse) => {
1785
+ this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)((status, writeResponse) => {
1781
1786
  if (status) {
1782
- if (typeof status === 'number') {
1783
- const hapStatusError = new HapStatusError(status);
1787
+ if (typeof status === "number") {
1788
+ const hapStatusError = new hapStatusError_1.HapStatusError(status);
1784
1789
  this.statusCode = hapStatusError.hapStatus;
1785
1790
  }
1786
- else if (status instanceof HapStatusError) {
1791
+ else if (status instanceof hapStatusError_1.HapStatusError) {
1787
1792
  this.statusCode = status.hapStatus;
1788
1793
  }
1789
1794
  else {
1790
- debug('[%s] Received error from set handler %s', this.displayName, status.stack);
1795
+ debug("[%s] Received error from set handler %s", this.displayName, status.stack);
1791
1796
  this.statusCode = extractHAPStatusFromError(status);
1792
1797
  }
1793
1798
  reject(this.statusCode);
@@ -1801,11 +1806,11 @@ export class Characteristic extends EventEmitter {
1801
1806
  }
1802
1807
  else {
1803
1808
  if (writeResponse != null) {
1804
- this.characteristicWarning('SET handler returned write response value, though the characteristic doesn\'t support write response', "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1809
+ this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1805
1810
  }
1806
1811
  this.value = value;
1807
1812
  resolve();
1808
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context });
1813
+ this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1809
1814
  }
1810
1815
  }), context, connection);
1811
1816
  }
@@ -1841,26 +1846,27 @@ export class Characteristic extends EventEmitter {
1841
1846
  }
1842
1847
  }
1843
1848
  getDefaultValue() {
1849
+ // noinspection JSDeprecatedSymbols
1844
1850
  switch (this.props.format) {
1845
1851
  case "bool" /* Formats.BOOL */:
1846
1852
  return false;
1847
1853
  case "string" /* Formats.STRING */:
1848
1854
  switch (this.UUID) {
1849
1855
  case Characteristic.Manufacturer.UUID:
1850
- return 'Default-Manufacturer';
1856
+ return "Default-Manufacturer";
1851
1857
  case Characteristic.Model.UUID:
1852
- return 'Default-Model';
1858
+ return "Default-Model";
1853
1859
  case Characteristic.SerialNumber.UUID:
1854
- return 'Default-SerialNumber';
1860
+ return "Default-SerialNumber";
1855
1861
  case Characteristic.FirmwareRevision.UUID:
1856
- return '0.0.0';
1862
+ return "0.0.0";
1857
1863
  default:
1858
- return '';
1864
+ return "";
1859
1865
  }
1860
1866
  case "data" /* Formats.DATA */:
1861
- return ''; // who knows!
1867
+ return ""; // who knows!
1862
1868
  case "tlv8" /* Formats.TLV8 */:
1863
- return ''; // who knows!
1869
+ return ""; // who knows!
1864
1870
  case "int" /* Formats.INT */:
1865
1871
  case "float" /* Formats.FLOAT */:
1866
1872
  case "uint8" /* Formats.UINT8 */:
@@ -1871,10 +1877,10 @@ export class Characteristic extends EventEmitter {
1871
1877
  case Characteristic.CurrentTemperature.UUID:
1872
1878
  return 0; // some existing integrations expect this to be 0 by default
1873
1879
  default: {
1874
- if (this.props.validValues?.length && typeof this.props.validValues[0] === 'number') {
1880
+ if (this.props.validValues?.length && typeof this.props.validValues[0] === "number") {
1875
1881
  return this.props.validValues[0];
1876
1882
  }
1877
- if (typeof this.props.minValue === 'number' && Number.isFinite(this.props.minValue)) {
1883
+ if (typeof this.props.minValue === "number" && Number.isFinite(this.props.minValue)) {
1878
1884
  return this.props.minValue;
1879
1885
  }
1880
1886
  return 0;
@@ -1896,10 +1902,10 @@ export class Characteristic extends EventEmitter {
1896
1902
  }
1897
1903
  switch (this.props.format) {
1898
1904
  case "bool" /* Formats.BOOL */: {
1899
- if (typeof value === 'boolean') {
1905
+ if (typeof value === "boolean") {
1900
1906
  return value;
1901
1907
  }
1902
- if (typeof value === 'number' && (value === 1 || value === 0)) {
1908
+ if (typeof value === "number" && (value === 1 || value === 0)) {
1903
1909
  return Boolean(value);
1904
1910
  }
1905
1911
  throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
@@ -1910,18 +1916,18 @@ export class Characteristic extends EventEmitter {
1910
1916
  case "uint16" /* Formats.UINT16 */:
1911
1917
  case "uint32" /* Formats.UINT32 */:
1912
1918
  case "uint64" /* Formats.UINT64 */: {
1913
- if (typeof value === 'boolean') {
1919
+ if (typeof value === "boolean") {
1914
1920
  value = value ? 1 : 0;
1915
1921
  }
1916
- if (typeof value !== 'number' || !Number.isFinite(value)) {
1917
- throw new TypeError(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1922
+ if (typeof value !== "number" || !Number.isFinite(value)) {
1923
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1918
1924
  }
1919
- const numericMin = maxWithUndefined(this.props.minValue, numericLowerBound(this.props.format));
1920
- const numericMax = minWithUndefined(this.props.maxValue, numericUpperBound(this.props.format));
1921
- if (typeof numericMin === 'number' && value < numericMin) {
1925
+ const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
1926
+ const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
1927
+ if (typeof numericMin === "number" && value < numericMin) {
1922
1928
  throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${numericMin}`);
1923
1929
  }
1924
- if (typeof numericMax === 'number' && value > numericMax) {
1930
+ if (typeof numericMax === "number" && value > numericMax) {
1925
1931
  throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${numericMax}`);
1926
1932
  }
1927
1933
  if (this.props.validValues && !this.props.validValues.includes(value)) {
@@ -1938,8 +1944,8 @@ export class Characteristic extends EventEmitter {
1938
1944
  return value;
1939
1945
  }
1940
1946
  case "string" /* Formats.STRING */: {
1941
- if (typeof value !== 'string') {
1942
- throw new TypeError(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1947
+ if (typeof value !== "string") {
1948
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1943
1949
  }
1944
1950
  const maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
1945
1951
  if (value.length > maxLength) {
@@ -1948,8 +1954,8 @@ export class Characteristic extends EventEmitter {
1948
1954
  return value;
1949
1955
  }
1950
1956
  case "data" /* Formats.DATA */: {
1951
- if (typeof value !== 'string') {
1952
- throw new TypeError(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1957
+ if (typeof value !== "string") {
1958
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1953
1959
  }
1954
1960
  // we don't validate base64 here
1955
1961
  const maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
@@ -1959,8 +1965,8 @@ export class Characteristic extends EventEmitter {
1959
1965
  return value;
1960
1966
  }
1961
1967
  case "tlv8" /* Formats.TLV8 */:
1962
- if (typeof value !== 'string') {
1963
- throw new TypeError(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1968
+ if (typeof value !== "string") {
1969
+ throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
1964
1970
  }
1965
1971
  return value;
1966
1972
  }
@@ -1977,7 +1983,7 @@ export class Characteristic extends EventEmitter {
1977
1983
  validateUserInput(value, warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */) {
1978
1984
  if (value === null) {
1979
1985
  if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
1980
- this.characteristicWarning('characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value', "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1986
+ this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1981
1987
  return this.value; // don't change the value
1982
1988
  }
1983
1989
  if (this.props.format === "data" /* Formats.DATA */ || this.props.format === "tlv8" /* Formats.TLV8 */) {
@@ -1993,11 +1999,11 @@ export class Characteristic extends EventEmitter {
1993
1999
  * As an intermediate step we kept the behavior but added a warning printed to the console.
1994
2000
  * In a future update we will do the breaking change of return null below!
1995
2001
  */
1996
- if (this.UUID.endsWith(BASE_UUID)) { // we have an apple defined characteristic (at least assuming nobody else uses the UUID namespace)
2002
+ if (this.UUID.endsWith(uuid_1.BASE_UUID)) { // we have an apple defined characteristic (at least assuming nobody else uses the UUID namespace)
1997
2003
  if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
1998
2004
  return value; // null is allowed as a value for ProgrammableSwitchEvent
1999
2005
  }
2000
- this.characteristicWarning('characteristic was supplied illegal value: null! Home App will reject null for Apple defined characteristics', warningType);
2006
+ this.characteristicWarning("characteristic was supplied illegal value: null! Home App will reject null for Apple defined characteristics", warningType);
2001
2007
  // if the value has been set previously, return it now, otherwise continue with validation to have a default value set.
2002
2008
  if (this.value !== null) {
2003
2009
  return this.value;
@@ -2010,16 +2016,16 @@ export class Characteristic extends EventEmitter {
2010
2016
  }
2011
2017
  switch (this.props.format) {
2012
2018
  case "bool" /* Formats.BOOL */: {
2013
- if (typeof value === 'boolean') {
2019
+ if (typeof value === "boolean") {
2014
2020
  return value;
2015
2021
  }
2016
- if (typeof value === 'number') {
2022
+ if (typeof value === "number") {
2017
2023
  return value === 1;
2018
2024
  }
2019
- if (typeof value === 'string') {
2020
- return value === '1' || value === 'true';
2025
+ if (typeof value === "string") {
2026
+ return value === "1" || value === "true";
2021
2027
  }
2022
- this.characteristicWarning(`characteristic value expected boolean and received ${typeof value}`, warningType);
2028
+ this.characteristicWarning("characteristic value expected boolean and received " + typeof value, warningType);
2023
2029
  return false;
2024
2030
  }
2025
2031
  case "int" /* Formats.INT */:
@@ -2028,19 +2034,19 @@ export class Characteristic extends EventEmitter {
2028
2034
  case "uint16" /* Formats.UINT16 */:
2029
2035
  case "uint32" /* Formats.UINT32 */:
2030
2036
  case "uint64" /* Formats.UINT64 */: {
2031
- if (typeof value === 'boolean') {
2037
+ if (typeof value === "boolean") {
2032
2038
  value = value ? 1 : 0;
2033
2039
  }
2034
- if (typeof value === 'string') {
2035
- value = this.props.format === "float" /* Formats.FLOAT */ ? Number.parseFloat(value) : Number.parseInt(value, 10);
2040
+ if (typeof value === "string") {
2041
+ value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
2036
2042
  }
2037
- if (typeof value !== 'number' || !Number.isFinite(value)) {
2043
+ if (typeof value !== "number" || !Number.isFinite(value)) {
2038
2044
  this.characteristicWarning(`characteristic value expected valid finite number and received "${value}" (${typeof value})`, warningType);
2039
- value = typeof this.value === 'number' ? this.value : this.props.minValue || 0;
2045
+ value = typeof this.value === "number" ? this.value : this.props.minValue || 0;
2040
2046
  }
2041
- const numericMin = maxWithUndefined(this.props.minValue, numericLowerBound(this.props.format));
2042
- const numericMax = minWithUndefined(this.props.maxValue, numericUpperBound(this.props.format));
2043
- let stepValue;
2047
+ const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
2048
+ const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
2049
+ let stepValue = undefined;
2044
2050
  if (this.props.format === "float" /* Formats.FLOAT */) {
2045
2051
  stepValue = this.props.minStep;
2046
2052
  }
@@ -2078,14 +2084,14 @@ export class Characteristic extends EventEmitter {
2078
2084
  return value;
2079
2085
  }
2080
2086
  case "string" /* Formats.STRING */: {
2081
- if (typeof value === 'number') {
2082
- this.characteristicWarning('characteristic was supplied illegal value: number instead of string, '
2083
- + 'supplying illegal values will throw errors in the future', warningType);
2087
+ if (typeof value === "number") {
2088
+ this.characteristicWarning("characteristic was supplied illegal value: number instead of string, " +
2089
+ "supplying illegal values will throw errors in the future", warningType);
2084
2090
  value = String(value);
2085
2091
  }
2086
- if (typeof value !== 'string') {
2087
- this.characteristicWarning(`characteristic value expected string and received ${typeof value}`, warningType);
2088
- value = typeof this.value === 'string' ? this.value : `${value}`;
2092
+ if (typeof value !== "string") {
2093
+ this.characteristicWarning("characteristic value expected string and received " + (typeof value), warningType);
2094
+ value = typeof this.value === "string" ? this.value : value + "";
2089
2095
  }
2090
2096
  // mirrors the case value = null at the beginning
2091
2097
  if (value.length <= 1 && (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID)) {
@@ -2099,41 +2105,40 @@ export class Characteristic extends EventEmitter {
2099
2105
  value = value.substring(0, maxLength);
2100
2106
  }
2101
2107
  if (value.length > 0 && this.UUID === Characteristic.ConfiguredName.UUID) {
2102
- checkName(this.displayName, 'ConfiguredName', value);
2108
+ (0, checkName_1.checkName)(this.displayName, "ConfiguredName", value);
2103
2109
  }
2104
2110
  return value;
2105
2111
  }
2106
2112
  case "data" /* Formats.DATA */:
2107
- if (typeof value !== 'string') {
2108
- throw new TypeError('characteristic with DATA format must have string value');
2113
+ if (typeof value !== "string") {
2114
+ throw new Error("characteristic with DATA format must have string value");
2109
2115
  }
2110
2116
  if (this.props.maxDataLen != null && value.length > this.props.maxDataLen) {
2111
- // can't cut it as we would basically set binary rubbish afterward
2112
- throw new Error('characteristic with DATA format exceeds specified maxDataLen');
2117
+ // can't cut it as we would basically set binary rubbish afterwards
2118
+ throw new Error("characteristic with DATA format exceeds specified maxDataLen");
2113
2119
  }
2114
2120
  return value;
2115
2121
  case "tlv8" /* Formats.TLV8 */:
2116
2122
  if (value === undefined) {
2117
- this.characteristicWarning('characteristic was supplied illegal value: undefined', warningType);
2123
+ this.characteristicWarning("characteristic was supplied illegal value: undefined", warningType);
2118
2124
  return this.value;
2119
2125
  }
2120
2126
  return value; // we trust that this is valid tlv8
2121
2127
  }
2122
2128
  // hopefully it shouldn't get to this point
2123
2129
  if (value === undefined) {
2124
- this.characteristicWarning('characteristic was supplied illegal value: undefined', "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
2130
+ this.characteristicWarning("characteristic was supplied illegal value: undefined", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
2125
2131
  return this.value;
2126
2132
  }
2127
2133
  return value;
2128
2134
  }
2129
2135
  /**
2130
- * @private
2136
+ * @private used to assign iid to characteristic
2131
2137
  */
2132
2138
  _assignID(identifierCache, accessoryName, serviceUUID, serviceSubtype) {
2133
2139
  // generate our IID based on our UUID
2134
2140
  this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
2135
2141
  }
2136
- // eslint-disable-next-line unicorn/error-message
2137
2142
  characteristicWarning(message, type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, stack = new Error().stack) {
2138
2143
  this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
2139
2144
  }
@@ -2159,7 +2164,7 @@ export class Characteristic extends EventEmitter {
2159
2164
  if (getListeners.length) {
2160
2165
  // the callback can only be called once, so we remove all old listeners
2161
2166
  this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
2162
- // @ts-expect-error - force type
2167
+ // @ts-expect-error: force type
2163
2168
  getListeners.forEach(listener => this.addListener("get" /* CharacteristicEventTypes.GET */, listener));
2164
2169
  }
2165
2170
  this.removeOnGet();
@@ -2170,7 +2175,7 @@ export class Characteristic extends EventEmitter {
2170
2175
  if (setListeners.length) {
2171
2176
  // the callback can only be called once, so we remove all old listeners
2172
2177
  this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
2173
- // @ts-expect-error - force type
2178
+ // @ts-expect-error: force type
2174
2179
  setListeners.forEach(listener => this.addListener("set" /* CharacteristicEventTypes.SET */, listener));
2175
2180
  }
2176
2181
  this.removeOnSet();
@@ -2180,7 +2185,7 @@ export class Characteristic extends EventEmitter {
2180
2185
  }
2181
2186
  /**
2182
2187
  * Returns a JSON representation of this characteristic suitable for delivering to HAP clients.
2183
- * @private
2188
+ * @private used to generate response to /accessories query
2184
2189
  */
2185
2190
  async toHAP(connection, contactGetHandlers = true) {
2186
2191
  const object = this.internalHAPRepresentation();
@@ -2195,63 +2200,63 @@ export class Characteristic extends EventEmitter {
2195
2200
  const value = contactGetHandlers
2196
2201
  ? await this.handleGetRequest(connection).catch(() => {
2197
2202
  const value = this.getDefaultValue();
2198
- debug('[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s', this.displayName, `${value}`);
2203
+ debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", this.displayName, `${value}`);
2199
2204
  return value; // use default value
2200
2205
  })
2201
2206
  : this.value;
2202
- object.value = formatOutgoingCharacteristicValue(value, this.props);
2207
+ object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
2203
2208
  }
2204
2209
  return object;
2205
2210
  }
2206
2211
  /**
2207
2212
  * Returns a JSON representation of this characteristic without the value.
2208
- * @private
2213
+ * @private used to generate the config hash
2209
2214
  */
2210
2215
  internalHAPRepresentation() {
2211
- assert(this.iid, `iid cannot be undefined for characteristic '${this.displayName}'`);
2216
+ (0, assert_1.default)(this.iid, "iid cannot be undefined for characteristic '" + this.displayName + "'");
2212
2217
  // TODO include the value for characteristics of the AccessoryInformation service
2213
2218
  return {
2214
- 'type': toShortForm(this.UUID),
2215
- 'iid': this.iid,
2216
- 'value': null,
2217
- 'perms': this.props.perms,
2218
- 'description': this.props.description || this.displayName,
2219
- 'format': this.props.format,
2220
- 'unit': this.props.unit,
2221
- 'minValue': this.props.minValue,
2222
- 'maxValue': this.props.maxValue,
2223
- 'minStep': this.props.minStep,
2224
- 'maxLen': this.props.maxLen,
2225
- 'maxDataLen': this.props.maxDataLen,
2226
- 'valid-values': this.props.validValues,
2227
- 'valid-values-range': this.props.validValueRanges,
2219
+ type: (0, uuid_1.toShortForm)(this.UUID),
2220
+ iid: this.iid,
2221
+ value: null,
2222
+ perms: this.props.perms,
2223
+ description: this.props.description || this.displayName,
2224
+ format: this.props.format,
2225
+ unit: this.props.unit,
2226
+ minValue: this.props.minValue,
2227
+ maxValue: this.props.maxValue,
2228
+ minStep: this.props.minStep,
2229
+ maxLen: this.props.maxLen,
2230
+ maxDataLen: this.props.maxDataLen,
2231
+ "valid-values": this.props.validValues,
2232
+ "valid-values-range": this.props.validValueRanges,
2228
2233
  };
2229
2234
  }
2230
2235
  /**
2231
2236
  * Serialize characteristic into json string.
2232
2237
  *
2233
2238
  * @param characteristic - Characteristic object.
2234
- * @private
2239
+ * @private used to store characteristic on disk
2235
2240
  */
2236
2241
  static serialize(characteristic) {
2237
2242
  let constructorName;
2238
- if (characteristic.constructor.name !== 'Characteristic') {
2243
+ if (characteristic.constructor.name !== "Characteristic") {
2239
2244
  constructorName = characteristic.constructor.name;
2240
2245
  }
2241
2246
  return {
2242
2247
  displayName: characteristic.displayName,
2243
2248
  UUID: characteristic.UUID,
2244
2249
  eventOnlyCharacteristic: characteristic.UUID === Characteristic.ProgrammableSwitchEvent.UUID, // support downgrades for now
2245
- constructorName,
2250
+ constructorName: constructorName,
2246
2251
  value: characteristic.value,
2247
- props: clone({}, characteristic.props),
2252
+ props: (0, clone_1.clone)({}, characteristic.props),
2248
2253
  };
2249
2254
  }
2250
2255
  /**
2251
2256
  * Deserialize characteristic from json string.
2252
2257
  *
2253
2258
  * @param json - Json string representing a characteristic.
2254
- * @private
2259
+ * @private used to recreate characteristic from disk
2255
2260
  */
2256
2261
  static deserialize(json) {
2257
2262
  let characteristic;
@@ -2269,10 +2274,9 @@ export class Characteristic extends EventEmitter {
2269
2274
  return characteristic;
2270
2275
  }
2271
2276
  }
2277
+ exports.Characteristic = Characteristic;
2272
2278
  // We have a cyclic dependency problem. Within this file we have the definitions of "./definitions" as
2273
2279
  // type imports only (in order to define the static properties). Setting those properties is done outside
2274
2280
  // this file, within the definition files. Therefore, we import it at the end of this file. Seems weird, but is important.
2275
- (async () => {
2276
- await import('./definitions/CharacteristicDefinitions.js');
2277
- })();
2281
+ require("./definitions/CharacteristicDefinitions");
2278
2282
  //# sourceMappingURL=Characteristic.js.map