iobroker.iot 3.6.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +8 -4
  2. package/admin/assets/index-5zouxn2w.js +680 -0
  3. package/admin/index_m.html +1 -1
  4. package/admin/rules/assets/{index-BRdNnGcA.js → index-DwYdaT5M.js} +80 -81
  5. package/admin/rules/customRuleBlocks.js +2 -2
  6. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/AlexaResponse.js +101 -95
  7. package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -0
  8. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +22 -36
  9. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
  10. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +19 -0
  11. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
  12. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +14 -0
  13. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
  14. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +19 -0
  15. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
  16. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +16 -0
  17. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
  18. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +14 -0
  19. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
  20. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +27 -28
  21. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
  22. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +14 -0
  23. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
  24. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +14 -0
  25. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
  26. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +19 -0
  27. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
  28. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +25 -0
  29. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
  30. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +14 -0
  31. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
  32. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +37 -0
  33. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
  34. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +32 -0
  35. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +1 -0
  36. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +29 -0
  37. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +1 -0
  38. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +34 -27
  39. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +1 -0
  40. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +39 -0
  41. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +1 -0
  42. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +19 -22
  43. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +1 -0
  44. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +14 -0
  45. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +1 -0
  46. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +36 -0
  47. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +1 -0
  48. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +57 -0
  49. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +1 -0
  50. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +57 -0
  51. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +1 -0
  52. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +12 -0
  53. package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +1 -0
  54. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +16 -0
  55. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +1 -0
  56. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +127 -0
  57. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
  58. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +18 -0
  59. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +1 -0
  60. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +38 -0
  61. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
  62. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +20 -29
  63. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +1 -0
  64. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +23 -0
  65. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
  66. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/LockState.js +9 -12
  67. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +1 -0
  68. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +34 -0
  69. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
  70. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +19 -0
  71. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +1 -0
  72. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +18 -0
  73. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +1 -0
  74. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +9 -9
  75. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +1 -0
  76. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +31 -0
  77. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +1 -0
  78. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +22 -0
  79. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +1 -0
  80. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +49 -0
  81. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
  82. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +21 -0
  83. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +1 -0
  84. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +38 -0
  85. package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +1 -0
  86. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +20 -0
  87. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
  88. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +26 -0
  89. package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
  90. package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js +148 -0
  91. package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
  92. package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js +13 -0
  93. package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js.map +1 -0
  94. package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +17 -0
  95. package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
  96. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Controls/Control.js +73 -104
  97. package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
  98. package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js +182 -0
  99. package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
  100. package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js +127 -0
  101. package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
  102. package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js +10 -0
  103. package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js.map +1 -0
  104. package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js +38 -0
  105. package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
  106. package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js +208 -0
  107. package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
  108. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Controls/Light.js +15 -22
  109. package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
  110. package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js +35 -0
  111. package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
  112. package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js +17 -0
  113. package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
  114. package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +26 -0
  115. package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
  116. package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js +10 -0
  117. package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js.map +1 -0
  118. package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js +21 -0
  119. package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
  120. package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js +21 -0
  121. package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
  122. package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +85 -0
  123. package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
  124. package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +27 -0
  125. package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
  126. package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js +116 -0
  127. package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
  128. package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +10 -0
  129. package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +1 -0
  130. package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js +10 -0
  131. package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js.map +1 -0
  132. package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js +121 -0
  133. package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
  134. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Device.js +29 -30
  135. package/build-backend/lib/AlexaSmartHomeV3/Device.js.map +1 -0
  136. package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js +392 -0
  137. package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -0
  138. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +10 -0
  139. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +1 -0
  140. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +10 -0
  141. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +1 -0
  142. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +10 -0
  143. package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +1 -0
  144. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Helpers/AdapterProvider.js +12 -21
  145. package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
  146. package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +53 -0
  147. package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +1 -0
  148. package/{lib → build-backend/lib}/AlexaSmartHomeV3/Helpers/IotProxy.js +9 -26
  149. package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +1 -0
  150. package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js +93 -0
  151. package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +1 -0
  152. package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +112 -0
  153. package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +1 -0
  154. package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js +625 -0
  155. package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -0
  156. package/build-backend/lib/Utils.js +96 -0
  157. package/build-backend/lib/Utils.js.map +1 -0
  158. package/build-backend/lib/adminCommonSocket.js +715 -0
  159. package/build-backend/lib/adminCommonSocket.js.map +1 -0
  160. package/build-backend/lib/alexaCustom.js +542 -0
  161. package/build-backend/lib/alexaCustom.js.map +1 -0
  162. package/{lib → build-backend/lib}/alexaSmartHomeV2.js +4 -8
  163. package/{lib → build-backend/lib}/alexaSmartHomeV3.js +25 -45
  164. package/build-backend/lib/alexaSmartHomeV3.js.map +1 -0
  165. package/{lib → build-backend/lib}/alisa.js +41 -44
  166. package/{lib → build-backend/lib}/devices.js +11 -8
  167. package/build-backend/lib/devices.js.map +1 -0
  168. package/{lib → build-backend/lib}/functions.js +11 -8
  169. package/build-backend/lib/functions.js.map +1 -0
  170. package/{lib → build-backend/lib}/googleHome.js +25 -26
  171. package/{lib → build-backend/lib}/notifications.js +15 -22
  172. package/build-backend/lib/notifications.js.map +1 -0
  173. package/{lib → build-backend/lib}/remote.js +615 -636
  174. package/build-backend/lib/remote.js.map +1 -0
  175. package/{lib → build-backend/lib}/rooms.js +11 -8
  176. package/build-backend/lib/rooms.js.map +1 -0
  177. package/{lib → build-backend/lib}/texts.js +6 -4
  178. package/build-backend/lib/texts.js.map +1 -0
  179. package/build-backend/lib/translate.js +21 -0
  180. package/build-backend/lib/translate.js.map +1 -0
  181. package/{lib → build-backend/lib}/visuApp.js +45 -65
  182. package/build-backend/lib/visuApp.js.map +1 -0
  183. package/build-backend/main.js +1361 -0
  184. package/build-backend/main.js.map +1 -0
  185. package/io-package.json +14 -14
  186. package/package.json +18 -15
  187. package/admin/assets/index-DCbOB3g_.js +0 -681
  188. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +0 -15
  189. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +0 -10
  190. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +0 -15
  191. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +0 -10
  192. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +0 -10
  193. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +0 -10
  194. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +0 -10
  195. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +0 -15
  196. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +0 -20
  197. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +0 -10
  198. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +0 -34
  199. package/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -14
  200. package/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -27
  201. package/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -39
  202. package/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -13
  203. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -38
  204. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -55
  205. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -56
  206. package/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -14
  207. package/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -11
  208. package/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +0 -108
  209. package/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -14
  210. package/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +0 -40
  211. package/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +0 -22
  212. package/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +0 -32
  213. package/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -17
  214. package/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -14
  215. package/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -28
  216. package/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -20
  217. package/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +0 -52
  218. package/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -19
  219. package/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -14
  220. package/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -22
  221. package/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +0 -28
  222. package/lib/AlexaSmartHomeV3/Controls/AirCondition.js +0 -144
  223. package/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -12
  224. package/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +0 -17
  225. package/lib/AlexaSmartHomeV3/Controls/Ct.js +0 -172
  226. package/lib/AlexaSmartHomeV3/Controls/Dimmer.js +0 -124
  227. package/lib/AlexaSmartHomeV3/Controls/Door.js +0 -9
  228. package/lib/AlexaSmartHomeV3/Controls/Gate.js +0 -42
  229. package/lib/AlexaSmartHomeV3/Controls/Hue.js +0 -207
  230. package/lib/AlexaSmartHomeV3/Controls/Lock.js +0 -36
  231. package/lib/AlexaSmartHomeV3/Controls/Motion.js +0 -17
  232. package/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -25
  233. package/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -10
  234. package/lib/AlexaSmartHomeV3/Controls/Socket.js +0 -21
  235. package/lib/AlexaSmartHomeV3/Controls/Temperature.js +0 -22
  236. package/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -86
  237. package/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +0 -28
  238. package/lib/AlexaSmartHomeV3/Controls/Volume.js +0 -109
  239. package/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -9
  240. package/lib/AlexaSmartHomeV3/Controls/Window.js +0 -9
  241. package/lib/AlexaSmartHomeV3/Controls/index.js +0 -14
  242. package/lib/AlexaSmartHomeV3/DeviceManager.js +0 -415
  243. package/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -8
  244. package/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -5
  245. package/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -5
  246. package/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -70
  247. package/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -95
  248. package/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -82
  249. package/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -583
  250. package/lib/Utils.js +0 -608
  251. package/lib/adminCommonSocket.js +0 -781
  252. package/lib/alexaCustom.js +0 -622
  253. package/lib/translate.js +0 -19
  254. package/main.js +0 -1454
