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