iobroker.iot 4.0.3 → 4.1.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.
Files changed (251) hide show
  1. package/README.md +5 -517
  2. package/admin/assets/index-6Itc0U48.js +681 -0
  3. package/admin/index_m.html +1 -1
  4. package/admin/rules/assets/{hostInit-hos3Txsy.js → hostInit-Dxp6BaAc.js} +2 -2
  5. package/admin/rules/assets/index-208Qrr3S.js +1152 -0
  6. package/admin/rules/assets/{index-CbxmbJvB.js → index-Bvn52imU.js} +1 -1
  7. package/admin/rules/assets/preload-helper-BDBacUwf.js +1 -0
  8. package/admin/rules/assets/{virtualExposes-BNZJTatg.js → virtualExposes-O8-92o9I.js} +1 -1
  9. package/admin/rules/customRuleBlocks.js +2 -2
  10. package/admin/rules/i18n/de.json +8 -8
  11. package/admin/rules/i18n/es.json +8 -8
  12. package/admin/rules/i18n/fr.json +8 -8
  13. package/admin/rules/i18n/it.json +8 -8
  14. package/admin/rules/i18n/nl.json +8 -8
  15. package/admin/rules/i18n/pl.json +8 -8
  16. package/admin/rules/i18n/pt.json +8 -8
  17. package/admin/rules/i18n/ru.json +8 -8
  18. package/admin/rules/i18n/uk.json +8 -8
  19. package/admin/rules/i18n/zh-cn.json +8 -8
  20. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +6 -0
  21. package/build/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -0
  22. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +2 -7
  23. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
  24. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +6 -5
  25. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
  26. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +3 -2
  27. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
  28. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +4 -3
  29. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
  30. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +3 -2
  31. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
  32. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +3 -2
  33. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
  34. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +4 -3
  35. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
  36. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +3 -2
  37. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
  38. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +3 -2
  39. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
  40. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +6 -5
  41. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
  42. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +5 -4
  43. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
  44. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +3 -2
  45. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
  46. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +5 -4
  47. package/build/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
  48. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +1 -1
  49. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +1 -1
  50. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +20 -18
  51. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
  52. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +2 -7
  53. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
  54. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +9 -0
  55. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
  56. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +20 -0
  57. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +1 -0
  58. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +17 -3
  59. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
  60. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +6 -0
  61. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +1 -0
  62. package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +3 -3
  63. package/build/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
  64. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -3
  65. package/build/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
  66. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +5 -7
  67. package/build/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
  68. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/AirCondition.js +65 -71
  69. package/build/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
  70. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +5 -1
  71. package/build/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
  72. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Control.js +13 -29
  73. package/build/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
  74. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Ct.js +66 -73
  75. package/build/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
  76. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Dimmer.js +32 -39
  77. package/build/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
  78. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Gate.js +5 -7
  79. package/build/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
  80. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Hue.js +91 -89
  81. package/build/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
  82. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Light.js +10 -14
  83. package/build/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
  84. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Lock.js +6 -8
  85. package/build/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
  86. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Motion.js +5 -1
  87. package/build/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
  88. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -10
  89. package/build/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
  90. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Socket.js +5 -7
  91. package/build/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
  92. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Temperature.js +5 -7
  93. package/build/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
  94. package/build/lib/AlexaSmartHomeV3/Controls/Thermostat.js +82 -0
  95. package/build/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
  96. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +5 -7
  97. package/build/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
  98. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Volume.js +29 -36
  99. package/build/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
  100. package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/index.js +6 -6
  101. package/build/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
  102. package/{build-backend → build}/lib/AlexaSmartHomeV3/DeviceManager.js +16 -10
  103. package/build/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -0
  104. package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +4 -1
  105. package/build/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
  106. package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +1 -3
  107. package/build/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +1 -0
  108. package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +23 -16
  109. package/build/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +1 -0
  110. package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -1
  111. package/build/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -0
  112. package/{build-backend → build}/lib/alexaSmartHomeV3.js +3 -3
  113. package/build/lib/alexaSmartHomeV3.js.map +1 -0
  114. package/{build-backend → build}/main.js +29 -9
  115. package/build/main.js.map +1 -0
  116. package/io-package.json +30 -29
  117. package/package.json +13 -13
  118. package/admin/assets/index-BjEWVyqN.js +0 -681
  119. package/admin/rules/assets/index-_Y2FN5EZ.js +0 -1152
  120. package/admin/rules/assets/preload-helper-Dp1pzeXC.js +0 -1
  121. package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +0 -1
  122. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +0 -1
  123. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +0 -1
  124. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +0 -1
  125. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +0 -1
  126. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +0 -1
  127. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +0 -1
  128. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +0 -1
  129. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +0 -1
  130. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +0 -1
  131. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +0 -1
  132. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +0 -1
  133. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +0 -1
  134. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +0 -1
  135. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +0 -1
  136. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +0 -1
  137. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +0 -1
  138. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +0 -1
  139. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +0 -1
  140. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +0 -1
  141. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +0 -1
  142. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +0 -1
  143. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +0 -1
  144. package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +0 -1
  145. package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +0 -1
  146. package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +0 -1
  147. package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +0 -1
  148. package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +0 -1
  149. package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +0 -1
  150. package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +0 -1
  151. package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +0 -1
  152. package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +0 -1
  153. package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +0 -1
  154. package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +0 -1
  155. package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +0 -1
  156. package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +0 -1
  157. package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -85
  158. package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +0 -1
  159. package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +0 -1
  160. package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +0 -1
  161. package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +0 -1
  162. package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js.map +0 -1
  163. package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +0 -1
  164. package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +0 -1
  165. package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +0 -1
  166. package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +0 -1
  167. package/build-backend/lib/alexaSmartHomeV3.js.map +0 -1
  168. package/build-backend/main.js.map +0 -1
  169. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -0
  170. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +0 -0
  171. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -0
  172. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +0 -0
  173. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +0 -0
  174. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +0 -0
  175. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -0
  176. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +0 -0
  177. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +0 -0
  178. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +0 -0
  179. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -0
  180. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +0 -0
  181. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -0
  182. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +0 -0
  183. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -0
  184. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +0 -0
  185. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -0
  186. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +0 -0
  187. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -0
  188. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +0 -0
  189. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -0
  190. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +0 -0
  191. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +0 -0
  192. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +0 -0
  193. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -0
  194. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +0 -0
  195. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -0
  196. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +0 -0
  197. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -0
  198. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +0 -0
  199. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -0
  200. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +0 -0
  201. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -0
  202. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +0 -0
  203. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -0
  204. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +0 -0
  205. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -0
  206. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Blind.js.map +0 -0
  207. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Door.js +0 -0
  208. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Door.js.map +0 -0
  209. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -0
  210. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Slider.js.map +0 -0
  211. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -0
  212. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +0 -0
  213. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Window.js +0 -0
  214. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Controls/Window.js.map +0 -0
  215. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Device.js +0 -0
  216. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Device.js.map +0 -0
  217. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -0
  218. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +0 -0
  219. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -0
  220. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +0 -0
  221. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -0
  222. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +0 -0
  223. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +0 -0
  224. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +0 -0
  225. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -0
  226. /package/{build-backend → build}/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +0 -0
  227. /package/{build-backend → build}/lib/Utils.js +0 -0
  228. /package/{build-backend → build}/lib/Utils.js.map +0 -0
  229. /package/{build-backend → build}/lib/adminCommonSocket.js +0 -0
  230. /package/{build-backend → build}/lib/adminCommonSocket.js.map +0 -0
  231. /package/{build-backend → build}/lib/alexaCustom.js +0 -0
  232. /package/{build-backend → build}/lib/alexaCustom.js.map +0 -0
  233. /package/{build-backend → build}/lib/alexaSmartHomeV2.js +0 -0
  234. /package/{build-backend → build}/lib/alisa.js +0 -0
  235. /package/{build-backend → build}/lib/devices.js +0 -0
  236. /package/{build-backend → build}/lib/devices.js.map +0 -0
  237. /package/{build-backend → build}/lib/functions.js +0 -0
  238. /package/{build-backend → build}/lib/functions.js.map +0 -0
  239. /package/{build-backend → build}/lib/googleHome.js +0 -0
  240. /package/{build-backend → build}/lib/notifications.js +0 -0
  241. /package/{build-backend → build}/lib/notifications.js.map +0 -0
  242. /package/{build-backend → build}/lib/remote.js +0 -0
  243. /package/{build-backend → build}/lib/remote.js.map +0 -0
  244. /package/{build-backend → build}/lib/rooms.js +0 -0
  245. /package/{build-backend → build}/lib/rooms.js.map +0 -0
  246. /package/{build-backend → build}/lib/texts.js +0 -0
  247. /package/{build-backend → build}/lib/texts.js.map +0 -0
  248. /package/{build-backend → build}/lib/translate.js +0 -0
  249. /package/{build-backend → build}/lib/translate.js.map +0 -0
  250. /package/{build-backend → build}/lib/visuApp.js +0 -0
  251. /package/{build-backend → build}/lib/visuApp.js.map +0 -0