@@ -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;AAIpD,gFAAwD;AACxD,4GAAoF;AAGpF,gFAAwD;AAGxD,MAAqB,EAAG,SAAQ,2BAAiB;IACrC,qBAAqB,CAAmC;IACxD,WAAW,CAAyB;IACpC,2BAA2B,CAAyC;IACpE,0BAA0B,CAA8B;IACxD,WAAW,CAAyB;IAE5C,IAAI,UAAU;QACV,OAAO,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,kCAAwB,CAAC,CAAC;IACtC,CAAC;IAED,gBAAgB;QACZ,MAAM,GAAG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N,CAAC;IACL,CAAC;CACJ;AAzND,qBAyNC","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 CapabilitiesBase } from '../Alexa/Capabilities/Base';\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 { AlexaV3Category, AlexaV3DirectiveValue, AlexaV3Request, IotExternalDetectorState } from '../types';\n\nexport default class Ct extends AdjustableControl {\n private _brightnessCapability: BrightnessController | undefined;\n private _brightness: Brightness | undefined;\n private _colorTemperatureCapability: ColorTemperatureController | undefined;\n private _powerControllerCapability: PowerController | undefined;\n private _powerState: PowerState | undefined;\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [ColorTemperatureInKelvin];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n const map = this.statesMap;\n const result = [new Capabilities.ColorController()];\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();\n this._brightness = this._brightnessCapability.brightness;\n result.push(this._brightnessCapability);\n }\n\n // if the state TEMPERATURE configured\n if (this.states[map.temperature]) {\n this._colorTemperatureCapability = new Capabilities.ColorTemperatureController();\n result.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();\n this._powerState = this._powerControllerCapability.powerState;\n result.push(this._powerControllerCapability);\n }\n\n for (const property of result.flatMap(item => item.properties)) {\n const initObject = this.composeInitObject(property);\n if (initObject) {\n property.init(initObject);\n }\n }\n\n return result;\n }\n\n 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 composeInitObject(property: PropertiesBase):\n | {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n }\n | undefined {\n const map = this.statesMap;\n\n if (property.propertyName === PowerState.propertyName) {\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 if (property.propertyName === Brightness.propertyName) {\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(\n value as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n );\n },\n };\n }\n\n if (property.propertyName === ColorTemperatureInKelvin.propertyName) {\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 =\n 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}\n"]}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const PowerController_1 = __importDefault(require("../Alexa/Capabilities/PowerController"));
7
+ const BrightnessController_1 = __importDefault(require("../Alexa/Capabilities/BrightnessController"));
8
+ const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
9
+ const Utils_1 = require("../Helpers/Utils");
10
+ const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
11
+ const Brightness_1 = __importDefault(require("../Alexa/Properties/Brightness"));
12
+ const AdapterProvider_1 = __importDefault(require("../Helpers/AdapterProvider"));
13
+ class Dimmer extends AdjustableControl_1.default {
14
+ _powerControllerCapability;
15
+ _powerState;
16
+ _brightnessCapability;
17
+ _brightness;
18
+ get categories() {
19
+ return ['LIGHT'];
20
+ }
21
+ adjustableProperties() {
22
+ return [Brightness_1.default];
23
+ }
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
+ async setState(property, value) {
39
+ // set the property itself
40
+ await AdapterProvider_1.default.setState(property.setId, value);
41
+ property.currentValue = value;
42
+ const valuesRange = (0, Utils_1.configuredRangeOrDefault)(this.states[this.statesMap.set]);
43
+ // todo: use adapter.config.deviceOffLevel
44
+ // If
45
+ if (property.propertyName === PowerState_1.default.propertyName) {
46
+ // set brightness
47
+ if (value) {
48
+ const smartName = this.states[this.statesMap.set].smartName;
49
+ let byOn;
50
+ if (smartName && typeof smartName === 'object') {
51
+ byOn = smartName.byON;
52
+ }
53
+ // set byOn to the configured value or 100 otherwise
54
+ byOn =
55
+ byOn === undefined || byOn === null || isNaN(byOn)
56
+ ? valuesRange.max
57
+ : parseFloat(byOn);
58
+ await AdapterProvider_1.default.setState(this._brightness.setId, byOn);
59
+ this._brightness.currentValue = byOn;
60
+ }
61
+ else {
62
+ // set brightness to 0 on power OFF
63
+ await AdapterProvider_1.default.setState(this._brightness.setId, valuesRange.min);
64
+ this._brightness.currentValue = valuesRange.min;
65
+ }
66
+ }
67
+ else {
68
+ // set power
69
+ const powerValue = value !== valuesRange.min;
70
+ // only do this on different IDs for brightness and power
71
+ if (this._brightness.setId !== this._powerState.setId) {
72
+ await AdapterProvider_1.default.setState(this._powerState.setId, powerValue);
73
+ }
74
+ this._powerState.currentValue = powerValue;
75
+ }
76
+ }
77
+ async getOrRetrieveCurrentValue(property) {
78
+ if (property.currentValue === undefined) {
79
+ property.currentValue = await AdapterProvider_1.default.getState(property.getId);
80
+ const valuesRange = (0, Utils_1.configuredRangeOrDefault)(this.states[this.statesMap.set]);
81
+ // convert non-zero brightness to power = true
82
+ if (property.propertyName === this._powerState.propertyName && property.getId === this._brightness.getId) {
83
+ property.currentValue = property.currentValue !== valuesRange.min;
84
+ }
85
+ }
86
+ if (property.currentValue === undefined) {
87
+ throw new Error(`unable to retrieve ${property.getId}`);
88
+ }
89
+ return property.currentValue;
90
+ }
91
+ composeInitObject(property) {
92
+ /*
93
+ Device of type 'dimmer' can be switched 'ON'/'OFF' and its brightness can be set to a value between 0 and 100.
94
+
95
+ If there is no 'ON_SET' state available:
96
+ - switching control 'OFF' is done via setting its brightness to 0
97
+ - switching control 'ON' is done via setting its brightness to the configured 'byOn' value or to the last known brightness.
98
+ */
99
+ 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
+ }
124
+ }
125
+ }
126
+ exports.default = Dimmer;
127
+ //# sourceMappingURL=Dimmer.js.map
@@ -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;AACx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,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;gBACxF,WAAW,EAAE,UAAgC,UAAiC;oBAC1E,OAAO,UAAU,KAAK,oBAAU,CAAC,EAAE,CAAC;gBACxC,CAAC;gBACD,WAAW,EAAE,UAAU,KAAsC;oBACzD,OAAO,KAAK,CAAC,CAAC,CAAC,oBAAU,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAU,CAAC,GAAG,CAAC;gBAClD,CAAC;aACJ,CAAC;QACN,CAAC;QAED,IAAI,QAAQ,CAAC,YAAY,KAAK,oBAAU,CAAC,YAAY,EAAE,CAAC;YACpD,OAAO;gBACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;gBAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAE;gBAClC,WAAW,EAAE,UAAgC,UAAiC;oBAC1E,OAAO,CACH,IAAA,yBAAiB,EACb,UAAoB,EACpB,IAAI,CAAC,cAAwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,IAAI,CAAC,CACT,CAAC;gBACN,CAAC;gBACD,WAAW,EAAE,UAET,KAAsC;oBAEtC,OAAO,IAAA,uBAAe,EAClB,KAAe,EACf,IAAI,CAAC,cAAwB,EAC7B,IAAI,CAAC,cAAwB,CAChC,CAAC;gBACN,CAAC;aACJ,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AApJD,yBAoJC","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 { AlexaV3Category, AlexaV3DirectiveValue, IotExternalDetectorState } from '../types';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\nimport type { Base as PropertiesBase } from '../Alexa/Properties/Base';\n\nexport default class Dimmer extends AdjustableControl {\n private _powerControllerCapability!: PowerController;\n private _powerState!: PowerState;\n private _brightnessCapability!: BrightnessController;\n private _brightness!: Brightness;\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [Brightness];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n this._powerControllerCapability = new PowerController();\n this._powerState = this._powerControllerCapability.powerState;\n\n this._brightnessCapability = new BrightnessController();\n this._brightness = this._brightnessCapability.brightness;\n\n const result = [this._powerControllerCapability, this._brightnessCapability];\n for (const property of result.flatMap(item => item.properties)) {\n const initObj = this.composeInitObject(property);\n if (initObj) {\n property.init(initObj);\n }\n }\n\n return result;\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 composeInitObject(property: PropertiesBase):\n | {\n setState: IotExternalDetectorState;\n getState: IotExternalDetectorState;\n alexaSetter?: (alexaValue: AlexaV3DirectiveValue) => ioBroker.StateValue | undefined;\n alexaGetter?: (value: ioBroker.StateValue | undefined) => AlexaV3DirectiveValue;\n }\n | undefined {\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\n if (property.propertyName === PowerState.propertyName) {\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 if (property.propertyName === Brightness.propertyName) {\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(\n value as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n );\n },\n };\n }\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const ContactSensor_1 = __importDefault(require("./ContactSensor"));
7
+ class Door extends ContactSensor_1.default {
8
+ }
9
+ exports.default = Door;
10
+ //# sourceMappingURL=Door.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Door.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Door.ts"],"names":[],"mappings":";;;;;AAAA,oEAA4C;AAE5C,MAAqB,IAAK,SAAQ,uBAAa;CAAG;AAAlD,uBAAkD","sourcesContent":["import ContactSensor from './ContactSensor';\n\nexport default class Door extends ContactSensor {}\n"]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
+ const ModeValues_1 = __importDefault(require("../Alexa/ModeValues"));
8
+ const Control_1 = __importDefault(require("./Control"));
9
+ class Gate extends Control_1.default {
10
+ get categories() {
11
+ return ['GARAGE_DOOR'];
12
+ }
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
+ modeInitObject() {
21
+ const map = this.statesMap;
22
+ const mode = 'Gate.Position';
23
+ return {
24
+ setState: this.states[map.set],
25
+ getState: this.states[map.set],
26
+ alexaSetter: function (alexaValue) {
27
+ return alexaValue === `${mode}.${ModeValues_1.default.Open.value}`;
28
+ },
29
+ alexaGetter: function (value) {
30
+ return value ? `${mode}.${ModeValues_1.default.Open.value}` : `${mode}.${ModeValues_1.default.Closed.value}`;
31
+ },
32
+ instance: mode,
33
+ supportedModes: [new ModeValues_1.default.Open(mode), new ModeValues_1.default.Closed(mode)],
34
+ };
35
+ }
36
+ }
37
+ exports.default = Gate;
38
+ //# sourceMappingURL=Gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gate.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Gate.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,qEAAwC;AACxC,wDAAgC;AAKhC,MAAqB,IAAK,SAAQ,iBAAO;IACrC,IAAI,UAAU;QACV,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3B,CAAC;IAED,gBAAgB;QACZ,MAAM,MAAM,GAAG,CAAC,IAAI,sBAAY,CAAC,cAAc,EAAE,CAAC,CAAC;QACnD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,cAAc;QAQV,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,MAAM,IAAI,GAAG,eAAe,CAAC;QAE7B,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAE;YAC/B,WAAW,EAAE,UAAU,UAAU;gBAC7B,OAAO,UAAU,KAAK,GAAG,IAAI,IAAI,oBAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACxD,CAAC;YACD,WAAW,EAAE,UAAU,KAAK;gBACxB,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,oBAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,oBAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACnF,CAAC;YACD,QAAQ,EAAE,IAAI;YACd,cAAc,EAAE,CAAC,IAAI,oBAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,oBAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACjE,CAAC;IACN,CAAC;CACJ;AArCD,uBAqCC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport Modes from '../Alexa/ModeValues';\nimport Control from './Control';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\nimport type { Base as ModeBase } from '../Alexa/ModeValues/Base';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, IotExternalDetectorState } from '../types';\n\nexport default class Gate extends Control {\n get categories(): AlexaV3Category[] {\n return ['GARAGE_DOOR'];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n const result = [new Capabilities.ModeController()];\n for (const property of result.flatMap(item => item.properties)) {\n property.init(this.modeInitObject());\n }\n return result;\n }\n\n 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"]}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
+ const Utils_1 = require("../Helpers/Utils");
8
+ const Properties_1 = __importDefault(require("../Alexa/Properties"));
9
+ const PowerState_1 = __importDefault(require("../Alexa/Properties/PowerState"));
10
+ const Brightness_1 = __importDefault(require("../Alexa/Properties/Brightness"));
11
+ const AdapterProvider_1 = __importDefault(require("../Helpers/AdapterProvider"));
12
+ const AdjustableControl_1 = __importDefault(require("./AdjustableControl"));
13
+ const Color_1 = __importDefault(require("../Alexa/Properties/Color"));
14
+ const ColorTemperatureInKelvin_1 = __importDefault(require("../Alexa/Properties/ColorTemperatureInKelvin"));
15
+ class Hue extends AdjustableControl_1.default {
16
+ _powerControllerCapability;
17
+ _powerState;
18
+ _brightnessCapability;
19
+ _brightness;
20
+ _colorTemperatureCapability;
21
+ get categories() {
22
+ return ['LIGHT'];
23
+ }
24
+ adjustableProperties() {
25
+ return [Properties_1.default.ColorTemperatureInKelvin];
26
+ }
27
+ initCapabilities() {
28
+ const map = this.statesMap;
29
+ const result = [new Capabilities_1.default.ColorController()];
30
+ // if the state DIMMER or BRIGHTNESS configured
31
+ if (this.states[map.dimmer] || this.states[map.brightness]) {
32
+ this._brightnessCapability = new Capabilities_1.default.BrightnessController();
33
+ this._brightness = this._brightnessCapability.brightness;
34
+ result.push(this._brightnessCapability);
35
+ }
36
+ // if the state TEMPERATURE configured
37
+ if (this.states[map.temperature]) {
38
+ this._colorTemperatureCapability = new Capabilities_1.default.ColorTemperatureController();
39
+ result.push(this._colorTemperatureCapability);
40
+ }
41
+ // if the state ON, DIMMER or BRIGHTNESS configured
42
+ if (this.states[map.on] || this._brightness) {
43
+ this._powerControllerCapability = new Capabilities_1.default.PowerController();
44
+ this._powerState = this._powerControllerCapability.powerState;
45
+ result.push(this._powerControllerCapability);
46
+ }
47
+ for (const property of result.flatMap(item => item.properties)) {
48
+ const initObj = this.composeInitObject(property);
49
+ if (initObj) {
50
+ property.init(initObj);
51
+ }
52
+ }
53
+ return result;
54
+ }
55
+ async getOrRetrieveCurrentValue(property) {
56
+ const map = this.statesMap;
57
+ if (property.currentValue === undefined) {
58
+ property.currentValue = await AdapterProvider_1.default.getState(property.getId);
59
+ // convert the non-zero brightness to power = true
60
+ if (property.propertyName === Properties_1.default.PowerState.propertyName && !this.states[map.on]) {
61
+ property.currentValue = property.currentValue !== 0;
62
+ }
63
+ if (property.propertyName === Properties_1.default.Color.propertyName) {
64
+ // @ts-expect-error special case for Color property
65
+ property.currentValue = {
66
+ hue: property.currentValue,
67
+ saturation: property.hal.saturation,
68
+ brightness: property.hal.brightness,
69
+ };
70
+ }
71
+ }
72
+ if (property.currentValue === undefined) {
73
+ throw new Error(`unable to retrieve ${property.getId}`);
74
+ }
75
+ return property.currentValue;
76
+ }
77
+ async setState(property, value) {
78
+ const map = this.statesMap;
79
+ if (property.propertyName === PowerState_1.default.propertyName) {
80
+ if (this.states[map.on]) {
81
+ await AdapterProvider_1.default.setState(property.setId, value ?? false);
82
+ property.currentValue = value;
83
+ }
84
+ else {
85
+ if (value) {
86
+ // set brightness
87
+ // set byOn to the configured value or range.max otherwise
88
+ const range = (0, Utils_1.configuredRangeOrDefault)(this.states[map.dimmer] || this.states[map.brightness]);
89
+ const smartName = (this.states[map.dimmer] || this.states[map.brightness])?.smartName;
90
+ let byOn;
91
+ if (smartName && typeof smartName === 'object') {
92
+ byOn = smartName.byON;
93
+ }
94
+ byOn =
95
+ byOn === null || byOn === undefined || isNaN(byOn)
96
+ ? range.max
97
+ : parseFloat(byOn);
98
+ await AdapterProvider_1.default.setState(this._brightness.setId, byOn);
99
+ this._brightness.currentValue = byOn;
100
+ this._powerState.currentValue = true;
101
+ }
102
+ else {
103
+ // set brightness to 0 on power OFF
104
+ await AdapterProvider_1.default.setState(this._brightness.setId, 0);
105
+ this._brightness.currentValue = 0;
106
+ this._powerState.currentValue = false;
107
+ }
108
+ }
109
+ }
110
+ else if (property.propertyName === Brightness_1.default.propertyName) {
111
+ await AdapterProvider_1.default.setState(property.setId, value ?? 0);
112
+ property.currentValue = value;
113
+ }
114
+ else if (property.propertyName === Color_1.default.propertyName) {
115
+ const colorProperty = property;
116
+ const hueValue = value;
117
+ await AdapterProvider_1.default.setState(colorProperty.hal.hue, hueValue.hue);
118
+ if (colorProperty.hal.saturation) {
119
+ await AdapterProvider_1.default.setState(colorProperty.hal.saturation, hueValue.saturation);
120
+ }
121
+ // do not set brightness
122
+ // https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-colorcontroller.html
123
+ // Important: For the best user experience, when you make a color change, maintain the current brightness setting of the endpoint.
124
+ // For example, if a light bulb is currently set to white at 0.5 brightness, and a user requests a color change to red,
125
+ // the SetColor directive specifies hue = 0, saturation = 1, and brightness = 1. Here, set the hue to 0, the saturation to 1,
126
+ // and ignore the brightness value of 1 in the directive. Instead, maintain the current brightness value of 0.5.
127
+ property.currentValue = value;
128
+ }
129
+ else if (property.propertyName === ColorTemperatureInKelvin_1.default.propertyName) {
130
+ await AdapterProvider_1.default.setState(property.setId, value ?? 2200);
131
+ property.currentValue = value;
132
+ }
133
+ }
134
+ async adjustValue(event, property) {
135
+ // extract Alexa delta value from event
136
+ const delta = property.alexaDirectiveValue(event);
137
+ // convert delta to iobroker value
138
+ const value = property.value(delta);
139
+ // set iobroker state
140
+ await this.setState(property, value);
141
+ return value;
142
+ }
143
+ composeInitObject(property) {
144
+ const map = this.statesMap;
145
+ if (property.propertyName === Properties_1.default.PowerState.propertyName) {
146
+ return {
147
+ setState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
148
+ getState: this.states[map.on] || this.states[map.dimmer] || this.states[map.brightness],
149
+ alexaSetter: function (alexaValue) {
150
+ return alexaValue === PowerState_1.default.ON;
151
+ },
152
+ alexaGetter: function (value) {
153
+ return value ? PowerState_1.default.ON : PowerState_1.default.OFF;
154
+ },
155
+ };
156
+ }
157
+ if (property.propertyName === Brightness_1.default.propertyName) {
158
+ return {
159
+ setState: this.states[map.dimmer] || this.states[map.brightness],
160
+ getState: this.states[map.dimmer] || this.states[map.brightness],
161
+ alexaSetter: function (alexaValue) {
162
+ return ((0, Utils_1.denormalize_0_100)(alexaValue, this.valuesRangeMin, this.valuesRangeMax) ?? 0);
163
+ },
164
+ alexaGetter: function (value) {
165
+ return (0, Utils_1.normalize_0_100)(value, this.valuesRangeMin, this.valuesRangeMax);
166
+ },
167
+ };
168
+ }
169
+ if (property.propertyName === Properties_1.default.Color.propertyName) {
170
+ return {
171
+ hal: {
172
+ hue: this.states[map.hue].id,
173
+ saturation: this.states[map.saturation]?.id,
174
+ brightness: (this.states[map.dimmer] || this.states[map.brightness])?.id,
175
+ },
176
+ };
177
+ }
178
+ if (property.propertyName === Properties_1.default.ColorTemperatureInKelvin.propertyName) {
179
+ return {
180
+ setState: this.states[map.temperature],
181
+ getState: this.states[map.temperature],
182
+ alexaSetter: function (alexaValue) {
183
+ if (alexaValue === 1) {
184
+ // increase directive
185
+ const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
186
+ let index = this.colorTemperatureTable.indexOf(closest) + 1;
187
+ index =
188
+ index >= this.colorTemperatureTable.length ? this.colorTemperatureTable.length - 1 : index;
189
+ return this.colorTemperatureTable[index];
190
+ }
191
+ if (alexaValue === -1) {
192
+ // decrease directive
193
+ const closest = (0, Utils_1.closestFromList)(this.currentValue || this.colorTemperatureTable[0], this.colorTemperatureTable);
194
+ let index = this.colorTemperatureTable.indexOf(closest) - 1;
195
+ index = index < 0 ? 0 : index;
196
+ return this.colorTemperatureTable[index];
197
+ }
198
+ return alexaValue;
199
+ },
200
+ alexaGetter: function (value) {
201
+ return value;
202
+ },
203
+ };
204
+ }
205
+ }
206
+ }
207
+ exports.default = Hue;
208
+ //# sourceMappingURL=Hue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hue.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Hue.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AAIjD,4CAAiH;AACjH,qEAA6C;AAC7C,gFAAwD;AACxD,gFAAwD;AACxD,iFAAyD;AACzD,4EAAoD;AAIpD,sEAA8C;AAC9C,4GAAoF;AAEpF,MAAqB,GAAI,SAAQ,2BAAiB;IACtC,0BAA0B,CAAmB;IAC7C,WAAW,CAAc;IACzB,qBAAqB,CAAwB;IAC7C,WAAW,CAAc;IACzB,2BAA2B,CAA8B;IAEjE,IAAI,UAAU;QACV,OAAO,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,oBAAoB;QAChB,OAAO,CAAC,oBAAU,CAAC,wBAAwB,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB;QACZ,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,IAAI,sBAAY,CAAC,eAAe,EAAE,CAAC,CAAC;QAEpD,+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,EAAE,CAAC;YACrE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC;YACzD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC5C,CAAC;QAED,sCAAsC;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,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AC7C,CAAC;oBACD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;wBACpB,qBAAqB;wBACrB,MAAM,OAAO,GAAG,IAAA,uBAAe,EAC1B,IAAI,CAAC,YAAuB,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAC9D,IAAI,CAAC,qBAAqB,CAC7B,CAAC;wBACF,IAAI,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;wBAC5D,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;wBAC9B,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;oBAC7C,CAAC;oBAED,OAAO,UAAoB,CAAC;gBAChC,CAAC;gBACD,WAAW,EAAE,UAET,KAAsC;oBAEtC,OAAO,KAAe,CAAC;gBAC3B,CAAC;aACJ,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAlPD,sBAkPC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport type PowerController from '../Alexa/Capabilities/PowerController';\nimport type BrightnessController from '../Alexa/Capabilities/BrightnessController';\nimport type ColorTemperatureController from '../Alexa/Capabilities/ColorTemperatureController';\nimport { configuredRangeOrDefault, denormalize_0_100, normalize_0_100, closestFromList } from '../Helpers/Utils';\nimport Properties from '../Alexa/Properties';\nimport PowerState from '../Alexa/Properties/PowerState';\nimport Brightness from '../Alexa/Properties/Brightness';\nimport AdapterProvider from '../Helpers/AdapterProvider';\nimport AdjustableControl from './AdjustableControl';\nimport type { Base as PropertiesBase, ControlStateInitObject } from '../Alexa/Properties/Base';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, AlexaV3Request } from '../types';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\nimport Color from '../Alexa/Properties/Color';\nimport ColorTemperatureInKelvin from '../Alexa/Properties/ColorTemperatureInKelvin';\n\nexport default class Hue extends AdjustableControl {\n private _powerControllerCapability!: PowerController;\n private _powerState!: PowerState;\n private _brightnessCapability!: BrightnessController;\n private _brightness!: Brightness;\n private _colorTemperatureCapability!: ColorTemperatureController;\n\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n adjustableProperties(): (typeof PropertiesBase)[] {\n return [Properties.ColorTemperatureInKelvin];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n const map = this.statesMap;\n const result = [new Capabilities.ColorController()];\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();\n this._brightness = this._brightnessCapability.brightness;\n result.push(this._brightnessCapability);\n }\n\n // if the state TEMPERATURE configured\n if (this.states[map.temperature]) {\n this._colorTemperatureCapability = new Capabilities.ColorTemperatureController();\n result.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();\n this._powerState = this._powerControllerCapability.powerState;\n result.push(this._powerControllerCapability);\n }\n\n for (const property of result.flatMap(item => item.properties)) {\n const initObj = this.composeInitObject(property);\n if (initObj) {\n property.init(initObj);\n }\n }\n\n return result;\n }\n\n async getOrRetrieveCurrentValue(property: Color): 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 === Properties.PowerState.propertyName && !this.states[map.on]) {\n property.currentValue = property.currentValue !== 0;\n }\n\n if (property.propertyName === Properties.Color.propertyName) {\n // @ts-expect-error special case for Color property\n property.currentValue = {\n hue: property.currentValue,\n saturation: property.hal.saturation,\n brightness: property.hal.brightness,\n };\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 | undefined): 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 ?? false);\n property.currentValue = value;\n } else {\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: string | number | undefined | null;\n if (smartName && typeof smartName === 'object') {\n byOn = smartName.byON;\n }\n byOn =\n byOn === null || byOn === undefined || isNaN(byOn as number)\n ? (range.max as number)\n : parseFloat(byOn as string);\n await AdapterProvider.setState(this._brightness.setId, byOn);\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 (property.propertyName === Brightness.propertyName) {\n await AdapterProvider.setState(property.setId, value ?? 0);\n property.currentValue = value;\n } else if (property.propertyName === Color.propertyName) {\n const colorProperty = property as Color;\n const hueValue = value as unknown as { hue: number; saturation: number };\n await AdapterProvider.setState(colorProperty.hal.hue, hueValue.hue);\n if (colorProperty.hal.saturation) {\n await AdapterProvider.setState(colorProperty.hal.saturation, hueValue.saturation);\n }\n\n // do not set brightness\n\n // https://developer.amazon.com/en-US/docs/alexa/device-apis/alexa-colorcontroller.html\n // Important: For the best user experience, when you make a color change, maintain the current brightness setting of the endpoint.\n // For example, if a light bulb is currently set to white at 0.5 brightness, and a user requests a color change to red,\n // the SetColor directive specifies hue = 0, saturation = 1, and brightness = 1. Here, set the hue to 0, the saturation to 1,\n // and ignore the brightness value of 1 in the directive. Instead, maintain the current brightness value of 0.5.\n\n property.currentValue = value;\n } else if (property.propertyName === ColorTemperatureInKelvin.propertyName) {\n await AdapterProvider.setState(property.setId, value ?? 2200);\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);\n\n return value as AlexaV3DirectiveValue;\n }\n\n composeInitObject(property: PropertiesBase): ControlStateInitObject | undefined {\n const map = this.statesMap;\n\n if (property.propertyName === Properties.PowerState.propertyName) {\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 (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return value ? PowerState.ON : PowerState.OFF;\n },\n };\n }\n\n if (property.propertyName === Brightness.propertyName) {\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(\n value as number,\n this.valuesRangeMin as number,\n this.valuesRangeMax as number,\n );\n },\n };\n }\n\n if (property.propertyName === Properties.Color.propertyName) {\n return {\n hal: {\n hue: this.states[map.hue]!.id,\n saturation: this.states[map.saturation]?.id,\n brightness: (this.states[map.dimmer] || this.states[map.brightness])?.id,\n },\n };\n }\n\n if (property.propertyName === Properties.ColorTemperatureInKelvin.propertyName) {\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 =\n 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 (\n this: PropertiesBase,\n value: ioBroker.StateValue | undefined,\n ): AlexaV3DirectiveValue {\n return value as number;\n },\n };\n }\n }\n}\n"]}
@@ -1,43 +1,36 @@
1
- const Capabilities = require('../Alexa/Capabilities');
2
- const Control = require('./Control');
3
-
4
- /**
5
- * @class
6
- */
7
- class Light extends Control {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
+ const Control_1 = __importDefault(require("./Control"));
8
+ class Light extends Control_1.default {
8
9
  get categories() {
9
10
  return ['LIGHT'];
10
11
  }
11
-
12
12
  initCapabilities() {
13
- let result = [new Capabilities.PowerController()];
14
-
13
+ const result = [new Capabilities_1.default.PowerController()];
15
14
  for (const property of result.flatMap(item => item.properties)) {
16
- property.init(this.powerStateInitObject())
15
+ property.init(this.powerStateInitObject());
17
16
  }
18
-
19
17
  return result;
20
18
  }
21
-
22
19
  initEnforcedCapabilities() {
23
- let result = [new Capabilities.BrightnessController()];
20
+ const result = [new Capabilities_1.default.BrightnessController()];
24
21
  for (const property of result.flatMap(item => item.properties)) {
25
22
  property.init(this.brightnessInitObject());
26
23
  }
27
-
28
24
  return result;
29
25
  }
30
-
31
26
  get statesMap() {
32
27
  return {
33
- 'set': 'SET',
34
- 'actual': 'ON_ACTUAL',
28
+ set: 'SET',
29
+ actual: 'ON_ACTUAL',
35
30
  };
36
31
  }
37
-
38
32
  brightnessInitObject() {
39
33
  const map = this.statesMap;
40
-
41
34
  return {
42
35
  setState: this.states[map.set],
43
36
  getState: this.states[map.actual],
@@ -50,5 +43,5 @@ class Light extends Control {
50
43
  };
51
44
  }
52
45
  }
53
-
54
- module.exports = Light;
46
+ exports.default = Light;
47
+ //# sourceMappingURL=Light.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Light.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Light.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,wDAAgC;AAIhC,MAAqB,KAAM,SAAQ,iBAAO;IACtC,IAAI,UAAU;QACV,OAAO,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,gBAAgB;QACZ,MAAM,MAAM,GAAG,CAAC,IAAI,sBAAY,CAAC,eAAe,EAAE,CAAC,CAAC;QAEpD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,wBAAwB;QACpB,MAAM,MAAM,GAAG,CAAC,IAAI,sBAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;QACzD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QAIT,OAAO;YACH,GAAG,EAAE,KAAK;YACV,MAAM,EAAE,WAAW;SACtB,CAAC;IACN,CAAC;IAED,oBAAoB;QAMhB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;QAE3B,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,UAAU,UAAiC;gBACpD,OAAQ,UAAqB,GAAG,CAAC,CAAC;YACtC,CAAC;YACD,WAAW,EAAE,UAAU,KAAsC;gBACzD,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AArDD,wBAqDC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport Control from './Control';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, IotExternalDetectorState } from '../types';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\n\nexport default class Light extends Control {\n get categories(): AlexaV3Category[] {\n return ['LIGHT'];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n const result = [new Capabilities.PowerController()];\n\n for (const property of result.flatMap(item => item.properties)) {\n property.init(this.powerStateInitObject());\n }\n\n return result;\n }\n\n initEnforcedCapabilities(): CapabilitiesBase[] {\n const result = [new Capabilities.BrightnessController()];\n for (const property of result.flatMap(item => item.properties)) {\n property.init(this.brightnessInitObject());\n }\n\n return result;\n }\n\n get statesMap(): {\n set: string;\n actual: string;\n } {\n return {\n set: 'SET',\n actual: 'ON_ACTUAL',\n };\n }\n\n brightnessInitObject(): {\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\n return {\n setState: this.states[map.set]!,\n getState: this.states[map.actual]!,\n alexaSetter: function (alexaValue: AlexaV3DirectiveValue): ioBroker.StateValue | undefined {\n return (alexaValue as number) > 0;\n },\n alexaGetter: function (value: ioBroker.StateValue | undefined): AlexaV3DirectiveValue {\n return value ? 100 : 0;\n },\n };\n }\n}\n"]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Capabilities_1 = __importDefault(require("../Alexa/Capabilities"));
7
+ const Properties_1 = __importDefault(require("../Alexa/Properties"));
8
+ const Control_1 = __importDefault(require("./Control"));
9
+ class Lock extends Control_1.default {
10
+ get categories() {
11
+ return ['SMARTLOCK'];
12
+ }
13
+ initCapabilities() {
14
+ const result = [new Capabilities_1.default.LockController()];
15
+ for (const property of result.flatMap(item => item.properties)) {
16
+ property.init(this.lockStateInitObject());
17
+ }
18
+ return result;
19
+ }
20
+ lockStateInitObject() {
21
+ const map = this.statesMap;
22
+ return {
23
+ setState: this.states[map.set],
24
+ getState: this.states[map.actual],
25
+ alexaSetter: function (alexaValue) {
26
+ return alexaValue === Properties_1.default.LockState.UNLOCK;
27
+ },
28
+ alexaGetter: function (value) {
29
+ return value ? Properties_1.default.LockState.UNLOCKED : Properties_1.default.LockState.LOCKED;
30
+ },
31
+ };
32
+ }
33
+ }
34
+ exports.default = Lock;
35
+ //# sourceMappingURL=Lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Lock.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Controls/Lock.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,qEAA6C;AAC7C,wDAAgC;AAIhC,MAAqB,IAAK,SAAQ,iBAAO;IACrC,IAAI,UAAU;QACV,OAAO,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC;IAED,gBAAgB;QACZ,MAAM,MAAM,GAAG,CAAC,IAAI,sBAAY,CAAC,cAAc,EAAE,CAAC,CAAC;QACnD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YAC7D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,mBAAmB;QAMf,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,CAAE;YAClC,WAAW,EAAE,UAAU,UAAU;gBAC7B,OAAO,UAAU,KAAK,oBAAU,CAAC,SAAS,CAAC,MAAM,CAAC;YACtD,CAAC;YACD,WAAW,EAAE,UAAU,KAAK;gBACxB,OAAO,KAAK,CAAC,CAAC,CAAC,oBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAU,CAAC,SAAS,CAAC,MAAM,CAAC;YAC/E,CAAC;SACJ,CAAC;IACN,CAAC;CACJ;AA/BD,uBA+BC","sourcesContent":["import Capabilities from '../Alexa/Capabilities';\nimport Properties from '../Alexa/Properties';\nimport Control from './Control';\nimport type { Base as CapabilitiesBase } from '../Alexa/Capabilities/Base';\nimport type { AlexaV3Category, AlexaV3DirectiveValue, IotExternalDetectorState } from '../types';\n\nexport default class Lock extends Control {\n get categories(): AlexaV3Category[] {\n return ['SMARTLOCK'];\n }\n\n initCapabilities(): CapabilitiesBase[] {\n const result = [new Capabilities.LockController()];\n for (const property of result.flatMap(item => item.properties)) {\n property.init(this.lockStateInitObject());\n }\n return result;\n }\n\n lockStateInitObject(): {\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.set]!,\n getState: this.states[map.actual]!,\n alexaSetter: function (alexaValue) {\n return alexaValue === Properties.LockState.UNLOCK;\n },\n alexaGetter: function (value) {\n return value ? Properties.LockState.UNLOCKED : Properties.LockState.LOCKED;\n },\n };\n }\n}\n"]}