hap-nodejs 1.1.1-beta.2 → 1.1.1-beta.4

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