@homebridge/hap-nodejs 2.3.1-beta.1 → 2.3.1-beta.3

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 (252) hide show
  1. package/README.md +13 -4
  2. package/dist/accessories/types.d.ts +0 -1
  3. package/dist/hap.d.ts +1 -1
  4. package/dist/hap.js +6 -4
  5. package/dist/hap.js.map +1 -1
  6. package/dist/index.d.ts +4 -1
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal-types.d.ts +6 -7
  10. package/dist/internal-types.js +1 -5
  11. package/dist/internal-types.js.map +1 -1
  12. package/dist/lib/Accessory.d.ts +53 -25
  13. package/dist/lib/Accessory.js +289 -171
  14. package/dist/lib/Accessory.js.map +1 -1
  15. package/dist/lib/Advertiser.d.ts +37 -18
  16. package/dist/lib/Advertiser.js +143 -62
  17. package/dist/lib/Advertiser.js.map +1 -1
  18. package/dist/lib/Bridge.d.ts +1 -2
  19. package/dist/lib/Bridge.js +1 -1
  20. package/dist/lib/Characteristic.d.ts +19 -20
  21. package/dist/lib/Characteristic.js +187 -153
  22. package/dist/lib/Characteristic.js.map +1 -1
  23. package/dist/lib/HAPServer.d.ts +19 -13
  24. package/dist/lib/HAPServer.js +266 -220
  25. package/dist/lib/HAPServer.js.map +1 -1
  26. package/dist/lib/Service.d.ts +11 -11
  27. package/dist/lib/Service.js +54 -37
  28. package/dist/lib/Service.js.map +1 -1
  29. package/dist/lib/camera/RTPProxy.d.ts +5 -5
  30. package/dist/lib/camera/RTPProxy.js +48 -23
  31. package/dist/lib/camera/RTPProxy.js.map +1 -1
  32. package/dist/lib/camera/RTPStreamManagement.d.ts +18 -13
  33. package/dist/lib/camera/RTPStreamManagement.js +247 -216
  34. package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
  35. package/dist/lib/camera/RecordingManagement.d.ts +13 -13
  36. package/dist/lib/camera/RecordingManagement.js +115 -110
  37. package/dist/lib/camera/RecordingManagement.js.map +1 -1
  38. package/dist/lib/camera/index.d.ts +0 -1
  39. package/dist/lib/controller/AdaptiveLightingController.d.ts +41 -36
  40. package/dist/lib/controller/AdaptiveLightingController.js +126 -113
  41. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
  42. package/dist/lib/controller/CameraController.d.ts +17 -17
  43. package/dist/lib/controller/CameraController.js +30 -26
  44. package/dist/lib/controller/CameraController.js.map +1 -1
  45. package/dist/lib/controller/Controller.d.ts +15 -12
  46. package/dist/lib/controller/Controller.js +0 -1
  47. package/dist/lib/controller/Controller.js.map +1 -1
  48. package/dist/lib/controller/DoorbellController.d.ts +6 -6
  49. package/dist/lib/controller/DoorbellController.js +10 -3
  50. package/dist/lib/controller/DoorbellController.js.map +1 -1
  51. package/dist/lib/controller/RemoteController.d.ts +46 -27
  52. package/dist/lib/controller/RemoteController.js +268 -178
  53. package/dist/lib/controller/RemoteController.js.map +1 -1
  54. package/dist/lib/controller/index.d.ts +0 -1
  55. package/dist/lib/datastream/DataStreamManagement.d.ts +6 -6
  56. package/dist/lib/datastream/DataStreamManagement.js +30 -26
  57. package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
  58. package/dist/lib/datastream/DataStreamParser.d.ts +25 -8
  59. package/dist/lib/datastream/DataStreamParser.js +124 -105
  60. package/dist/lib/datastream/DataStreamParser.js.map +1 -1
  61. package/dist/lib/datastream/DataStreamServer.d.ts +47 -23
  62. package/dist/lib/datastream/DataStreamServer.js +285 -143
  63. package/dist/lib/datastream/DataStreamServer.js.map +1 -1
  64. package/dist/lib/datastream/index.d.ts +0 -1
  65. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -1
  66. package/dist/lib/definitions/CharacteristicDefinitions.js +578 -578
  67. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
  68. package/dist/lib/definitions/ServiceDefinitions.d.ts +0 -1
  69. package/dist/lib/definitions/index.d.ts +0 -1
  70. package/dist/lib/gen/HomeKit.d.ts +0 -1
  71. package/dist/lib/model/AccessoryInfo.d.ts +5 -6
  72. package/dist/lib/model/AccessoryInfo.js +23 -19
  73. package/dist/lib/model/AccessoryInfo.js.map +1 -1
  74. package/dist/lib/model/ControllerStorage.d.ts +11 -5
  75. package/dist/lib/model/ControllerStorage.js +34 -8
  76. package/dist/lib/model/ControllerStorage.js.map +1 -1
  77. package/dist/lib/model/HAPFileStorage.d.ts +20 -2
  78. package/dist/lib/model/HAPFileStorage.js +59 -10
  79. package/dist/lib/model/HAPFileStorage.js.map +1 -1
  80. package/dist/lib/model/HAPStorage.d.ts +0 -1
  81. package/dist/lib/model/HAPStorage.js +6 -3
  82. package/dist/lib/model/HAPStorage.js.map +1 -1
  83. package/dist/lib/model/IdentifierCache.d.ts +2 -3
  84. package/dist/lib/model/IdentifierCache.js +26 -13
  85. package/dist/lib/model/IdentifierCache.js.map +1 -1
  86. package/dist/lib/tv/AccessControlManagement.d.ts +6 -7
  87. package/dist/lib/tv/AccessControlManagement.js +13 -19
  88. package/dist/lib/tv/AccessControlManagement.js.map +1 -1
  89. package/dist/lib/util/checkName.d.ts +1 -2
  90. package/dist/lib/util/checkName.js.map +1 -1
  91. package/dist/lib/util/clone.d.ts +0 -1
  92. package/dist/lib/util/clone.js.map +1 -1
  93. package/dist/lib/util/color-utils.d.ts +1 -2
  94. package/dist/lib/util/color-utils.js +1 -1
  95. package/dist/lib/util/errors.d.ts +4 -0
  96. package/dist/lib/util/errors.js +15 -0
  97. package/dist/lib/util/errors.js.map +1 -0
  98. package/dist/lib/util/eventedhttp.d.ts +63 -19
  99. package/dist/lib/util/eventedhttp.js +170 -48
  100. package/dist/lib/util/eventedhttp.js.map +1 -1
  101. package/dist/lib/util/hapCrypto.d.ts +1 -2
  102. package/dist/lib/util/hapCrypto.js +6 -7
  103. package/dist/lib/util/hapCrypto.js.map +1 -1
  104. package/dist/lib/util/hapStatusError.d.ts +0 -1
  105. package/dist/lib/util/hapStatusError.js +1 -1
  106. package/dist/lib/util/hapStatusError.js.map +1 -1
  107. package/dist/lib/util/net-utils.d.ts +1 -2
  108. package/dist/lib/util/net-utils.js +6 -7
  109. package/dist/lib/util/net-utils.js.map +1 -1
  110. package/dist/lib/util/once.d.ts +0 -1
  111. package/dist/lib/util/promise-utils.d.ts +1 -2
  112. package/dist/lib/util/promise-utils.js +2 -1
  113. package/dist/lib/util/promise-utils.js.map +1 -1
  114. package/dist/lib/util/request-util.d.ts +4 -4
  115. package/dist/lib/util/request-util.js +29 -28
  116. package/dist/lib/util/request-util.js.map +1 -1
  117. package/dist/lib/util/time.d.ts +1 -2
  118. package/dist/lib/util/time.js.map +1 -1
  119. package/dist/lib/util/tlv.d.ts +4 -4
  120. package/dist/lib/util/tlv.js +16 -5
  121. package/dist/lib/util/tlv.js.map +1 -1
  122. package/dist/lib/util/uuid.d.ts +5 -2
  123. package/dist/lib/util/uuid.js +6 -0
  124. package/dist/lib/util/uuid.js.map +1 -1
  125. package/dist/types.d.ts +20 -17
  126. package/dist/types.js +0 -1
  127. package/dist/types.js.map +1 -1
  128. package/package.json +8 -14
  129. package/dist/accessories/AirConditioner_accessory.d.ts +0 -2
  130. package/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
  131. package/dist/accessories/AirConditioner_accessory.js +0 -126
  132. package/dist/accessories/AirConditioner_accessory.js.map +0 -1
  133. package/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
  134. package/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
  135. package/dist/accessories/AppleTVRemote_accessory.js +0 -146
  136. package/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
  137. package/dist/accessories/Camera_accessory.d.ts +0 -2
  138. package/dist/accessories/Camera_accessory.d.ts.map +0 -1
  139. package/dist/accessories/Camera_accessory.js +0 -562
  140. package/dist/accessories/Camera_accessory.js.map +0 -1
  141. package/dist/accessories/Fan_accessory.d.ts +0 -2
  142. package/dist/accessories/Fan_accessory.d.ts.map +0 -1
  143. package/dist/accessories/Fan_accessory.js +0 -71
  144. package/dist/accessories/Fan_accessory.js.map +0 -1
  145. package/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
  146. package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
  147. package/dist/accessories/GarageDoorOpener_accessory.js +0 -76
  148. package/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
  149. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
  150. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
  151. package/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -103
  152. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
  153. package/dist/accessories/Light_accessory.d.ts +0 -2
  154. package/dist/accessories/Light_accessory.d.ts.map +0 -1
  155. package/dist/accessories/Light_accessory.js +0 -143
  156. package/dist/accessories/Light_accessory.js.map +0 -1
  157. package/dist/accessories/Lock_accessory.d.ts +0 -2
  158. package/dist/accessories/Lock_accessory.d.ts.map +0 -1
  159. package/dist/accessories/Lock_accessory.js +0 -74
  160. package/dist/accessories/Lock_accessory.js.map +0 -1
  161. package/dist/accessories/MotionSensor_accessory.d.ts +0 -2
  162. package/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
  163. package/dist/accessories/MotionSensor_accessory.js +0 -43
  164. package/dist/accessories/MotionSensor_accessory.js.map +0 -1
  165. package/dist/accessories/Outlet_accessory.d.ts +0 -2
  166. package/dist/accessories/Outlet_accessory.d.ts.map +0 -1
  167. package/dist/accessories/Outlet_accessory.js +0 -77
  168. package/dist/accessories/Outlet_accessory.js.map +0 -1
  169. package/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
  170. package/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
  171. package/dist/accessories/SmartSpeaker_accessory.js +0 -42
  172. package/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
  173. package/dist/accessories/Sprinkler_accessory.d.ts +0 -2
  174. package/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
  175. package/dist/accessories/Sprinkler_accessory.js +0 -126
  176. package/dist/accessories/Sprinkler_accessory.js.map +0 -1
  177. package/dist/accessories/TV_accessory.d.ts +0 -2
  178. package/dist/accessories/TV_accessory.d.ts.map +0 -1
  179. package/dist/accessories/TV_accessory.js +0 -99
  180. package/dist/accessories/TV_accessory.js.map +0 -1
  181. package/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
  182. package/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
  183. package/dist/accessories/TemperatureSensor_accessory.js +0 -42
  184. package/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
  185. package/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
  186. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
  187. package/dist/accessories/Wi-FiRouter_accessory.js +0 -14
  188. package/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
  189. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
  190. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
  191. package/dist/accessories/Wi-FiSatellite_accessory.js +0 -16
  192. package/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
  193. package/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
  194. package/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
  195. package/dist/accessories/gstreamer-audioProducer.js +0 -145
  196. package/dist/accessories/gstreamer-audioProducer.js.map +0 -1
  197. package/dist/accessories/types.d.ts.map +0 -1
  198. package/dist/hap.d.ts.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/internal-types.d.ts.map +0 -1
  201. package/dist/lib/Accessory.d.ts.map +0 -1
  202. package/dist/lib/Advertiser.d.ts.map +0 -1
  203. package/dist/lib/Bridge.d.ts.map +0 -1
  204. package/dist/lib/Characteristic.d.ts.map +0 -1
  205. package/dist/lib/HAPServer.d.ts.map +0 -1
  206. package/dist/lib/Service.d.ts.map +0 -1
  207. package/dist/lib/camera/RTPProxy.d.ts.map +0 -1
  208. package/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
  209. package/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
  210. package/dist/lib/camera/index.d.ts.map +0 -1
  211. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
  212. package/dist/lib/controller/CameraController.d.ts.map +0 -1
  213. package/dist/lib/controller/Controller.d.ts.map +0 -1
  214. package/dist/lib/controller/DoorbellController.d.ts.map +0 -1
  215. package/dist/lib/controller/RemoteController.d.ts.map +0 -1
  216. package/dist/lib/controller/index.d.ts.map +0 -1
  217. package/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
  218. package/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
  219. package/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
  220. package/dist/lib/datastream/index.d.ts.map +0 -1
  221. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
  222. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
  223. package/dist/lib/definitions/generate-definitions.d.ts +0 -34
  224. package/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
  225. package/dist/lib/definitions/generate-definitions.js +0 -624
  226. package/dist/lib/definitions/generate-definitions.js.map +0 -1
  227. package/dist/lib/definitions/generator-configuration.d.ts +0 -22
  228. package/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
  229. package/dist/lib/definitions/generator-configuration.js +0 -674
  230. package/dist/lib/definitions/generator-configuration.js.map +0 -1
  231. package/dist/lib/definitions/index.d.ts.map +0 -1
  232. package/dist/lib/gen/HomeKit.d.ts.map +0 -1
  233. package/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
  234. package/dist/lib/model/ControllerStorage.d.ts.map +0 -1
  235. package/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
  236. package/dist/lib/model/HAPStorage.d.ts.map +0 -1
  237. package/dist/lib/model/IdentifierCache.d.ts.map +0 -1
  238. package/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
  239. package/dist/lib/util/checkName.d.ts.map +0 -1
  240. package/dist/lib/util/clone.d.ts.map +0 -1
  241. package/dist/lib/util/color-utils.d.ts.map +0 -1
  242. package/dist/lib/util/eventedhttp.d.ts.map +0 -1
  243. package/dist/lib/util/hapCrypto.d.ts.map +0 -1
  244. package/dist/lib/util/hapStatusError.d.ts.map +0 -1
  245. package/dist/lib/util/net-utils.d.ts.map +0 -1
  246. package/dist/lib/util/once.d.ts.map +0 -1
  247. package/dist/lib/util/promise-utils.d.ts.map +0 -1
  248. package/dist/lib/util/request-util.d.ts.map +0 -1
  249. package/dist/lib/util/time.d.ts.map +0 -1
  250. package/dist/lib/util/tlv.d.ts.map +0 -1
  251. package/dist/lib/util/uuid.d.ts.map +0 -1
  252. package/dist/types.d.ts.map +0 -1