@@ -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
- * This function maps a passed on control to an array of objects. Each object contains an Alexa capability the control natively supports
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
- property.currentValue = await AdapterProvider_1.default.getState(property.getId);
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(`${JSON.stringify(propertiesToReport)}`);
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/B,SAAS,CAAqB;IACrB,OAAO,GAAyD,EAAE,CAAC;IAEtF;;OAEG;IACH,YAAY,eAA0C;QAClD,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAEnC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC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,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE;YAClC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE;YAClC,WAAW,EAAE,UAAU,WAAkC;gBACrD,yBAAyB;gBACzB,OAAO,CAAC,CAAC;YACb,CAAC;YACD,WAAW,EAAE,UAAU,KAAsC;gBACzD,OAAO,KAAK,CAAC,CAAC,CAAC,wBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,wBAAc,CAAC,YAAY,CAAC;YACzE,CAAC;SACJ,CAAC;IACN,CAAC;IAES,oBAAoB;QAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,gEAAgE;QAChE,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE;YAClC,WAAW,EAAE,UAAgC,UAAiC;gBAC1E,OAAO,CACH,IAAA,yBAAiB,EACb,UAAoB,EACpB,IAAI,CAAC,cAAwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,IAAI,CAAC,CACT,CAAC;YACN,CAAC;YACD,WAAW,EAAE,UAET,KAAsC;gBAEtC,OAAO,IAAA,uBAAe,EAAC,KAAe,EAAE,IAAI,CAAC,cAAwB,EAAE,IAAI,CAAC,cAAwB,CAAC,CAAC;YAC1G,CAAC;SACJ,CAAC;IACN,CAAC;;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
- get categories() {
20
- return ['LIGHT'];
21
- }
22
- adjustableProperties() {
23
- return [ColorTemperatureInKelvin_1.default];
24
- }
25
- initCapabilities() {
19
+ constructor(detectedControl) {
20
+ super(detectedControl);
26
21
  const map = this.statesMap;
27
- const result = [new Capabilities_1.default.ColorController()];
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
- result.push(this._brightnessCapability);
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
- result.push(this._colorTemperatureCapability);
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
- result.push(this._powerControllerCapability);
38
+ this._supported.push(this._powerControllerCapability);
44
39
  }
45
- for (const property of result.flatMap(item => item.properties)) {
46
- const initObject = this.composeInitObject(property);
47
- if (initObject) {
48
- property.init(initObject);
49
- }
50
- }
51
- return result;
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
- composeInitObject(property) {
120
+ composeInitObjectPowerState() {
127
121
  const map = this.statesMap;
128
- if (property.propertyName === PowerState_1.default.propertyName) {
129
- return {
130
- setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
131
- getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
132
- alexaSetter: function (alexaValue) {
133
- return alexaValue === PowerState_1.default.ON;
134
- },
135
- alexaGetter: function (value) {
136
- return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
137
- },
138
- };
139
- }
140
- if (property.propertyName === Brightness_1.default.propertyName) {
141
- return {
142
- setState: this.states[map.dimmer] || this.states[map.brightness],
143
- getState: this.states[map.dimmer] || this.states[map.brightness],
144
- alexaSetter: function (alexaValue) {
145
- return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
146
- },
147
- alexaGetter: function (value) {
148
- return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
149
- },
150
- };
151
- }
152
- if (property.propertyName === ColorTemperatureInKelvin_1.default.propertyName) {
153
- return {
154
- setState: this.states[map.temperature],
155
- getState: this.states[map.temperature],
156
- alexaSetter: function (alexaValue) {
157
- if (alexaValue === 1) {
158
- // increase directive
159
- const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
160
- let index = this.colorTemperatureTable.indexOf(closest) + 1;
161
- index =
162
- index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
163
- return this.colorTemperatureTable[index];
164
- }
165
- if (alexaValue === -1) {
166
- // decrease directive
167
- const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
168
- let index = this.colorTemperatureTable.indexOf(closest) - 1;
169
- index = index < 0 ? 0 : index;
170
- return this.colorTemperatureTable[index];
171
- }
172
- return alexaValue;
173
- },
174
- alexaGetter: function (value) {
175
- return value;
176
- },
177
- };
178
- }
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,gFAAw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ChC,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"]}
@@ -15,26 +15,20 @@ class Dimmer extends AdjustableControl_1.default {
15
15
  _powerState;
16
16
  _brightnessCapability;
17
17
  _brightness;
18
+ constructor(detectedControl) {
19
+ super(detectedControl);
20
+ this._powerControllerCapability = new PowerController_1.default(this.composeInitObjectPowerState());
21
+ this._powerState = this._powerControllerCapability.powerState;
22
+ this._brightnessCapability = new BrightnessController_1.default(this.composeInitObjectBrightness());
23
+ this._brightness = this._brightnessCapability.brightness;
24
+ this._supported = [this._powerControllerCapability, this._brightnessCapability];
25
+ }
18
26
  get categories() {
19
27
  return ['LIGHT'];
20
28
  }
21
29
  adjustableProperties() {
22
30
  return [Brightness_1.default];
23
31
  }
24
- initCapabilities() {
25
- this._powerControllerCapability = new PowerController_1.default();
26
- this._powerState = this._powerControllerCapability.powerState;
27
- this._brightnessCapability = new BrightnessController_1.default();
28
- this._brightness = this._brightnessCapability.brightness;
29
- const result = [this._powerControllerCapability, this._brightnessCapability];
30
- for (const property of result.flatMap(item => item.properties)) {
31
- const initObj = this.composeInitObject(property);
32
- if (initObj) {
33
- property.init(initObj);
34
- }
35
- }
36
- return result;
37
- }
38
32
  async setState(property, value) {
39
33
  // set the property itself
40
34
  await AdapterProvider_1.default.setState(property.setId, value);
@@ -88,7 +82,20 @@ class Dimmer extends AdjustableControl_1.default {
88
82
  }
89
83
  return property.currentValue;
90
84
  }
91
- composeInitObject(property) {
85
+ composeInitObjectPowerState() {
86
+ const map = this.statesMap;
87
+ return {
88
+ setState: this.states[map.on_set] || this.states[map.set],
89
+ getState: this.states[map.on_actual] || this.states[map.on_set] || this.states[map.set],
90
+ alexaSetter: function (alexaValue) {
91
+ return alexaValue === PowerState_1.default.ON;
92
+ },
93
+ alexaGetter: function (value) {
94
+ return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
95
+ },
96
+ };
97
+ }
98
+ composeInitObjectBrightness() {
92
99
  /*
93
100
  Device of type 'dimmer' can be switched 'ON'/'OFF' and its brightness can be set to a value between 0 and 100.
94
101
 
@@ -97,30 +104,16 @@ class Dimmer extends AdjustableControl_1.default {
97
104
  - switching control 'ON' is done via setting its brightness to the configured 'byOn' value or to the last known brightness.
98
105
  */
99
106
  const map = this.statesMap;
100
- if (property.propertyName === PowerState_1.default.propertyName) {
101
- return {
102
- setState: this.states[map.on_set] || this.states[map.set],
103
- getState: this.states[map.on_actual] || this.states[map.on_set] || this.states[map.set],
104
- alexaSetter: function (alexaValue) {
105
- return alexaValue === PowerState_1.default.ON;
106
- },
107
- alexaGetter: function (value) {
108
- return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
109
- },
110
- };
111
- }
112
- if (property.propertyName === Brightness_1.default.propertyName) {
113
- return {
114
- setState: this.states[map.set],
115
- getState: this.states[map.actual],
116
- alexaSetter: function (alexaValue) {
117
- return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
118
- },
119
- alexaGetter: function (value) {
120
- return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
121
- },
122
- };
123
- }
107
+ return {
108
+ setState: this.states[map.set],
109
+ getState: this.states[map.actual],
110
+ alexaSetter: function (alexaValue) {
111
+ return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
112
+ },
113
+ alexaGetter: function (value) {
114
+ return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
115
+ },
116
+ };
124
117
  }
125
118
  }
126
119
  exports.default = Dimmer;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dimmer.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Dimmer.ts"],"names":[],"mappings":";;;;;AAAA,4FAAoE;AACpE,sGAA8E;AAC9E,4EAAoD;AACpD,4CAAgG;AAChG,gFAAwD;AACxD,gFAAwD;AACxD,iFAAyD;AASzD,MAAqB,MAAO,SAAQ,2BAAiB;IAChC,0BAA0B,CAAkB;IAC5C,WAAW,CAAa;IACxB,qBAAqB,CAAuB;IAC5C,WAAW,CAAa;IAEzC,YAAY,eAA0C;QAClD,KAAK,CAAC,eAAe,CAAC,CAAC;QAEvB,IAAI,CAAC,0BAA0B,GAAG,IAAI,yBAAe,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC,CAAC;QAC1F,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,UAAU,CAAC;QAE9D,IAAI,CAAC,qBAAqB,GAAG,IAAI,8BAAoB,CAAC,IAAI,CAAC,2BAA2B,EAAE,CA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AwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,IAAI,CAAC,CACT,CAAC;YACN,CAAC;YACD,WAAW,EAAE,UAET,KAAsC;gBAEtC,OAAO,IAAA,uBAAe,EAAC,KAAe,EAAE,IAAI,CAAC,cAAwB,EAAE,IAAI,CAAC,cAAwB,CAAC,CAAC;YAC1G,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AA3ID,yBA2IC","sourcesContent":["import PowerController from '../Alexa/Capabilities/PowerController';\nimport BrightnessController from '../Alexa/Capabilities/BrightnessController';\nimport AdjustableControl from './AdjustableControl';\nimport { configuredRangeOrDefault, denormalize_0_100, normalize_0_100 } from '../Helpers/Utils';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport Brightness from '../Alexa/Properties/Brightness';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\n\nexport default class Dimmer extends AdjustableControl {\n private readonly _powerControllerCapability: PowerController;\n private readonly _powerState: PowerState;\n private readonly _brightnessCapability: BrightnessController;\n private readonly _brightness: Brightness;\n\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n\n this._powerControllerCapability = new PowerController(this.composeInitObjectPowerState());\n this._powerState = this._powerControllerCapability.powerState;\n\n this._brightnessCapability = new BrightnessController(this.composeInitObjectBrightness());\n this._brightness = this._brightnessCapability.brightness;\n\n this._supported = [this._powerControllerCapability, this._brightnessCapability];\n }\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [Brightness];\n }\n\n async setState(property: PropertiesBase, value: ioBroker.StateValue): Promise<void> {\n // set the property itself\n await AdapterProvider.setState(property.setId, value);\n property.currentValue = value;\n const valuesRange = configuredRangeOrDefault(this.states[this.statesMap.set]!);\n\n // todo: use adapter.config.deviceOffLevel\n // If\n\n if (property.propertyName === PowerState.propertyName) {\n // set brightness\n if (value) {\n const smartName = this.states[this.statesMap.set]!.smartName;\n let byOn: string | number | undefined | null;\n if (smartName && typeof smartName === 'object') {\n byOn = smartName.byON;\n }\n // set byOn to the configured value or 100 otherwise\n byOn =\n byOn === undefined || byOn === null || isNaN(byOn as number)\n ? (valuesRange.max as number)\n : parseFloat(byOn as string);\n await AdapterProvider.setState(this._brightness.setId, byOn);\n this._brightness.currentValue = byOn;\n } else {\n // set brightness to 0 on power OFF\n await AdapterProvider.setState(this._brightness.setId, valuesRange.min);\n this._brightness.currentValue = valuesRange.min;\n }\n } else {\n // set power\n const powerValue = value !== valuesRange.min;\n\n // only do this on different IDs for brightness and power\n if (this._brightness.setId !== this._powerState.setId) {\n await AdapterProvider.setState(this._powerState.setId, powerValue);\n }\n this._powerState.currentValue = powerValue;\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 const valuesRange = configuredRangeOrDefault(this.states[this.statesMap.set]!);\n // convert non-zero brightness to power = true\n if (property.propertyName === this._powerState.propertyName && property.getId === this._brightness.getId) {\n property.currentValue = property.currentValue !== valuesRange.min;\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.on_set] || this.states[map.set]!,\n getState: this.states[map.on_actual] || this.states[map.on_set] || this.states[map.set]!,\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 private composeInitObjectBrightness(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n } {\n /*\n Device of type 'dimmer' can be switched 'ON'/'OFF' and its brightness can be set to a value between 0 and 100.\n\n If there is no 'ON_SET' state available:\n - switching control 'OFF' is done via setting its brightness to 0\n - switching control 'ON' is done via setting its brightness to the configured 'byOn' value or to the last known brightness.\n */\n\n const map = this.statesMap;\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"]}
@@ -7,16 +7,14 @@ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
7
  const ModeValues_1 = __importDefault(require("../Alexa/ModeValues"));
8
8
  const Control_1 = __importDefault(require("./Control"));
9
9
  class Gate extends Control_1.default {
10
+ constructor(detectedControl) {
11
+ super(detectedControl);
12
+ const modeController = new Capabilities_1.default.ModeController(this.modeInitObject());
13
+ this._supported = [modeController];
14
+ }
10
15
  get categories() {
11
16
  return ['GARAGE_DOOR'];
12
17
  }
13
- initCapabilities() {
14
- const result = [new Capabilities_1.default.ModeController()];
15
- for (const property of result.flatMap(item => item.properties)) {
16
- property.init(this.modeInitObject());
17
- }
18
- return result;
19
- }
20
18
  modeInitObject() {
21
19
  const map = this.statesMap;
22
20
  const mode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;IACN,CAAC;CACJ;AAnCD,uBAmCC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport Modes from '../Alexa/ModeValues';\nimport Control from './Control';\nimport type { Base as ModeBase } from '../Alexa/ModeValues/Base';\nimport type {\n AlexaV3Category,\n AlexaV3DirectiveValue,\n IotExternalDetectorState,\n IotExternalPatternControl,\n} from '../types';\n\nexport default class Gate extends Control {\n constructor(detectedControl: IotExternalPatternControl) {\n super(detectedControl);\n const modeController = new Capabilities.ModeController(this.modeInitObject());\n this._supported = [modeController];\n }\n\n get categories(): AlexaV3Category[] {\n return ['GARAGE_DOOR'];\n }\n\n private modeInitObject(): {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n instance?: string;\n supportedModes?: ModeBase[];\n } {\n const map = this.statesMap;\n const mode = 'Gate.Position';\n\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.set]!,\n alexaSetter: function (alexaValue) {\n return alexaValue === `${mode}.${Modes.Open.value}`;\n },\n alexaGetter: function (value) {\n return value ? `${mode}.${Modes.Open.value}` : `${mode}.${Modes.Closed.value}`;\n },\n instance: mode,\n supportedModes: [new Modes.Open(mode), new Modes.Closed(mode)],\n };\n }\n}\n"]}