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,583 +0,0 @@
|
|
|
1
|
-
const crypto = require('crypto');
|
|
2
|
-
const AdapterProvider = require('./AdapterProvider.js');
|
|
3
|
-
|
|
4
|
-
const { ChannelDetector } = require('iobroker.type-detector');
|
|
5
|
-
|
|
6
|
-
let onlyValidCharactersAndLength = function (name) {
|
|
7
|
-
return name.substring(0, 128).replace(/[^.a-zA-Z0-9äÄüÜöÖßÉéÈèÀàÂâÊêÙùÛûÇçÎîËëÏïŸÿÔôŒœãõìòáíóú]+/g, ' ');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let isRoom = function (payload) {
|
|
11
|
-
return payload && payload._id && payload._id.startsWith('enum.rooms.');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let isFunctionality = function (payload) {
|
|
15
|
-
return payload && payload._id && payload._id.startsWith('enum.functions.');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let allEnums = async function (adapter) {
|
|
19
|
-
const result = await adapter.getObjectViewAsync('system', 'enum', {});
|
|
20
|
-
return result.rows.map(row => row.value);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let parentOf = function (id) {
|
|
24
|
-
const parts = (id || '').split('.');
|
|
25
|
-
parts.pop();
|
|
26
|
-
return parts.join('.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let allObjects = async function (adapter) {
|
|
30
|
-
const states = await adapter.getObjectViewAsync('system', 'state', {});
|
|
31
|
-
const channels = await adapter.getObjectViewAsync('system', 'channel', {});
|
|
32
|
-
const devices = await adapter.getObjectViewAsync('system', 'device', {});
|
|
33
|
-
const enums = await adapter.getObjectViewAsync('system', 'enum', {});
|
|
34
|
-
|
|
35
|
-
return states.rows
|
|
36
|
-
.concat(channels.rows)
|
|
37
|
-
.concat(devices.rows)
|
|
38
|
-
.concat(enums.rows)
|
|
39
|
-
.reduce((obj, item) => (
|
|
40
|
-
obj[item.id] = {
|
|
41
|
-
common: item.value?.common,
|
|
42
|
-
type: item.value?.type,
|
|
43
|
-
}, obj), {}
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const SMART_TYPES = {
|
|
48
|
-
'LIGHT': 'light',
|
|
49
|
-
'SWITCH': 'socket',
|
|
50
|
-
'THERMOSTAT': 'thermostat',
|
|
51
|
-
'SMARTPLUG': 'socket',
|
|
52
|
-
'SMARTLOCK': 'lock',
|
|
53
|
-
'CAMERA': 'camera',
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const getSmartNameFromObj = (obj, instanceId, noCommon) => {
|
|
57
|
-
if (!obj) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
if (!obj.common) {
|
|
61
|
-
return obj.smartName;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!noCommon) {
|
|
65
|
-
return obj.common.smartName;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return obj.common?.custom && obj.common.custom[instanceId] ?
|
|
69
|
-
obj.common.custom[instanceId].smartName : undefined;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const functionalitiesAndRooms = async function (adapter) {
|
|
73
|
-
const enumerations = await allEnums(adapter);
|
|
74
|
-
// skip empty enums (with no members, i.e. states, assigned)
|
|
75
|
-
const notEmptyRoomsAndFunctionalities = enumerations.filter(item => {
|
|
76
|
-
const smartName = getSmartNameFromObj(item, adapter.namespace, adapter.config.noCommon);
|
|
77
|
-
return smartName !== false && smartName !== 'ignore';
|
|
78
|
-
}).filter(item => item?.common?.members?.length);
|
|
79
|
-
// all enums that are of type 'function'
|
|
80
|
-
const functionalities = notEmptyRoomsAndFunctionalities.filter(item => isFunctionality(item));
|
|
81
|
-
// all enums, that are of type 'room'
|
|
82
|
-
const rooms = notEmptyRoomsAndFunctionalities.filter(item => isRoom(item));
|
|
83
|
-
return [functionalities, rooms];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
let getChannelId = function (id, objects) {
|
|
87
|
-
if (objects[id] && objects[id].type === 'channel') {
|
|
88
|
-
return id;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (objects[id] && objects[id].type === 'state') {
|
|
92
|
-
const channelId = parentOf(id);
|
|
93
|
-
if (objects[channelId] && objects[channelId].type === 'channel') {
|
|
94
|
-
return channelId;
|
|
95
|
-
}
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let getDeviceId = function (id, objects) {
|
|
101
|
-
const channelId = getChannelId(id, objects);
|
|
102
|
-
if (channelId) {
|
|
103
|
-
const deviceId = parentOf(channelId);
|
|
104
|
-
if (objects[deviceId] && (objects[deviceId].type === 'device' || objects[deviceId].type === 'channel')) {
|
|
105
|
-
return deviceId;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
module.exports = {
|
|
112
|
-
parseISOString(dateTimeAsISOString) {
|
|
113
|
-
const b = dateTimeAsISOString.split(/\D+/);
|
|
114
|
-
return new Date(Date.UTC(b[0], --b[1], b[2], b[3], b[4], b[5], b[6]));
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
configuredRangeOrDefault(state) {
|
|
118
|
-
if (state.common?.type === 'boolean') {
|
|
119
|
-
return { min: false, max: true };
|
|
120
|
-
}
|
|
121
|
-
const configuredMin = state.common?.min;
|
|
122
|
-
const configuredMax = state.common?.max;
|
|
123
|
-
const min = configuredMin === undefined || isNaN(configuredMin) ? 0 : parseFloat(configuredMin);
|
|
124
|
-
const max = configuredMax === undefined || isNaN(configuredMax) ? 100 : parseFloat(configuredMax);
|
|
125
|
-
|
|
126
|
-
return { min, max };
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
currentHour: function () {
|
|
130
|
-
const datetime = new Date();
|
|
131
|
-
datetime.setMinutes(0);
|
|
132
|
-
datetime.setSeconds(0);
|
|
133
|
-
return datetime;
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
isToday: function (datetime) {
|
|
137
|
-
const today = new Date()
|
|
138
|
-
return datetime.getDate() === today.getDate() &&
|
|
139
|
-
datetime.getMonth() === today.getMonth() &&
|
|
140
|
-
datetime.getFullYear() === today.getFullYear();
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
isCurrentHour: function (datetime) {
|
|
144
|
-
const now = new Date();
|
|
145
|
-
const diffInHours = Math.abs(now.getTime() - datetime.getTime()) / 3.6e6;
|
|
146
|
-
return diffInHours < 1;
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
endpointId: function (id) {
|
|
150
|
-
// even more restrictive than Alexa documents
|
|
151
|
-
const regex = /^[A-Za-z0-9\-_]{1,256}$/g;
|
|
152
|
-
id = id.replace(/\s/g, '_');
|
|
153
|
-
if (!regex.test(id)) {
|
|
154
|
-
const hash = crypto.createHash('sha256').update(id).digest('hex');
|
|
155
|
-
id = `${hash}#${id.replace(/[^A-Za-z0-9\-_]+/g, '-')}`.substring(0, 256);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return id;
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
onlyValidCharactersAndLengthForFriendlyName: function (name) {
|
|
162
|
-
return name.substring(0, 128).replace(/[^.a-zA-Z0-9äÄüÜöÖßÉéÈèÀàÂâÊêÙùÛûÇçÎîËëÏïŸÿÔôŒœãõìòáíóú]+/g, ' ');
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
stringify: function (smartName, lang) {
|
|
166
|
-
if (typeof smartName === 'object') {
|
|
167
|
-
return smartName[lang] || smartName.en;
|
|
168
|
-
}
|
|
169
|
-
return this.onlyValidCharactersAndLengthForFriendlyName(smartName);
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
friendlyNameByRoomAndFunctionName: function (control, lang, replaces) {
|
|
173
|
-
const funcNameFirst = AdapterProvider.get().config.functionFirst;
|
|
174
|
-
let concatenation = AdapterProvider.get().config.concatWord;
|
|
175
|
-
let name;
|
|
176
|
-
|
|
177
|
-
let roomName = control.room?.common?.name;
|
|
178
|
-
let translateRoomName;
|
|
179
|
-
if (typeof roomName === 'object') {
|
|
180
|
-
roomName = roomName[lang] || roomName.en;
|
|
181
|
-
// try to translate from en to any other language
|
|
182
|
-
translateRoomName = lang && lang !== 'en' && !roomName[lang];
|
|
183
|
-
} else {
|
|
184
|
-
// always try to translate room names provided as a non-object type
|
|
185
|
-
translateRoomName = true;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (translateRoomName) {
|
|
189
|
-
let roomsTranslator = require('../../rooms.js');
|
|
190
|
-
roomName = roomsTranslator(lang, roomName)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
let funcName = control.functionality?.common?.name;
|
|
194
|
-
let translateFunctionalityName;
|
|
195
|
-
if (typeof funcName === 'object') {
|
|
196
|
-
funcName = funcName[lang] || funcName.en;
|
|
197
|
-
translateFunctionalityName = lang && lang !== 'en' && !funcName[lang];
|
|
198
|
-
} else {
|
|
199
|
-
translateFunctionalityName = true;
|
|
200
|
-
}
|
|
201
|
-
if (translateFunctionalityName) {
|
|
202
|
-
let funcsTranslator = require('../../functions.js');
|
|
203
|
-
funcName = funcsTranslator(lang, funcName);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
concatenation = concatenation ? ` ${concatenation} ` : ' ';
|
|
207
|
-
|
|
208
|
-
name = `${funcNameFirst ? funcName : roomName}${concatenation}${funcNameFirst ? roomName : funcName}`;
|
|
209
|
-
name = name.trim();
|
|
210
|
-
|
|
211
|
-
return this.onlyValidCharactersAndLengthForFriendlyName(name);
|
|
212
|
-
},
|
|
213
|
-
/**
|
|
214
|
-
* Checks whether the provided value is a valid smart name.
|
|
215
|
-
* @param {*} smartName The value to check
|
|
216
|
-
* @param {String} [lang='en'] Configured language
|
|
217
|
-
* @returns {Boolean} True if a valid smart name, false - otherwise.
|
|
218
|
-
*/
|
|
219
|
-
isValidSmartName: function (smartName, lang) {
|
|
220
|
-
let name = smartName;
|
|
221
|
-
if (smartName === false || smartName === 'ignore') {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
if (smartName && typeof smartName === 'object') {
|
|
225
|
-
name = smartName[lang] || smartName.en || smartName.de;
|
|
226
|
-
}
|
|
227
|
-
return ![null, undefined, 'ignore', false].includes(name);
|
|
228
|
-
},
|
|
229
|
-
/**
|
|
230
|
-
* Checks a value for validity or returns a default.
|
|
231
|
-
* @param value The value being checked
|
|
232
|
-
* @param defaultValue A default value if the passed value is not valid
|
|
233
|
-
* @returns {*} The passed value if valid otherwise the default value.
|
|
234
|
-
*/
|
|
235
|
-
defaultIfNullOrEmpty: function (value, defaultValue) {
|
|
236
|
-
if (value === undefined || (typeof value === 'object' && Object.keys(value).length === 0) || value === "")
|
|
237
|
-
return defaultValue;
|
|
238
|
-
|
|
239
|
-
return value;
|
|
240
|
-
},
|
|
241
|
-
/**
|
|
242
|
-
* Inspects all objects (states, channels and devices) and tries to identify so-called 'controls'
|
|
243
|
-
*
|
|
244
|
-
* To identify the controls, the ioBroker type detector library is used (https://github.com/ioBroker/ioBroker.type-detector).
|
|
245
|
-
* @async
|
|
246
|
-
* @param adapter The iot adapter instance
|
|
247
|
-
* @param lang language
|
|
248
|
-
* @returns {Promise<Array>} An array containing the detected controls
|
|
249
|
-
*/
|
|
250
|
-
controls: async function (adapter, lang) {
|
|
251
|
-
// here we collect ids to inspect
|
|
252
|
-
const list = [];
|
|
253
|
-
|
|
254
|
-
// fetch all objects (states, channels and devices in terms of iobroker)
|
|
255
|
-
let devicesObject = await allObjects(adapter);
|
|
256
|
-
// fetch all defined rooms and functions (enumerations)
|
|
257
|
-
const [functionalities, rooms] = await functionalitiesAndRooms(adapter);
|
|
258
|
-
|
|
259
|
-
// every member of a function enumeration is added to the list of ids to inspect
|
|
260
|
-
functionalities.forEach(functionEnumItem => {
|
|
261
|
-
functionEnumItem.common.members.forEach(id => {
|
|
262
|
-
const smartName = getSmartNameFromObj(devicesObject[id], adapter.namespace, adapter.config.noCommon);
|
|
263
|
-
|
|
264
|
-
if (devicesObject[id] &&
|
|
265
|
-
devicesObject[id].common &&
|
|
266
|
-
(devicesObject[id].type === 'state' || devicesObject[id].type === 'channel' || devicesObject[id].type === 'device') &&
|
|
267
|
-
!list.includes(id) &&
|
|
268
|
-
smartName !== false && // if the device is not disabled
|
|
269
|
-
smartName !== 'ignore'
|
|
270
|
-
) {
|
|
271
|
-
list.push(id);
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// a member of a room enumeration is only added if neither its parent (channel) nor its grandparent (device) is in
|
|
277
|
-
rooms.forEach(roomEnumItem => {
|
|
278
|
-
roomEnumItem.common.members.forEach(id => {
|
|
279
|
-
const smartName = getSmartNameFromObj(devicesObject[id], adapter.namespace, adapter.config.noCommon);
|
|
280
|
-
if (devicesObject[id] &&
|
|
281
|
-
devicesObject[id].common &&
|
|
282
|
-
(devicesObject[id].type === 'state' || devicesObject[id].type === 'channel' || devicesObject[id].type === 'device') &&
|
|
283
|
-
!list.includes(id) &&
|
|
284
|
-
smartName !== false && // if the device is not disabled
|
|
285
|
-
smartName !== 'ignore'
|
|
286
|
-
) {
|
|
287
|
-
const channelId = getChannelId(id, devicesObject);
|
|
288
|
-
if (channelId) {
|
|
289
|
-
if (!list.includes(channelId)) {
|
|
290
|
-
const deviceId = getDeviceId(id, devicesObject);
|
|
291
|
-
if (deviceId) {
|
|
292
|
-
if (!list.includes(deviceId)) {
|
|
293
|
-
list.push(id);
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
list.push(id);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
} else {
|
|
300
|
-
list.push(id);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
})
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
// all ids, i.e. ids of all iobroker states/channels/devices
|
|
307
|
-
const keys = Object.keys(devicesObject).sort();
|
|
308
|
-
|
|
309
|
-
const idsWithSmartName = [];
|
|
310
|
-
// if a state has got a smart name directly assigned and neither itself nor its channel is in the list, add its id to the inspection list
|
|
311
|
-
// and process it first
|
|
312
|
-
keys.forEach(id => {
|
|
313
|
-
const smartName = devicesObject[id] && getSmartNameFromObj(devicesObject[id], adapter.namespace, adapter.config.noCommon);
|
|
314
|
-
if (this.isValidSmartName(smartName, lang) &&
|
|
315
|
-
devicesObject[id].common &&
|
|
316
|
-
(devicesObject[id].type === 'state' || devicesObject[id].type === 'channel' || devicesObject[id].type === 'device')
|
|
317
|
-
) {
|
|
318
|
-
idsWithSmartName.push(id);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// collect first all smart names and remove them from the auto-groups
|
|
323
|
-
let detectedControls = [];
|
|
324
|
-
const detector = new ChannelDetector();
|
|
325
|
-
|
|
326
|
-
const patterns = detector.getPatterns();
|
|
327
|
-
// process states with defined smartName
|
|
328
|
-
for (let s = 0; s < idsWithSmartName.length; s++) {
|
|
329
|
-
const id = idsWithSmartName[s];
|
|
330
|
-
const common = devicesObject[id].common;
|
|
331
|
-
const smartName = getSmartNameFromObj(devicesObject[id], adapter.namespace, adapter.config.noCommon);
|
|
332
|
-
// try to convert the state to typeDetector format
|
|
333
|
-
// "smartName": {
|
|
334
|
-
// "de": "Rote Lampe",
|
|
335
|
-
// "smartType": "LIGHT", // optional
|
|
336
|
-
// "byON": 80 // optional
|
|
337
|
-
// }
|
|
338
|
-
if (!smartName.smartType) {
|
|
339
|
-
// by default,
|
|
340
|
-
// all booleans are sockets
|
|
341
|
-
// all numbers are dimmer
|
|
342
|
-
// string is not possible to control
|
|
343
|
-
if (common.type === 'boolean' || common.type === 'mixed') { // we will write boolean
|
|
344
|
-
smartName.smartType = 'socket';
|
|
345
|
-
} else if (common.type === 'number') {
|
|
346
|
-
smartName.smartType = 'dimmer';
|
|
347
|
-
} else {
|
|
348
|
-
smartName.smartType = 'socket';
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
// convert alexa2 smartType to alexa 3
|
|
352
|
-
if (SMART_TYPES[smartName.smartType]) {
|
|
353
|
-
smartName.smartType = SMART_TYPES[smartName.smartType];
|
|
354
|
-
}
|
|
355
|
-
// try to simulate typeDetector format
|
|
356
|
-
if (patterns[smartName.smartType]) {
|
|
357
|
-
const control = JSON.parse(JSON.stringify(patterns[smartName.smartType]));
|
|
358
|
-
// find first required
|
|
359
|
-
const state = control.states.find(state => state.required);
|
|
360
|
-
if (state) {
|
|
361
|
-
state.id = id;
|
|
362
|
-
// process control
|
|
363
|
-
// remove all unassigned control register
|
|
364
|
-
control.states = control.states.filter(s => s.id);
|
|
365
|
-
|
|
366
|
-
// take all smartNames if any
|
|
367
|
-
control.states.forEach(s => {
|
|
368
|
-
s.smartName = getSmartNameFromObj(devicesObject[s.id], adapter.namespace, adapter.config.noCommon);
|
|
369
|
-
s.common = {
|
|
370
|
-
min: devicesObject[s.id]?.common?.min,
|
|
371
|
-
max: devicesObject[s.id]?.common?.max,
|
|
372
|
-
type: devicesObject[s.id]?.common?.type,
|
|
373
|
-
states: devicesObject[s.id]?.common?.states,
|
|
374
|
-
role: devicesObject[s.id]?.common?.role,
|
|
375
|
-
name: devicesObject[s.id]?.common?.name,
|
|
376
|
-
};
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
devicesObject[id].common.smartName = smartName;
|
|
380
|
-
|
|
381
|
-
control.object = {
|
|
382
|
-
id,
|
|
383
|
-
type: devicesObject[id].type,
|
|
384
|
-
common: devicesObject[id].common,
|
|
385
|
-
autoDetected: false,
|
|
386
|
-
toggle: smartName?.toggle,
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// remove id from the groups
|
|
390
|
-
let pos = list.indexOf(id);
|
|
391
|
-
if (pos !== -1) {
|
|
392
|
-
list.splice(pos, 1);
|
|
393
|
-
}
|
|
394
|
-
const channelId = getChannelId(id, devicesObject);
|
|
395
|
-
pos = list.indexOf(channelId);
|
|
396
|
-
if (pos !== -1) {
|
|
397
|
-
list.splice(pos, 1);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
const name = smartName[lang] || smartName.en || smartName.de;
|
|
401
|
-
control.groupNames = name.split(',').map(n => n.trim());
|
|
402
|
-
|
|
403
|
-
adapter.log.debug(`[ALEXA3] added ${id} with smartName as "${smartName.smartType}"`);
|
|
404
|
-
detectedControls.push(control);
|
|
405
|
-
} else {
|
|
406
|
-
// ignored
|
|
407
|
-
adapter.log.debug(`[ALEXA3] Ignored state ${id} with smartName ${JSON.stringify(smartName)} and type ${common.type}`);
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
// ignored
|
|
411
|
-
adapter.log.debug(`[ALEXA3] Ignored state ${id} with smartName ${JSON.stringify(smartName)} and type ${common.type}`);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// initialize iobroker type detector
|
|
416
|
-
const usedIds = [];
|
|
417
|
-
const ignoreIndicators = ['UNREACH_STICKY']; // Ignore indicators by name
|
|
418
|
-
const excludedTypes = ['info'];
|
|
419
|
-
const options = {
|
|
420
|
-
objects: devicesObject,
|
|
421
|
-
_keysOptional: keys,
|
|
422
|
-
_usedIdsOptional: usedIds,
|
|
423
|
-
ignoreIndicators,
|
|
424
|
-
excludedTypes,
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
// go other the list of ids to inspect and collect the detected controls
|
|
428
|
-
list.forEach(id => {
|
|
429
|
-
options.id = id;
|
|
430
|
-
let controls = detector.detect(options);
|
|
431
|
-
if (controls) {
|
|
432
|
-
controls.forEach(control => {
|
|
433
|
-
// if any detected state has an ID, we can use this control
|
|
434
|
-
if (control.states.find(state => state.id)) {
|
|
435
|
-
// console.log(`In ${id} was detected "${control.type}" with the following states:`);
|
|
436
|
-
|
|
437
|
-
// remove all unassigned control register
|
|
438
|
-
control.states = control.states.filter(s => s.id);
|
|
439
|
-
|
|
440
|
-
// take all smartNames if any
|
|
441
|
-
control.states.forEach(s => {
|
|
442
|
-
s.smartName = getSmartNameFromObj(devicesObject[s.id], adapter.namespace, adapter.config.noCommon);
|
|
443
|
-
s.common = {
|
|
444
|
-
min: devicesObject[s.id]?.common?.min,
|
|
445
|
-
max: devicesObject[s.id]?.common?.max,
|
|
446
|
-
type: devicesObject[s.id]?.common?.type,
|
|
447
|
-
states: devicesObject[s.id]?.common?.states,
|
|
448
|
-
role: devicesObject[s.id]?.common?.role,
|
|
449
|
-
name: devicesObject[s.id]?.common?.name,
|
|
450
|
-
};
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
// find out the room the found control is in
|
|
454
|
-
let room = rooms.find(room => room?.common?.members.includes(id))
|
|
455
|
-
|
|
456
|
-
// find out the functionality the found control assigned to
|
|
457
|
-
let functionality = functionalities.find(functionality => functionality?.common?.members.includes(id))
|
|
458
|
-
|
|
459
|
-
const smartName = getSmartNameFromObj(devicesObject[id], adapter.namespace, adapter.config.noCommon);
|
|
460
|
-
control.object = {
|
|
461
|
-
id,
|
|
462
|
-
type: devicesObject[id].type,
|
|
463
|
-
common: {
|
|
464
|
-
min: devicesObject[id].common?.min,
|
|
465
|
-
max: devicesObject[id].common?.max,
|
|
466
|
-
type: devicesObject[id].common?.type,
|
|
467
|
-
states: devicesObject[id].common?.states,
|
|
468
|
-
role: devicesObject[id].common?.role,
|
|
469
|
-
name: devicesObject[id].common?.name,
|
|
470
|
-
smartName,
|
|
471
|
-
},
|
|
472
|
-
autoDetected: true,
|
|
473
|
-
toggle: smartName?.toggle,
|
|
474
|
-
};
|
|
475
|
-
|
|
476
|
-
control.room = room ? {
|
|
477
|
-
id: room._id,
|
|
478
|
-
common: room.common
|
|
479
|
-
} : undefined;
|
|
480
|
-
|
|
481
|
-
control.functionality = functionality ? {
|
|
482
|
-
id: functionality._id,
|
|
483
|
-
common: functionality.common,
|
|
484
|
-
} : undefined;
|
|
485
|
-
|
|
486
|
-
detectedControls.push(control);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
} else {
|
|
490
|
-
// console.log(`Nothing found for ${id}`);
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
return detectedControls;
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Normalizes any provided value with observed min and max to the range 0..100
|
|
499
|
-
* @param {number} value - value to be normalized
|
|
500
|
-
* @param {number} min - min observed (possible) value
|
|
501
|
-
* @param {number} max - max observed (possible) value
|
|
502
|
-
* @returns Normalized value in the range 0..100 or undefined on invalid input
|
|
503
|
-
*/
|
|
504
|
-
normalize_0_100: function (value, min, max) {
|
|
505
|
-
return min >= max || value < min || value > max ? undefined : Math.round((value - min) / (max - min) * 100)
|
|
506
|
-
},
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Denormalizes any provided value from range 0..100 to the min..max range
|
|
510
|
-
* @param {number} normalized - normalized value
|
|
511
|
-
* @param {number} min - min observed (possible) value
|
|
512
|
-
* @param {number} max - max observed (possible) value
|
|
513
|
-
* @returns Denormalized value in the range min-max
|
|
514
|
-
*/
|
|
515
|
-
denormalize_0_100: function (normalized, min, max) {
|
|
516
|
-
return min >= max || normalized < 0 || normalized > 100 ? undefined : Math.round(normalized / 100 * (max - min) + min)
|
|
517
|
-
},
|
|
518
|
-
/**
|
|
519
|
-
* Returns distinct objects in a list based on values of the provided property name
|
|
520
|
-
* @param {Array} list - list of objects
|
|
521
|
-
* @param {string} propertyName - name of the property to build distinct values on
|
|
522
|
-
* @param {boolean} combineValues - if the values should be combined and not just overwritten
|
|
523
|
-
* @returns {Array} List containing at most one element per property value
|
|
524
|
-
*/
|
|
525
|
-
distinctByPropertyName: function (list, propertyName, combineValues) {
|
|
526
|
-
let map = new Map();
|
|
527
|
-
for (const item of list) {
|
|
528
|
-
if (map.has(item[propertyName]) && combineValues) {
|
|
529
|
-
const existing = map.get(item[propertyName]);
|
|
530
|
-
if (existing.value === 'ON' || existing.value === 'OFF') {
|
|
531
|
-
if (item.value === 'ON') {
|
|
532
|
-
existing.value = item.value;
|
|
533
|
-
}
|
|
534
|
-
} else if (isFinite(existing.value) && isFinite(item.value)) {
|
|
535
|
-
existing.value = Math.max(existing.value, item.value);
|
|
536
|
-
}
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
map.set(item[propertyName], item);
|
|
540
|
-
}
|
|
541
|
-
return Array.from(map.values());
|
|
542
|
-
},
|
|
543
|
-
className: function (thisToString) {
|
|
544
|
-
let classNameRegEx = /\S+\s+([a-zA-Z_$][0-9a-zA-Z_$]*)/;
|
|
545
|
-
return classNameRegEx.exec(thisToString)[1];
|
|
546
|
-
},
|
|
547
|
-
/**
|
|
548
|
-
* Updates the provided value if required to fit it into the range 0..100
|
|
549
|
-
* @param {Number} value
|
|
550
|
-
* @returns
|
|
551
|
-
*/
|
|
552
|
-
ensureValueInRange_0_100: function (value) {
|
|
553
|
-
return this.ensureValueInRange(value, 0, 100);
|
|
554
|
-
},
|
|
555
|
-
/**
|
|
556
|
-
* Updates the provided value if required to fit it into the range min..max
|
|
557
|
-
* @param {Number} value
|
|
558
|
-
* @param {Number} min
|
|
559
|
-
* @param {Number} max
|
|
560
|
-
* @returns
|
|
561
|
-
*/
|
|
562
|
-
ensureValueInRange: function (value, min, max) {
|
|
563
|
-
return Math.max(min, Math.min(max, value));
|
|
564
|
-
},
|
|
565
|
-
|
|
566
|
-
firstLower: function (input) {
|
|
567
|
-
return input && input[0].toLowerCase() + input.slice(1) || input;
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
closestFromList: function (target, list) {
|
|
571
|
-
return list.reduce((prev, curr) => Math.abs(curr - target) < Math.abs(prev - target) ? curr : prev);
|
|
572
|
-
},
|
|
573
|
-
|
|
574
|
-
asEnum: function (values) {
|
|
575
|
-
const enumeration = {};
|
|
576
|
-
let i = 0;
|
|
577
|
-
for (const value of values) {
|
|
578
|
-
enumeration[enumeration[i] = value] = i;
|
|
579
|
-
i++;
|
|
580
|
-
}
|
|
581
|
-
return enumeration;
|
|
582
|
-
}
|
|
583
|
-
}
|