@@ -3,50 +3,49 @@ import assert from 'node:assert';
3
3
  import { Buffer } from 'node:buffer';
4
4
  import { EventEmitter } from 'node:events';
5
5
  import createDebug from 'debug';
6
- import { Characteristic, } from '../Characteristic.js';
6
+ import { ChangeReason, Characteristic, CharacteristicEventTypes, } from '../Characteristic.js';
7
7
  import { HAPStatus } from '../HAPServer.js';
8
8
  import { ColorUtils } from '../util/color-utils.js';
9
+ import { errorMessage, errorStack } from '../util/errors.js';
9
10
  import { HapStatusError } from '../util/hapStatusError.js';
10
11
  import { epochMillisFromMillisSince2001_01_01Buffer } from '../util/time.js';
11
12
  import * as tlv from '../util/tlv.js';
12
13
  import * as uuid from '../util/uuid.js';
14
+ import { DefaultControllerType, } from './Controller.js';
13
15
  const debug = createDebug('HAP-NodeJS:Controller:TransitionControl');
14
16
  // lower bound for the update timer, an update interval of zero sent by the controller would otherwise result in a busy loop
15
17
  const MINIMUM_UPDATE_INTERVAL = 1000;
16
- // eslint-disable-next-line no-restricted-syntax
18
+ /**
19
+ * The longest delay a node.js timer holds (about 24.8 days). Node.js fires a timer with a longer delay after 1 ms.
20
+ */
21
+ const MAXIMUM_TIMER_DELAY = 2 ** 31 - 1;
17
22
  var SupportedCharacteristicValueTransitionConfigurationsTypes;
18
23
  (function (SupportedCharacteristicValueTransitionConfigurationsTypes) {
19
24
  SupportedCharacteristicValueTransitionConfigurationsTypes[SupportedCharacteristicValueTransitionConfigurationsTypes["SUPPORTED_TRANSITION_CONFIGURATION"] = 1] = "SUPPORTED_TRANSITION_CONFIGURATION";
20
25
  })(SupportedCharacteristicValueTransitionConfigurationsTypes || (SupportedCharacteristicValueTransitionConfigurationsTypes = {}));
21
- // eslint-disable-next-line no-restricted-syntax
22
26
  var SupportedValueTransitionConfigurationTypes;
