iobroker.iot 4.0.2 → 4.1.0
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 -0
- package/admin/assets/index-Ck_2gqQY.js +681 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{ActionVisu-D9x2f6zu.js → ActionVisu-DE8dgNVF.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js → ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js} +2 -2
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +5 -0
- package/admin/rules/assets/bootstrap-Ba57tu25.js +1 -0
- package/admin/rules/assets/{hostInit-hos3Txsy.js → hostInit-Dxp6BaAc.js} +2 -2
- package/admin/rules/assets/index-208Qrr3S.js +1152 -0
- package/admin/rules/assets/{index-Duo7mFlZ.js → index-Bvn52imU.js} +2 -2
- package/admin/rules/assets/{index-CAAeiKCc.js → index-DjPMvPni.js} +2 -2
- package/admin/rules/assets/preload-helper-BDBacUwf.js +1 -0
- package/admin/rules/assets/virtualExposes-O8-92o9I.js +2 -0
- package/admin/rules/customRuleBlocks.js +2 -2
- package/admin/rules/i18n/de.json +8 -8
- package/admin/rules/i18n/es.json +8 -8
- package/admin/rules/i18n/fr.json +8 -8
- package/admin/rules/i18n/it.json +8 -8
- package/admin/rules/i18n/nl.json +8 -8
- package/admin/rules/i18n/pl.json +8 -8
- package/admin/rules/i18n/pt.json +8 -8
- package/admin/rules/i18n/ru.json +8 -8
- package/admin/rules/i18n/uk.json +8 -8
- package/admin/rules/i18n/zh-cn.json +8 -8
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +2 -7
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +6 -5
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +4 -3
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +4 -3
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +6 -5
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +5 -4
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +3 -2
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +5 -4
- package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +20 -18
- package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +2 -7
- package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +3 -0
- package/build/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +3 -3
- package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +3 -3
- package/build/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -3
- package/build/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AirCondition.js +64 -69
- package/build/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +5 -1
- package/build/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Control.js +13 -29
- package/build/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Ct.js +66 -73
- package/build/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Dimmer.js +32 -39
- package/build/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Gate.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Hue.js +91 -89
- package/build/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Light.js +10 -14
- package/build/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Lock.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Motion.js +5 -1
- package/build/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -10
- package/build/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Socket.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Temperature.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
- package/build/lib/AlexaSmartHomeV3/Controls/Thermostat.js +82 -0
- package/build/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +5 -7
- package/build/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Volume.js +29 -36
- package/build/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/index.js +6 -6
- package/build/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
- package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +4 -1
- package/build/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
- package/{build-backend → build}/lib/alexaCustom.js +71 -60
- package/build/lib/alexaCustom.js.map +1 -0
- package/{build-backend → build}/lib/alexaSmartHomeV3.js +3 -3
- package/build/lib/alexaSmartHomeV3.js.map +1 -0
- package/{build-backend → build}/main.js +6 -6
- package/build/main.js.map +1 -0
- package/io-package.json +30 -29
- package/package.json +12 -12
- package/admin/assets/index-5zouxn2w.js +0 -680
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +0 -10
- package/admin/rules/assets/bootstrap-BCFKIiwZ.js +0 -1
- package/admin/rules/assets/index-DwYdaT5M.js +0 -1151
- package/admin/rules/assets/preload-helper-Dp1pzeXC.js +0 -1
- package/admin/rules/assets/virtualExposes-BqVak7rX.js +0 -2
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -85
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +0 -1
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +0 -1
- package/build-backend/lib/alexaCustom.js.map +0 -1
- package/build-backend/lib/alexaSmartHomeV3.js.map +0 -1
- package/build-backend/main.js.map +0 -1
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Blind.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Door.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Door.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Slider.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Window.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Window.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Device.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Device.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/DeviceManager.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/DeviceManager.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -0
- /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +0 -0
- /package/{build-backend → build}/lib/Utils.js +0 -0
- /package/{build-backend → build}/lib/Utils.js.map +0 -0
- /package/{build-backend → build}/lib/adminCommonSocket.js +0 -0
- /package/{build-backend → build}/lib/adminCommonSocket.js.map +0 -0
- /package/{build-backend → build}/lib/alexaSmartHomeV2.js +0 -0
- /package/{build-backend → build}/lib/alisa.js +0 -0
- /package/{build-backend → build}/lib/devices.js +0 -0
- /package/{build-backend → build}/lib/devices.js.map +0 -0
- /package/{build-backend → build}/lib/functions.js +0 -0
- /package/{build-backend → build}/lib/functions.js.map +0 -0
- /package/{build-backend → build}/lib/googleHome.js +0 -0
- /package/{build-backend → build}/lib/notifications.js +0 -0
- /package/{build-backend → build}/lib/notifications.js.map +0 -0
- /package/{build-backend → build}/lib/remote.js +0 -0
- /package/{build-backend → build}/lib/remote.js.map +0 -0
- /package/{build-backend → build}/lib/rooms.js +0 -0
- /package/{build-backend → build}/lib/rooms.js.map +0 -0
- /package/{build-backend → build}/lib/texts.js +0 -0
- /package/{build-backend → build}/lib/texts.js.map +0 -0
- /package/{build-backend → build}/lib/translate.js +0 -0
- /package/{build-backend → build}/lib/translate.js.map +0 -0
- /package/{build-backend → build}/lib/visuApp.js +0 -0
- /package/{build-backend → build}/lib/visuApp.js.map +0 -0
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Control_1 = __importDefault(require("./Control"));
|
|
7
7
|
const Base_1 = require("../Alexa/Properties/Base");
|
|
8
8
|
class AdjustableControl extends Control_1.default {
|
|
9
|
-
adjustableProperties() {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
9
|
isAdjustDirective(event) {
|
|
13
10
|
return this.adjustableProperties().some(property => property.matches(event) && property.directive(event) === Base_1.Base.ADJUST);
|
|
14
11
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdjustableControl.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/AdjustableControl.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,mDAAkE;AAGlE,MAA8B,iBAAkB,SAAQ,iBAAO;IAG3D,iBAAiB,CAAC,KAAqB;QACnC,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC,IAAI,CACnC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,WAAc,CAAC,MAAM,CAC7F,CAAC;IACN,CAAC;IAED,WAAW,CACP,KAAqB;QAErB,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAClG,CAAC;CACJ;AAdD,oCAcC","sourcesContent":["import Control from './Control';\nimport { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport type { AlexaV3DirectiveValue, AlexaV3Request } from '../types';\n\nexport default abstract class AdjustableControl extends Control {\n abstract adjustableProperties(): (typeof PropertiesBase)[];\n\n isAdjustDirective(event: AlexaV3Request): boolean {\n return this.adjustableProperties().some(\n property => property.matches(event) && property.directive(event) === PropertiesBase.ADJUST,\n );\n }\n\n valueSetter(\n event: AlexaV3Request,\n ): (event: AlexaV3Request, property: PropertiesBase) => Promise<AlexaV3DirectiveValue> {\n return this.isAdjustDirective(event) ? this.adjustValue.bind(this) : super.valueSetter(event);\n }\n}\n"]}
|
package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js
RENAMED
|
@@ -7,16 +7,14 @@ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
|
|
|
7
7
|
const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
|
|
8
8
|
const Percentage_1 = __importDefault(require("../Alexa/Properties/Percentage"));
|
|
9
9
|
class AdjustablePercentageControl extends AdjustableControl_1.default {
|
|
10
|
+
constructor(detectedControl) {
|
|
11
|
+
super(detectedControl);
|
|
12
|
+
const percentageController = new Capabilities_1.default.PercentageController(this.percentageInitObject());
|
|
13
|
+
this._supported = [percentageController];
|
|
14
|
+
}
|
|
10
15
|
adjustableProperties() {
|
|
11
16
|
return [Percentage_1.default];
|
|
12
17
|
}
|
|
13
|
-
initCapabilities() {
|
|
14
|
-
const result = [new Capabilities_1.default.PercentageController()];
|
|
15
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
16
|
-
property.init(this.percentageInitObject());
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
18
|
async setState(property, value) {
|
|
21
19
|
// todo: byON
|
|
22
20
|
return super.setState(property, value);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdjustablePercentageControl.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,4EAAoD;AACpD,gFAAwD;AAIxD,MAAqB,2BAA4B,SAAQ,2BAAiB;IACtE,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,MAAM,oBAAoB,GAAG,IAAI,sBAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,UAAU,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC7C,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,oBAAU,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAwB,EAAE,KAA0B;QAC/D,aAAa;QACb,OAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;CACJ;AAfD,8CAeC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport AdjustableControl from './AdjustableControl';\nimport Percentage from '../Alexa/Properties/Percentage';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport { type IotExternalPatternControl } from '../types';\n\nexport default class AdjustablePercentageControl extends AdjustableControl {\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n const percentageController = new Capabilities.PercentageController(this.percentageInitObject());\n this._supported = [percentageController];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [Percentage];\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n // todo: byON\n return super.setState(property, value);\n }\n}\n"]}
|
|
@@ -7,7 +7,6 @@ const ThermostatController_1 = __importDefault(require("../Alexa/Capabilities/Th
|
|
|
7
7
|
const ThermostatMode_1 = __importDefault(require("../Alexa/Properties/ThermostatMode"));
|
|
8
8
|
const PowerController_1 = __importDefault(require("../Alexa/Capabilities/PowerController"));
|
|
9
9
|
const TemperatureSensor_1 = __importDefault(require("../Alexa/Capabilities/TemperatureSensor"));
|
|
10
|
-
const Temperature_1 = __importDefault(require("../Alexa/Properties/Temperature"));
|
|
11
10
|
const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
|
|
12
11
|
const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
|
|
13
12
|
const Utils_1 = require("../Helpers/Utils");
|
|
@@ -19,6 +18,18 @@ class AirCondition extends AdjustableControl_1.default {
|
|
|
19
18
|
_powerController;
|
|
20
19
|
_powerState;
|
|
21
20
|
_lastKnownMode;
|
|
21
|
+
constructor(detectedControl) {
|
|
22
|
+
super(detectedControl);
|
|
23
|
+
this._thermostatController = new ThermostatController_1.default(this.composeInitObjectThermostatMode(), this.composeInitObjectTargetSetpoint());
|
|
24
|
+
this._thermostatMode = this._thermostatController.thermostatMode;
|
|
25
|
+
this._powerController = new PowerController_1.default(this.composeInitObjectPowerState());
|
|
26
|
+
this._powerState = this._powerController.powerState;
|
|
27
|
+
this._supported = [
|
|
28
|
+
new TemperatureSensor_1.default(this.composeInitObjectTemperature()),
|
|
29
|
+
this._thermostatController,
|
|
30
|
+
this._powerController,
|
|
31
|
+
];
|
|
32
|
+
}
|
|
22
33
|
get categories() {
|
|
23
34
|
return ['AIR_CONDITIONER'];
|
|
24
35
|
}
|
|
@@ -28,23 +39,6 @@ class AirCondition extends AdjustableControl_1.default {
|
|
|
28
39
|
get dedicatedOnOff() {
|
|
29
40
|
return this.states[this.statesMap.power] !== undefined;
|
|
30
41
|
}
|
|
31
|
-
initCapabilities() {
|
|
32
|
-
this._thermostatController = new ThermostatController_1.default();
|
|
33
|
-
this._thermostatMode = this._thermostatController.thermostatMode;
|
|
34
|
-
this._powerController = new PowerController_1.default();
|
|
35
|
-
this._powerState = this._powerController.powerState;
|
|
36
|
-
const result = [new TemperatureSensor_1.default(), this._thermostatController, this._powerController];
|
|
37
|
-
for (const property of result.flatMap(item => item.properties)) {
|
|
38
|
-
const initObject = this.composeInitObject(property);
|
|
39
|
-
if (initObject) {
|
|
40
|
-
property.init(initObject);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
throw new Error(`Unable to initialize property ${property.propertyName}`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
42
|
async setState(property, value) {
|
|
49
43
|
// if we set power ON/OFF via thermostat mode
|
|
50
44
|
if (property.propertyName === PowerState_1.default.propertyName && !this.dedicatedOnOff) {
|
|
@@ -90,58 +84,59 @@ class AirCondition extends AdjustableControl_1.default {
|
|
|
90
84
|
}
|
|
91
85
|
return property.currentValue;
|
|
92
86
|
}
|
|
93
|
-
|
|
87
|
+
composeInitObjectPowerState() {
|
|
94
88
|
const map = this.statesMap;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
89
|
+
return {
|
|
90
|
+
setState: this.states[map.power] || this.states[map.mode],
|
|
91
|
+
getState: this.states[map.power] || this.states[map.mode],
|
|
92
|
+
alexaSetter: function (alexaValue) {
|
|
93
|
+
return alexaValue === PowerState_1.default.ON;
|
|
94
|
+
},
|
|
95
|
+
alexaGetter: function (value) {
|
|
96
|
+
return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
composeInitObjectThermostatMode() {
|
|
101
|
+
const map = this.statesMap;
|
|
102
|
+
return {
|
|
103
|
+
setState: this.states[map.mode],
|
|
104
|
+
getState: this.states[map.mode],
|
|
105
|
+
alexaSetter: function (alexaValue) {
|
|
106
|
+
return this.supportedModesAsEnum[alexaValue];
|
|
107
|
+
},
|
|
108
|
+
alexaGetter: function (value) {
|
|
109
|
+
return this.supportedModesAsEnum[value];
|
|
110
|
+
},
|
|
111
|
+
supportedModes: [
|
|
112
|
+
ThermostatMode_1.default.AUTO,
|
|
113
|
+
ThermostatMode_1.default.COOL,
|
|
114
|
+
ThermostatMode_1.default.ECO,
|
|
115
|
+
ThermostatMode_1.default.HEAT,
|
|
116
|
+
ThermostatMode_1.default.OFF,
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
composeInitObjectTargetSetpoint() {
|
|
121
|
+
const map = this.statesMap;
|
|
122
|
+
// const range = Utils.configuredRangeOrDefault(this.states[map.set]);
|
|
123
|
+
return {
|
|
124
|
+
setState: this.states[map.set],
|
|
125
|
+
getState: this.states[map.actual] || this.states[map.set],
|
|
126
|
+
alexaSetter: function (alexaValue) {
|
|
127
|
+
return (0, Utils_1.ensureValueInRange)(alexaValue, this.valuesRangeMin, this.valuesRangeMax);
|
|
128
|
+
},
|
|
129
|
+
alexaGetter: function (value) {
|
|
130
|
+
return value || 0;
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
composeInitObjectTemperature() {
|
|
135
|
+
const map = this.statesMap;
|
|
136
|
+
return {
|
|
137
|
+
setState: this.states[map.set],
|
|
138
|
+
getState: this.states[map.actual] || this.states[map.set],
|
|
139
|
+
};
|
|
145
140
|
}
|
|
146
141
|
}
|
|
147
142
|
exports.default = AirCondition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AirCondition.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/AirCondition.ts"],"names":[],"mappings":";;;;;AAAA,sGAA8E;AAC9E,wFAAgE;AAChE,4FAAoE;AACpE,gGAAwE;AACxE,gFAAwD;AACxD,4EAAoD;AACpD,4CAAsD;AACtD,wFAAgE;AAEhE,iFAAyD;AAQzD,MAAqB,YAAa,SAAQ,2BAAiB;IACtC,qBAAqB,CAAuB;IAC5C,eAAe,CAAiB;IAChC,gBAAgB,CAAkB;IAClC,WAAW,CAAa;IACjC,cAAc,CAA8B;IAEpD,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,IAAI,CAAC,qBAAqB,GAAG,IAAI,8BAAoB,CACjD,IAAI,CAAC,+BAA+B,EAAE,EACtC,IAAI,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AC,KAAe,CAAC,CAAC;YACtD,CAAC;YACD,cAAc,EAAE;gBACZ,wBAAc,CAAC,IAAI;gBACnB,wBAAc,CAAC,IAAI;gBACnB,wBAAc,CAAC,GAAG;gBAClB,wBAAc,CAAC,IAAI;gBACnB,wBAAc,CAAC,GAAG;aACrB;SACJ,CAAC;IACN,CAAC;IAEO,+BAA+B;QAMnC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,sEAAsE;QACtE,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC1D,WAAW,EAAE,UAAgC,UAAiC;gBAC1E,OAAO,IAAA,0BAAkB,EACrB,UAAoB,EACpB,IAAI,CAAC,cAAwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,CAAC;YACN,CAAC;YACD,WAAW,EAAE,UAAU,KAAsC;gBACzD,OAAO,KAAK,IAAI,CAAC,CAAC;YACtB,CAAC;SACJ,CAAC;IACN,CAAC;IAEO,4BAA4B;QAIhC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;SAC7D,CAAC;IACN,CAAC;CACJ;AA5KD,+BA4KC","sourcesContent":["import ThermostatController from '../Alexa/Capabilities/ThermostatController';\nimport ThermostatMode from '../Alexa/Properties/ThermostatMode';\nimport PowerController from '../Alexa/Capabilities/PowerController';\nimport TemperatureSensor from '../Alexa/Capabilities/TemperatureSensor';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport AdjustableControl from './AdjustableControl';\nimport { ensureValueInRange } from '../Helpers/Utils';\nimport TargetSetpoint from '../Alexa/Properties/TargetSetpoint';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\n\nexport default class AirCondition extends AdjustableControl {\n private readonly _thermostatController: ThermostatController;\n private readonly _thermostatMode: ThermostatMode;\n private readonly _powerController: PowerController;\n private readonly _powerState: PowerState;\n private _lastKnownMode: number | string | undefined;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n this._thermostatController = new ThermostatController(\n this.composeInitObjectThermostatMode(),\n this.composeInitObjectTargetSetpoint(),\n );\n this._thermostatMode = this._thermostatController.thermostatMode;\n this._powerController = new PowerController(this.composeInitObjectPowerState());\n this._powerState = this._powerController.powerState;\n\n this._supported = [\n new TemperatureSensor(this.composeInitObjectTemperature()),\n this._thermostatController,\n this._powerController,\n ];\n }\n\n get categories(): AlexaV3Category[] {\n return ['AIR_CONDITIONER'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [TargetSetpoint];\n }\n\n get dedicatedOnOff(): boolean {\n return this.states[this.statesMap.power] !== undefined;\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue | undefined): Promise<void> {\n // if we set power ON/OFF via thermostat mode\n if (property.propertyName === PowerState.propertyName && !this.dedicatedOnOff) {\n // set the mode to the last known value or AUTO by switching power ON\n if (value) {\n this._lastKnownMode ||= this._thermostatMode.supportedModesAsEnum[ThermostatMode.AUTO];\n await AdapterProvider.setState(this._thermostatMode.setId, this._lastKnownMode);\n this._thermostatMode.currentValue = this._lastKnownMode;\n this._powerState.currentValue = true;\n } else {\n // set mode to OFF\n const modeOffValue = this._thermostatMode.supportedModesAsEnum[ThermostatMode.OFF];\n await AdapterProvider.setState(this._thermostatMode.setId, modeOffValue);\n this._thermostatMode.currentValue = this._lastKnownMode;\n this._powerState.currentValue = false;\n }\n } else {\n // just set the property\n await AdapterProvider.setState(property.setId, value!);\n property.currentValue = value;\n\n if (property.propertyName === ThermostatMode.propertyName) {\n this._lastKnownMode = value as string;\n if (!this.dedicatedOnOff) {\n this._powerState.currentValue =\n value !== this._thermostatMode.supportedModesAsEnum[ThermostatMode.OFF];\n }\n }\n }\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 // convert mode != OFF to power = true\n if (property.propertyName === this._powerState.propertyName && !this.dedicatedOnOff) {\n property.currentValue =\n property.currentValue !== this._thermostatMode.supportedModesAsEnum[ThermostatMode.OFF];\n }\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 private composeInitObjectPowerState(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.power] || this.states[map.mode]!,\n getState: this.states[map.power] || this.states[map.mode]!,\n alexaSetter: function (alexaValue: AlexaV3DirectiveValue): boolean {\n return alexaValue === PowerState.ON;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n private composeInitObjectThermostatMode(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n supportedModes?: string[];\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.mode]!,\n getState: this.states[map.mode]!,\n alexaSetter: function (\n this: PropertiesBase,\n alexaValue: AlexaV3DirectiveValue,\n ): ioBroker.StateValue | undefined {\n return this.supportedModesAsEnum[alexaValue as string];\n },\n alexaGetter: function (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return this.supportedModesAsEnum[value as string];\n },\n supportedModes: [\n ThermostatMode.AUTO,\n ThermostatMode.COOL,\n ThermostatMode.ECO,\n ThermostatMode.HEAT,\n ThermostatMode.OFF,\n ],\n };\n }\n\n private composeInitObjectTargetSetpoint(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n // const range = Utils.configuredRangeOrDefault(this.states[map.set]);\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.actual] || this.states[map.set]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return ensureValueInRange(\n alexaValue as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n );\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value || 0;\n },\n };\n }\n\n private composeInitObjectTemperature(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.actual] || this.states[map.set]!,\n };\n }\n}\n"]}
|
|
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const ContactSensor_1 = require("../Alexa/Capabilities/ContactSensor");
|
|
7
7
|
const ReadOnlyDetector_1 = __importDefault(require("./ReadOnlyDetector"));
|
|
8
8
|
class ContactSensor extends ReadOnlyDetector_1.default {
|
|
9
|
+
constructor(detectedControl) {
|
|
10
|
+
super(detectedControl);
|
|
11
|
+
this._supported = [this.capability];
|
|
12
|
+
}
|
|
9
13
|
get capability() {
|
|
10
|
-
return new ContactSensor_1.ContactSensor();
|
|
14
|
+
return new ContactSensor_1.ContactSensor(this.detectedStateInitObject());
|
|
11
15
|
}
|
|
12
16
|
get categories() {
|
|
13
17
|
return ['CONTACT_SENSOR'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactSensor.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/ContactSensor.ts"],"names":[],"mappings":";;;;;AAAA,uEAAiG;AAEjG,0EAAkD;AAGlD,MAAqB,aAAc,SAAQ,0BAAgB;IACvD,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,UAAU;QACV,OAAO,IAAI,6BAAyB,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,UAAU;QACV,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,CAAC;CACJ;AAbD,gCAaC","sourcesContent":["import { ContactSensor as ContactSensorCapabilities } from '../Alexa/Capabilities/ContactSensor';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\nimport ReadOnlyDetector from './ReadOnlyDetector';\nimport type { AlexaV3Category, IotExternalPatternControl } from '../types';\n\nexport default class ContactSensor extends ReadOnlyDetector {\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n this._supported = [this.capability];\n }\n\n get capability(): CapabilitiesBase {\n return new ContactSensorCapabilities(this.detectedStateInitObject());\n }\n\n get categories(): AlexaV3Category[] {\n return ['CONTACT_SENSOR'];\n }\n}\n"]}
|
|
@@ -37,33 +37,11 @@ class Control {
|
|
|
37
37
|
* @param detectedControl - The detected control in terms of iobroker type detector.
|
|
38
38
|
*/
|
|
39
39
|
constructor(detectedControl) {
|
|
40
|
-
this.initStates(detectedControl);
|
|
41
|
-
this._supported = this.initCapabilities();
|
|
42
|
-
this._enforced = this.initEnforcedCapabilities();
|
|
43
40
|
this.log = new Logger_1.default(this);
|
|
44
41
|
this.log.silly(`created instance`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* and at least one property. Every property is initialized with corresponding iobroker state ids and value converters from Alexa to iobroker types
|
|
49
|
-
* and vice versa.
|
|
50
|
-
*
|
|
51
|
-
* @returns Array of objects with natively supported Alexa capabilities and correspondingly configured instances of StateProxies
|
|
52
|
-
*/
|
|
53
|
-
initCapabilities() {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* This function maps a passed on control to an array of objects. Each object contains an Alexa capability the control can handle even
|
|
58
|
-
* though not natively supported (e.g., the light control can handle the Alexa BrightnessController directive by switching
|
|
59
|
-
* itself `ON` on brightness > 0 and `OFF` on brightness == 0)
|
|
60
|
-
* Every capability has at least one property with set up iobroker state ids and value converters from Alexa to iobroker types
|
|
61
|
-
* and vice versa.
|
|
62
|
-
*
|
|
63
|
-
* @returns Array of objects with natively supported Alexa capabilities and correspondingly configured instances of StateProxies
|
|
64
|
-
*/
|
|
65
|
-
initEnforcedCapabilities() {
|
|
66
|
-
return [];
|
|
42
|
+
this.initStates(detectedControl);
|
|
43
|
+
this._supported = [];
|
|
44
|
+
this._enforced = [];
|
|
67
45
|
}
|
|
68
46
|
get allCapabilities() {
|
|
69
47
|
return this.supported.concat(this.enforced);
|
|
@@ -207,7 +185,11 @@ class Control {
|
|
|
207
185
|
}
|
|
208
186
|
async getOrRetrieveCurrentValue(property) {
|
|
209
187
|
if (property.currentValue === undefined) {
|
|
210
|
-
|
|
188
|
+
const id = property.getId;
|
|
189
|
+
if (!id) {
|
|
190
|
+
throw new Error(`no ID defined for property "${property.propertyName}" of "${this.name}"`);
|
|
191
|
+
}
|
|
192
|
+
property.currentValue = await AdapterProvider_1.default.getState(id);
|
|
211
193
|
}
|
|
212
194
|
if (property.currentValue === undefined) {
|
|
213
195
|
throw new Error(`unable to retrieve ${property.getId}`);
|
|
@@ -215,7 +197,6 @@ class Control {
|
|
|
215
197
|
return property.currentValue;
|
|
216
198
|
}
|
|
217
199
|
async reportState() {
|
|
218
|
-
this.log.debug(`reporting state`);
|
|
219
200
|
const propertiesToReport = [];
|
|
220
201
|
for (const capability of this.supported) {
|
|
221
202
|
for (const property of capability.properties) {
|
|
@@ -233,12 +214,15 @@ class Control {
|
|
|
233
214
|
propertiesToReport.push(toReport);
|
|
234
215
|
}
|
|
235
216
|
catch (error) {
|
|
236
|
-
this.log.error(`failed reporting state for property ${property.propertyName} of ${this.name}`);
|
|
217
|
+
this.log.error(`failed reporting state for property "${property.propertyName}" of "${this.name}"`);
|
|
218
|
+
if (error.stack) {
|
|
219
|
+
this.log.debug(`${error.stack}`);
|
|
220
|
+
}
|
|
237
221
|
this.log.debug(`${error}`);
|
|
238
222
|
}
|
|
239
223
|
}
|
|
240
224
|
}
|
|
241
|
-
this.log.debug(
|
|
225
|
+
this.log.debug(`reporting state: ${JSON.stringify(propertiesToReport)}`);
|
|
242
226
|
return propertiesToReport;
|
|
243
227
|
}
|
|
244
228
|
toString() {
|
|
@@ -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;IAClB,UAAU,CAAqB;IAC/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,CAAC,cAAwB,EAAE,IAAI,CAAC,cAAwB,CAAC,CAAC;YAC1G,CAAC;SACJ,CAAC;IACN,CAAC;;AApWL,0BAqWC","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 protected _supported: CapabilitiesBase[];\n protected _enforced: CapabilitiesBase[];\n protected 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.log = new Logger(this);\n this.log.silly(`created instance`);\n\n this.initStates(detectedControl);\n this._supported = [];\n this._enforced = [];\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 protected async getOrRetrieveCurrentValue(property: PropertiesBase): Promise<ioBroker.StateValue> {\n if (property.currentValue === undefined) {\n const id = property.getId;\n if (!id) {\n throw new Error(`no ID defined for property \"${property.propertyName}\" of \"${this.name}\"`);\n }\n property.currentValue = await AdapterProvider.getState(id);\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 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 if (error.stack) {\n this.log.debug(`${error.stack}`);\n }\n this.log.debug(`${error}`);\n }\n }\n }\n\n this.log.debug(`reporting state: ${JSON.stringify(propertiesToReport)}`);\n return propertiesToReport;\n }\n\n toString(): string {\n return `${this.constructor.name}`;\n }\n\n private 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 protected 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 protected 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 protected 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 protected 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"]}
|
|
@@ -16,39 +16,33 @@ class Ct extends AdjustableControl_1.default {
|
|
|
16
16
|
_colorTemperatureCapability;
|
|
17
17
|
_powerControllerCapability;
|
|
18
18
|
_powerState;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
adjustableProperties() {
|
|
23
|
-
return [ColorTemperatureInKelvin_1.default];
|
|
24
|
-
}
|
|
25
|
-
initCapabilities() {
|
|
19
|
+
constructor(detectedControl) {
|
|
20
|
+
super(detectedControl);
|
|
26
21
|
const map = this.statesMap;
|
|
27
|
-
|
|
22
|
+
this._supported = [new Capabilities_1.default.ColorController(this.blankInitObject())];
|
|
28
23
|
// if the state DIMMER or BRIGHTNESS configured
|
|
29
24
|
if (this.states[map.dimmer] || this.states[map.brightness]) {
|
|
30
|
-
this._brightnessCapability = new Capabilities_1.default.BrightnessController();
|
|
25
|
+
this._brightnessCapability = new Capabilities_1.default.BrightnessController(this.composeInitObjectBrightness());
|
|
31
26
|
this._brightness = this._brightnessCapability.brightness;
|
|
32
|
-
|
|
27
|
+
this._supported.push(this._brightnessCapability);
|
|
33
28
|
}
|
|
34
29
|
// if the state TEMPERATURE configured
|
|
35
30
|
if (this.states[map.temperature]) {
|
|
36
|
-
this._colorTemperatureCapability = new Capabilities_1.default.ColorTemperatureController();
|
|
37
|
-
|
|
31
|
+
this._colorTemperatureCapability = new Capabilities_1.default.ColorTemperatureController(this.composeInitObjectColorTemperature());
|
|
32
|
+
this._supported.push(this._colorTemperatureCapability);
|
|
38
33
|
}
|
|
39
34
|
// if the state ON, DIMMER or BRIGHTNESS configured
|
|
40
35
|
if (this.states[map.on] || this._brightness) {
|
|
41
|
-
this._powerControllerCapability = new Capabilities_1.default.PowerController();
|
|
36
|
+
this._powerControllerCapability = new Capabilities_1.default.PowerController(this.composeInitObjectPowerState());
|
|
42
37
|
this._powerState = this._powerControllerCapability.powerState;
|
|
43
|
-
|
|
38
|
+
this._supported.push(this._powerControllerCapability);
|
|
44
39
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return result;
|
|
40
|
+
}
|
|
41
|
+
get categories() {
|
|
42
|
+
return ['LIGHT'];
|
|
43
|
+
}
|
|
44
|
+
adjustableProperties() {
|
|
45
|
+
return [ColorTemperatureInKelvin_1.default];
|
|
52
46
|
}
|
|
53
47
|
async getOrRetrieveCurrentValue(property) {
|
|
54
48
|
const map = this.statesMap;
|
|
@@ -123,59 +117,58 @@ class Ct extends AdjustableControl_1.default {
|
|
|
123
117
|
await this.setState(property, value ?? 0);
|
|
124
118
|
return value;
|
|
125
119
|
}
|
|
126
|
-
|
|
120
|
+
composeInitObjectPowerState() {
|
|
127
121
|
const map = this.statesMap;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
122
|
+
return {
|
|
123
|
+
setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
124
|
+
getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
|
|
125
|
+
alexaSetter: function (alexaValue) {
|
|
126
|
+
return alexaValue === PowerState_1.default.ON;
|
|
127
|
+
},
|
|
128
|
+
alexaGetter: function (value) {
|
|
129
|
+
return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
composeInitObjectBrightness() {
|
|
134
|
+
const map = this.statesMap;
|
|
135
|
+
return {
|
|
136
|
+
setState: this.states[map.dimmer] || this.states[map.brightness],
|
|
137
|
+
getState: this.states[map.dimmer] || this.states[map.brightness],
|
|
138
|
+
alexaSetter: function (alexaValue) {
|
|
139
|
+
return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
|
|
140
|
+
},
|
|
141
|
+
alexaGetter: function (value) {
|
|
142
|
+
return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
composeInitObjectColorTemperature() {
|
|
147
|
+
const map = this.statesMap;
|
|
148
|
+
return {
|
|
149
|
+
setState: this.states[map.temperature],
|
|
150
|
+
getState: this.states[map.temperature],
|
|
151
|
+
alexaSetter: function (alexaValue) {
|
|
152
|
+
if (alexaValue === 1) {
|
|
153
|
+
// increase directive
|
|
154
|
+
const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
155
|
+
let index = this.colorTemperatureTable.indexOf(closest) + 1;
|
|
156
|
+
index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
|
|
157
|
+
return this.colorTemperatureTable[index];
|
|
158
|
+
}
|
|
159
|
+
if (alexaValue === -1) {
|
|
160
|
+
// decrease directive
|
|
161
|
+
const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
|
|
162
|
+
let index = this.colorTemperatureTable.indexOf(closest) - 1;
|
|
163
|
+
index = index < 0 ? 0 : index;
|
|
164
|
+
return this.colorTemperatureTable[index];
|
|
165
|
+
}
|
|
166
|
+
return alexaValue;
|
|
167
|
+
},
|
|
168
|
+
alexaGetter: function (value) {
|
|
169
|
+
return value;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
179
172
|
}
|
|
180
173
|
}
|
|
181
174
|
exports.default = Ct;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Ct.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Ct.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,4CAAiH;AACjH,iFAAyD;AACzD,4EAAoD;AAGpD,gFAAwD;AACxD,4GAAoF;AAGpF,gFAAwD;AASxD,MAAqB,EAAG,SAAQ,2BAAiB;IAC5B,qBAAqB,CAAmC;IACxD,WAAW,CAAyB;IACpC,2BAA2B,CAAyC;IACpE,0BAA0B,CAA8B;IACxD,WAAW,CAAyB;IAErD,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,sBAAY,CAAC,eAAe,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;QAE7E,+CAA+C;QAC/C,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACzD,IAAI,CAAC,qBAAqB,GAAG,IAAI,sBAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;YACvG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC;YACzD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACrD,CAAC;QAED,sCAAsC;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,GAA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,GAAG,IAAA,uBAAe,EAC1B,IAAI,CAAC,YAAuB,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAC9D,IAAI,CAAC,qBAAqB,CAC7B,CAAC;oBACF,IAAI,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBAC5D,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;oBAC9B,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;gBAC7C,CAAC;gBAED,OAAO,UAAoB,CAAC;YAChC,CAAC;YACD,WAAW,EAAE,UAAU,KAAsC;gBACzD,OAAO,KAAe,CAAC;YAC3B,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AAtND,qBAsNC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport { configuredRangeOrDefault, denormalize_0_100, normalize_0_100, closestFromList } from '../Helpers/Utils';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport AdjustableControl from './AdjustableControl';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\nimport type BrightnessController from '../Alexa/Capabilities/BrightnessController';\nimport Brightness from '../Alexa/Properties/Brightness';\nimport ColorTemperatureInKelvin from '../Alexa/Properties/ColorTemperatureInKelvin';\nimport type ColorTemperatureController from '../Alexa/Capabilities/ColorTemperatureController';\nimport type PowerController from '../Alexa/Capabilities/PowerController';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n AlexaV3Request,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\n\nexport default class Ct extends AdjustableControl {\n private readonly _brightnessCapability: BrightnessController | undefined;\n private readonly _brightness: Brightness | undefined;\n private readonly _colorTemperatureCapability: ColorTemperatureController | undefined;\n private readonly _powerControllerCapability: PowerController | undefined;\n private readonly _powerState: PowerState | undefined;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n const map = this.statesMap;\n this._supported = [new Capabilities.ColorController(this.blankInitObject())];\n\n // if the state DIMMER or BRIGHTNESS configured\n if (this.states[map.dimmer] || this.states[map.brightness]) {\n this._brightnessCapability = new Capabilities.BrightnessController(this.composeInitObjectBrightness());\n this._brightness = this._brightnessCapability.brightness;\n this._supported.push(this._brightnessCapability);\n }\n\n // if the state TEMPERATURE configured\n if (this.states[map.temperature]) {\n this._colorTemperatureCapability = new Capabilities.ColorTemperatureController(\n this.composeInitObjectColorTemperature(),\n );\n this._supported.push(this._colorTemperatureCapability);\n }\n\n // if the state ON, DIMMER or BRIGHTNESS configured\n if (this.states[map.on] || this._brightness) {\n this._powerControllerCapability = new Capabilities.PowerController(this.composeInitObjectPowerState());\n this._powerState = this._powerControllerCapability.powerState;\n this._supported.push(this._powerControllerCapability);\n }\n }\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [ColorTemperatureInKelvin];\n }\n\n protected async getOrRetrieveCurrentValue(property: PropertiesBase): Promise<ioBroker.StateValue> {\n const map = this.statesMap;\n\n if (property.currentValue === undefined) {\n property.currentValue = await AdapterProvider.getState(property.getId);\n // convert the non-zero brightness to power = true\n if (property.propertyName === PowerState.propertyName && !this.states[map.on]) {\n property.currentValue = property.currentValue !== 0;\n }\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 setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n const map = this.statesMap;\n\n if (property.propertyName === PowerState.propertyName) {\n if (this.states[map.on]) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n } else {\n if (!this._brightness) {\n throw new Error('No brightness property configured');\n }\n if (!this._powerState) {\n throw new Error('No powerState property configured');\n }\n\n if (value) {\n // set brightness\n // set byOn to the configured value or range.max otherwise\n const range = configuredRangeOrDefault(this.states[map.dimmer] || this.states[map.brightness]!);\n const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;\n let byOn: number | string | undefined | null;\n if (smartName && typeof smartName === 'object') {\n byOn = smartName.byON;\n } else {\n byOn = undefined;\n }\n if (byOn === undefined || byOn === null || isNaN(byOn as unknown as number)) {\n byOn = range.max as number | string | undefined | null;\n } else {\n byOn = parseFloat(byOn);\n }\n await AdapterProvider.setState(this._brightness.setId, byOn ?? 100);\n this._brightness.currentValue = byOn;\n this._powerState.currentValue = true;\n } else {\n // set brightness to 0 on power OFF\n await AdapterProvider.setState(this._brightness.setId, 0);\n this._brightness.currentValue = 0;\n this._powerState.currentValue = false;\n }\n }\n } else if (\n property.propertyName === Brightness.propertyName ||\n property.propertyName === ColorTemperatureInKelvin.propertyName\n ) {\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n }\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\n // convert delta to iobroker value\n const value = property.value(delta);\n\n // set iobroker state\n await this.setState(property, value ?? 0);\n\n return value as AlexaV3DirectiveValue;\n }\n\n protected composeInitObjectPowerState(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness]!,\n alexaSetter: function (this: PropertiesBase, alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue {\n return alexaValue === PowerState.ON;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n protected composeInitObjectBrightness(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.dimmer] || this.states[map.brightness]!,\n getState: this.states[map.dimmer] || this.states[map.brightness]!,\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 protected composeInitObjectColorTemperature(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n const map = this.statesMap;\n return {\n setState: this.states[map.temperature]!,\n getState: this.states[map.temperature]!,\n alexaSetter: function (\n this: ColorTemperatureInKelvin,\n alexaValue: AlexaV3DirectiveValue,\n ): ioBroker.StateValue {\n if (alexaValue === 1) {\n // increase directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) + 1;\n index = index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;\n return this.colorTemperatureTable[index];\n }\n if (alexaValue === -1) {\n // decrease directive\n const closest = closestFromList(\n (this.currentValue as number) || this.colorTemperatureTable[0],\n this.colorTemperatureTable,\n );\n let index = this.colorTemperatureTable.indexOf(closest) - 1;\n index = index < 0 ? 0 : index;\n return this.colorTemperatureTable[index];\n }\n\n return alexaValue as number;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value as number;\n },\n };\n }\n}\n"]}
|