hap-nodejs 1.1.1-beta.1 → 1.1.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.
- package/@types/bonjour-hap.d.ts +50 -53
- package/README.md +16 -19
- package/dist/accessories/AirConditioner_accessory.js +28 -30
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +69 -81
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +141 -136
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +18 -22
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +33 -35
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +42 -44
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +32 -34
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +25 -26
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +13 -16
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +20 -22
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +18 -20
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +34 -37
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +43 -45
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +12 -15
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +9 -12
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +11 -14
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +37 -38
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.d.ts +63 -63
- package/dist/accessories/types.d.ts.map +1 -1
- package/dist/accessories/types.js +83 -87
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.d.ts +26 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -34
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +1 -1
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +19 -21
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +39 -38
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +314 -292
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +7 -7
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +128 -136
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -1
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +2 -6
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +40 -41
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +204 -208
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +31 -30
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +220 -229
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +22 -22
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +63 -67
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +2 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +28 -44
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +34 -33
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +179 -151
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +19 -17
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +160 -151
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +3 -3
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +3 -6
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +33 -33
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +152 -144
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +22 -20
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +74 -78
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +4 -4
- package/dist/lib/controller/Controller.d.ts.map +1 -1
- package/dist/lib/controller/Controller.js +5 -8
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +5 -4
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +9 -13
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +39 -37
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +208 -197
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +5 -5
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/controller/index.js +5 -8
- package/dist/lib/controller/index.js.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +39 -39
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +1 -0
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +57 -77
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +23 -22
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +154 -164
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +3 -3
- package/dist/lib/datastream/index.d.ts.map +1 -1
- package/dist/lib/datastream/index.js +3 -6
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/dbus/align.d.ts +2 -0
- package/dist/lib/dbus/align.d.ts.map +1 -0
- package/dist/lib/dbus/align.js +12 -0
- package/dist/lib/dbus/align.js.map +1 -0
- package/dist/lib/dbus/bus.d.ts +38 -0
- package/dist/lib/dbus/bus.d.ts.map +1 -0
- package/dist/lib/dbus/bus.js +222 -0
- package/dist/lib/dbus/bus.js.map +1 -0
- package/dist/lib/dbus/constants.d.ts +43 -0
- package/dist/lib/dbus/constants.d.ts.map +1 -0
- package/dist/lib/dbus/constants.js +53 -0
- package/dist/lib/dbus/constants.js.map +1 -0
- package/dist/lib/dbus/dbus-buffer.d.ts +30 -0
- package/dist/lib/dbus/dbus-buffer.d.ts.map +1 -0
- package/dist/lib/dbus/dbus-buffer.js +175 -0
- package/dist/lib/dbus/dbus-buffer.js.map +1 -0
- package/dist/lib/dbus/handshake.d.ts +2 -0
- package/dist/lib/dbus/handshake.d.ts.map +1 -0
- package/dist/lib/dbus/handshake.js +130 -0
- package/dist/lib/dbus/handshake.js.map +1 -0
- package/dist/lib/dbus/index.d.ts +3 -0
- package/dist/lib/dbus/index.d.ts.map +1 -0
- package/dist/lib/dbus/index.js +123 -0
- package/dist/lib/dbus/index.js.map +1 -0
- package/dist/lib/dbus/introspect.d.ts +30 -0
- package/dist/lib/dbus/introspect.d.ts.map +1 -0
- package/dist/lib/dbus/introspect.js +208 -0
- package/dist/lib/dbus/introspect.js.map +1 -0
- package/dist/lib/dbus/marshall.d.ts +2 -0
- package/dist/lib/dbus/marshall.d.ts.map +1 -0
- package/dist/lib/dbus/marshall.js +97 -0
- package/dist/lib/dbus/marshall.js.map +1 -0
- package/dist/lib/dbus/marshallers.d.ts +10 -0
- package/dist/lib/dbus/marshallers.d.ts.map +1 -0
- package/dist/lib/dbus/marshallers.js +329 -0
- package/dist/lib/dbus/marshallers.js.map +1 -0
- package/dist/lib/dbus/message.d.ts +4 -0
- package/dist/lib/dbus/message.d.ts.map +1 -0
- package/dist/lib/dbus/message.js +116 -0
- package/dist/lib/dbus/message.js.map +1 -0
- package/dist/lib/dbus/put.d.ts +21 -0
- package/dist/lib/dbus/put.d.ts.map +1 -0
- package/dist/lib/dbus/put.js +120 -0
- package/dist/lib/dbus/put.js.map +1 -0
- package/dist/lib/dbus/readline.d.ts +2 -0
- package/dist/lib/dbus/readline.d.ts.map +1 -0
- package/dist/lib/dbus/readline.js +27 -0
- package/dist/lib/dbus/readline.js.map +1 -0
- package/dist/lib/dbus/signature.d.ts +2 -0
- package/dist/lib/dbus/signature.d.ts.map +1 -0
- package/dist/lib/dbus/signature.js +58 -0
- package/dist/lib/dbus/signature.js.map +1 -0
- package/dist/lib/dbus/stdifaces.d.ts +3 -0
- package/dist/lib/dbus/stdifaces.d.ts.map +1 -0
- package/dist/lib/dbus/stdifaces.js +206 -0
- package/dist/lib/dbus/stdifaces.js.map +1 -0
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +958 -1204
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +620 -695
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.d.ts +3 -3
- package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +246 -253
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +160 -165
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.d.ts +2 -2
- package/dist/lib/definitions/index.d.ts.map +1 -1
- package/dist/lib/definitions/index.js +2 -5
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +4 -3
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +50 -53
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +3 -3
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +17 -22
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +2 -2
- package/dist/lib/model/HAPStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPStorage.js +4 -11
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +1 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +19 -27
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +9 -9
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +27 -29
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +2 -2
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +6 -9
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts.map +1 -1
- package/dist/lib/util/clone.js +1 -5
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +4 -9
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +23 -22
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +109 -116
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +3 -2
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +31 -40
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +1 -1
- package/dist/lib/util/hapStatusError.d.ts.map +1 -1
- package/dist/lib/util/hapStatusError.js +4 -8
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +1 -1
- package/dist/lib/util/net-utils.js +17 -23
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts.map +1 -1
- package/dist/lib/util/once.js +2 -6
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +1 -1
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +3 -9
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +3 -2
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +11 -19
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +1 -0
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +6 -11
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +1 -0
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +28 -43
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +1 -0
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +26 -38
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -5
- package/dist/types.js.map +1 -1
- package/package.json +51 -46
- package/@types/simple-plist.d.ts +0 -4
- package/dist/lib/gen/HomeKit.d.ts +0 -7
- package/dist/lib/gen/HomeKit.d.ts.map +0 -1
- package/dist/lib/gen/HomeKit.js +0 -8
- package/dist/lib/gen/HomeKit.js.map +0 -1
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const tlv = tslib_1.__importStar(require("../util/tlv"));
|
|
14
|
-
const debug = (0, debug_1.default)("HAP-NodeJS:Controller:TransitionControl");
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
3
|
+
import { EventEmitter } from 'node:events';
|
|
4
|
+
import createDebug from 'debug';
|
|
5
|
+
import { Characteristic } from '../Characteristic.js';
|
|
6
|
+
import { ColorUtils } from '../util/color-utils.js';
|
|
7
|
+
import { HapStatusError } from '../util/hapStatusError.js';
|
|
8
|
+
import { epochMillisFromMillisSince2001_01_01Buffer } from '../util/time.js';
|
|
9
|
+
import { decode, decodeWithLists, encode, readVariableUIntLE, writeFloat32LE, writeUInt32, writeVariableUIntLE, } from '../util/tlv.js';
|
|
10
|
+
import { unparse, write } from '../util/uuid.js';
|
|
11
|
+
const debug = createDebug('HAP-NodeJS:Controller:TransitionControl');
|
|
12
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
15
13
|
var SupportedCharacteristicValueTransitionConfigurationsTypes;
|
|
16
14
|
(function (SupportedCharacteristicValueTransitionConfigurationsTypes) {
|
|
17
15
|
SupportedCharacteristicValueTransitionConfigurationsTypes[SupportedCharacteristicValueTransitionConfigurationsTypes["SUPPORTED_TRANSITION_CONFIGURATION"] = 1] = "SUPPORTED_TRANSITION_CONFIGURATION";
|
|
18
16
|
})(SupportedCharacteristicValueTransitionConfigurationsTypes || (SupportedCharacteristicValueTransitionConfigurationsTypes = {}));
|
|
17
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
19
18
|
var SupportedValueTransitionConfigurationTypes;
|
|
20
19
|
(function (SupportedValueTransitionConfigurationTypes) {
|
|
21
20
|
SupportedValueTransitionConfigurationTypes[SupportedValueTransitionConfigurationTypes["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
|
|
22
21
|
SupportedValueTransitionConfigurationTypes[SupportedValueTransitionConfigurationTypes["TRANSITION_TYPE"] = 2] = "TRANSITION_TYPE";
|
|
23
22
|
})(SupportedValueTransitionConfigurationTypes || (SupportedValueTransitionConfigurationTypes = {}));
|
|
23
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
24
24
|
var TransitionType;
|
|
25
25
|
(function (TransitionType) {
|
|
26
26
|
TransitionType[TransitionType["BRIGHTNESS"] = 1] = "BRIGHTNESS";
|
|
27
27
|
TransitionType[TransitionType["COLOR_TEMPERATURE"] = 2] = "COLOR_TEMPERATURE";
|
|
28
28
|
})(TransitionType || (TransitionType = {}));
|
|
29
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
29
30
|
var TransitionControlTypes;
|
|
30
31
|
(function (TransitionControlTypes) {
|
|
31
32
|
TransitionControlTypes[TransitionControlTypes["READ_CURRENT_VALUE_TRANSITION_CONFIGURATION"] = 1] = "READ_CURRENT_VALUE_TRANSITION_CONFIGURATION";
|
|
32
33
|
TransitionControlTypes[TransitionControlTypes["UPDATE_VALUE_TRANSITION_CONFIGURATION"] = 2] = "UPDATE_VALUE_TRANSITION_CONFIGURATION";
|
|
33
34
|
})(TransitionControlTypes || (TransitionControlTypes = {}));
|
|
35
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
34
36
|
var ReadValueTransitionConfiguration;
|
|
35
37
|
(function (ReadValueTransitionConfiguration) {
|
|
36
38
|
ReadValueTransitionConfiguration[ReadValueTransitionConfiguration["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
|
|
37
39
|
})(ReadValueTransitionConfiguration || (ReadValueTransitionConfiguration = {}));
|
|
40
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
38
41
|
var UpdateValueTransitionConfigurationsTypes;
|
|
39
42
|
(function (UpdateValueTransitionConfigurationsTypes) {
|
|
40
43
|
UpdateValueTransitionConfigurationsTypes[UpdateValueTransitionConfigurationsTypes["VALUE_TRANSITION_CONFIGURATION"] = 1] = "VALUE_TRANSITION_CONFIGURATION";
|
|
41
44
|
})(UpdateValueTransitionConfigurationsTypes || (UpdateValueTransitionConfigurationsTypes = {}));
|
|
45
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
42
46
|
var ValueTransitionConfigurationTypes;
|
|
43
47
|
(function (ValueTransitionConfigurationTypes) {
|
|
44
|
-
// noinspection JSUnusedGlobalSymbols
|
|
45
48
|
ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
|
|
46
49
|
ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["TRANSITION_PARAMETERS"] = 2] = "TRANSITION_PARAMETERS";
|
|
47
50
|
ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["UNKNOWN_3"] = 3] = "UNKNOWN_3";
|
|
@@ -51,18 +54,21 @@ var ValueTransitionConfigurationTypes;
|
|
|
51
54
|
ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["UNKNOWN_7"] = 7] = "UNKNOWN_7";
|
|
52
55
|
ValueTransitionConfigurationTypes[ValueTransitionConfigurationTypes["NOTIFY_INTERVAL_THRESHOLD"] = 8] = "NOTIFY_INTERVAL_THRESHOLD";
|
|
53
56
|
})(ValueTransitionConfigurationTypes || (ValueTransitionConfigurationTypes = {}));
|
|
57
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
54
58
|
var ValueTransitionParametersTypes;
|
|
55
59
|
(function (ValueTransitionParametersTypes) {
|
|
56
60
|
ValueTransitionParametersTypes[ValueTransitionParametersTypes["TRANSITION_ID"] = 1] = "TRANSITION_ID";
|
|
57
61
|
ValueTransitionParametersTypes[ValueTransitionParametersTypes["START_TIME"] = 2] = "START_TIME";
|
|
58
62
|
ValueTransitionParametersTypes[ValueTransitionParametersTypes["UNKNOWN_3"] = 3] = "UNKNOWN_3";
|
|
59
63
|
})(ValueTransitionParametersTypes || (ValueTransitionParametersTypes = {}));
|
|
64
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
60
65
|
var TransitionCurveConfigurationTypes;
|
|
61
66
|
(function (TransitionCurveConfigurationTypes) {
|
|
62
67
|
TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["TRANSITION_ENTRY"] = 1] = "TRANSITION_ENTRY";
|
|
63
68
|
TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["ADJUSTMENT_CHARACTERISTIC_IID"] = 2] = "ADJUSTMENT_CHARACTERISTIC_IID";
|
|
64
69
|
TransitionCurveConfigurationTypes[TransitionCurveConfigurationTypes["ADJUSTMENT_MULTIPLIER_RANGE"] = 3] = "ADJUSTMENT_MULTIPLIER_RANGE";
|
|
65
70
|
})(TransitionCurveConfigurationTypes || (TransitionCurveConfigurationTypes = {}));
|
|
71
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
66
72
|
var TransitionEntryTypes;
|
|
67
73
|
(function (TransitionEntryTypes) {
|
|
68
74
|
TransitionEntryTypes[TransitionEntryTypes["ADJUSTMENT_FACTOR"] = 1] = "ADJUSTMENT_FACTOR";
|
|
@@ -70,30 +76,33 @@ var TransitionEntryTypes;
|
|
|
70
76
|
TransitionEntryTypes[TransitionEntryTypes["TRANSITION_OFFSET"] = 3] = "TRANSITION_OFFSET";
|
|
71
77
|
TransitionEntryTypes[TransitionEntryTypes["DURATION"] = 4] = "DURATION";
|
|
72
78
|
})(TransitionEntryTypes || (TransitionEntryTypes = {}));
|
|
79
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
73
80
|
var TransitionAdjustmentMultiplierRange;
|
|
74
81
|
(function (TransitionAdjustmentMultiplierRange) {
|
|
75
82
|
TransitionAdjustmentMultiplierRange[TransitionAdjustmentMultiplierRange["MINIMUM_ADJUSTMENT_MULTIPLIER"] = 1] = "MINIMUM_ADJUSTMENT_MULTIPLIER";
|
|
76
83
|
TransitionAdjustmentMultiplierRange[TransitionAdjustmentMultiplierRange["MAXIMUM_ADJUSTMENT_MULTIPLIER"] = 2] = "MAXIMUM_ADJUSTMENT_MULTIPLIER";
|
|
77
84
|
})(TransitionAdjustmentMultiplierRange || (TransitionAdjustmentMultiplierRange = {}));
|
|
85
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
78
86
|
var ValueTransitionConfigurationResponseTypes;
|
|
79
87
|
(function (ValueTransitionConfigurationResponseTypes) {
|
|
80
88
|
ValueTransitionConfigurationResponseTypes[ValueTransitionConfigurationResponseTypes["VALUE_CONFIGURATION_STATUS"] = 1] = "VALUE_CONFIGURATION_STATUS";
|
|
81
89
|
})(ValueTransitionConfigurationResponseTypes || (ValueTransitionConfigurationResponseTypes = {}));
|
|
90
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
82
91
|
var ValueTransitionConfigurationStatusTypes;
|
|
83
92
|
(function (ValueTransitionConfigurationStatusTypes) {
|
|
84
93
|
ValueTransitionConfigurationStatusTypes[ValueTransitionConfigurationStatusTypes["CHARACTERISTIC_IID"] = 1] = "CHARACTERISTIC_IID";
|
|
85
94
|
ValueTransitionConfigurationStatusTypes[ValueTransitionConfigurationStatusTypes["TRANSITION_PARAMETERS"] = 2] = "TRANSITION_PARAMETERS";
|
|
86
95
|
ValueTransitionConfigurationStatusTypes[ValueTransitionConfigurationStatusTypes["TIME_SINCE_START"] = 3] = "TIME_SINCE_START";
|
|
87
96
|
})(ValueTransitionConfigurationStatusTypes || (ValueTransitionConfigurationStatusTypes = {}));
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
97
|
function isAdaptiveLightingContext(context) {
|
|
90
|
-
return context &&
|
|
98
|
+
return context && 'controller' in context;
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* Defines in which mode the {@link AdaptiveLightingController} will operate in.
|
|
94
102
|
* @group Adaptive Lighting
|
|
95
103
|
*/
|
|
96
|
-
|
|
104
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
105
|
+
export var AdaptiveLightingControllerMode;
|
|
97
106
|
(function (AdaptiveLightingControllerMode) {
|
|
98
107
|
/**
|
|
99
108
|
* In automatic mode pretty much everything from setup to transition scheduling is done by the controller.
|
|
@@ -104,11 +113,12 @@ var AdaptiveLightingControllerMode;
|
|
|
104
113
|
* This is useful for lights which natively support transitions.
|
|
105
114
|
*/
|
|
106
115
|
AdaptiveLightingControllerMode[AdaptiveLightingControllerMode["MANUAL"] = 2] = "MANUAL";
|
|
107
|
-
})(AdaptiveLightingControllerMode || (
|
|
116
|
+
})(AdaptiveLightingControllerMode || (AdaptiveLightingControllerMode = {}));
|
|
108
117
|
/**
|
|
109
118
|
* @group Adaptive Lighting
|
|
110
119
|
*/
|
|
111
|
-
|
|
120
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
121
|
+
export var AdaptiveLightingControllerEvents;
|
|
112
122
|
(function (AdaptiveLightingControllerEvents) {
|
|
113
123
|
/**
|
|
114
124
|
* This event is called once a HomeKit controller enables Adaptive Lighting
|
|
@@ -122,7 +132,7 @@ var AdaptiveLightingControllerEvents;
|
|
|
122
132
|
* The current transition will still be associated with the controller object when this event is called.
|
|
123
133
|
*/
|
|
124
134
|
AdaptiveLightingControllerEvents["DISABLED"] = "disable";
|
|
125
|
-
})(AdaptiveLightingControllerEvents || (
|
|
135
|
+
})(AdaptiveLightingControllerEvents || (AdaptiveLightingControllerEvents = {}));
|
|
126
136
|
/**
|
|
127
137
|
* This class allows adding Adaptive Lighting support to Lightbulb services.
|
|
128
138
|
* The Lightbulb service MUST have the {@link Characteristic.ColorTemperature} characteristic AND
|
|
@@ -136,7 +146,7 @@ var AdaptiveLightingControllerEvents;
|
|
|
136
146
|
* (updating the schedule according to your current day/night situation).
|
|
137
147
|
* Once enabled the lightbulb will execute the provided transitions. The color temperature value set is always
|
|
138
148
|
* dependent on the current brightness value. Meaning brighter light will be colder and darker light will be warmer.
|
|
139
|
-
* HomeKit considers Adaptive Lighting to be disabled as soon a write happens to either the
|
|
149
|
+
* HomeKit considers Adaptive Lighting to be disabled as soon a 'write' happens to either the
|
|
140
150
|
* Hue/Saturation or the ColorTemperature characteristics.
|
|
141
151
|
* The AdaptiveLighting state must persist across reboots.
|
|
142
152
|
*
|
|
@@ -153,10 +163,10 @@ var AdaptiveLightingControllerEvents;
|
|
|
153
163
|
*
|
|
154
164
|
* <b>AUTOMATIC (Default mode):</b>
|
|
155
165
|
*
|
|
156
|
-
* This is the easiest mode to
|
|
166
|
+
* This is the easiest mode to set up and needs less to no work form your side for AdaptiveLighting to work.
|
|
157
167
|
* The AdaptiveLightingController will go through setup procedure with HomeKit and automatically update
|
|
158
168
|
* the color temperature characteristic base on the current transition schedule.
|
|
159
|
-
* It is also adjusting the color temperature when a write to the brightness characteristic happens.
|
|
169
|
+
* It is also adjusting the color temperature when a 'write' to the brightness characteristic happens.
|
|
160
170
|
* Additionally, it will also handle turning off AdaptiveLighting, when it detects a write happening to the
|
|
161
171
|
* ColorTemperature, Hue or Saturation characteristic (though it can only detect writes coming from HomeKit and
|
|
162
172
|
* can't detect changes done to the physical devices directly! See below).
|
|
@@ -178,12 +188,12 @@ var AdaptiveLightingControllerEvents;
|
|
|
178
188
|
* - When using Hue/Saturation:
|
|
179
189
|
* When using Hue/Saturation in combination with the ColorTemperature characteristic you need to update the
|
|
180
190
|
* respective other in a particular way depending on if being in "color mode" or "color temperature mode".
|
|
181
|
-
* When a write happens to Hue/Saturation characteristic in is advised to set the internal value of the
|
|
191
|
+
* When a 'write' happens to Hue/Saturation characteristic in is advised to set the internal value of the
|
|
182
192
|
* ColorTemperature to the minimal (NOT RAISING an event).
|
|
183
|
-
* When a write happens to the ColorTemperature characteristic just MUST convert to a proper representation
|
|
193
|
+
* When a 'write' happens to the ColorTemperature characteristic just MUST convert to a proper representation
|
|
184
194
|
* in hue and saturation values, with RAISING an event.
|
|
185
195
|
* As noted above you MUST NOT call the {@link Characteristic.setValue} method for this, as this will be considered
|
|
186
|
-
* a write to the characteristic and will turn off AdaptiveLighting. Instead, you should use
|
|
196
|
+
* a 'write' to the characteristic and will turn off AdaptiveLighting. Instead, you should use
|
|
187
197
|
* {@link Characteristic.updateValue} for this.
|
|
188
198
|
* You can and SHOULD use the supplied utility method {@link ColorUtils.colorTemperatureToHueAndSaturation}
|
|
189
199
|
* for converting mired to hue and saturation values.
|
|
@@ -201,7 +211,7 @@ var AdaptiveLightingControllerEvents;
|
|
|
201
211
|
* are only sent in the defined interval threshold, adjust the color temperature when brightness is changed
|
|
202
212
|
* and signal that Adaptive Lighting should be disabled if ColorTemperature, Hue or Saturation is changed manually.
|
|
203
213
|
*
|
|
204
|
-
* First step is to
|
|
214
|
+
* First step is to set up an event handler for the {@link AdaptiveLightingControllerEvents.UPDATE}, which is called
|
|
205
215
|
* when AdaptiveLighting is enabled, the HomeHub updates the schedule for the next 24 hours or AdaptiveLighting
|
|
206
216
|
* is restored from disk on startup.
|
|
207
217
|
* In the event handler you can get the current schedule via {@link AdaptiveLightingController.getAdaptiveLightingTransitionCurve},
|
|
@@ -215,14 +225,14 @@ var AdaptiveLightingControllerEvents;
|
|
|
215
225
|
* the color temperature when the brightness of the lightbulb changes (see {@link AdaptiveLightingTransitionCurveEntry.brightnessAdjustmentFactor}),
|
|
216
226
|
* and signal when AdaptiveLighting got disabled by calling {@link AdaptiveLightingController.disableAdaptiveLighting}
|
|
217
227
|
* when ColorTemperature, Hue or Saturation where changed manually.
|
|
218
|
-
* Lastly you should set up
|
|
228
|
+
* Lastly you should set up an event handler for the {@link AdaptiveLightingControllerEvents.DISABLED} event.
|
|
219
229
|
* In yet unknown circumstances HomeKit may also send a dedicated disable command via the control point characteristic.
|
|
220
230
|
* Be prepared to handle that.
|
|
221
231
|
*
|
|
222
232
|
* @group Adaptive Lighting
|
|
223
233
|
*/
|
|
224
|
-
// eslint-disable-next-line
|
|
225
|
-
class AdaptiveLightingController extends
|
|
234
|
+
// eslint-disable-next-line ts/no-unsafe-declaration-merging
|
|
235
|
+
export class AdaptiveLightingController extends EventEmitter {
|
|
226
236
|
stateChangeDelegate;
|
|
227
237
|
lightbulb;
|
|
228
238
|
mode;
|
|
@@ -256,8 +266,8 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
256
266
|
this.lightbulb = service;
|
|
257
267
|
this.mode = options?.controllerMode ?? 1 /* AdaptiveLightingControllerMode.AUTOMATIC */;
|
|
258
268
|
this.customTemperatureAdjustment = options?.customTemperatureAdjustment ?? 0;
|
|
259
|
-
(
|
|
260
|
-
(
|
|
269
|
+
assert(this.lightbulb.testCharacteristic(Characteristic.ColorTemperature), 'Lightbulb must have the ColorTemperature characteristic added!');
|
|
270
|
+
assert(this.lightbulb.testCharacteristic(Characteristic.Brightness), 'Lightbulb must have the Brightness characteristic added!');
|
|
261
271
|
this.adjustmentFactorChangedListener = this.handleAdjustmentFactorChanged.bind(this);
|
|
262
272
|
this.characteristicManualWrittenChangeListener = this.handleCharacteristicManualWritten.bind(this);
|
|
263
273
|
}
|
|
@@ -265,11 +275,11 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
265
275
|
* @private
|
|
266
276
|
*/
|
|
267
277
|
controllerId() {
|
|
268
|
-
return "characteristic-transition" /* DefaultControllerType.CHARACTERISTIC_TRANSITION */
|
|
278
|
+
return `${"characteristic-transition" /* DefaultControllerType.CHARACTERISTIC_TRANSITION */}-${this.lightbulb.getServiceId()}`;
|
|
269
279
|
}
|
|
270
280
|
// ----------- PUBLIC API START -----------
|
|
271
281
|
/**
|
|
272
|
-
* Returns if
|
|
282
|
+
* Returns if an Adaptive Lighting transition is currently active.
|
|
273
283
|
*/
|
|
274
284
|
isAdaptiveLightingActive() {
|
|
275
285
|
return !!this.activeTransition;
|
|
@@ -305,68 +315,68 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
305
315
|
this.lastNotifiedHueValue = 0;
|
|
306
316
|
this.didRunFirstInitializationStep = false;
|
|
307
317
|
this.activeTransitionCount?.sendEventNotification(0);
|
|
308
|
-
debug(
|
|
318
|
+
debug('[%s] Disabling adaptive lighting', this.lightbulb.displayName);
|
|
309
319
|
}
|
|
310
320
|
/**
|
|
311
|
-
* Returns the time
|
|
321
|
+
* Returns the time when the current transition curve was started in epoch time millis.
|
|
312
322
|
* A transition curves is active for 24 hours typically and is renewed every 24 hours by a HomeHub.
|
|
313
|
-
* Additionally see {@link getAdaptiveLightingTimeOffset}.
|
|
323
|
+
* Additionally, see {@link getAdaptiveLightingTimeOffset}.
|
|
314
324
|
*/
|
|
315
325
|
getAdaptiveLightingStartTimeOfTransition() {
|
|
316
326
|
if (!this.activeTransition) {
|
|
317
|
-
throw new Error(
|
|
327
|
+
throw new Error('There is no active transition!');
|
|
318
328
|
}
|
|
319
329
|
return this.activeTransition.transitionStartMillis;
|
|
320
330
|
}
|
|
321
331
|
/**
|
|
322
332
|
* It is not necessarily given, that we have the same time (or rather the correct time) as the HomeKit controller
|
|
323
333
|
* who set up the transition schedule.
|
|
324
|
-
* Thus we record the delta between our current time and the
|
|
334
|
+
* Thus, we record the delta between our current time and the time send with the setup request.
|
|
325
335
|
* <code>timeOffset</code> is defined as <code>Date.now() - getAdaptiveLightingStartTimeOfTransition();</code>.
|
|
326
336
|
* So in the case were we actually have a correct local time, it most likely will be positive (due to network latency).
|
|
327
337
|
* But of course it can also be negative.
|
|
328
338
|
*/
|
|
329
339
|
getAdaptiveLightingTimeOffset() {
|
|
330
340
|
if (!this.activeTransition) {
|
|
331
|
-
throw new Error(
|
|
341
|
+
throw new Error('There is no active transition!');
|
|
332
342
|
}
|
|
333
343
|
return this.activeTransition.timeMillisOffset;
|
|
334
344
|
}
|
|
335
345
|
getAdaptiveLightingTransitionCurve() {
|
|
336
346
|
if (!this.activeTransition) {
|
|
337
|
-
throw new Error(
|
|
347
|
+
throw new Error('There is no active transition!');
|
|
338
348
|
}
|
|
339
349
|
return this.activeTransition.transitionCurve;
|
|
340
350
|
}
|
|
341
351
|
getAdaptiveLightingBrightnessMultiplierRange() {
|
|
342
352
|
if (!this.activeTransition) {
|
|
343
|
-
throw new Error(
|
|
353
|
+
throw new Error('There is no active transition!');
|
|
344
354
|
}
|
|
345
355
|
return this.activeTransition.brightnessAdjustmentRange;
|
|
346
356
|
}
|
|
347
357
|
/**
|
|
348
358
|
* This method returns the interval (in milliseconds) in which the light should update its internal color temperature
|
|
349
359
|
* (aka changes it physical color).
|
|
350
|
-
* A lightbulb should ideally change this also when turned
|
|
360
|
+
* A lightbulb should ideally change this also when turned off in oder to have a smooth transition when turning the light on.
|
|
351
361
|
*
|
|
352
|
-
* Typically this evaluates to 60000 milliseconds (60 seconds).
|
|
362
|
+
* Typically, this evaluates to 60000 milliseconds (60 seconds).
|
|
353
363
|
*/
|
|
354
364
|
getAdaptiveLightingUpdateInterval() {
|
|
355
365
|
if (!this.activeTransition) {
|
|
356
|
-
throw new Error(
|
|
366
|
+
throw new Error('There is no active transition!');
|
|
357
367
|
}
|
|
358
368
|
return this.activeTransition.updateInterval;
|
|
359
369
|
}
|
|
360
370
|
/**
|
|
361
|
-
* Returns the minimum interval threshold (in milliseconds)
|
|
371
|
+
* Returns the minimum interval threshold (in milliseconds) an accessory may notify HomeKit controllers about a new
|
|
362
372
|
* color temperature value via event notifications (what happens when you call {@link Characteristic.updateValue}).
|
|
363
373
|
* Meaning the accessory should only send event notifications to subscribed HomeKit controllers at the specified interval.
|
|
364
374
|
*
|
|
365
|
-
* Typically this evaluates to 600000 milliseconds (10 minutes).
|
|
375
|
+
* Typically, this evaluates to 600000 milliseconds (10 minutes).
|
|
366
376
|
*/
|
|
367
377
|
getAdaptiveLightingNotifyIntervalThreshold() {
|
|
368
378
|
if (!this.activeTransition) {
|
|
369
|
-
throw new Error(
|
|
379
|
+
throw new Error('There is no active transition!');
|
|
370
380
|
}
|
|
371
381
|
return this.activeTransition.notifyIntervalThreshold;
|
|
372
382
|
}
|
|
@@ -385,7 +395,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
385
395
|
}
|
|
386
396
|
else if (this.mode === 2 /* AdaptiveLightingControllerMode.MANUAL */) {
|
|
387
397
|
if (!this.activeTransition) {
|
|
388
|
-
throw new Error(
|
|
398
|
+
throw new Error('There is no active transition!');
|
|
389
399
|
}
|
|
390
400
|
const update = {
|
|
391
401
|
transitionStartMillis: this.activeTransition.transitionStartMillis,
|
|
@@ -398,7 +408,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
398
408
|
this.emit("update" /* AdaptiveLightingControllerEvents.UPDATE */, update);
|
|
399
409
|
}
|
|
400
410
|
else {
|
|
401
|
-
throw new Error(
|
|
411
|
+
throw new Error(`Unsupported adaptive lighting controller mode: ${this.mode}`);
|
|
402
412
|
}
|
|
403
413
|
if (!calledFromDeserializer) {
|
|
404
414
|
this.stateChangeDelegate?.();
|
|
@@ -406,18 +416,18 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
406
416
|
}
|
|
407
417
|
handleAdaptiveLightingEnabled() {
|
|
408
418
|
if (!this.activeTransition) {
|
|
409
|
-
throw new Error(
|
|
419
|
+
throw new Error('There is no active transition!');
|
|
410
420
|
}
|
|
411
|
-
this.colorTemperatureCharacteristic = this.lightbulb.getCharacteristic(
|
|
412
|
-
this.brightnessCharacteristic = this.lightbulb.getCharacteristic(
|
|
421
|
+
this.colorTemperatureCharacteristic = this.lightbulb.getCharacteristic(Characteristic.ColorTemperature);
|
|
422
|
+
this.brightnessCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Brightness);
|
|
413
423
|
this.colorTemperatureCharacteristic.on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
|
|
414
424
|
this.brightnessCharacteristic.on("change" /* CharacteristicEventTypes.CHANGE */, this.adjustmentFactorChangedListener);
|
|
415
|
-
if (this.lightbulb.testCharacteristic(
|
|
416
|
-
this.hueCharacteristic = this.lightbulb.getCharacteristic(
|
|
425
|
+
if (this.lightbulb.testCharacteristic(Characteristic.Hue)) {
|
|
426
|
+
this.hueCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Hue)
|
|
417
427
|
.on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
|
|
418
428
|
}
|
|
419
|
-
if (this.lightbulb.testCharacteristic(
|
|
420
|
-
this.saturationCharacteristic = this.lightbulb.getCharacteristic(
|
|
429
|
+
if (this.lightbulb.testCharacteristic(Characteristic.Saturation)) {
|
|
430
|
+
this.saturationCharacteristic = this.lightbulb.getCharacteristic(Characteristic.Saturation)
|
|
421
431
|
.on("change" /* CharacteristicEventTypes.CHANGE */, this.characteristicManualWrittenChangeListener);
|
|
422
432
|
}
|
|
423
433
|
}
|
|
@@ -434,8 +444,8 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
434
444
|
// consider the following scenario:
|
|
435
445
|
// a HomeKit controller queries the light (meaning e.g. Brightness, Hue and Saturation characteristics).
|
|
436
446
|
// As of the implementation of the light the brightness characteristic get handler returns first
|
|
437
|
-
// (and returns a value different
|
|
438
|
-
// This change handler gets called and we will update the color temperature accordingly
|
|
447
|
+
// (and returns a value different from the cached value).
|
|
448
|
+
// This change handler gets called, and we will update the color temperature accordingly
|
|
439
449
|
// (which also adjusts the internal cached values for Hue and Saturation).
|
|
440
450
|
// After some short time the Hue or Saturation get handler return with the last known value to the plugin.
|
|
441
451
|
// As those values now differ from the cached values (we already updated) we get a call to handleCharacteristicManualWritten
|
|
@@ -446,7 +456,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
446
456
|
// It doesn't ensure that those race conditions do not happen anymore, but with a 1s delay it reduces the possibility by a bit
|
|
447
457
|
setTimeout(() => {
|
|
448
458
|
if (!this.activeTransition) {
|
|
449
|
-
return; // was disabled in the
|
|
459
|
+
return; // was disabled in the meantime
|
|
450
460
|
}
|
|
451
461
|
this.scheduleNextUpdate(true);
|
|
452
462
|
}, 1000).unref();
|
|
@@ -457,7 +467,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
457
467
|
}
|
|
458
468
|
/**
|
|
459
469
|
* This method is called when a change happens to the Hue/Saturation or ColorTemperature characteristic.
|
|
460
|
-
* When such a write happens (caused by the user changing the color/temperature) Adaptive Lighting must be disabled.
|
|
470
|
+
* When such a 'write' happens (caused by the user changing the color/temperature) Adaptive Lighting must be disabled.
|
|
461
471
|
*
|
|
462
472
|
* @param change
|
|
463
473
|
*/
|
|
@@ -466,7 +476,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
466
476
|
// we ignore write request which are the result of calls made to updateValue or sendEventNotification
|
|
467
477
|
// or the result of a changed value returned by a read handler
|
|
468
478
|
// or the change was done by the controller itself
|
|
469
|
-
debug(
|
|
479
|
+
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);
|
|
470
480
|
this.disableAdaptiveLighting();
|
|
471
481
|
}
|
|
472
482
|
}
|
|
@@ -476,7 +486,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
476
486
|
*/
|
|
477
487
|
getCurrentAdaptiveLightingTransitionPoint() {
|
|
478
488
|
if (!this.activeTransition) {
|
|
479
|
-
throw new Error(
|
|
489
|
+
throw new Error('Cannot calculate current transition point if no transition is active!');
|
|
480
490
|
}
|
|
481
491
|
// adjustedNow is the now() date corrected to the time of the initiating controller
|
|
482
492
|
const adjustedNow = Date.now() - this.activeTransition.timeMillisOffset;
|
|
@@ -484,8 +494,8 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
484
494
|
const offset = adjustedNow - this.activeTransition.transitionStartMillis;
|
|
485
495
|
let i = this.lastTransitionPointInfo?.curveIndex ?? 0;
|
|
486
496
|
let lowerBoundTimeOffset = this.lastTransitionPointInfo?.lowerBoundTimeOffset ?? 0; // time offset to the lowerBound transition entry
|
|
487
|
-
let lowerBound
|
|
488
|
-
let upperBound
|
|
497
|
+
let lowerBound;
|
|
498
|
+
let upperBound;
|
|
489
499
|
for (; i + 1 < this.activeTransition.transitionCurve.length; i++) {
|
|
490
500
|
const lowerBound0 = this.activeTransition.transitionCurve[i];
|
|
491
501
|
const upperBound0 = this.activeTransition.transitionCurve[i + 1];
|
|
@@ -501,7 +511,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
501
511
|
else if (this.lastTransitionPointInfo) {
|
|
502
512
|
// if we reached here the entry in the transitionCurve we are searching for is somewhere before current i.
|
|
503
513
|
// This can only happen when we have a faulty lastTransitionPointInfo (otherwise we would start from i=0).
|
|
504
|
-
// Thus we try again by searching from i=0
|
|
514
|
+
// Thus, we try again by searching from i=0
|
|
505
515
|
this.lastTransitionPointInfo = undefined;
|
|
506
516
|
return this.getCurrentAdaptiveLightingTransitionPoint();
|
|
507
517
|
}
|
|
@@ -515,19 +525,19 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
515
525
|
curveIndex: i,
|
|
516
526
|
// we need to subtract lowerBound.transitionTime. When we start the loop above
|
|
517
527
|
// with a saved transition point, we will always add lowerBound.transitionTime as first step.
|
|
518
|
-
// Otherwise our calculations are simply wrong.
|
|
528
|
+
// Otherwise, our calculations are simply wrong.
|
|
519
529
|
lowerBoundTimeOffset: lowerBoundTimeOffset - lowerBound.transitionTime,
|
|
520
530
|
};
|
|
521
531
|
return {
|
|
522
|
-
lowerBoundTimeOffset
|
|
532
|
+
lowerBoundTimeOffset,
|
|
523
533
|
transitionOffset: offset - lowerBoundTimeOffset,
|
|
524
|
-
lowerBound
|
|
525
|
-
upperBound
|
|
534
|
+
lowerBound,
|
|
535
|
+
upperBound,
|
|
526
536
|
};
|
|
527
537
|
}
|
|
528
538
|
scheduleNextUpdate(dryRun = false) {
|
|
529
539
|
if (!this.activeTransition) {
|
|
530
|
-
throw new Error(
|
|
540
|
+
throw new Error('tried scheduling transition when no transition was active!');
|
|
531
541
|
}
|
|
532
542
|
if (!dryRun) {
|
|
533
543
|
this.updateTimeout = undefined;
|
|
@@ -538,7 +548,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
538
548
|
}
|
|
539
549
|
const transitionPoint = this.getCurrentAdaptiveLightingTransitionPoint();
|
|
540
550
|
if (!transitionPoint) {
|
|
541
|
-
debug(
|
|
551
|
+
debug('[%s] Reached end of transition curve!', this.lightbulb.displayName);
|
|
542
552
|
if (!dryRun) {
|
|
543
553
|
// the transition schedule is only for 24 hours, we reached the end?
|
|
544
554
|
this.disableAdaptiveLighting();
|
|
@@ -566,8 +576,8 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
566
576
|
const min = this.colorTemperatureCharacteristic?.props.minValue ?? 140;
|
|
567
577
|
const max = this.colorTemperatureCharacteristic?.props.maxValue ?? 500;
|
|
568
578
|
temperature = Math.max(min, Math.min(max, temperature));
|
|
569
|
-
const color =
|
|
570
|
-
debug(
|
|
579
|
+
const color = ColorUtils.colorTemperatureToHueAndSaturation(temperature);
|
|
580
|
+
debug('[%s] Next temperature value is %d (for brightness %d adj: %s)', this.lightbulb.displayName, temperature, adjustmentMultiplier, this.customTemperatureAdjustment);
|
|
571
581
|
const context = {
|
|
572
582
|
controller: this,
|
|
573
583
|
omitEventUpdate: true,
|
|
@@ -575,8 +585,8 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
575
585
|
/*
|
|
576
586
|
* We set saturation and hue values BEFORE we call the ColorTemperature SET handler (via setValue).
|
|
577
587
|
* First thought was so the API user could get the values in the SET handler of the color temperature characteristic.
|
|
578
|
-
* Do this is probably not really elegant
|
|
579
|
-
*
|
|
588
|
+
* Do this is probably not really elegant because this would only work when Adaptive Lighting is turned on
|
|
589
|
+
* and the accessory MUST in any case update the Hue/Saturation values on a ColorTemperature write
|
|
580
590
|
* (obviously only if Hue/Saturation characteristics are added to the service).
|
|
581
591
|
*
|
|
582
592
|
* The clever thing about this though is that, that it prevents notifications from being sent for Hue and Saturation
|
|
@@ -593,18 +603,18 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
593
603
|
if (this.hueCharacteristic) {
|
|
594
604
|
this.hueCharacteristic.value = color.hue;
|
|
595
605
|
}
|
|
596
|
-
this.colorTemperatureCharacteristic?.handleSetRequest(temperature, undefined, context).catch(reason => {
|
|
597
|
-
debug(
|
|
606
|
+
this.colorTemperatureCharacteristic?.handleSetRequest(temperature, undefined, context).catch((reason) => {
|
|
607
|
+
debug('[%s] Failed to next adaptive lighting transition point: %d', this.lightbulb.displayName, reason);
|
|
598
608
|
});
|
|
599
609
|
if (!this.activeTransition) {
|
|
600
|
-
console.warn(
|
|
601
|
-
|
|
602
|
-
|
|
610
|
+
console.warn(`[${this.lightbulb.displayName}] Adaptive Lighting was probably disable my mistake by some call in `
|
|
611
|
+
+ `the SET handler of the ColorTemperature characteristic! `
|
|
612
|
+
+ `Please check that you don't call setValue/setCharacteristic on the Hue, Saturation or ColorTemperature characteristic!`);
|
|
603
613
|
return;
|
|
604
614
|
}
|
|
605
615
|
const now = Date.now();
|
|
606
616
|
if (!dryRun && now - this.lastEventNotificationSent >= this.activeTransition.notifyIntervalThreshold) {
|
|
607
|
-
debug(
|
|
617
|
+
debug('[%s] Sending event notifications for current transition!', this.lightbulb.displayName);
|
|
608
618
|
this.lastEventNotificationSent = now;
|
|
609
619
|
const eventContext = {
|
|
610
620
|
controller: this,
|
|
@@ -635,7 +645,7 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
635
645
|
/**
|
|
636
646
|
* @private
|
|
637
647
|
*/
|
|
638
|
-
// eslint-disable-next-line
|
|
648
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
639
649
|
initWithServices(serviceMap) {
|
|
640
650
|
// do nothing
|
|
641
651
|
}
|
|
@@ -643,26 +653,26 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
643
653
|
* @private
|
|
644
654
|
*/
|
|
645
655
|
configureServices() {
|
|
646
|
-
this.supportedTransitionConfiguration = this.lightbulb.getCharacteristic(
|
|
647
|
-
this.transitionControl = this.lightbulb.getCharacteristic(
|
|
648
|
-
.updateValue(
|
|
649
|
-
this.activeTransitionCount = this.lightbulb.getCharacteristic(
|
|
656
|
+
this.supportedTransitionConfiguration = this.lightbulb.getCharacteristic(Characteristic.SupportedCharacteristicValueTransitionConfiguration);
|
|
657
|
+
this.transitionControl = this.lightbulb.getCharacteristic(Characteristic.CharacteristicValueTransitionControl)
|
|
658
|
+
.updateValue('');
|
|
659
|
+
this.activeTransitionCount = this.lightbulb.getCharacteristic(Characteristic.CharacteristicValueActiveTransitionCount)
|
|
650
660
|
.updateValue(0);
|
|
651
661
|
this.supportedTransitionConfiguration
|
|
652
662
|
.onGet(this.handleSupportedTransitionConfigurationRead.bind(this));
|
|
653
663
|
this.transitionControl
|
|
654
664
|
.onGet(() => {
|
|
655
|
-
return this.buildTransitionControlResponseBuffer().toString(
|
|
665
|
+
return this.buildTransitionControlResponseBuffer().toString('base64');
|
|
656
666
|
})
|
|
657
|
-
.onSet(value => {
|
|
667
|
+
.onSet((value) => {
|
|
658
668
|
try {
|
|
659
669
|
return this.handleTransitionControlWrite(value);
|
|
660
670
|
}
|
|
661
671
|
catch (error) {
|
|
662
672
|
console.warn(`[%s] DEBUG: '${value}'`);
|
|
663
|
-
console.warn(
|
|
673
|
+
console.warn(`[%s] Encountered error on CharacteristicValueTransitionControl characteristic: ${error.stack}`);
|
|
664
674
|
this.disableAdaptiveLighting();
|
|
665
|
-
throw new
|
|
675
|
+
throw new HapStatusError(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
|
|
666
676
|
}
|
|
667
677
|
});
|
|
668
678
|
}
|
|
@@ -719,14 +729,14 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
719
729
|
this.stateChangeDelegate = delegate;
|
|
720
730
|
}
|
|
721
731
|
handleSupportedTransitionConfigurationRead() {
|
|
722
|
-
const brightnessIID = this.lightbulb?.getCharacteristic(
|
|
723
|
-
const temperatureIID = this.lightbulb?.getCharacteristic(
|
|
724
|
-
(
|
|
725
|
-
(
|
|
726
|
-
return
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
]).toString(
|
|
732
|
+
const brightnessIID = this.lightbulb?.getCharacteristic(Characteristic.Brightness).iid;
|
|
733
|
+
const temperatureIID = this.lightbulb?.getCharacteristic(Characteristic.ColorTemperature).iid;
|
|
734
|
+
assert(brightnessIID, 'iid for brightness characteristic is undefined');
|
|
735
|
+
assert(temperatureIID, 'iid for temperature characteristic is undefined');
|
|
736
|
+
return encode(1 /* SupportedCharacteristicValueTransitionConfigurationsTypes.SUPPORTED_TRANSITION_CONFIGURATION */, [
|
|
737
|
+
encode(1 /* SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, writeVariableUIntLE(brightnessIID), 2 /* SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE */, 1 /* TransitionType.BRIGHTNESS */),
|
|
738
|
+
encode(1 /* SupportedValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, writeVariableUIntLE(temperatureIID), 2 /* SupportedValueTransitionConfigurationTypes.TRANSITION_TYPE */, 2 /* TransitionType.COLOR_TEMPERATURE */),
|
|
739
|
+
]).toString('base64');
|
|
730
740
|
}
|
|
731
741
|
buildTransitionControlResponseBuffer(time) {
|
|
732
742
|
if (!this.activeTransition) {
|
|
@@ -734,22 +744,22 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
734
744
|
}
|
|
735
745
|
const active = this.activeTransition;
|
|
736
746
|
const timeSinceStart = time ?? (Date.now() - active.timeMillisOffset - active.transitionStartMillis);
|
|
737
|
-
const timeSinceStartBuffer =
|
|
738
|
-
let parameters =
|
|
747
|
+
const timeSinceStartBuffer = writeVariableUIntLE(timeSinceStart);
|
|
748
|
+
let parameters = encode(1 /* ValueTransitionParametersTypes.TRANSITION_ID */, write(active.transitionId), 2 /* ValueTransitionParametersTypes.START_TIME */, Buffer.from(active.transitionStartBuffer, 'hex'));
|
|
739
749
|
if (active.id3) {
|
|
740
750
|
parameters = Buffer.concat([
|
|
741
751
|
parameters,
|
|
742
|
-
|
|
752
|
+
encode(3 /* ValueTransitionParametersTypes.UNKNOWN_3 */, Buffer.from(active.id3, 'hex')),
|
|
743
753
|
]);
|
|
744
754
|
}
|
|
745
|
-
const status =
|
|
746
|
-
return
|
|
755
|
+
const status = encode(1 /* ValueTransitionConfigurationStatusTypes.CHARACTERISTIC_IID */, writeVariableUIntLE(active.iid), 2 /* ValueTransitionConfigurationStatusTypes.TRANSITION_PARAMETERS */, parameters, 3 /* ValueTransitionConfigurationStatusTypes.TIME_SINCE_START */, timeSinceStartBuffer);
|
|
756
|
+
return encode(1 /* ValueTransitionConfigurationResponseTypes.VALUE_CONFIGURATION_STATUS */, status);
|
|
747
757
|
}
|
|
748
758
|
handleTransitionControlWrite(value) {
|
|
749
|
-
if (typeof value !==
|
|
750
|
-
throw new
|
|
759
|
+
if (typeof value !== 'string') {
|
|
760
|
+
throw new HapStatusError(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
751
761
|
}
|
|
752
|
-
const tlvData =
|
|
762
|
+
const tlvData = decode(Buffer.from(value, 'base64'));
|
|
753
763
|
const responseBuffers = [];
|
|
754
764
|
const readTransition = tlvData[1 /* TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION */];
|
|
755
765
|
if (readTransition) {
|
|
@@ -765,63 +775,62 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
765
775
|
responseBuffers.push(updateTransitionResponse);
|
|
766
776
|
}
|
|
767
777
|
}
|
|
768
|
-
return Buffer.concat(responseBuffers).toString(
|
|
778
|
+
return Buffer.concat(responseBuffers).toString('base64');
|
|
769
779
|
}
|
|
770
780
|
handleTransitionControlReadTransition(buffer) {
|
|
771
|
-
const readTransition =
|
|
772
|
-
const iid =
|
|
781
|
+
const readTransition = decode(buffer);
|
|
782
|
+
const iid = readVariableUIntLE(readTransition[1 /* ReadValueTransitionConfiguration.CHARACTERISTIC_IID */]);
|
|
773
783
|
if (this.activeTransition) {
|
|
774
784
|
if (this.activeTransition.iid !== iid) {
|
|
775
|
-
console.warn(
|
|
776
|
-
|
|
777
|
-
throw new hapStatusError_1.HapStatusError(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
785
|
+
console.warn(`[${this.lightbulb.displayName}] iid of current adaptive lighting transition (${this.activeTransition.iid}) doesn't match the requested one ${iid}`);
|
|
786
|
+
throw new HapStatusError(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
778
787
|
}
|
|
779
|
-
let parameters =
|
|
788
|
+
let parameters = encode(1 /* ValueTransitionParametersTypes.TRANSITION_ID */, write(this.activeTransition.transitionId), 2 /* ValueTransitionParametersTypes.START_TIME */, Buffer.from(this.activeTransition.transitionStartBuffer, 'hex'));
|
|
780
789
|
if (this.activeTransition.id3) {
|
|
781
790
|
parameters = Buffer.concat([
|
|
782
791
|
parameters,
|
|
783
|
-
|
|
792
|
+
encode(3 /* ValueTransitionParametersTypes.UNKNOWN_3 */, Buffer.from(this.activeTransition.id3, 'hex')),
|
|
784
793
|
]);
|
|
785
794
|
}
|
|
786
|
-
return
|
|
795
|
+
return encode(1 /* TransitionControlTypes.READ_CURRENT_VALUE_TRANSITION_CONFIGURATION */, encode(1 /* ValueTransitionConfigurationTypes.CHARACTERISTIC_IID */, writeVariableUIntLE(this.activeTransition.iid), 2 /* ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS */, parameters, 3 /* ValueTransitionConfigurationTypes.UNKNOWN_3 */, 1, 5 /* ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION */, encode(1 /* TransitionCurveConfigurationTypes.TRANSITION_ENTRY */, this.activeTransition.transitionCurve.map((entry, index, array) => {
|
|
787
796
|
const duration = array[index - 1]?.duration ?? 0; // we store stuff differently :sweat_smile:
|
|
788
|
-
return
|
|
789
|
-
}), 2 /* TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID */,
|
|
797
|
+
return encode(1 /* TransitionEntryTypes.ADJUSTMENT_FACTOR */, writeFloat32LE(entry.brightnessAdjustmentFactor), 2 /* TransitionEntryTypes.VALUE */, writeFloat32LE(entry.temperature), 3 /* TransitionEntryTypes.TRANSITION_OFFSET */, writeVariableUIntLE(entry.transitionTime), 4 /* TransitionEntryTypes.DURATION */, writeVariableUIntLE(duration));
|
|
798
|
+
}), 2 /* TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID */, writeVariableUIntLE(this.activeTransition.brightnessCharacteristicIID), 3 /* TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE */, encode(1 /* TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER */, writeUInt32(this.activeTransition.brightnessAdjustmentRange.minBrightnessValue), 2 /* TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER */, writeUInt32(this.activeTransition.brightnessAdjustmentRange.maxBrightnessValue))), 6 /* ValueTransitionConfigurationTypes.UPDATE_INTERVAL */, writeVariableUIntLE(this.activeTransition.updateInterval), 8 /* ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD */, writeVariableUIntLE(this.activeTransition.notifyIntervalThreshold)));
|
|
790
799
|
}
|
|
791
800
|
else {
|
|
792
801
|
return undefined; // returns empty string
|
|
793
802
|
}
|
|
794
803
|
}
|
|
795
804
|
handleTransitionControlUpdateTransition(buffer) {
|
|
796
|
-
const updateTransition =
|
|
797
|
-
const transitionConfiguration =
|
|
798
|
-
const iid =
|
|
805
|
+
const updateTransition = decode(buffer);
|
|
806
|
+
const transitionConfiguration = decode(updateTransition[1 /* UpdateValueTransitionConfigurationsTypes.VALUE_TRANSITION_CONFIGURATION */]);
|
|
807
|
+
const iid = readVariableUIntLE(transitionConfiguration[1 /* ValueTransitionConfigurationTypes.CHARACTERISTIC_IID */]);
|
|
799
808
|
if (!this.lightbulb.getCharacteristicByIID(iid)) {
|
|
800
|
-
throw new
|
|
809
|
+
throw new HapStatusError(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
|
|
801
810
|
}
|
|
802
811
|
const param3 = transitionConfiguration[3 /* ValueTransitionConfigurationTypes.UNKNOWN_3 */]?.readUInt8(0); // when present it is always 1
|
|
803
812
|
if (!param3) { // if HomeKit just sends the iid, we consider that as "disable adaptive lighting" (assumption)
|
|
804
813
|
this.handleAdaptiveLightingDisabled();
|
|
805
|
-
return
|
|
814
|
+
return encode(2 /* TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION */, Buffer.alloc(0));
|
|
806
815
|
}
|
|
807
|
-
const parametersTLV =
|
|
808
|
-
const curveConfiguration =
|
|
816
|
+
const parametersTLV = decode(transitionConfiguration[2 /* ValueTransitionConfigurationTypes.TRANSITION_PARAMETERS */]);
|
|
817
|
+
const curveConfiguration = decodeWithLists(transitionConfiguration[5 /* ValueTransitionConfigurationTypes.TRANSITION_CURVE_CONFIGURATION */]);
|
|
809
818
|
const updateInterval = transitionConfiguration[6 /* ValueTransitionConfigurationTypes.UPDATE_INTERVAL */]?.readUInt16LE(0);
|
|
810
819
|
const notifyIntervalThreshold = transitionConfiguration[8 /* ValueTransitionConfigurationTypes.NOTIFY_INTERVAL_THRESHOLD */].readUInt32LE(0);
|
|
811
820
|
const transitionId = parametersTLV[1 /* ValueTransitionParametersTypes.TRANSITION_ID */];
|
|
812
821
|
const startTime = parametersTLV[2 /* ValueTransitionParametersTypes.START_TIME */];
|
|
813
822
|
const id3 = parametersTLV[3 /* ValueTransitionParametersTypes.UNKNOWN_3 */]; // this may be undefined
|
|
814
|
-
const startTimeMillis =
|
|
823
|
+
const startTimeMillis = epochMillisFromMillisSince2001_01_01Buffer(startTime);
|
|
815
824
|
const timeMillisOffset = Date.now() - startTimeMillis;
|
|
816
825
|
const transitionCurve = [];
|
|
817
|
-
let previous
|
|
826
|
+
let previous;
|
|
818
827
|
const transitions = curveConfiguration[1 /* TransitionCurveConfigurationTypes.TRANSITION_ENTRY */];
|
|
819
828
|
for (const entry of transitions) {
|
|
820
|
-
const tlvEntry =
|
|
829
|
+
const tlvEntry = decode(entry);
|
|
821
830
|
const adjustmentFactor = tlvEntry[1 /* TransitionEntryTypes.ADJUSTMENT_FACTOR */].readFloatLE(0);
|
|
822
831
|
const value = tlvEntry[2 /* TransitionEntryTypes.VALUE */].readFloatLE(0);
|
|
823
|
-
const transitionOffset =
|
|
824
|
-
const duration = tlvEntry[4 /* TransitionEntryTypes.DURATION */] ?
|
|
832
|
+
const transitionOffset = readVariableUIntLE(tlvEntry[3 /* TransitionEntryTypes.TRANSITION_OFFSET */]);
|
|
833
|
+
const duration = tlvEntry[4 /* TransitionEntryTypes.DURATION */] ? readVariableUIntLE(tlvEntry[4 /* TransitionEntryTypes.DURATION */]) : undefined;
|
|
825
834
|
if (previous) {
|
|
826
835
|
previous.duration = duration;
|
|
827
836
|
}
|
|
@@ -832,37 +841,36 @@ class AdaptiveLightingController extends events_1.EventEmitter {
|
|
|
832
841
|
};
|
|
833
842
|
transitionCurve.push(previous);
|
|
834
843
|
}
|
|
835
|
-
const adjustmentIID =
|
|
836
|
-
const adjustmentMultiplierRange =
|
|
844
|
+
const adjustmentIID = readVariableUIntLE(curveConfiguration[2 /* TransitionCurveConfigurationTypes.ADJUSTMENT_CHARACTERISTIC_IID */]);
|
|
845
|
+
const adjustmentMultiplierRange = decode(curveConfiguration[3 /* TransitionCurveConfigurationTypes.ADJUSTMENT_MULTIPLIER_RANGE */]);
|
|
837
846
|
const minAdjustmentMultiplier = adjustmentMultiplierRange[1 /* TransitionAdjustmentMultiplierRange.MINIMUM_ADJUSTMENT_MULTIPLIER */].readUInt32LE(0);
|
|
838
847
|
const maxAdjustmentMultiplier = adjustmentMultiplierRange[2 /* TransitionAdjustmentMultiplierRange.MAXIMUM_ADJUSTMENT_MULTIPLIER */].readUInt32LE(0);
|
|
839
848
|
this.activeTransition = {
|
|
840
|
-
iid
|
|
849
|
+
iid,
|
|
841
850
|
transitionStartMillis: startTimeMillis,
|
|
842
|
-
timeMillisOffset
|
|
843
|
-
transitionId:
|
|
844
|
-
transitionStartBuffer: startTime.toString(
|
|
845
|
-
id3: id3?.toString(
|
|
851
|
+
timeMillisOffset,
|
|
852
|
+
transitionId: unparse(transitionId),
|
|
853
|
+
transitionStartBuffer: startTime.toString('hex'),
|
|
854
|
+
id3: id3?.toString('hex'),
|
|
846
855
|
brightnessCharacteristicIID: adjustmentIID,
|
|
847
856
|
brightnessAdjustmentRange: {
|
|
848
857
|
minBrightnessValue: minAdjustmentMultiplier,
|
|
849
858
|
maxBrightnessValue: maxAdjustmentMultiplier,
|
|
850
859
|
},
|
|
851
|
-
transitionCurve
|
|
860
|
+
transitionCurve,
|
|
852
861
|
updateInterval: updateInterval ?? 60000,
|
|
853
|
-
notifyIntervalThreshold
|
|
862
|
+
notifyIntervalThreshold,
|
|
854
863
|
};
|
|
855
864
|
if (this.updateTimeout) {
|
|
856
865
|
clearTimeout(this.updateTimeout);
|
|
857
866
|
this.updateTimeout = undefined;
|
|
858
|
-
debug(
|
|
867
|
+
debug('[%s] Adaptive lighting was renewed.', this.lightbulb.displayName);
|
|
859
868
|
}
|
|
860
869
|
else {
|
|
861
|
-
debug(
|
|
870
|
+
debug('[%s] Adaptive lighting was enabled.', this.lightbulb.displayName);
|
|
862
871
|
}
|
|
863
872
|
this.handleActiveTransitionUpdated();
|
|
864
|
-
return
|
|
873
|
+
return encode(2 /* TransitionControlTypes.UPDATE_VALUE_TRANSITION_CONFIGURATION */, this.buildTransitionControlResponseBuffer(0));
|
|
865
874
|
}
|
|
866
875
|
}
|
|
867
|
-
exports.AdaptiveLightingController = AdaptiveLightingController;
|
|
868
876
|
//# sourceMappingURL=AdaptiveLightingController.js.map
|