iobroker.iot 3.6.0 → 4.0.2
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/README.md +8 -4
- package/admin/assets/index-5zouxn2w.js +680 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{index-BRdNnGcA.js → index-DwYdaT5M.js} +80 -81
- package/admin/rules/customRuleBlocks.js +2 -2
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/AlexaResponse.js +101 -95
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +22 -36
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +27 -28
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +25 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +32 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +29 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +34 -27
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +39 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +19 -22
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +36 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +12 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +20 -29
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +23 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/LockState.js +9 -12
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +34 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +9 -9
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +31 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +22 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +49 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +20 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js +148 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js +13 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Controls/Control.js +73 -104
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js +182 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js +208 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Controls/Light.js +15 -22
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js +35 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +85 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +27 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js +116 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js +121 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Device.js +29 -30
- package/build-backend/lib/AlexaSmartHomeV3/Device.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js +392 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Helpers/AdapterProvider.js +12 -21
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +53 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +1 -0
- package/{lib → build-backend/lib}/AlexaSmartHomeV3/Helpers/IotProxy.js +9 -26
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js +93 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +112 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js +625 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -0
- package/build-backend/lib/Utils.js +96 -0
- package/build-backend/lib/Utils.js.map +1 -0
- package/build-backend/lib/adminCommonSocket.js +715 -0
- package/build-backend/lib/adminCommonSocket.js.map +1 -0
- package/build-backend/lib/alexaCustom.js +542 -0
- package/build-backend/lib/alexaCustom.js.map +1 -0
- package/{lib → build-backend/lib}/alexaSmartHomeV2.js +4 -8
- package/{lib → build-backend/lib}/alexaSmartHomeV3.js +25 -45
- package/build-backend/lib/alexaSmartHomeV3.js.map +1 -0
- package/{lib → build-backend/lib}/alisa.js +41 -44
- package/{lib → build-backend/lib}/devices.js +11 -8
- package/build-backend/lib/devices.js.map +1 -0
- package/{lib → build-backend/lib}/functions.js +11 -8
- package/build-backend/lib/functions.js.map +1 -0
- package/{lib → build-backend/lib}/googleHome.js +25 -26
- package/{lib → build-backend/lib}/notifications.js +15 -22
- package/build-backend/lib/notifications.js.map +1 -0
- package/{lib → build-backend/lib}/remote.js +615 -636
- package/build-backend/lib/remote.js.map +1 -0
- package/{lib → build-backend/lib}/rooms.js +11 -8
- package/build-backend/lib/rooms.js.map +1 -0
- package/{lib → build-backend/lib}/texts.js +6 -4
- package/build-backend/lib/texts.js.map +1 -0
- package/build-backend/lib/translate.js +21 -0
- package/build-backend/lib/translate.js.map +1 -0
- package/{lib → build-backend/lib}/visuApp.js +45 -65
- package/build-backend/lib/visuApp.js.map +1 -0
- package/build-backend/main.js +1361 -0
- package/build-backend/main.js.map +1 -0
- package/io-package.json +14 -14
- package/package.json +18 -15
- package/admin/assets/index-DCbOB3g_.js +0 -681
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +0 -34
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -27
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -39
- package/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -13
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -38
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -55
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -56
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -11
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +0 -108
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +0 -40
- package/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +0 -22
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +0 -32
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -17
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -28
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +0 -52
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -19
- package/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/AirCondition.js +0 -144
- package/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -12
- package/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/Ct.js +0 -172
- package/lib/AlexaSmartHomeV3/Controls/Dimmer.js +0 -124
- package/lib/AlexaSmartHomeV3/Controls/Door.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Gate.js +0 -42
- package/lib/AlexaSmartHomeV3/Controls/Hue.js +0 -207
- package/lib/AlexaSmartHomeV3/Controls/Lock.js +0 -36
- package/lib/AlexaSmartHomeV3/Controls/Motion.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -25
- package/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -10
- package/lib/AlexaSmartHomeV3/Controls/Socket.js +0 -21
- package/lib/AlexaSmartHomeV3/Controls/Temperature.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -86
- package/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/Volume.js +0 -109
- package/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Window.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/index.js +0 -14
- package/lib/AlexaSmartHomeV3/DeviceManager.js +0 -415
- package/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -8
- package/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -70
- package/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -95
- package/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -82
- package/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -583
- package/lib/Utils.js +0 -608
- package/lib/adminCommonSocket.js +0 -781
- package/lib/alexaCustom.js +0 -622
- package/lib/translate.js +0 -19
- package/main.js +0 -1454
|
@@ -1,39 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AlexaResponse_1 = __importDefault(require("../Alexa/AlexaResponse"));
|
|
7
|
+
const Utils_1 = require("../Helpers/Utils");
|
|
8
|
+
const Logger_1 = __importDefault(require("../Helpers/Logger"));
|
|
9
|
+
const AdapterProvider_1 = __importDefault(require("../Helpers/AdapterProvider"));
|
|
10
|
+
const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
|
|
11
|
+
const DetectionState_1 = __importDefault(require("../Alexa/Properties/DetectionState"));
|
|
7
12
|
/**
|
|
8
13
|
* Represents the base functionality for a control in a smart device. A smart device has at least one control.
|
|
9
14
|
* The specific functionality, natively supported capabilities, etc. are defined in derived classes.
|
|
10
|
-
* @class
|
|
11
15
|
*/
|
|
12
16
|
class Control {
|
|
17
|
+
static stateKeys = [
|
|
18
|
+
'SET',
|
|
19
|
+
'ACTUAL',
|
|
20
|
+
'ON_SET',
|
|
21
|
+
'ON_ACTUAL',
|
|
22
|
+
'POWER',
|
|
23
|
+
'MODE',
|
|
24
|
+
'HUE',
|
|
25
|
+
'DIMMER',
|
|
26
|
+
'BRIGHTNESS',
|
|
27
|
+
'SATURATION',
|
|
28
|
+
'TEMPERATURE',
|
|
29
|
+
'ON',
|
|
30
|
+
'MUTE',
|
|
31
|
+
];
|
|
32
|
+
log;
|
|
33
|
+
_supported;
|
|
34
|
+
_enforced;
|
|
35
|
+
_states = {};
|
|
13
36
|
/**
|
|
14
|
-
* @constructor
|
|
15
37
|
* @param detectedControl - The detected control in terms of iobroker type detector.
|
|
16
38
|
*/
|
|
17
39
|
constructor(detectedControl) {
|
|
18
|
-
this.stateKeys = [
|
|
19
|
-
'SET',
|
|
20
|
-
'ACTUAL',
|
|
21
|
-
'ON_SET',
|
|
22
|
-
'ON_ACTUAL',
|
|
23
|
-
'POWER',
|
|
24
|
-
'MODE',
|
|
25
|
-
'HUE',
|
|
26
|
-
'DIMMER',
|
|
27
|
-
'BRIGHTNESS',
|
|
28
|
-
'SATURATION',
|
|
29
|
-
'TEMPERATURE',
|
|
30
|
-
'ON',
|
|
31
|
-
'MUTE',
|
|
32
|
-
];
|
|
33
40
|
this.initStates(detectedControl);
|
|
34
41
|
this._supported = this.initCapabilities();
|
|
35
42
|
this._enforced = this.initEnforcedCapabilities();
|
|
36
|
-
this.log = new
|
|
43
|
+
this.log = new Logger_1.default(this);
|
|
37
44
|
this.log.silly(`created instance`);
|
|
38
45
|
}
|
|
39
46
|
/**
|
|
@@ -58,13 +65,11 @@ class Control {
|
|
|
58
65
|
initEnforcedCapabilities() {
|
|
59
66
|
return [];
|
|
60
67
|
}
|
|
61
|
-
|
|
62
68
|
get allCapabilities() {
|
|
63
69
|
return this.supported.concat(this.enforced);
|
|
64
70
|
}
|
|
65
|
-
|
|
66
71
|
static get type() {
|
|
67
|
-
return
|
|
72
|
+
return (0, Utils_1.firstLower)((0, Utils_1.className)(this.toString()));
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* Getter for Alexa categories
|
|
@@ -72,7 +77,6 @@ class Control {
|
|
|
72
77
|
get categories() {
|
|
73
78
|
return ['OTHER'];
|
|
74
79
|
}
|
|
75
|
-
|
|
76
80
|
get name() {
|
|
77
81
|
return `${this.constructor.name}`;
|
|
78
82
|
}
|
|
@@ -90,16 +94,18 @@ class Control {
|
|
|
90
94
|
}
|
|
91
95
|
/**
|
|
92
96
|
* This function returns whether the control natively supports the passed on Alexa directive.
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
97
|
+
*
|
|
98
|
+
* @param event The event containing the Alexa directive as it comes from AWS Alexa Service
|
|
99
|
+
* @returns True if the control natively supports the directive, false - otherwise
|
|
95
100
|
*/
|
|
96
101
|
supports(event) {
|
|
97
102
|
return this.supported.find(capability => capability.matches(event)) !== undefined;
|
|
98
103
|
}
|
|
99
104
|
/**
|
|
100
105
|
* This function returns whether the control though doesn't natively support the passed on Alexa directive, but able to handle it.
|
|
101
|
-
*
|
|
102
|
-
* @
|
|
106
|
+
*
|
|
107
|
+
* @param event The event containing the Alexa directive as it comes from AWS Alexa Service
|
|
108
|
+
* @returns True if the control can handle the directive, false - otherwise
|
|
103
109
|
*/
|
|
104
110
|
canHandle(event) {
|
|
105
111
|
return this.enforced.find(capability => capability.matches(event)) !== undefined;
|
|
@@ -107,64 +113,56 @@ class Control {
|
|
|
107
113
|
/**
|
|
108
114
|
* This function processes an Alexa directive. Usually the result of the processing is setting an iobroker state to some value
|
|
109
115
|
* as a reaction to an interaction with Alexa via voice, app, etc.
|
|
110
|
-
*
|
|
111
|
-
* @param
|
|
112
|
-
* @returns
|
|
116
|
+
*
|
|
117
|
+
* @param event The event containing the Alexa directive as it comes from AWS Alexa Service
|
|
118
|
+
* @returns Object containing the response to be sent to Alexa Service
|
|
113
119
|
*/
|
|
114
120
|
async handle(event) {
|
|
115
121
|
this.log.debug(`handling Alexa event`);
|
|
116
122
|
this.log.silly(`${JSON.stringify(event)}`);
|
|
117
|
-
|
|
118
123
|
const property = this.allCapabilities
|
|
119
124
|
.flatMap(item => item.properties)
|
|
120
125
|
.find(property => property.matches(event));
|
|
121
|
-
|
|
122
126
|
if (property) {
|
|
123
127
|
let alexaValue;
|
|
124
128
|
try {
|
|
125
129
|
const setter = this.valueSetter(event);
|
|
126
130
|
alexaValue = await setter(event, property);
|
|
127
|
-
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
128
133
|
this.log.debug(`${error}`);
|
|
129
134
|
this.log.error(`failed handling Alexa event`);
|
|
130
|
-
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
136
|
+
return Promise.reject(AlexaResponse_1.default.endpointUnreachable(event.directive.header.messageId).get());
|
|
131
137
|
}
|
|
132
|
-
|
|
133
138
|
// even though the handler successfully processed the Alexa event,
|
|
134
139
|
// we return an error here for ENFORCED capabilities, to prevent
|
|
135
140
|
// reporting multiple successes for the same capability and
|
|
136
141
|
// running into a situation of returning a wrong value back to Alexa
|
|
137
142
|
if (this.enforced.find(capability => capability.matches(event))) {
|
|
138
|
-
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
144
|
+
return Promise.reject(AlexaResponse_1.default.directiveNotSupportedByControl(this.name, event?.directive?.header?.namespace, event?.directive?.header?.messageId, event?.directive?.header?.payloadVersion).get());
|
|
139
145
|
}
|
|
140
|
-
|
|
141
|
-
const response = AlexaResponse.handled(event, property.propertyName, property.reportValue(alexaValue), property.instance);
|
|
142
|
-
|
|
146
|
+
const response = AlexaResponse_1.default.handled(event, property.propertyName, property.reportValue(alexaValue), property.instance);
|
|
143
147
|
// though the processed directive required to change a single value, the response must contain values of all "relevant" properties
|
|
144
148
|
// Please refer to this for details: https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-thermostatcontroller.html#settargettemperature-response-event
|
|
145
|
-
|
|
146
149
|
// TODO: add values of relevant properties to response
|
|
147
|
-
|
|
148
150
|
this.log.silly(`${JSON.stringify(response.get())}`);
|
|
149
151
|
return response.get();
|
|
150
152
|
}
|
|
151
|
-
|
|
152
|
-
const errorResponse = AlexaResponse.directiveNotSupportedByControl(this.name, event?.directive?.header?.namespace);
|
|
153
|
+
const errorResponse = AlexaResponse_1.default.directiveNotSupportedByControl(this.name, event?.directive?.header?.namespace, event?.directive?.header?.messageId, event?.directive?.header?.payloadVersion);
|
|
153
154
|
this.log.silly(`${JSON.stringify(errorResponse.get())}`);
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
154
156
|
return Promise.reject(errorResponse.get());
|
|
155
157
|
}
|
|
156
|
-
|
|
157
|
-
valueSetter(event) {
|
|
158
|
+
valueSetter(_event) {
|
|
158
159
|
return this.setValue.bind(this);
|
|
159
160
|
}
|
|
160
|
-
|
|
161
161
|
async setValue(event, property) {
|
|
162
162
|
// extract alexa value from event
|
|
163
163
|
const alexaValue = property.alexaDirectiveValue(event);
|
|
164
|
-
|
|
165
164
|
// convert alexa value to iobroker value
|
|
166
165
|
let value = property.value(alexaValue);
|
|
167
|
-
|
|
168
166
|
// if set, the device could support toggle
|
|
169
167
|
if (event.currentState) {
|
|
170
168
|
// console.error(`----------------------------------- command: ${value}, current value: ${JSON.stringify(event.currentState)}`);
|
|
@@ -172,11 +170,12 @@ class Control {
|
|
|
172
170
|
if (state && value === true) {
|
|
173
171
|
// it could support toggle.
|
|
174
172
|
// get current value
|
|
175
|
-
|
|
173
|
+
const current = property.value(state.value);
|
|
176
174
|
if (current === true) {
|
|
177
175
|
// turn off
|
|
178
176
|
value = false;
|
|
179
|
-
}
|
|
177
|
+
}
|
|
178
|
+
else if (current !== false) {
|
|
180
179
|
const currentValue = await this.getOrRetrieveCurrentValue(property);
|
|
181
180
|
if (currentValue === true) {
|
|
182
181
|
// turn off
|
|
@@ -185,15 +184,12 @@ class Control {
|
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
|
-
|
|
189
187
|
// set iobroker state
|
|
190
188
|
await this.setState(property, value);
|
|
191
|
-
|
|
192
189
|
property.currentValue = value;
|
|
193
190
|
// return value as expected by Alexa
|
|
194
191
|
return property.alexaValue(value);
|
|
195
192
|
}
|
|
196
|
-
|
|
197
193
|
async adjustValue(event, property) {
|
|
198
194
|
// extract Alexa delta value from event
|
|
199
195
|
const delta = property.alexaDirectiveValue(event);
|
|
@@ -202,97 +198,74 @@ class Control {
|
|
|
202
198
|
// convert the current value to Alexa value
|
|
203
199
|
const valueToAdjust = property.alexaValue(currentValue);
|
|
204
200
|
// adjust Alexa value
|
|
205
|
-
const adjustedValue =
|
|
201
|
+
const adjustedValue = (0, Utils_1.ensureValueInRange_0_100)(parseFloat(valueToAdjust || '0') + parseFloat(delta || '0'));
|
|
206
202
|
// convert adjusted value to iobroker value
|
|
207
203
|
const value = property.value(adjustedValue);
|
|
208
|
-
|
|
209
204
|
// set iobroker state
|
|
210
205
|
await this.setState(property, value);
|
|
211
|
-
|
|
212
206
|
return adjustedValue;
|
|
213
207
|
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @param {Object} property
|
|
217
|
-
*/
|
|
218
208
|
async getOrRetrieveCurrentValue(property) {
|
|
219
209
|
if (property.currentValue === undefined) {
|
|
220
|
-
property.currentValue = await
|
|
210
|
+
property.currentValue = await AdapterProvider_1.default.getState(property.getId);
|
|
221
211
|
}
|
|
222
|
-
|
|
223
212
|
if (property.currentValue === undefined) {
|
|
224
213
|
throw new Error(`unable to retrieve ${property.getId}`);
|
|
225
214
|
}
|
|
226
|
-
|
|
227
215
|
return property.currentValue;
|
|
228
216
|
}
|
|
229
|
-
|
|
230
217
|
async reportState() {
|
|
231
218
|
this.log.debug(`reporting state`);
|
|
232
|
-
|
|
233
|
-
let propertiesToReport = [];
|
|
234
|
-
|
|
219
|
+
const propertiesToReport = [];
|
|
235
220
|
for (const capability of this.supported) {
|
|
236
221
|
for (const property of capability.properties) {
|
|
237
222
|
try {
|
|
238
223
|
await this.getOrRetrieveCurrentValue(property);
|
|
239
|
-
|
|
240
|
-
let toReport = {
|
|
224
|
+
const toReport = {
|
|
241
225
|
namespace: capability.namespace,
|
|
242
226
|
instance: property.instance,
|
|
243
227
|
name: property.propertyName,
|
|
244
228
|
value: property.reportValue(property.alexaValue(property.currentValue)),
|
|
245
229
|
};
|
|
246
|
-
|
|
247
230
|
if (!toReport.instance) {
|
|
248
231
|
delete toReport.instance;
|
|
249
232
|
}
|
|
250
|
-
|
|
251
233
|
propertiesToReport.push(toReport);
|
|
252
|
-
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
253
236
|
this.log.error(`failed reporting state for property ${property.propertyName} of ${this.name}`);
|
|
254
237
|
this.log.debug(`${error}`);
|
|
255
238
|
}
|
|
256
239
|
}
|
|
257
240
|
}
|
|
258
|
-
|
|
259
241
|
this.log.debug(`${JSON.stringify(propertiesToReport)}`);
|
|
260
242
|
return propertiesToReport;
|
|
261
243
|
}
|
|
262
|
-
|
|
263
244
|
toString() {
|
|
264
245
|
return `${this.constructor.name}`;
|
|
265
246
|
}
|
|
266
|
-
|
|
267
247
|
initStates(ctrl) {
|
|
268
|
-
|
|
269
|
-
for (const stateKey of this.stateKeys) {
|
|
248
|
+
for (const stateKey of Control.stateKeys) {
|
|
270
249
|
this._states[stateKey] = ctrl.states.find(s => s.name === stateKey);
|
|
271
250
|
}
|
|
272
251
|
}
|
|
273
|
-
|
|
274
252
|
get states() {
|
|
275
253
|
return this._states;
|
|
276
254
|
}
|
|
277
|
-
|
|
278
255
|
get statesMap() {
|
|
279
|
-
const map = {}
|
|
280
|
-
for (const stateKey of
|
|
256
|
+
const map = {};
|
|
257
|
+
for (const stateKey of Control.stateKeys) {
|
|
281
258
|
map[stateKey.toLowerCase()] = stateKey;
|
|
282
259
|
}
|
|
283
260
|
return map;
|
|
284
261
|
}
|
|
285
|
-
|
|
286
262
|
async setState(property, value) {
|
|
287
|
-
await
|
|
263
|
+
await AdapterProvider_1.default.setState(property.setId, value);
|
|
288
264
|
property.currentValue = value;
|
|
289
265
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
266
|
//-------------------------------------------------------
|
|
293
267
|
// standard property init objects
|
|
294
268
|
//
|
|
295
|
-
|
|
296
269
|
blankInitObject() {
|
|
297
270
|
// const states = this.initStates(ctrl);
|
|
298
271
|
const map = this.statesMap;
|
|
@@ -301,52 +274,48 @@ class Control {
|
|
|
301
274
|
getState: this.states[map.actual],
|
|
302
275
|
};
|
|
303
276
|
}
|
|
304
|
-
|
|
305
277
|
powerStateInitObject() {
|
|
306
278
|
// const states = this.initStates(ctrl);
|
|
307
279
|
const map = this.statesMap;
|
|
308
|
-
|
|
309
280
|
return {
|
|
310
281
|
setState: this.states[map.set],
|
|
311
282
|
getState: this.states[map.actual],
|
|
312
283
|
alexaSetter: function (alexaValue) {
|
|
313
|
-
return alexaValue ===
|
|
284
|
+
return alexaValue === PowerState_1.default.ON;
|
|
314
285
|
},
|
|
315
286
|
alexaGetter: function (value) {
|
|
316
|
-
return value ?
|
|
287
|
+
return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
|
|
317
288
|
},
|
|
318
289
|
};
|
|
319
290
|
}
|
|
320
|
-
|
|
321
291
|
detectedStateInitObject() {
|
|
322
292
|
const map = this.statesMap;
|
|
323
293
|
return {
|
|
324
294
|
setState: this.states[map.actual],
|
|
325
295
|
getState: this.states[map.actual],
|
|
326
|
-
alexaSetter: function (
|
|
296
|
+
alexaSetter: function (_alexaValue) {
|
|
327
297
|
// should be never called
|
|
328
298
|
return 0;
|
|
329
299
|
},
|
|
330
300
|
alexaGetter: function (value) {
|
|
331
|
-
return value ?
|
|
301
|
+
return value ? DetectionState_1.default.DETECTED : DetectionState_1.default.NOT_DETECTED;
|
|
332
302
|
},
|
|
333
303
|
};
|
|
334
304
|
}
|
|
335
|
-
|
|
336
305
|
percentageInitObject() {
|
|
337
306
|
const map = this.statesMap;
|
|
338
|
-
// const range =
|
|
307
|
+
// const range = configuredRangeOrDefault(this.states[map.set]);
|
|
339
308
|
return {
|
|
340
309
|
setState: this.states[map.set],
|
|
341
310
|
getState: this.states[map.actual],
|
|
342
311
|
alexaSetter: function (alexaValue) {
|
|
343
|
-
return
|
|
312
|
+
return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) || 0);
|
|
344
313
|
},
|
|
345
314
|
alexaGetter: function (value) {
|
|
346
|
-
return
|
|
315
|
+
return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
|
|
347
316
|
},
|
|
348
317
|
};
|
|
349
318
|
}
|
|
350
319
|
}
|
|
351
|
-
|
|
352
|
-
|
|
320
|
+
exports.default = Control;
|
|
321
|
+
//# sourceMappingURL=Control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Control.ts"],"names":[],"mappings":";;;;;AAAA,2EAAmD;AACnD,4CAAuH;AACvH,+DAAuC;AACvC,iFAAyD;AAEzD,gFAAwD;AACxD,wFAAgE;AAWhE;;;GAGG;AACH,MAAqB,OAAO;IACxB,MAAM,CAAC,SAAS,GAAG;QACf,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,QAAQ;QACR,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,IAAI;QACJ,MAAM;KACT,CAAC;IACc,GAAG,CAAS;IACZ,UAAU,CAAqB;IAC/B,SAAS,CAAqB;IAC9B,OAAO,GAAyD,EAAE,CAAC;IAEnF;;OAEG;IACH,YAAY,eAA0C;QAClD,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACjD,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACvC,CAAC;IACD;;;;;;OAMG;IACH,gBAAgB;QACZ,OAAO,EAAE,CAAC;IACd,CAAC;IACD;;;;;;;;OAQG;IACH,wBAAwB;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CA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AC;YACzE,CAAC;SACJ,CAAC;IACN,CAAC;IAED,oBAAoB;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,gEAAgE;QAChE,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE;YAClC,WAAW,EAAE,UAAgC,UAAiC;gBAC1E,OAAO,CACH,IAAA,yBAAiB,EACb,UAAoB,EACpB,IAAI,CAAC,cAAwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,IAAI,CAAC,CACT,CAAC;YACN,CAAC;YACD,WAAW,EAAE,UAET,KAAsC;gBAEtC,OAAO,IAAA,uBAAe,EAAC,KAAe,EAAE,IAAI,CAAC,cAAwB,EAAE,IAAI,CAAC,cAAwB,CAAC,CAAC;YAC1G,CAAC;SACJ,CAAC;IACN,CAAC;;AApXL,0BAqXC","sourcesContent":["import AlexaResponse from '../Alexa/AlexaResponse';\nimport { firstLower, className, ensureValueInRange_0_100, denormalize_0_100, normalize_0_100 } from '../Helpers/Utils';\nimport Logger from '../Helpers/Logger';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport type { ControlStateInitObject, Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport DetectionState from '../Alexa/Properties/DetectionState';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n AlexaV3ReportedState,\n AlexaV3Request,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\n\n/**\n * Represents the base functionality for a control in a smart device. A smart device has at least one control.\n * The specific functionality, natively supported capabilities, etc. are defined in derived classes.\n */\nexport default class Control {\n static stateKeys = [\n 'SET',\n 'ACTUAL',\n 'ON_SET',\n 'ON_ACTUAL',\n 'POWER',\n 'MODE',\n 'HUE',\n 'DIMMER',\n 'BRIGHTNESS',\n 'SATURATION',\n 'TEMPERATURE',\n 'ON',\n 'MUTE',\n ];\n public readonly log: Logger;\n public readonly _supported: CapabilitiesBase[];\n public readonly _enforced: CapabilitiesBase[];\n public readonly _states: Record<string, IotExternalDetectorState | undefined> = {};\n\n /**\n * @param detectedControl - The detected control in terms of iobroker type detector.\n */\n constructor(detectedControl: IotExternalPatternControl) {\n this.initStates(detectedControl);\n this._supported = this.initCapabilities();\n this._enforced = this.initEnforcedCapabilities();\n this.log = new Logger(this);\n this.log.silly(`created instance`);\n }\n /**\n * This function maps a passed on control to an array of objects. Each object contains an Alexa capability the control natively supports\n * and at least one property. Every property is initialized with corresponding iobroker state ids and value converters from Alexa to iobroker types\n * and vice versa.\n *\n * @returns Array of objects with natively supported Alexa capabilities and correspondingly configured instances of StateProxies\n */\n initCapabilities(): CapabilitiesBase[] {\n return [];\n }\n /**\n * This function maps a passed on control to an array of objects. Each object contains an Alexa capability the control can handle even\n * though not natively supported (e.g., the light control can handle the Alexa BrightnessController directive by switching\n * itself `ON` on brightness > 0 and `OFF` on brightness == 0)\n * Every capability has at least one property with set up iobroker state ids and value converters from Alexa to iobroker types\n * and vice versa.\n *\n * @returns Array of objects with natively supported Alexa capabilities and correspondingly configured instances of StateProxies\n */\n initEnforcedCapabilities(): CapabilitiesBase[] {\n return [];\n }\n\n get allCapabilities(): CapabilitiesBase[] {\n return this.supported.concat(this.enforced);\n }\n\n static get type(): string {\n return firstLower(className(this.toString()));\n }\n /**\n * Getter for Alexa categories\n */\n get categories(): AlexaV3Category[] {\n return ['OTHER'];\n }\n\n get name(): string {\n return `${this.constructor.name}`;\n }\n /**\n * Getter for _supported\n */\n get supported(): CapabilitiesBase[] {\n return this._supported;\n }\n /**\n * Getter for _enforced\n */\n get enforced(): CapabilitiesBase[] {\n return this._enforced;\n }\n /**\n * This function returns whether the control natively supports the passed on Alexa directive.\n *\n * @param event The event containing the Alexa directive as it comes from AWS Alexa Service\n * @returns True if the control natively supports the directive, false - otherwise\n */\n supports(event: AlexaV3Request): boolean {\n return this.supported.find(capability => capability.matches(event)) !== undefined;\n }\n /**\n * This function returns whether the control though doesn't natively support the passed on Alexa directive, but able to handle it.\n *\n * @param event The event containing the Alexa directive as it comes from AWS Alexa Service\n * @returns True if the control can handle the directive, false - otherwise\n */\n canHandle(event: AlexaV3Request): boolean {\n return this.enforced.find(capability => capability.matches(event)) !== undefined;\n }\n /**\n * This function processes an Alexa directive. Usually the result of the processing is setting an iobroker state to some value\n * as a reaction to an interaction with Alexa via voice, app, etc.\n *\n * @param event The event containing the Alexa directive as it comes from AWS Alexa Service\n * @returns Object containing the response to be sent to Alexa Service\n */\n async handle(event: AlexaV3Request): Promise<AlexaResponse> {\n this.log.debug(`handling Alexa event`);\n this.log.silly(`${JSON.stringify(event)}`);\n\n const property = this.allCapabilities\n .flatMap(item => item.properties)\n .find(property => property.matches(event));\n\n if (property) {\n let alexaValue: AlexaV3DirectiveValue;\n try {\n const setter = this.valueSetter(event);\n alexaValue = await setter(event, property);\n } catch (error) {\n this.log.debug(`${error}`);\n this.log.error(`failed handling Alexa event`);\n\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(AlexaResponse.endpointUnreachable(event.directive.header.messageId).get());\n }\n\n // even though the handler successfully processed the Alexa event,\n // we return an error here for ENFORCED capabilities, to prevent\n // reporting multiple successes for the same capability and\n // running into a situation of returning a wrong value back to Alexa\n if (this.enforced.find(capability => capability.matches(event))) {\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(\n AlexaResponse.directiveNotSupportedByControl(\n this.name,\n event?.directive?.header?.namespace,\n event?.directive?.header?.messageId,\n event?.directive?.header?.payloadVersion,\n ).get(),\n );\n }\n\n const response = AlexaResponse.handled(\n event,\n property.propertyName,\n property.reportValue(alexaValue),\n property.instance,\n );\n\n // though the processed directive required to change a single value, the response must contain values of all \"relevant\" properties\n // Please refer to this for details: https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-thermostatcontroller.html#settargettemperature-response-event\n\n // TODO: add values of relevant properties to response\n\n this.log.silly(`${JSON.stringify(response.get())}`);\n return response.get();\n }\n\n const errorResponse = AlexaResponse.directiveNotSupportedByControl(\n this.name,\n event?.directive?.header?.namespace,\n event?.directive?.header?.messageId,\n event?.directive?.header?.payloadVersion,\n );\n this.log.silly(`${JSON.stringify(errorResponse.get())}`);\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n return Promise.reject(errorResponse.get());\n }\n\n valueSetter(\n _event: AlexaV3Request,\n ): (event: AlexaV3Request, property: PropertiesBase) => Promise<AlexaV3DirectiveValue> {\n return this.setValue.bind(this);\n }\n\n async setValue(event: AlexaV3Request, property: PropertiesBase): Promise<AlexaV3DirectiveValue> {\n // extract alexa value from event\n const alexaValue = property.alexaDirectiveValue(event);\n\n // convert alexa value to iobroker value\n let value = property.value(alexaValue);\n\n // if set, the device could support toggle\n if (event.currentState) {\n // console.error(`----------------------------------- command: ${value}, current value: ${JSON.stringify(event.currentState)}`);\n const state = event.currentState.find(item => item.name === property.propertyName);\n if (state && value === true) {\n // it could support toggle.\n // get current value\n const current = property.value(state.value);\n if (current === true) {\n // turn off\n value = false;\n } else if (current !== false) {\n const currentValue = await this.getOrRetrieveCurrentValue(property);\n if (currentValue === true) {\n // turn off\n value = false;\n }\n }\n }\n }\n\n // set iobroker state\n await this.setState(property, value!);\n\n property.currentValue = value;\n // return value as expected by Alexa\n return property.alexaValue(value);\n }\n\n async adjustValue(event: AlexaV3Request, property: PropertiesBase): Promise<AlexaV3DirectiveValue> {\n // extract Alexa delta value from event\n const delta = property.alexaDirectiveValue(event);\n // get current value\n const currentValue = await this.getOrRetrieveCurrentValue(property);\n // convert the current value to Alexa value\n const valueToAdjust = property.alexaValue(currentValue);\n // adjust Alexa value\n const adjustedValue = ensureValueInRange_0_100(\n parseFloat((valueToAdjust as string) || '0') + parseFloat((delta as string) || '0'),\n );\n // convert adjusted value to iobroker value\n const value = property.value(adjustedValue);\n\n // set iobroker state\n await this.setState(property, value as ioBroker.StateValue);\n\n return adjustedValue;\n }\n\n async getOrRetrieveCurrentValue(property: PropertiesBase): Promise<ioBroker.StateValue> {\n if (property.currentValue === undefined) {\n property.currentValue = await AdapterProvider.getState(property.getId);\n }\n\n if (property.currentValue === undefined) {\n throw new Error(`unable to retrieve ${property.getId}`);\n }\n\n return property.currentValue;\n }\n\n async reportState(): Promise<AlexaV3ReportedState[]> {\n this.log.debug(`reporting state`);\n\n const propertiesToReport: AlexaV3ReportedState[] = [];\n\n for (const capability of this.supported) {\n for (const property of capability.properties) {\n try {\n await this.getOrRetrieveCurrentValue(property);\n\n const toReport: AlexaV3ReportedState = {\n namespace: capability.namespace,\n instance: property.instance,\n name: property.propertyName,\n value: property.reportValue(property.alexaValue(property.currentValue)),\n };\n\n if (!toReport.instance) {\n delete toReport.instance;\n }\n\n propertiesToReport.push(toReport);\n } catch (error) {\n this.log.error(`failed reporting state for property ${property.propertyName} of ${this.name}`);\n this.log.debug(`${error}`);\n }\n }\n }\n\n this.log.debug(`${JSON.stringify(propertiesToReport)}`);\n return propertiesToReport;\n }\n\n toString(): string {\n return `${this.constructor.name}`;\n }\n\n initStates(ctrl: IotExternalPatternControl): void {\n for (const stateKey of Control.stateKeys) {\n this._states[stateKey] = ctrl.states.find(s => s.name === stateKey);\n }\n }\n\n get states(): Record<string, IotExternalDetectorState | undefined> {\n return this._states;\n }\n\n get statesMap(): Record<string, string> {\n const map: Record<string, string> = {};\n for (const stateKey of Control.stateKeys) {\n map[stateKey.toLowerCase()] = stateKey;\n }\n return map;\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n }\n\n //-------------------------------------------------------\n // standard property init objects\n //\n\n blankInitObject(): ControlStateInitObject {\n // const states = this.initStates(ctrl);\n const map = this.statesMap;\n return {\n setState: this.states[map.actual]!,\n getState: this.states[map.actual]!,\n };\n }\n\n powerStateInitObject(): ControlStateInitObject {\n // const states = this.initStates(ctrl);\n const map = this.statesMap;\n\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.actual]!,\n alexaSetter: function (alexaValue) {\n return alexaValue === PowerState.ON;\n },\n alexaGetter: function (value) {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n detectedStateInitObject(): ControlStateInitObject {\n const map = this.statesMap;\n return {\n setState: this.states[map.actual]!,\n getState: this.states[map.actual]!,\n alexaSetter: function (_alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue | undefined {\n // should be never called\n return 0;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? DetectionState.DETECTED : DetectionState.NOT_DETECTED;\n },\n };\n }\n\n percentageInitObject(): ControlStateInitObject {\n const map = this.statesMap;\n // const range = configuredRangeOrDefault(this.states[map.set]);\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.actual]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return (\n denormalize_0_100(\n alexaValue as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n ) || 0\n );\n },\n alexaGetter: function (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return normalize_0_100(value as number, this.valuesRangeMin as number, this.valuesRangeMax as number);\n },\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
|
|
7
|
+
const Utils_1 = require("../Helpers/Utils");
|
|
8
|
+
const AdapterProvider_1 = __importDefault(require("../Helpers/AdapterProvider"));
|
|
9
|
+
const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
|
|
10
|
+
const Brightness_1 = __importDefault(require("../Alexa/Properties/Brightness"));
|
|
11
|
+
const ColorTemperatureInKelvin_1 = __importDefault(require("../Alexa/Properties/ColorTemperatureInKelvin"));
|
|
12
|
+
const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
|
|
13
|
+
class Ct extends AdjustableControl_1.default {
|
|
14
|
+
_brightnessCapability;
|
|
15
|
+
_brightness;
|
|
16
|
+
_colorTemperatureCapability;
|
|
17
|
+
_powerControllerCapability;
|
|
18
|
+
_powerState;
|
|
19
|
+
get categories() {
|
|
20
|
+
return ['LIGHT'];
|
|
21
|
+
}
|
|
22
|
+
adjustableProperties() {
|
|
23
|
+
return [ColorTemperatureInKelvin_1.default];
|
|
24
|
+
}
|
|
25
|
+
initCapabilities() {
|
|
26
|
+
const map = this.statesMap;
|
|
27
|
+
const result = [new Capabilities_1.default.ColorController()];
|
|
28
|
+
// if the state DIMMER or BRIGHTNESS configured
|
|
29
|
+
if (this.states[map.dimmer] || this.states[map.brightness]) {
|
|
30
|
+
this._brightnessCapability = new Capabilities_1.default.BrightnessController();
|
|
31
|
+
this._brightness = this._brightnessCapability.brightness;
|
|
32
|
+
result.push(this._brightnessCapability);
|
|
33
|
+
}
|
|
34
|
+
// if the state TEMPERATURE configured
|
|
35
|
+
if (this.states[map.temperature]) {
|
|
36
|
+
this._colorTemperatureCapability = new Capabilities_1.default.ColorTemperatureController();
|
|
37
|
+
result.push(this._colorTemperatureCapability);
|
|
38
|
+
}
|
|
39
|
+
// if the state ON, DIMMER or BRIGHTNESS configured
|
|
40
|
+
if (this.states[map.on] || this._brightness) {
|
|
41
|
+
this._powerControllerCapability = new Capabilities_1.default.PowerController();
|
|
42
|
+
this._powerState = this._powerControllerCapability.powerState;
|
|
43
|
+
result.push(this._powerControllerCapability);
|
|
44
|
+
}
|
|
45
|
+
for (const property of result.flatMap(item => item.properties)) {
|
|
46
|
+
const initObject = this.composeInitObject(property);
|
|
47
|
+
if (initObject) {
|
|
48
|
+
property.init(initObject);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
async getOrRetrieveCurrentValue(property) {
|
|
54
|
+
const map = this.statesMap;
|
|
55
|
+
if (property.currentValue === undefined) {
|
|
56
|
+
property.currentValue = await AdapterProvider_1.default.getState(property.getId);
|
|
57
|
+
// convert the non-zero brightness to power = true
|
|
58
|
+
if (property.propertyName === PowerState_1.default.propertyName && !this.states[map.on]) {
|
|
59
|
+
property.currentValue = property.currentValue !== 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (property.currentValue === undefined) {
|
|
63
|
+
throw new Error(`unable to retrieve ${property.getId}`);
|
|
64
|
+
}
|
|
65
|
+
return property.currentValue;
|
|
66
|
+
}
|
|
67
|
+
async setState(property, value) {
|
|
68
|
+
const map = this.statesMap;
|
|
69
|
+
if (property.propertyName === PowerState_1.default.propertyName) {
|
|
70
|
+
if (this.states[map.on]) {
|
|
71
|
+
await AdapterProvider_1.default.setState(property.setId, value);
|
|
72
|
+
property.currentValue = value;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
if (!this._brightness) {
|
|
76
|
+
throw new Error('No brightness property configured');
|
|
77
|
+
}
|
|
78
|
+
if (!this._powerState) {
|
|
79
|
+
throw new Error('No powerState property configured');
|
|
80
|
+
}
|
|
81
|
+
if (value) {
|
|
82
|
+
// set brightness
|
|
83
|
+
// set byOn to the configured value or range.max otherwise
|
|
84
|
+
const range = (0, Utils_1.configuredRangeOrDefault)(this.states[map.dimmer] || this.states[map.brightness]);
|
|
85
|
+
const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;
|
|
86
|
+
let byOn;
|
|
87
|
+
if (smartName && typeof smartName === 'object') {
|
|
88
|
+
byOn = smartName.byON;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
byOn = undefined;
|
|
92
|
+
}
|
|
93
|
+
if (byOn === undefined || byOn === null || isNaN(byOn)) {
|
|
94
|
+
byOn = range.max;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
byOn = parseFloat(byOn);
|
|
98
|
+
}
|
|
99
|
+
await AdapterProvider_1.default.setState(this._brightness.setId, byOn ?? 100);
|
|
100
|
+
this._brightness.currentValue = byOn;
|
|
101
|
+
this._powerState.currentValue = true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// set brightness to 0 on power OFF
|
|
105
|
+
await AdapterProvider_1.default.setState(this._brightness.setId, 0);
|
|
106
|
+
this._brightness.currentValue = 0;
|
|
107
|
+
this._powerState.currentValue = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (property.propertyName === Brightness_1.default.propertyName ||
|
|
112
|
+
property.propertyName === ColorTemperatureInKelvin_1.default.propertyName) {
|
|
113
|
+
await AdapterProvider_1.default.setState(property.setId, value);
|
|
114
|
+
property.currentValue = value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async adjustValue(event, property) {
|
|
118
|
+
// extract Alexa delta value from event
|
|
119
|
+
const delta = property.alexaDirectiveValue(event);
|
|
120
|
+
// convert delta to iobroker value
|
|
121
|
+
const value = property.value(delta);
|
|
122
|
+
// set iobroker state
|
|
123
|
+
await this.setState(property, value ?? 0);
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
composeInitObject(property) {
|
|
127
|
+
const map = this.statesMap;
|
|
128
|
+
if (property.propertyName === PowerState_1.default.propertyName) {
|
|
129
|
+
return {
|
|
130
|
+
setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
131
|
+
getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
132
|
+
alexaSetter: function (alexaValue) {
|
|
133
|
+
return alexaValue === PowerState_1.default.ON;
|
|
134
|
+
},
|
|
135
|
+
alexaGetter: function (value) {
|
|
136
|
+
return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (property.propertyName === Brightness_1.default.propertyName) {
|
|
141
|
+
return {
|
|
142
|
+
setState: this.states[map.dimmer] || this.states[map.brightness],
|
|
143
|
+
getState: this.states[map.dimmer] || this.states[map.brightness],
|
|
144
|
+
alexaSetter: function (alexaValue) {
|
|
145
|
+
return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
|
|
146
|
+
},
|
|
147
|
+
alexaGetter: function (value) {
|
|
148
|
+
return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
if (property.propertyName === ColorTemperatureInKelvin_1.default.propertyName) {
|
|
153
|
+
return {
|
|
154
|
+
setState: this.states[map.temperature],
|
|
155
|
+
getState: this.states[map.temperature],
|
|
156
|
+
alexaSetter: function (alexaValue) {
|
|
157
|
+
if (alexaValue === 1) {
|
|
158
|
+
// increase directive
|
|
159
|
+
const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
160
|
+
let index = this.colorTemperatureTable.indexOf(closest) + 1;
|
|
161
|
+
index =
|
|
162
|
+
index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
|
|
163
|
+
return this.colorTemperatureTable[index];
|
|
164
|
+
}
|
|
165
|
+
if (alexaValue === -1) {
|
|
166
|
+
// decrease directive
|
|
167
|
+
const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
168
|
+
let index = this.colorTemperatureTable.indexOf(closest) - 1;
|
|
169
|
+
index = index < 0 ? 0 : index;
|
|
170
|
+
return this.colorTemperatureTable[index];
|
|
171
|
+
}
|
|
172
|
+
return alexaValue;
|
|
173
|
+
},
|
|
174
|
+
alexaGetter: function (value) {
|
|
175
|
+
return value;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.default = Ct;
|
|
182
|
+
//# sourceMappingURL=Ct.js.map
|