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