23
27
  (function (SupportedValueTransitionConfigurationTypes) {
24
28
  SupportedValueTransitionConfigurationTypes[SupportedValueTransitionConfigurationTypes["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
25
29
  SupportedValueTransitionConfigurationTypes[SupportedValueTransitionConfigurationTypes["TRANSITION_TYPE"] = 2] = "TRANSITION_TYPE";
26
30
  })(SupportedValueTransitionConfigurationTypes || (SupportedValueTransitionConfigurationTypes = {}));
27
- // eslint-disable-next-line no-restricted-syntax
28
31
  var TransitionType;
29
32
  (function (TransitionType) {
30
33
  TransitionType[TransitionType["BRIGHTNESS"] = 1] = "BRIGHTNESS";
31
34
  TransitionType[TransitionType["COLOR_TEMPERATURE"] = 2] = "COLOR_TEMPERATURE";
32
35
  })(TransitionType || (TransitionType = {}));
33
- // eslint-disable-next-line no-restricted-syntax
34
36
  var TransitionControlTypes;
35
37
  (function (TransitionControlTypes) {
36
38
  TransitionControlTypes[TransitionControlTypes["READ_CURRENT_VALUE_TRANSITION_CONFIGURATION"] = 1] = "READ_CURRENT_VALUE_TRANSITION_CONFIGURATION";
37
39
  TransitionControlTypes[TransitionControlTypes["UPDATE_VALUE_TRANSITION_CONFIGURATION"] = 2] = "UPDATE_VALUE_TRANSITION_CONFIGURATION";
38
40
  })(TransitionControlTypes || (TransitionControlTypes = {}));
39
- // eslint-disable-next-line no-restricted-syntax
40
41
  var ReadValueTransitionConfiguration;
41
42
  (function (ReadValueTransitionConfiguration) {
42
43
  ReadValueTransitionConfiguration[ReadValueTransitionConfiguration["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
43
44
  })(ReadValueTransitionConfiguration || (ReadValueTransitionConfiguration = {}));
44
- // eslint-disable-next-line no-restricted-syntax
45
45
  var UpdateValueTransitionConfigurationsTypes;
46
46
  (function (UpdateValueTransitionConfigurationsTypes) {
47
47
  UpdateValueTransitionConfigurationsTypes[UpdateValueTransitionConfigurationsTypes["VALUE_TRANSITION_CONFIGURATION"] = 1] = "VALUE_TRANSITION_CONFIGURATION";
48
48
  })(UpdateValueTransitionConfigurationsTypes || (UpdateValueTransitionConfigurationsTypes = {}));
49
- // eslint-disable-next-line no-restricted-syntax
50
49
  var ValueTransitionConfigurationTypes;
51
50
  (function (ValueTransitionConfigurationTypes) {
52
51
  // noinspection JSUnusedGlobalSymbols
@@ -59,21 +58,18 @@ var ValueTransitionConfigurationTypes;
59
58
  ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["UNKNOWN_7"] = 7] = "UNKNOWN_7";
60
59
  ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["NOTIFY_INTERVAL_THRESHOLD"] = 8] = "NOTIFY_INTERVAL_THRESHOLD";
61
60
  })(ValueTransitionConfigurationTypes || (ValueTransitionConfigurationTypes = {}));
62
- // eslint-disable-next-line no-restricted-syntax
63
61
  var ValueTransitionParametersTypes;
64
62
  (function (ValueTransitionParametersTypes) {
65
63
  ValueTransitionParametersTypes[ValueTransitionParametersTypes["TRANSITION_ID"] = 1] = "TRANSITION_ID";
66
64
  ValueTransitionParametersTypes[ValueTransitionParametersTypes["START_TIME"] = 2] = "START_TIME";
67
65
  ValueTransitionParametersTypes[ValueTransitionParametersTypes["UNKNOWN_3"] = 3] = "UNKNOWN_3";
68
66
  })(ValueTransitionParametersTypes || (ValueTransitionParametersTypes = {}));
69
- // eslint-disable-next-line no-restricted-syntax
70
67
  var TransitionCurveConfigurationTypes;
71
68
  (function (TransitionCurveConfigurationTypes) {
72
69
  TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["TRANSITION_ENTRY"] = 1] = "TRANSITION_ENTRY";
73
70
  TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["ADJUSTMENT_CHARACTERISTIC_IID"] = 2] = "ADJUSTMENT_CHARACTERISTIC_IID";
74
71
  TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["ADJUSTMENT_MULTIPLIER_RANGE"] = 3] = "ADJUSTMENT_MULTIPLIER_RANGE";
75
72
  })(TransitionCurveConfigurationTypes || (TransitionCurveConfigurationTypes = {}));
76
- // eslint-disable-next-line no-restricted-syntax
77
73
  var TransitionEntryTypes;
78
74
  (function (TransitionEntryTypes) {
79
75
  TransitionEntryTypes[TransitionEntryTypes["ADJUSTMENT_FACTOR"] = 1] = "ADJUSTMENT_FACTOR";
@@ -81,18 +77,15 @@ var TransitionEntryTypes;
81
77
  TransitionEntryTypes[TransitionEntryTypes["TRANSITION_OFFSET"] = 3] = "TRANSITION_OFFSET";
82
78
  TransitionEntryTypes[TransitionEntryTypes["DURATION"] = 4] = "DURATION";
83
79
  })(TransitionEntryTypes || (TransitionEntryTypes = {}));
84
- // eslint-disable-next-line no-restricted-syntax
85
80
  var TransitionAdjustmentMultiplierRange;
86
81
  (function (TransitionAdjustmentMultiplierRange) {
87
82
  TransitionAdjustmentMultiplierRange[TransitionAdjustmentMultiplierRange["MINIMUM_ADJUSTMENT_MULTIPLIER"] = 1] = "MINIMUM_ADJUSTMENT_MULTIPLIER";
88
83
  TransitionAdjustmentMultiplierRange[TransitionAdjustmentMultiplierRange["MAXIMUM_ADJUSTMENT_MULTIPLIER"] = 2] = "MAXIMUM_ADJUSTMENT_MULTIPLIER";
89
84
  })(TransitionAdjustmentMultiplierRange || (TransitionAdjustmentMultiplierRange = {}));
90
- // eslint-disable-next-line no-restricted-syntax
91
85
  var ValueTransitionConfigurationResponseTypes;
92
86
  (function (ValueTransitionConfigurationResponseTypes) {
93
87
  ValueTransitionConfigurationResponseTypes[ValueTransitionConfigurationResponseTypes["VALUE_CONFIGURATION_STATUS"] = 1] = "VALUE_CONFIGURATION_STATUS";
94
88
  })(ValueTransitionConfigurationResponseTypes || (ValueTransitionConfigurationResponseTypes = {}));
95
- // eslint-disable-next-line no-restricted-syntax
96
89
  var ValueTransitionConfigurationStatusTypes;
97
90
  (function (ValueTransitionConfigurationStatusTypes) {
98
91
  ValueTransitionConfigurationStatusTypes[ValueTransitionConfigurationStatusTypes["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
@@ -100,13 +93,13 @@ var ValueTransitionConfigurationStatusTypes;
100
93
  ValueTransitionConfigurationStatusTypes[ValueTransitionConfigurationStatusTypes["TIME_SINCE_START"] = 3] = "TIME_SINCE_START";
101
94
  })(ValueTransitionConfigurationStatusTypes || (ValueTransitionConfigurationStatusTypes = {}));
102
95
  function isAdaptiveLightingContext(context) {
103
- return context && 'controller' in context;
96
+ // a plugin may pass anything as context, and `in` throws for a string or a number
97
+ return typeof context === 'object' && context !== null && 'controller' in context;
104
98
  }
105
99
  /**
106
- * Defines in which mode the {@link AdaptiveLightingController} will operate in.
100
+ * Defines in which mode the {@link AdaptiveLightingController} will operate.
107
101
  * @group Adaptive Lighting
108
102
  */
109
- // eslint-disable-next-line no-restricted-syntax
110
103
  export var AdaptiveLightingControllerMode;
111
104
  (function (AdaptiveLightingControllerMode) {
112
105
  /**
@@ -122,7 +115,6 @@ export var AdaptiveLightingControllerMode;
122
115
  /**
123
116
  * @group Adaptive Lighting
124
117
  */
125
- // eslint-disable-next-line no-restricted-syntax
126
118
  export var AdaptiveLightingControllerEvents;
127
119
  (function (AdaptiveLightingControllerEvents) {
128
120
  /**
@@ -147,11 +139,11 @@ export var AdaptiveLightingControllerEvents;
147
139
  *
148
140
  * How Adaptive Lighting works:
149
141
  * When enabling AdaptiveLighting the iDevice will send a transition schedule for the next 24 hours.
150
- * This schedule will be renewed all 24 hours by a HomeHub in your home
142
+ * This schedule will be renewed every 24 hours by a HomeHub in your home
151
143
  * (updating the schedule according to your current day/night situation).
152
144
  * Once enabled the lightbulb will execute the provided transitions. The color temperature value set is always
153
145
  * dependent on the current brightness value. Meaning brighter light will be colder and darker light will be warmer.
154
- * HomeKit considers Adaptive Lighting to be disabled as soon a write happens to either the
146
+ * HomeKit considers Adaptive Lighting to be disabled as soon as a write happens to either the
155
147
  * Hue/Saturation or the ColorTemperature characteristics.
156
148
  * The AdaptiveLighting state must persist across reboots.
157
149
  *
@@ -163,14 +155,14 @@ export var AdaptiveLightingControllerEvents;
163
155
  *
164
156
  *
165
157
  *
166
- * Below is an overview what you need to or consider when enabling AdaptiveLighting (categorized by mode).
158
+ * Below is an overview of what you need to do or consider when enabling AdaptiveLighting (categorized by mode).
167
159
  * The {@link AdaptiveLightingControllerMode} can be defined with the second constructor argument.
168
160
  *
169
161
  * <b>AUTOMATIC (Default mode):</b>
170
162
  *
171
- * This is the easiest mode to setup and needs less to no work form your side for AdaptiveLighting to work.
163
+ * This is the easiest mode to setup and needs little to no work from your side for AdaptiveLighting to work.
172
164
  * The AdaptiveLightingController will go through setup procedure with HomeKit and automatically update
173
- * the color temperature characteristic base on the current transition schedule.
165
+ * the color temperature characteristic based on the current transition schedule.
174
166
  * It is also adjusting the color temperature when a write to the brightness characteristic happens.
175
167
  * Additionally, it will also handle turning off AdaptiveLighting, when it detects a write happening to the
176
168
  * ColorTemperature, Hue or Saturation characteristic (though it can only detect writes coming from HomeKit and
@@ -178,7 +170,7 @@ export var AdaptiveLightingControllerEvents;
178
170
  *
179
171
  * So what do you need to consider in automatic mode:
180
172
  * - Brightness and ColorTemperature characteristics MUST be set up. Hue and Saturation may be added for color support.
181
- * - Color temperature will be updated all 60 seconds by calling the SET handler of the ColorTemperature characteristic.
173
+ * - Color temperature will be updated every 60 seconds by calling the SET handler of the ColorTemperature characteristic.
182
174
  * So every transition behaves like a regular write to the ColorTemperature characteristic.
183
175
  * - Every transition step is dependent on the current brightness value. Try to keep the internal cache updated
184
176
  * as the controller won't call the GET handler every 60 seconds.
@@ -193,9 +185,9 @@ export var AdaptiveLightingControllerEvents;
193
185
  * - When using Hue/Saturation:
194
186
  * When using Hue/Saturation in combination with the ColorTemperature characteristic you need to update the
195
187
  * respective other in a particular way depending on if being in "color mode" or "color temperature mode".
196
- * When a write happens to Hue/Saturation characteristic in is advised to set the internal value of the
188
+ * When a write happens to Hue/Saturation characteristic it is advised to set the internal value of the
197
189
  * ColorTemperature to the minimal (NOT RAISING an event).
198
- * When a write happens to the ColorTemperature characteristic just MUST convert to a proper representation
190
+ * When a write happens to the ColorTemperature characteristic you MUST convert to a proper representation
199
191
  * in hue and saturation values, with RAISING an event.
200
192
  * As noted above you MUST NOT call the {@link Characteristic.setValue} method for this, as this will be considered
201
193
  * a write to the characteristic and will turn off AdaptiveLighting. Instead, you should use
@@ -206,17 +198,17 @@ export var AdaptiveLightingControllerEvents;
206
198
  *
207
199
  * <b>MANUAL mode:</b>
208
200
  *
209
- * Manual mode is recommended for any accessories which support transitions natively on the devices end.
201
+ * Manual mode is recommended for any accessories which support transitions natively on the device's end.
210
202
  * Like for example ZigBee lights which support sending transitions directly to the lightbulb which
211
203
  * then get executed ON the lightbulb itself reducing unnecessary network traffic.
212
- * Here is a quick overview what you have to consider to successfully implement AdaptiveLighting support.
204
+ * Here is a quick overview of what you have to consider to successfully implement AdaptiveLighting support.
213
205
  * The AdaptiveLightingController will also in manual mode do all the setup procedure.
214
206
  * It will also save the transition schedule to disk to keep AdaptiveLighting enabled across reboots.
215
207
  * The "only" thing you have to do yourself is handling the actual transitions, check that event notifications
216
208
  * are only sent in the defined interval threshold, adjust the color temperature when brightness is changed
217
209
  * and signal that Adaptive Lighting should be disabled if ColorTemperature, Hue or Saturation is changed manually.
218
210
  *
219
- * First step is to setup up an event handler for the {@link AdaptiveLightingControllerEvents.UPDATE}, which is called
211
+ * First step is to set up an event handler for the {@link AdaptiveLightingControllerEvents.UPDATE}, which is called
220
212
  * when AdaptiveLighting is enabled, the HomeHub updates the schedule for the next 24 hours or AdaptiveLighting
221
213
  * is restored from disk on startup.
222
214
  * In the event handler you can get the current schedule via {@link AdaptiveLightingController.getAdaptiveLightingTransitionCurve},
@@ -226,17 +218,16 @@ export var AdaptiveLightingControllerEvents;
226
218
  * Additionally {@link AdaptiveLightingController.getAdaptiveLightingBrightnessMultiplierRange} can be used
227
219
  * to get the valid range for the brightness value to calculate the brightness adjustment factor.
228
220
  * The method {@link AdaptiveLightingController.isAdaptiveLightingActive} can be used to check if AdaptiveLighting is enabled.
229
- * Besides, actually running the transition (see {@link AdaptiveLightingTransitionCurveEntry}) you must correctly update
221
+ * Besides actually running the transition (see {@link AdaptiveLightingTransitionCurveEntry}) you must correctly update
230
222
  * the color temperature when the brightness of the lightbulb changes (see {@link AdaptiveLightingTransitionCurveEntry.brightnessAdjustmentFactor}),
231
223
  * and signal when AdaptiveLighting got disabled by calling {@link AdaptiveLightingController.disableAdaptiveLighting}
232
- * when ColorTemperature, Hue or Saturation where changed manually.
233
- * Lastly you should set up a event handler for the {@link AdaptiveLightingControllerEvents.DISABLED} event.
224
+ * when ColorTemperature, Hue or Saturation were changed manually.
225
+ * Lastly you should set up an event handler for the {@link AdaptiveLightingControllerEvents.DISABLED} event.
234
226
  * In yet unknown circumstances HomeKit may also send a dedicated disable command via the control point characteristic.
235
227
  * Be prepared to handle that.
236
228
  *
237
229
  * @group Adaptive Lighting
238
230
  */
239
- // eslint-disable-next-line ts/no-unsafe-declaration-merging
240
231
  export class AdaptiveLightingController extends EventEmitter {
241
232
  stateChangeDelegate;
242
233
  lightbulb;
@@ -269,7 +260,7 @@ export class AdaptiveLightingController extends EventEmitter {
269
260
  constructor(service, options) {
270
261
  super();
271
262
  this.lightbulb = service;
272
- this.mode = options?.controllerMode ?? 1 /* AdaptiveLightingControllerMode.AUTOMATIC */;
263
+ this.mode = options?.controllerMode ?? AdaptiveLightingControllerMode.AUTOMATIC;
273
264
  this.customTemperatureAdjustment = options?.customTemperatureAdjustment ?? 0;
274
265
  assert(this.lightbulb.testCharacteristic(Characteristic.ColorTemperature), 'Lightbulb must have the ColorTemperature characteristic added!');
275
266
  assert(this.lightbulb.testCharacteristic(Characteristic.Brightness), 'Lightbulb must have the Brightness characteristic added!');
@@ -280,11 +271,11 @@ export class AdaptiveLightingController extends EventEmitter {
280
271
  * @private
281
272
  */
282
273
  controllerId() {
283
- return `${"characteristic-transition" /* DefaultControllerType.CHARACTERISTIC_TRANSITION */}-${this.lightbulb.getServiceId()}`;
274
+ return `${DefaultControllerType.CHARACTERISTIC_TRANSITION}-${this.lightbulb.getServiceId()}`;
284
275
  }
285
276
  // ----------- PUBLIC API START -----------
286
277
  /**
287
- * Returns if a Adaptive Lighting transition is currently active.
278
+ * Returns if an Adaptive Lighting transition is currently active.
288
279
  */
289
280
  isAdaptiveLightingActive() {
290
281
  return !!this.activeTransition;
@@ -302,10 +293,10 @@ export class AdaptiveLightingController extends EventEmitter {
302
293
  this.updateTimeout = undefined;
303
294
  }
304
295
  if (this.activeTransition) {
305
- this.colorTemperatureCharacteristic?.removeListener("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
306
- this.brightnessCharacteristic?.removeListener("change" /* CharacteristicEventTypes.CHANGE */, this.adjustmentFactorChangedListener);
307
- this.hueCharacteristic?.removeListener("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
308
- this.saturationCharacteristic?.removeListener("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
296
+ this.colorTemperatureCharacteristic?.removeListener(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
297
+ this.brightnessCharacteristic?.removeListener(CharacteristicEventTypes.CHANGE, this.adjustmentFactorChangedListener);
298
+ this.hueCharacteristic?.removeListener(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
299
+ this.saturationCharacteristic?.removeListener(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
309
300
  this.activeTransition = undefined;
310
301
  this.stateChangeDelegate?.();
311
302
  }
@@ -324,7 +315,7 @@ export class AdaptiveLightingController extends EventEmitter {
324
315
  }
325
316
  /**
326
317
  * Returns the time where the current transition curve was started in epoch time millis.
327
- * A transition curves is active for 24 hours typically and is renewed every 24 hours by a HomeHub.
318
+ * A transition curve is active for 24 hours typically and is renewed every 24 hours by a HomeHub.
328
319
  * Additionally see {@link getAdaptiveLightingTimeOffset}.
329
320
  */
330
321
  getAdaptiveLightingStartTimeOfTransition() {
@@ -336,9 +327,9 @@ export class AdaptiveLightingController extends EventEmitter {
336
327
  /**
337
328
  * It is not necessarily given, that we have the same time (or rather the correct time) as the HomeKit controller
338
329
  * who set up the transition schedule.
339
- * Thus we record the delta between our current time and the the time send with the setup request.
330
+ * Thus we record the delta between our current time and the time sent with the setup request.
340
331
  * <code>timeOffset</code> is defined as <code>Date.now() - getAdaptiveLightingStartTimeOfTransition();</code>.
341
- * So in the case were we actually have a correct local time, it most likely will be positive (due to network latency).
332
+ * So in the case where we actually have a correct local time, it most likely will be positive (due to network latency).
342
333
  * But of course it can also be negative.
343
334
  */
344
335
  getAdaptiveLightingTimeOffset() {
@@ -361,8 +352,8 @@ export class AdaptiveLightingController extends EventEmitter {
361
352
  }
362
353
  /**
363
354
  * This method returns the interval (in milliseconds) in which the light should update its internal color temperature
364
- * (aka changes it physical color).
365
- * A lightbulb should ideally change this also when turned of in oder to have a smooth transition when turning the light on.
355
+ * (aka changes its physical color).
356
+ * A lightbulb should ideally change this also when turned off in order to have a smooth transition when turning the light on.
366
357
  *
367
358
  * Typically this evaluates to 60000 milliseconds (60 seconds).
368
359
  */
@@ -373,7 +364,7 @@ export class AdaptiveLightingController extends EventEmitter {
373
364
  return this.activeTransition.updateInterval;
374
365
  }
375
366
  /**
376
- * Returns the minimum interval threshold (in milliseconds) a accessory may notify HomeKit controllers about a new
367
+ * Returns the minimum interval threshold (in milliseconds) an accessory may notify HomeKit controllers about a new
377
368
  * color temperature value via event notifications (what happens when you call {@link Characteristic.updateValue}).
378
369
  * Meaning the accessory should only send event notifications to subscribed HomeKit controllers at the specified interval.
379
370
  *
@@ -395,10 +386,10 @@ export class AdaptiveLightingController extends EventEmitter {
395
386
  this.activeTransitionCount.value = 1;
396
387
  }
397
388
  }
398
- if (this.mode === 1 /* AdaptiveLightingControllerMode.AUTOMATIC */) {
389
+ if (this.mode === AdaptiveLightingControllerMode.AUTOMATIC) {
399
390
  this.scheduleNextUpdate();
400
391
  }
401
- else if (this.mode === 2 /* AdaptiveLightingControllerMode.MANUAL */) {
392
+ else if (this.mode === AdaptiveLightingControllerMode.MANUAL) {
402
393
  if (!this.activeTransition) {
403
394
  throw new Error('There is no active transition!');
404
395
  }
@@ -410,7 +401,7 @@ export class AdaptiveLightingController extends EventEmitter {
410
401
  updateInterval: this.activeTransition.updateInterval,
411
402
  notifyIntervalThreshold: this.activeTransition.notifyIntervalThreshold,
412
403
  };
413
- this.emit("update" /* AdaptiveLightingControllerEvents.UPDATE */, update);
404
+ this.emit(AdaptiveLightingControllerEvents.UPDATE, update);
414
405
  }
415
406
  else {
416
407
  throw new Error(`Unsupported adaptive lighting controller mode: ${this.mode}`);
@@ -425,20 +416,20 @@ export class AdaptiveLightingController extends EventEmitter {
425
416
  }
426
417
  this.colorTemperatureCharacteristic = this.lightbulb.getCharacteristic(Characteristic.ColorTemperature);
427
418
  this.brightnessCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Brightness);
428
- this.colorTemperatureCharacteristic.on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
429
- this.brightnessCharacteristic.on("change" /* CharacteristicEventTypes.CHANGE */, this.adjustmentFactorChangedListener);
419
+ this.colorTemperatureCharacteristic.on(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
420
+ this.brightnessCharacteristic.on(CharacteristicEventTypes.CHANGE, this.adjustmentFactorChangedListener);
430
421
  if (this.lightbulb.testCharacteristic(Characteristic.Hue)) {
431
422
  this.hueCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Hue)
432
- .on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
423
+ .on(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
433
424
  }
434
425
  if (this.lightbulb.testCharacteristic(Characteristic.Saturation)) {
435
426
  this.saturationCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Saturation)
436
- .on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
427
+ .on(CharacteristicEventTypes.CHANGE, this.characteristicManualWrittenChangeListener);
437
428
  }
438
429
  }
439
430
  handleAdaptiveLightingDisabled() {
440
- if (this.mode === 2 /* AdaptiveLightingControllerMode.MANUAL */ && this.activeTransition) { // only emit the event if a transition is actually enabled
441
- this.emit("disable" /* AdaptiveLightingControllerEvents.DISABLED */);
431
+ if (this.mode === AdaptiveLightingControllerMode.MANUAL && this.activeTransition) { // only emit the event if a transition is actually enabled
432
+ this.emit(AdaptiveLightingControllerEvents.DISABLED);
442
433
  }
443
434
  this.disableAdaptiveLighting();
444
435
  }
@@ -455,13 +446,13 @@ export class AdaptiveLightingController extends EventEmitter {
455
446
  // After some short time the Hue or Saturation get handler return with the last known value to the plugin.
456
447
  // As those values now differ from the cached values (we already updated) we get a call to handleCharacteristicManualWritten
457
448
  // which again disables adaptive lighting.
458
- if (change.reason === "read" /* ChangeReason.READ */) {
449
+ if (change.reason === ChangeReason.READ) {
459
450
  // if the reason is a read request, we expect that Hue/Saturation are also read
460
451
  // thus we postpone our update to ColorTemperature a bit.
461
452
  // It doesn't ensure that those race conditions do not happen anymore, but with a 1s delay it reduces the possibility by a bit
462
453
  setTimeout(() => {
463
454
  if (!this.activeTransition) {
464
- return; // was disabled in the mean time
455
+ return; // was disabled in the meantime
465
456
  }
466
457
  this.scheduleNextUpdate(true);
467
458
  }, 1000).unref();
@@ -477,10 +468,10 @@ export class AdaptiveLightingController extends EventEmitter {
477
468
  * @param change
478
469
  */
479
470
  handleCharacteristicManualWritten(change) {
480
- if (change.reason === "write" /* ChangeReason.WRITE */ && !(isAdaptiveLightingContext(change.context) && change.context.controller === this)) {
481
- // we ignore write request which are the result of calls made to updateValue or sendEventNotification
482
- // or the result of a changed value returned by a read handler
483
- // or the change was done by the controller itself
471
+ // we ignore changes which are the result of calls made to updateValue or sendEventNotification
472
+ // or the result of a changed value returned by a read handler
473
+ // or the change was done by the controller itself
474
+ if (change.reason === ChangeReason.WRITE && !(isAdaptiveLightingContext(change.context) && change.context.controller === this)) {
484
475
  debug('[%s] Received a manual write to an characteristic (newValue: %d, oldValue: %d, reason: %s). Thus disabling adaptive lighting!', this.lightbulb.displayName, change.newValue, change.oldValue, change.reason);
485
476
  this.disableAdaptiveLighting();
486
477
  }
@@ -495,8 +486,10 @@ export class AdaptiveLightingController extends EventEmitter {
495
486
  }
496
487
  // adjustedNow is the now() date corrected to the time of the initiating controller
497
488
  const adjustedNow = Date.now() - this.activeTransition.timeMillisOffset;
498
- // "offset" since the start of the transition schedule
499
- const offset = adjustedNow - this.activeTransition.transitionStartMillis;
489
+ // "offset" since the start of the transition schedule.
490
+ // Before the first point of the curve (the clock was set back since the schedule arrived, or the first point lies
491
+ // in the future) the schedule has not started yet: stay on the first point instead of taking it for finished.
492
+ const offset = Math.max(adjustedNow - this.activeTransition.transitionStartMillis, this.activeTransition.transitionCurve[0]?.transitionTime ?? 0);
500
493
  let i = this.lastTransitionPointInfo?.curveIndex ?? 0;
501
494
  let lowerBoundTimeOffset = this.lastTransitionPointInfo?.lowerBoundTimeOffset ?? 0; // time offset to the lowerBound transition entry
502
495
  let lowerBound;
@@ -540,6 +533,13 @@ export class AdaptiveLightingController extends EventEmitter {
540
533
  upperBound,
541
534
  };
542
535
  }
536
+ /**
537
+ * The update interval is sent by the controller and may be any number up to 2^64. It is kept as sent, as the
538
+ * controller reads it back, but the timer waits at most {@link MAXIMUM_TIMER_DELAY}.
539
+ */
540
+ nextUpdateDelay(updateInterval) {
541
+ return Math.min(MAXIMUM_TIMER_DELAY, Math.max(MINIMUM_UPDATE_INTERVAL, updateInterval));
542
+ }
543
543
  scheduleNextUpdate(dryRun = false) {
544
544
  if (!this.activeTransition) {
545
545
  throw new Error('tried scheduling transition when no transition was active!');
@@ -585,7 +585,8 @@ export class AdaptiveLightingController extends EventEmitter {
585
585
  // e.g. the cached brightness value isn't a number; skip this step instead of throwing inside the update timer
586
586
  debug('[%s] Skipping adaptive lighting update as the calculated temperature is %d (for brightness %d)', this.lightbulb.displayName, temperature, adjustmentMultiplier);
587
587
  if (!dryRun) {
588
- this.updateTimeout = setTimeout(this.scheduleNextUpdate.bind(this), Math.max(MINIMUM_UPDATE_INTERVAL, this.activeTransition.updateInterval));
588
+ this.updateTimeout = setTimeout(this.scheduleNextUpdate.bind(this), this.nextUpdateDelay(this.activeTransition.updateInterval));
589
+ this.updateTimeout.unref();
589
590
  }
590
591
  return;
591
592
  }
@@ -601,11 +602,11 @@ export class AdaptiveLightingController extends EventEmitter {
601
602
  /*
602
603
  * We set saturation and hue values BEFORE we call the ColorTemperature SET handler (via setValue).
603
604
  * First thought was so the API user could get the values in the SET handler of the color temperature characteristic.
604
- * Do this is probably not really elegant cause this would only work when Adaptive Lighting is turned on
605
- * an the accessory MUST in any case update the Hue/Saturation values on a ColorTemperature write
605
+ * Doing this is probably not really elegant because this would only work when Adaptive Lighting is turned on
606
+ * and the accessory MUST in any case update the Hue/Saturation values on a ColorTemperature write
606
607
  * (obviously only if Hue/Saturation characteristics are added to the service).
607
608
  *
608
- * The clever thing about this though is that, that it prevents notifications from being sent for Hue and Saturation
609
+ * The clever thing about this though is that it prevents notifications from being sent for Hue and Saturation
609
610
  * outside the specified notifyIntervalThreshold (see below where notifications are manually sent).
610
611
  * As the dev will or must call something like updateValue to propagate the updated hue and saturation values
611
612
  * to all HomeKit clients (so that the color is reflected in the UI), HAP-NodeJS won't send notifications
@@ -620,10 +621,10 @@ export class AdaptiveLightingController extends EventEmitter {
620
621
  this.hueCharacteristic.value = color.hue;
621
622
  }
622
623
  this.colorTemperatureCharacteristic?.handleSetRequest(temperature, undefined, context).catch((reason) => {
623
- debug('[%s] Failed to next adaptive lighting transition point: %d', this.lightbulb.displayName, reason);
624
+ debug('[%s] Failed to set the next adaptive lighting transition point: %d', this.lightbulb.displayName, reason);
624
625
  });
625
626
  if (!this.activeTransition) {
626
- console.warn(`[${this.lightbulb.displayName}] Adaptive Lighting was probably disable my mistake by some call in `
627
+ console.warn(`[${this.lightbulb.displayName}] Adaptive Lighting was probably disabled by mistake by some call in `
627
628
  + 'the SET handler of the ColorTemperature characteristic! '
628
629
  + 'Please check that you don\'t call setValue/setCharacteristic on the Hue, Saturation or ColorTemperature characteristic!');
629
630
  return;
@@ -649,7 +650,8 @@ export class AdaptiveLightingController extends EventEmitter {
649
650
  }
650
651
  }
651
652
  if (!dryRun) {
652
- this.updateTimeout = setTimeout(this.scheduleNextUpdate.bind(this), Math.max(MINIMUM_UPDATE_INTERVAL, this.activeTransition.updateInterval));
653
+ this.updateTimeout = setTimeout(this.scheduleNextUpdate.bind(this), this.nextUpdateDelay(this.activeTransition.updateInterval));
654
+ this.updateTimeout.unref(); // the next update must not keep the process alive
653
655
  }
654
656
  }
655
657
  /**
@@ -662,7 +664,7 @@ export class AdaptiveLightingController extends EventEmitter {
662
664
  * @private
663
665
  */
664
666
  // eslint-disable-next-line unused-imports/no-unused-vars
665
- initWithServices(serviceMap) {
667
+ initWithServices(_serviceMap) {
666
668
  // do nothing
667
669
  }
668
670
  /**
@@ -689,8 +691,8 @@ export class AdaptiveLightingController extends EventEmitter {
689
691
  throw error; // the request was rejected on purpose, the active transition stays untouched
690
692
  }
691
693
  debug('[%s] Failed CharacteristicValueTransitionControl write: \'%s\'', this.lightbulb.displayName, value);
692
- console.warn(`[${this.lightbulb.displayName}] Encountered error on CharacteristicValueTransitionControl characteristic: ${error.stack}`);
693
- this.disableAdaptiveLighting();
694
+ console.warn(`[${this.lightbulb.displayName}] Encountered error on CharacteristicValueTransitionControl characteristic: ${errorStack(error) ?? errorMessage(error)}`);
695
+ this.handleAdaptiveLightingDisabled(); // also tells a plugin in MANUAL mode, which runs the transition itself
694
696
  throw new HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
695
697
  }
696
698
  });
@@ -705,7 +707,7 @@ export class AdaptiveLightingController extends EventEmitter {
705
707
  this.supportedTransitionConfiguration = undefined;
706
708
  this.transitionControl = undefined;
707
709
  this.activeTransitionCount = undefined;
708
- this.removeAllListeners();
710
+ // The listeners stay: they belong to the plugin, and the controller must work when it is added again.
709
711
  }
710
712
  /**
711
713
  * @private
@@ -752,9 +754,9 @@ export class AdaptiveLightingController extends EventEmitter {
752
754
  const temperatureIID = this.lightbulb?.getCharacteristic(Characteristic.ColorTemperature).iid;
753
755
  assert(brightnessIID, 'iid for brightness characteristic is undefined');
754
756
  assert(temperatureIID, 'iid for temperature characteristic is undefined');
755
- return tlv.encode(1 /* SupportedCharacteristicValueTransitionConfigurationsTypes.SUPPORTED_TRANSITION_CONFIGURATION */, [
756
- tlv.encode(1 /* SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, tlv.writeVariableUIntLE(brightnessIID), 2 /* SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE */, 1 /* TransitionType.BRIGHTNESS */),
757
- tlv.encode(1 /* SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, tlv.writeVariableUIntLE(temperatureIID), 2 /* SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE */, 2 /* TransitionType.COLOR_TEMPERATURE */),
757
+ return tlv.encode(SupportedCharacteristicValueTransitionConfigurationsTypes.SUPPORTED_TRANSITION_CONFIGURATION, [
758
+ tlv.encode(SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID, tlv.writeVariableUIntLE(brightnessIID), SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE, TransitionType.BRIGHTNESS),
759
+ tlv.encode(SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID, tlv.writeVariableUIntLE(temperatureIID), SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE, TransitionType.COLOR_TEMPERATURE),
758
760
  ]).toString('base64');
759
761
  }
760
762
  buildTransitionControlResponseBuffer(time) {
@@ -762,17 +764,18 @@ export class AdaptiveLightingController extends EventEmitter {
762
764
  return Buffer.alloc(0);
763
765
  }
764
766
  const active = this.activeTransition;
765
- const timeSinceStart = time ?? (Date.now() - active.timeMillisOffset - active.transitionStartMillis);
767
+ // never negative (see getCurrentAdaptiveLightingTransitionPoint), which an unsigned integer could not hold
768
+ const timeSinceStart = Math.max(0, time ?? (Date.now() - active.timeMillisOffset - active.transitionStartMillis));
766
769
  const timeSinceStartBuffer = tlv.writeVariableUIntLE(timeSinceStart);
767
- let parameters = tlv.encode(1 /* ValueTransitionParametersTypes.TRANSITION_ID */, uuid.write(active.transitionId), 2 /* ValueTransitionParametersTypes.START_TIME */, Buffer.from(active.transitionStartBuffer, 'hex'));
770
+ let parameters = tlv.encode(ValueTransitionParametersTypes.TRANSITION_ID, uuid.write(active.transitionId), ValueTransitionParametersTypes.START_TIME, Buffer.from(active.transitionStartBuffer, 'hex'));
768
771
  if (active.id3) {
769
772
  parameters = Buffer.concat([
770
773
  parameters,
771
- tlv.encode(3 /* ValueTransitionParametersTypes.UNKNOWN_3 */, Buffer.from(active.id3, 'hex')),
774
+ tlv.encode(ValueTransitionParametersTypes.UNKNOWN_3, Buffer.from(active.id3, 'hex')),
772
775
  ]);
773
776
  }
774
- const status = tlv.encode(1 /* ValueTransitionConfigurationStatusTypes.CHARACTERISTIC_IID */, tlv.writeVariableUIntLE(active.iid), 2 /* ValueTransitionConfigurationStatusTypes.TRANSITION_PARAMETERS */, parameters, 3 /* ValueTransitionConfigurationStatusTypes.TIME_SINCE_START */, timeSinceStartBuffer);
775
- return tlv.encode(1 /* ValueTransitionConfigurationResponseTypes.VALUE_CONFIGURATION_STATUS */, status);
777
+ const status = tlv.encode(ValueTransitionConfigurationStatusTypes.CHARACTERISTIC_IID, tlv.writeVariableUIntLE(active.iid), ValueTransitionConfigurationStatusTypes.TRANSITION_PARAMETERS, parameters, ValueTransitionConfigurationStatusTypes.TIME_SINCE_START, timeSinceStartBuffer);
778
+ return tlv.encode(ValueTransitionConfigurationResponseTypes.VALUE_CONFIGURATION_STATUS, status);
776
779
  }
777
780
  handleTransitionControlWrite(value) {
778
781
  if (typeof value !== 'string') {
@@ -780,14 +783,14 @@ export class AdaptiveLightingController extends EventEmitter {
780
783
  }
781
784
  const tlvData = tlv.decode(Buffer.from(value, 'base64'));
782
785
  const responseBuffers = [];
783
- const readTransition = tlvData[1 /* TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION */];
786
+ const readTransition = tlvData[TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION];
784
787
  if (readTransition) {
785
788
  const readTransitionResponse = this.handleTransitionControlReadTransition(readTransition);
786
789
  if (readTransitionResponse) {
787
790
  responseBuffers.push(readTransitionResponse);
788
791
  }
789
792
  }
790
- const updateTransition = tlvData[2 /* TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION */];
793
+ const updateTransition = tlvData[TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION];
791
794
  if (updateTransition) {
792
795
  const updateTransitionResponse = this.handleTransitionControlUpdateTransition(updateTransition);
793
796
  if (updateTransitionResponse) {
@@ -798,23 +801,23 @@ export class AdaptiveLightingController extends EventEmitter {
798
801
  }
799
802
  handleTransitionControlReadTransition(buffer) {
800
803
  const readTransition = tlv.decode(buffer);
801
- const iid = tlv.readVariableUIntLE(readTransition[1 /* ReadValueTransitionConfiguration.CHARACTERISTIC_IID */]);
804
+ const iid = tlv.readVariableUIntLE(readTransition[ReadValueTransitionConfiguration.CHARACTERISTIC_IID]);
802
805
  if (this.activeTransition) {
803
806
  if (this.activeTransition.iid !== iid) {
804
807
  console.warn(`[${this.lightbulb.displayName}] iid of current adaptive lighting transition (${this.activeTransition.iid}) doesn't match the requested one ${iid}`);
805
808
  throw new HapStatusError(HAPStatus.INVALID_VALUE_IN_REQUEST);
806
809
  }
807
- let parameters = tlv.encode(1 /* ValueTransitionParametersTypes.TRANSITION_ID */, uuid.write(this.activeTransition.transitionId), 2 /* ValueTransitionParametersTypes.START_TIME */, Buffer.from(this.activeTransition.transitionStartBuffer, 'hex'));
810
+ let parameters = tlv.encode(ValueTransitionParametersTypes.TRANSITION_ID, uuid.write(this.activeTransition.transitionId), ValueTransitionParametersTypes.START_TIME, Buffer.from(this.activeTransition.transitionStartBuffer, 'hex'));
808
811
  if (this.activeTransition.id3) {
809
812
  parameters = Buffer.concat([
810
813
  parameters,
811
- tlv.encode(3 /* ValueTransitionParametersTypes.UNKNOWN_3 */, Buffer.from(this.activeTransition.id3, 'hex')),
814
+ tlv.encode(ValueTransitionParametersTypes.UNKNOWN_3, Buffer.from(this.activeTransition.id3, 'hex')),
812
815
  ]);
813
816
  }
814
- return tlv.encode(1 /* TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION */, tlv.encode(1 /* ValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, tlv.writeVariableUIntLE(this.activeTransition.iid), 2 /* ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS */, parameters, 3 /* ValueTransitionConfigurationTypes.UNKNOWN_3 */, 1, 5 /* ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION */, tlv.encode(1 /* TransitionCurveConfigurationTypes.TRANSITION_ENTRY */, this.activeTransition.transitionCurve.map((entry, index, array) => {
817
+ return tlv.encode(TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION, tlv.encode(ValueTransitionConfigurationTypes.CHARACTERISTIC_IID, tlv.writeVariableUIntLE(this.activeTransition.iid), ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS, parameters, ValueTransitionConfigurationTypes.UNKNOWN_3, 1, ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION, tlv.encode(TransitionCurveConfigurationTypes.TRANSITION_ENTRY, this.activeTransition.transitionCurve.map((entry, index, array) => {
815
818
  const duration = array[index - 1]?.duration ?? 0; // we store stuff differently :sweat_smile:
816
- return tlv.encode(1 /* TransitionEntryTypes.ADJUSTMENT_FACTOR */, tlv.writeFloat32LE(entry.brightnessAdjustmentFactor), 2 /* TransitionEntryTypes.VALUE */, tlv.writeFloat32LE(entry.temperature), 3 /* TransitionEntryTypes.TRANSITION_OFFSET */, tlv.writeVariableUIntLE(entry.transitionTime), 4 /* TransitionEntryTypes.DURATION */, tlv.writeVariableUIntLE(duration));
817
- }), 2 /* TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID */, tlv.writeVariableUIntLE(this.activeTransition.brightnessCharacteristicIID), 3 /* TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE */, tlv.encode(1 /* TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER */, tlv.writeUInt32(this.activeTransition.brightnessAdjustmentRange.minBrightnessValue), 2 /* TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER */, tlv.writeUInt32(this.activeTransition.brightnessAdjustmentRange.maxBrightnessValue))), 6 /* ValueTransitionConfigurationTypes.UPDATE_INTERVAL */, tlv.writeVariableUIntLE(this.activeTransition.updateInterval), 8 /* ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD */, tlv.writeVariableUIntLE(this.activeTransition.notifyIntervalThreshold)));
819
+ return tlv.encode(TransitionEntryTypes.ADJUSTMENT_FACTOR, tlv.writeFloat32LE(entry.brightnessAdjustmentFactor), TransitionEntryTypes.VALUE, tlv.writeFloat32LE(entry.temperature), TransitionEntryTypes.TRANSITION_OFFSET, tlv.writeVariableUIntLE(entry.transitionTime), TransitionEntryTypes.DURATION, tlv.writeVariableUIntLE(duration));
820
+ }), TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID, tlv.writeVariableUIntLE(this.activeTransition.brightnessCharacteristicIID), TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE, tlv.encode(TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER, tlv.writeUInt32(this.activeTransition.brightnessAdjustmentRange.minBrightnessValue), TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER, tlv.writeUInt32(this.activeTransition.brightnessAdjustmentRange.maxBrightnessValue))), ValueTransitionConfigurationTypes.UPDATE_INTERVAL, tlv.writeVariableUIntLE(this.activeTransition.updateInterval), ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD, tlv.writeVariableUIntLE(this.activeTransition.notifyIntervalThreshold)));
818
821
  }
819
822
  else {
820
823
  return undefined; // returns empty string
@@ -822,35 +825,45 @@ export class AdaptiveLightingController extends EventEmitter {
822
825
  }
823
826
  handleTransitionControlUpdateTransition(buffer) {
824
827
  const updateTransition = tlv.decode(buffer);
825
- const transitionConfiguration = tlv.decode(updateTransition[1 /* UpdateValueTransitionConfigurationsTypes.VALUE_TRANSITION_CONFIGURATION */]);
826
- const iid = tlv.readVariableUIntLE(transitionConfiguration[1 /* ValueTransitionConfigurationTypes.CHARACTERISTIC_IID */]);
828
+ const transitionConfiguration = tlv.decode(updateTransition[UpdateValueTransitionConfigurationsTypes.VALUE_TRANSITION_CONFIGURATION]);
829
+ const iid = tlv.readVariableUIntLE(transitionConfiguration[ValueTransitionConfigurationTypes.CHARACTERISTIC_IID]);
827
830
  if (!this.lightbulb.getCharacteristicByIID(iid)) {
828
831
  throw new HapStatusError(HAPStatus.INVALID_VALUE_IN_REQUEST);
829
832
  }
830
- const param3 = transitionConfiguration[3 /* ValueTransitionConfigurationTypes.UNKNOWN_3 */]?.readUInt8(0); // when present it is always 1
833
+ const param3 = transitionConfiguration[ValueTransitionConfigurationTypes.UNKNOWN_3]?.readUInt8(0); // when present it is always 1
831
834
  if (!param3) { // if HomeKit just sends the iid, we consider that as "disable adaptive lighting" (assumption)
832
835
  this.handleAdaptiveLightingDisabled();
833
- return tlv.encode(2 /* TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION */, Buffer.alloc(0));
834
- }
835
- const parametersTLV = tlv.decode(transitionConfiguration[2 /* ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS */]);
836
- const curveConfiguration = tlv.decodeWithLists(transitionConfiguration[5 /* ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION */]);
837
- const updateInterval = transitionConfiguration[6 /* ValueTransitionConfigurationTypes.UPDATE_INTERVAL */]?.readUInt16LE(0);
838
- const notifyIntervalThreshold = transitionConfiguration[8 /* ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD */].readUInt32LE(0);
839
- const transitionId = parametersTLV[1 /* ValueTransitionParametersTypes.TRANSITION_ID */];
840
- const startTime = parametersTLV[2 /* ValueTransitionParametersTypes.START_TIME */];
841
- const id3 = parametersTLV[3 /* ValueTransitionParametersTypes.UNKNOWN_3 */]; // this may be undefined
836
+ return tlv.encode(TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION, Buffer.alloc(0));
837
+ }
838
+ const parametersTLV = tlv.decode(transitionConfiguration[ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS]);
839
+ const curveConfiguration = tlv.decodeWithLists(transitionConfiguration[ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION]);
840
+ // both are integers of variable size (and we answer a read with one): read them by the length which was sent
841
+ const updateIntervalBuffer = transitionConfiguration[ValueTransitionConfigurationTypes.UPDATE_INTERVAL];
842
+ const updateInterval = updateIntervalBuffer
843
+ ? tlv.readVariableUIntLE(updateIntervalBuffer)
844
+ : undefined;
845
+ const notifyIntervalThreshold = tlv.readVariableUIntLE(transitionConfiguration[ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD]);
846
+ const transitionId = parametersTLV[ValueTransitionParametersTypes.TRANSITION_ID];
847
+ const startTime = parametersTLV[ValueTransitionParametersTypes.START_TIME];
848
+ const id3 = parametersTLV[ValueTransitionParametersTypes.UNKNOWN_3]; // this may be undefined
842
849
  const startTimeMillis = epochMillisFromMillisSince2001_01_01Buffer(startTime);
843
850
  const timeMillisOffset = Date.now() - startTimeMillis;
844
851
  const transitionCurve = [];
845
852
  let previous;
846
- const transitions = curveConfiguration[1 /* TransitionCurveConfigurationTypes.TRANSITION_ENTRY */];
853
+ // decodeWithLists() only returns a list when the type occurred more than once: a curve of one entry is a plain Buffer
854
+ const transitions = [curveConfiguration[TransitionCurveConfigurationTypes.TRANSITION_ENTRY]].flat();
855
+ if (transitions.length < 2) {
856
+ // a curve needs two points to go from one to the next. With one, AUTOMATIC mode would answer the write with success
857
+ // and turn Adaptive Lighting off at once: refuse it and keep the transition which is running
858
+ throw new HapStatusError(HAPStatus.INVALID_VALUE_IN_REQUEST);
859
+ }
847
860
  for (const entry of transitions) {
848
861
  const tlvEntry = tlv.decode(entry);
849
- const adjustmentFactor = tlvEntry[1 /* TransitionEntryTypes.ADJUSTMENT_FACTOR */].readFloatLE(0);
850
- const value = tlvEntry[2 /* TransitionEntryTypes.VALUE */].readFloatLE(0);
851
- const transitionOffset = tlv.readVariableUIntLE(tlvEntry[3 /* TransitionEntryTypes.TRANSITION_OFFSET */]);
852
- const duration = tlvEntry[4 /* TransitionEntryTypes.DURATION */]
853
- ? tlv.readVariableUIntLE(tlvEntry[4 /* TransitionEntryTypes.DURATION */])
862
+ const adjustmentFactor = tlvEntry[TransitionEntryTypes.ADJUSTMENT_FACTOR].readFloatLE(0);
863
+ const value = tlvEntry[TransitionEntryTypes.VALUE].readFloatLE(0);
864
+ const transitionOffset = tlv.readVariableUIntLE(tlvEntry[TransitionEntryTypes.TRANSITION_OFFSET]);
865
+ const duration = tlvEntry[TransitionEntryTypes.DURATION]
866
+ ? tlv.readVariableUIntLE(tlvEntry[TransitionEntryTypes.DURATION])
854
867
  : undefined;
855
868
  if (previous) {
856
869
  previous.duration = duration;
@@ -862,10 +875,10 @@ export class AdaptiveLightingController extends EventEmitter {
862
875
  };
863
876
  transitionCurve.push(previous);
864
877
  }
865
- const adjustmentIID = tlv.readVariableUIntLE(curveConfiguration[2 /* TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID */]);
866
- const adjustmentMultiplierRange = tlv.decode(curveConfiguration[3 /* TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE */]);
867
- const minAdjustmentMultiplier = adjustmentMultiplierRange[1 /* TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER */].readUInt32LE(0);
868
- const maxAdjustmentMultiplier = adjustmentMultiplierRange[2 /* TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER */].readUInt32LE(0);
878
+ const adjustmentIID = tlv.readVariableUIntLE(curveConfiguration[TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID]);
879
+ const adjustmentMultiplierRange = tlv.decode(curveConfiguration[TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE]);
880
+ const minAdjustmentMultiplier = adjustmentMultiplierRange[TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER].readUInt32LE(0);
881
+ const maxAdjustmentMultiplier = adjustmentMultiplierRange[TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER].readUInt32LE(0);
869
882
  this.activeTransition = {
870
883
  iid,
871
884
  transitionStartMillis: startTimeMillis,
@@ -893,7 +906,7 @@ export class AdaptiveLightingController extends EventEmitter {
893
906
  debug('[%s] Adaptive lighting was enabled.', this.lightbulb.displayName);
894
907
  }
895
908
  this.handleActiveTransitionUpdated();
896
- return tlv.encode(2 /* TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION */, this.buildTransitionControlResponseBuffer(0));
909
+ return tlv.encode(TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION, this.buildTransitionControlResponseBuffer(0));
897
910
  }
898
911
  }
899
912
  //# sourceMappingURL=AdaptiveLightingController.js.map