hoffmation-base 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (185) hide show
  1. package/lib/liquid-pid.d.ts +2 -5
  2. package/lib/liquid-pid.js +2 -5
  3. package/lib/models/command/ShutterSetLevelCommand.d.ts +7 -0
  4. package/lib/models/command/ShutterSetLevelCommand.js +8 -1
  5. package/lib/models/command/WindowRestoreDesiredPositionCommand.d.ts +5 -0
  6. package/lib/models/command/WindowRestoreDesiredPositionCommand.js +5 -0
  7. package/lib/models/command/WindowSetDesiredPositionCommand.d.ts +6 -0
  8. package/lib/models/command/WindowSetDesiredPositionCommand.js +6 -0
  9. package/lib/models/command/WindowSetRolloByWeatherStatusCommand.d.ts +5 -0
  10. package/lib/models/command/WindowSetRolloByWeatherStatusCommand.js +5 -0
  11. package/lib/models/command/actuatorSetStateCommand.d.ts +7 -0
  12. package/lib/models/command/actuatorSetStateCommand.js +9 -2
  13. package/lib/models/command/actuatorToggleCommand.d.ts +5 -0
  14. package/lib/models/command/actuatorToggleCommand.js +6 -1
  15. package/lib/models/command/actuatorWriteStateToDeviceCommand.d.ts +7 -1
  16. package/lib/models/command/actuatorWriteStateToDeviceCommand.js +12 -2
  17. package/lib/models/command/baseCommand.d.ts +14 -1
  18. package/lib/models/command/baseCommand.js +40 -6
  19. package/lib/models/command/blockAutomaticCommand.d.ts +17 -0
  20. package/lib/models/command/blockAutomaticCommand.js +22 -0
  21. package/lib/models/command/blockAutomaticLiftBlockCommand.d.ts +12 -0
  22. package/lib/models/command/blockAutomaticLiftBlockCommand.js +17 -0
  23. package/lib/models/command/blockAutomaticUntilCommand.d.ts +17 -0
  24. package/lib/models/command/blockAutomaticUntilCommand.js +22 -0
  25. package/lib/models/command/commandSource.d.ts +19 -0
  26. package/lib/models/command/commandSource.js +20 -0
  27. package/lib/models/command/commandType.d.ts +3 -0
  28. package/lib/models/command/commandType.js +3 -0
  29. package/lib/models/command/dimmerSetLightCommand.d.ts +7 -6
  30. package/lib/models/command/dimmerSetLightCommand.js +13 -11
  31. package/lib/models/command/floorSetAllShuttersCommand.d.ts +4 -4
  32. package/lib/models/command/floorSetAllShuttersCommand.js +4 -4
  33. package/lib/models/command/index.d.ts +3 -0
  34. package/lib/models/command/index.js +7 -1
  35. package/lib/models/command/lampSetLightCommand.d.ts +7 -0
  36. package/lib/models/command/lampSetLightCommand.js +8 -1
  37. package/lib/models/command/lampSetTimeBasedCommand.d.ts +4 -4
  38. package/lib/models/command/lampSetTimeBasedCommand.js +5 -5
  39. package/lib/models/command/lampToggleLightCommand.d.ts +5 -5
  40. package/lib/models/command/lampToggleLightCommand.js +6 -6
  41. package/lib/models/command/ledSetLightCommand.d.ts +15 -9
  42. package/lib/models/command/ledSetLightCommand.js +16 -10
  43. package/lib/models/command/lightGroupSwitchTimeConditionalCommand.d.ts +6 -0
  44. package/lib/models/command/lightGroupSwitchTimeConditionalCommand.js +6 -0
  45. package/lib/models/command/restoreTargetAutomaticValueCommand.d.ts +5 -0
  46. package/lib/models/command/restoreTargetAutomaticValueCommand.js +6 -1
  47. package/lib/models/command/roomRestoreLightCommand.d.ts +5 -0
  48. package/lib/models/command/roomRestoreLightCommand.js +5 -0
  49. package/lib/models/command/roomRestoreShutterPositionCommand.d.ts +6 -0
  50. package/lib/models/command/roomRestoreShutterPositionCommand.js +6 -0
  51. package/lib/models/command/roomSetLightTimeBasedCommand.d.ts +3 -3
  52. package/lib/models/command/roomSetLightTimeBasedCommand.js +3 -3
  53. package/lib/models/command/shutterSunriseUpCommand.d.ts +5 -0
  54. package/lib/models/command/shutterSunriseUpCommand.js +5 -0
  55. package/lib/models/command/shutterSunsetDownCommand.d.ts +5 -0
  56. package/lib/models/command/shutterSunsetDownCommand.js +5 -0
  57. package/lib/models/command/wledSetLightCommand.d.ts +11 -0
  58. package/lib/models/command/wledSetLightCommand.js +13 -0
  59. package/lib/models/connectionCallbacks.d.ts +4 -4
  60. package/lib/models/deviceConfig.d.ts +2 -2
  61. package/lib/models/deviceSettings/acSettings.d.ts +6 -5
  62. package/lib/models/deviceSettings/acSettings.js +10 -8
  63. package/lib/models/deviceSettings/actuatorSettings.d.ts +13 -4
  64. package/lib/models/deviceSettings/actuatorSettings.js +19 -9
  65. package/lib/models/deviceSettings/garageDoorOpenerSettings.d.ts +0 -1
  66. package/lib/models/deviceSettings/garageDoorOpenerSettings.js +0 -1
  67. package/lib/models/deviceSettings/heaterSettings.d.ts +0 -6
  68. package/lib/models/deviceSettings/heaterSettings.js +0 -6
  69. package/lib/models/deviceSettings/ledSettings.js +10 -18
  70. package/lib/models/deviceSettings/motionSensorSettings.d.ts +0 -1
  71. package/lib/models/deviceSettings/motionSensorSettings.js +0 -1
  72. package/lib/models/deviceSettings/shutterSettings.d.ts +0 -3
  73. package/lib/models/deviceSettings/shutterSettings.js +0 -3
  74. package/lib/models/deviceSettings/wledSettings.js +5 -13
  75. package/lib/models/groupSettings/heatGroupSettings.d.ts +3 -1
  76. package/lib/models/groupSettings/heatGroupSettings.js +3 -1
  77. package/lib/models/iIdHolder.d.ts +6 -0
  78. package/lib/models/objectSettings.d.ts +2 -2
  79. package/lib/models/objectSettings.js +2 -2
  80. package/lib/models/rooms/RoomBase.d.ts +2 -1
  81. package/lib/models/rooms/RoomBase.js +4 -3
  82. package/lib/models/rooms/iRoomBase.d.ts +17 -0
  83. package/lib/models/rooms/iRoomImportEnforcer.d.ts +4 -0
  84. package/lib/server/devices/Griffe.js +0 -1
  85. package/lib/server/devices/IoBrokerBaseDevice.d.ts +11 -16
  86. package/lib/server/devices/IoBrokerBaseDevice.js +21 -17
  87. package/lib/server/devices/IoBrokerDeviceInfo.d.ts +2 -2
  88. package/lib/server/devices/IoBrokerDeviceInfo.js +6 -4
  89. package/lib/server/devices/baseDeviceInterfaces/iAcDevice.d.ts +30 -3
  90. package/lib/server/devices/baseDeviceInterfaces/iActuator.d.ts +16 -0
  91. package/lib/server/devices/baseDeviceInterfaces/iBaseDevice.d.ts +25 -0
  92. package/lib/server/devices/baseDeviceInterfaces/iBatteryDevice.d.ts +10 -1
  93. package/lib/server/devices/baseDeviceInterfaces/iBluetoothDetector.d.ts +5 -5
  94. package/lib/server/devices/baseDeviceInterfaces/iButtonSwitch.d.ts +13 -0
  95. package/lib/server/devices/baseDeviceInterfaces/iCameraDevice.d.ts +10 -0
  96. package/lib/server/devices/baseDeviceInterfaces/iDimmableLamp.d.ts +9 -2
  97. package/lib/server/devices/baseDeviceInterfaces/iEnergyManager.d.ts +13 -2
  98. package/lib/server/devices/baseDeviceInterfaces/iExcessEnergyConsumer.d.ts +16 -2
  99. package/lib/server/devices/baseDeviceInterfaces/iGarageDoorOpener.d.ts +10 -0
  100. package/lib/server/devices/baseDeviceInterfaces/iHandleSensor.d.ts +12 -0
  101. package/lib/server/devices/baseDeviceInterfaces/iHeater.d.ts +12 -2
  102. package/lib/server/devices/baseDeviceInterfaces/iHumiditySensor.d.ts +7 -0
  103. package/lib/server/devices/baseDeviceInterfaces/iLamp.d.ts +4 -0
  104. package/lib/server/devices/baseDeviceInterfaces/iLedRgbCct.d.ts +5 -0
  105. package/lib/server/devices/baseDeviceInterfaces/iMotionSensor.d.ts +7 -1
  106. package/lib/server/devices/baseDeviceInterfaces/iScene.d.ts +7 -0
  107. package/lib/server/devices/baseDeviceInterfaces/iShutter.d.ts +7 -0
  108. package/lib/server/devices/baseDeviceInterfaces/iSmokeDetectorDevice.d.ts +7 -0
  109. package/lib/server/devices/baseDeviceInterfaces/iSpeaker.d.ts +25 -0
  110. package/lib/server/devices/baseDeviceInterfaces/iTemperatureSensor.d.ts +11 -0
  111. package/lib/server/devices/baseDeviceInterfaces/iTemporaryDisableAutomatic.d.ts +7 -0
  112. package/lib/server/devices/baseDeviceInterfaces/iTvDevice.d.ts +12 -0
  113. package/lib/server/devices/baseDeviceInterfaces/iVibrationSensor.d.ts +0 -1
  114. package/lib/server/devices/blueIris/cameraDevice.d.ts +2 -3
  115. package/lib/server/devices/blueIris/cameraDevice.js +2 -3
  116. package/lib/server/devices/dachs/interfaces/KeyListEntity.d.ts +0 -8
  117. package/lib/server/devices/dachs/interfaces/KeyListEntity.js +0 -8
  118. package/lib/server/devices/dachs/lib/dachsHttpClient.d.ts +1 -1
  119. package/lib/server/devices/groups/Window.d.ts +1 -0
  120. package/lib/server/devices/groups/Window.js +1 -0
  121. package/lib/server/devices/groups/heatGroup.d.ts +7 -6
  122. package/lib/server/devices/groups/heatGroup.js +8 -9
  123. package/lib/server/devices/groups/lightGroup.d.ts +2 -2
  124. package/lib/server/devices/groups/lightGroup.js +11 -10
  125. package/lib/server/devices/groups/presenceGroup.d.ts +0 -1
  126. package/lib/server/devices/groups/presenceGroup.js +0 -1
  127. package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.d.ts +0 -1
  128. package/lib/server/devices/hmIPDevices/hmIpHeizgruppe.js +0 -6
  129. package/lib/server/devices/hmIPDevices/hmIpLampe.js +1 -2
  130. package/lib/server/devices/hmIPDevices/hmIpRoll.js +2 -2
  131. package/lib/server/devices/iDeviceUpdater.d.ts +11 -0
  132. package/lib/server/devices/jsObject/jsObjectEnergyManager.d.ts +1 -1
  133. package/lib/server/devices/jsObject/jsObjectEnergyManager.js +1 -1
  134. package/lib/server/devices/sharedFunctions/lampUtils.d.ts +1 -0
  135. package/lib/server/devices/sharedFunctions/lampUtils.js +32 -15
  136. package/lib/server/devices/wledDevice.d.ts +1 -0
  137. package/lib/server/devices/wledDevice.js +13 -8
  138. package/lib/server/devices/zigbee/BaseDevices/ZigbeeActuator.js +1 -2
  139. package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.d.ts +0 -2
  140. package/lib/server/devices/zigbee/BaseDevices/zigbeeDevice.js +9 -18
  141. package/lib/server/devices/zigbee/BaseDevices/zigbeeDimmer.js +8 -8
  142. package/lib/server/devices/zigbee/BaseDevices/zigbeeLedRGBCCT.d.ts +2 -1
  143. package/lib/server/devices/zigbee/BaseDevices/zigbeeLedRGBCCT.js +6 -4
  144. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.d.ts +1 -1
  145. package/lib/server/devices/zigbee/BaseDevices/zigbeeMotionSensor.js +1 -1
  146. package/lib/server/devices/zigbee/BaseDevices/zigbeeShutter.js +3 -3
  147. package/lib/server/devices/zigbee/BaseDevices/zigbeeSwitch.d.ts +1 -1
  148. package/lib/server/devices/zigbee/zigbeeAquaraVibra.d.ts +1 -1
  149. package/lib/server/devices/zigbee/zigbeeEuroHeater.d.ts +2 -3
  150. package/lib/server/devices/zigbee/zigbeeEuroHeater.js +2 -3
  151. package/lib/server/ioBroker/connection.d.ts +20 -20
  152. package/lib/server/ioBroker/connection.js +29 -21
  153. package/lib/server/ioBroker/socketIOConnectOptions.d.ts +2 -2
  154. package/lib/server/ioBroker/socketIOVisCommand.d.ts +5 -1
  155. package/lib/server/services/Sonos/polly-service.js +1 -2
  156. package/lib/server/services/Translation/res.d.ts +34 -19
  157. package/lib/server/services/Translation/res.js +34 -19
  158. package/lib/server/services/ac/ac-device.d.ts +0 -5
  159. package/lib/server/services/ac/ac-device.js +17 -18
  160. package/lib/server/services/ac/daikin-service.js +2 -1
  161. package/lib/server/services/ac/own-daikin-device.js +12 -4
  162. package/lib/server/services/api/api-service.d.ts +117 -52
  163. package/lib/server/services/api/api-service.js +160 -68
  164. package/lib/server/services/blockAutomaticHandler.d.ts +6 -8
  165. package/lib/server/services/blockAutomaticHandler.js +15 -13
  166. package/lib/server/services/dbo/iPersist.d.ts +96 -0
  167. package/lib/server/services/govee/own-govee-device.js +4 -7
  168. package/lib/server/services/https-service.d.ts +3 -2
  169. package/lib/server/services/https-service.js +3 -2
  170. package/lib/server/services/log-service/log-service.d.ts +2 -2
  171. package/lib/server/services/log-service/log-service.js +2 -2
  172. package/lib/server/services/news-service.d.ts +5 -6
  173. package/lib/server/services/news-service.js +5 -6
  174. package/lib/server/services/room-service/room-service.d.ts +3 -2
  175. package/lib/server/services/room-service/room-service.js +4 -3
  176. package/lib/server/services/settings-service.d.ts +3 -2
  177. package/lib/server/services/settings-service.js +3 -2
  178. package/lib/server/services/utils/iDisposeable.d.ts +3 -0
  179. package/lib/server/services/victron/victron-device.d.ts +2 -2
  180. package/lib/server/services/victron/victron-device.js +2 -2
  181. package/lib/server/services/weather/weather-current.d.ts +0 -2
  182. package/lib/server/services/weather/weather-service.d.ts +4 -1
  183. package/lib/server/services/weather/weather-service.js +4 -0
  184. package/lib/tsconfig.tsbuildinfo +1 -1
  185. package/package.json +6 -5
@@ -12,8 +12,8 @@ const config_1 = require("../../config");
12
12
  class API {
13
13
  /**
14
14
  * Endpoint to end a scene manually (or early if it has automatic turn off)
15
- * @param {string} deviceId
16
- * @returns {Error | null}
15
+ * @param deviceId - The id of the scene to end
16
+ * @returns In case it failed the Error containing the reason
17
17
  */
18
18
  static endScene(deviceId) {
19
19
  const d = this.getDevice(deviceId);
@@ -29,8 +29,8 @@ class API {
29
29
  }
30
30
  /**
31
31
  * Gets the instance of an Ac Device identified by id
32
- * @param {string} id
33
- * @returns {OwnDaikinDevice | undefined}
32
+ * @param id - The device id of the AC
33
+ * @returns The instance of the AC Device or undefined if not found
34
34
  */
35
35
  static getAc(id) {
36
36
  const result = this.getDevice(id);
@@ -39,10 +39,12 @@ class API {
39
39
  }
40
40
  return result;
41
41
  }
42
+ // TODO: Missing Comment
42
43
  static getDevices() {
43
44
  // console.log(Util.inspect(Devices.alLDevices, false, 5));
44
45
  return devices_1.Devices.alLDevices;
45
46
  }
47
+ // TODO: Missing Comment
46
48
  static getDevice(id) {
47
49
  const d = devices_1.Devices.alLDevices[id];
48
50
  if (d === undefined) {
@@ -50,6 +52,7 @@ class API {
50
52
  }
51
53
  return devices_1.Devices.alLDevices[id];
52
54
  }
55
+ // TODO: Missing Comment
53
56
  static getGroup(id) {
54
57
  const g = room_service_1.RoomService.Groups.get(id);
55
58
  if (g === undefined) {
@@ -57,23 +60,27 @@ class API {
57
60
  }
58
61
  return g;
59
62
  }
63
+ // TODO: Missing Comment
60
64
  static getRooms() {
61
65
  // console.log(inspect(Object.fromEntries(RoomService.Rooms)));
62
66
  return room_service_1.RoomService.Rooms;
63
67
  }
68
+ // TODO: Missing Comment
64
69
  static getRoom(id) {
65
70
  return room_service_1.RoomService.Rooms.get(id);
66
71
  }
72
+ // TODO: Missing Comment
67
73
  static getLog() {
68
74
  return log_service_1.ServerLogService.getLog();
69
75
  }
70
76
  /**
71
77
  * Turns on/off one AC identified by it's id
72
- * @param id The id of the device, if wrong false will be returned
73
- * @param {boolean} desiredState
74
- * @param {AcMode} desiredMode
75
- * @param desiredTemperature
76
- * @param forceTime The time in ms this should not change before automatic change is allowed again
78
+ * @param id - The id of the device, if wrong false will be returned
79
+ * @param desiredState - The desired state for the AC
80
+ * @param desiredMode - The desired mode for the AC
81
+ * @param desiredTemperature - The desired temperature for the AC in Celsius
82
+ * @param forceTime - The time in ms this should not change before automatic change is allowed again
83
+ * @returns True if the AC was found and the state was changed
77
84
  */
78
85
  static setAc(id, desiredState, desiredMode, desiredTemperature, forceTime = 60 * 60 * 1000) {
79
86
  const d = this.getAc(id);
@@ -99,7 +106,7 @@ class API {
99
106
  }
100
107
  /**
101
108
  * Turns on/off all AC´s in the home
102
- * @param {boolean} desiredState
109
+ * @param desiredState - The desired state for all AC´s
103
110
  */
104
111
  static setAllAc(desiredState) {
105
112
  ac_1.DaikinService.setAll(desiredState, true);
@@ -107,12 +114,23 @@ class API {
107
114
  }
108
115
  /**
109
116
  * Changes the status of a given Lamp
110
- * @param {string} deviceId The device Id of the lamp
111
- * @param {boolean} state The desired new state
112
- * @param timeout Desired time after which this should be reverted to normal state
113
- * @returns {Error | null} In case it failed the Error containing the reason
117
+ * @param deviceId - The device Id of the lamp
118
+ * @param state - The desired new state
119
+ * @param timeout - Desired time after which this should be reverted to normal state
120
+ * @returns In case it failed the Error containing the reason
121
+ * @deprecated Use "API.lampSetLight" instead
122
+ * TODO: Remove deprecated API method
114
123
  */
115
124
  static setLamp(deviceId, state, timeout = 60 * 60 * 1000) {
125
+ return this.lampSetLight(deviceId, new models_1.LampSetLightCommand(models_1.CommandSource.API, state, '', timeout));
126
+ }
127
+ /**
128
+ * Changes the status of a given Lamp
129
+ * @param deviceId - The device Id of the lamp
130
+ * @param c - The command(stack) to perform on the lamp
131
+ * @returns In case it failed the Error containing the reason.
132
+ */
133
+ static lampSetLight(deviceId, c) {
116
134
  const d = this.getDevice(deviceId);
117
135
  if (d === undefined) {
118
136
  return new Error(`Device with ID ${deviceId} not found`);
@@ -120,18 +138,29 @@ class API {
120
138
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.lamp)) {
121
139
  return new Error(`Device with ID ${deviceId} is no Lamp`);
122
140
  }
123
- d.log(models_1.LogLevel.Info, `API Call to set Lamp to ${state} for ${timeout}ms`);
124
- d.setLight(new models_1.LampSetLightCommand(models_1.CommandSource.API, state, '', timeout));
141
+ d.log(models_1.LogLevel.Info, `Received LampSetLightCommand API call.`);
142
+ d.setLight(c);
125
143
  return null;
126
144
  }
127
145
  /**
128
146
  * Changes the status of a given actuator
129
- * @param {string} deviceId The device Id of the actuator
130
- * @param {boolean} state The desired new state
131
- * @param timeout Desired time after which this should be reverted to automatic state
132
- * @returns {Error | null} In case it failed the Error containing the reason
147
+ * @param deviceId - The device Id of the actuator
148
+ * @param state - The desired new state
149
+ * @param timeout - Desired time after which this should be reverted to automatic state
150
+ * @returns In case it failed the Error containing the reason
151
+ * @deprecated Use "API.actuatorSetState" instead
152
+ * TODO: Remove deprecated API method
133
153
  */
134
154
  static setActuator(deviceId, state, timeout = 60 * 60 * 1000) {
155
+ return this.actuatorSetState(deviceId, new models_1.ActuatorSetStateCommand(models_1.CommandSource.API, state, '', timeout));
156
+ }
157
+ /**
158
+ * Changes the status of a given actuator
159
+ * @param deviceId - The device Id of the actuator
160
+ * @param c - The command(stack) to perform on the actuator
161
+ * @returns In case it failed the Error containing the reason
162
+ */
163
+ static actuatorSetState(deviceId, c) {
135
164
  const d = this.getDevice(deviceId);
136
165
  if (d === undefined) {
137
166
  return new Error(`Device with ID ${deviceId} not found`);
@@ -139,20 +168,31 @@ class API {
139
168
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.actuator)) {
140
169
  return new Error(`Device with ID ${deviceId} is no actuator`);
141
170
  }
142
- d.log(models_1.LogLevel.Info, `API Call to set Actuator to ${state} for ${timeout}ms`);
143
- d.setActuator(new models_1.ActuatorSetStateCommand(models_1.CommandSource.API, state, '', timeout));
171
+ d.log(models_1.LogLevel.Info, `Received ActuatorSetStateCommand API call.`);
172
+ d.setActuator(c);
144
173
  return null;
145
174
  }
146
175
  /**
147
- * Changes the status of a given actuator
148
- * @param {string} deviceId The device Id of the actuator
149
- * @param {boolean} state The desired new state
150
- * @param timeout A chosen Timeout after which the light should be reset
151
- * @param brightness The desired brightness
152
- * @param transitionTime The transition time during turnOn/turnOff
153
- * @returns {Error | null} In case it failed the Error containing the reason
176
+ * Changes the status of the given dimmer
177
+ * @param deviceId - The device Id of the actuator
178
+ * @param state - The desired new state
179
+ * @param timeout - A chosen Timeout after which the light should be reset
180
+ * @param brightness - The desired brightness
181
+ * @param transitionTime - The transition time during turnOn/turnOff
182
+ * @returns In case it failed the Error containing the reason
183
+ * @deprecated Use "API.dimmerSetLight" instead
184
+ * TODO: Remove deprecated API method
154
185
  */
155
186
  static setDimmer(deviceId, state, timeout, brightness, transitionTime) {
187
+ return this.dimmerSetLight(deviceId, new models_1.DimmerSetLightCommand(models_1.CommandSource.API, state, '', timeout, brightness, transitionTime));
188
+ }
189
+ /**
190
+ * Changes the status of the given dimmer
191
+ * @param deviceId - The device Id of the dimmable device.
192
+ * @param command - The command(stack) to perform on the dimmer
193
+ * @returns In case it failed the Error containing the reason.
194
+ */
195
+ static dimmerSetLight(deviceId, command) {
156
196
  const d = this.getDevice(deviceId);
157
197
  if (d === undefined) {
158
198
  return new Error(`Device with ID ${deviceId} not found`);
@@ -160,41 +200,64 @@ class API {
160
200
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.dimmablelamp)) {
161
201
  return new Error(`Device with ID ${deviceId} is no dimmablelamp`);
162
202
  }
163
- d.log(models_1.LogLevel.Info, `API Call to set Dimmer to ${state} with brightness ${brightness} for ${timeout}ms`);
164
- d.setLight(new models_1.DimmerSetLightCommand(models_1.CommandSource.API, state, '', timeout, brightness, transitionTime));
203
+ d.log(models_1.LogLevel.Info, `Received dimmerSetLight API call.`);
204
+ d.setLight(command);
165
205
  return null;
166
206
  }
167
207
  /**
168
- * Changes the status of a given actuator
169
- * @param {string} deviceId The device Id of the actuator
170
- * @param {boolean} state The desired new state
171
- * @param timeout A chosen Timeout after which the light should be reset
172
- * @param brightness The desired brightness
173
- * @param transitionTime The transition time during turnOn/turnOff
174
- * @param {string} color The desired color in 6 digit hex Code
175
- * @param {number} colorTemp The desired color Temperature (0 = more White)
176
- * @returns {Error | null} In case it failed the Error containing the reason
208
+ * Changes the status of a given led-device
209
+ * @param deviceId - The device Id of the actuator
210
+ * @param state - The desired new state
211
+ * @param timeout - A chosen Timeout after which the light should be reset
212
+ * @param brightness - The desired brightness
213
+ * @param transitionTime - The transition time during turnOn/turnOff
214
+ * @param color - The desired color in 6 digit hex Code
215
+ * @param colorTemp - The desired color Temperature (0 = more White)
216
+ * @returns In case it failed the Error containing the reason
217
+ * @deprecated Use "API.ledSetLight" instead
218
+ * TODO: Remove deprecated API method
177
219
  */
178
220
  static setLedLamp(deviceId, state, timeout, brightness, transitionTime, color, colorTemp) {
221
+ return this.ledSetLight(deviceId, new models_1.LedSetLightCommand(models_1.CommandSource.API, state, '', timeout, brightness, transitionTime, color, colorTemp));
222
+ }
223
+ /**
224
+ * Changes the status of a given led-device
225
+ * @param deviceId - The device Id of the LED-Device
226
+ * @param command - The command(stack) to perform on the led-device
227
+ * @returns In case it failed the Error containing the reason
228
+ */
229
+ static ledSetLight(deviceId, command) {
179
230
  const d = this.getDevice(deviceId);
180
231
  if (d === undefined) {
181
232
  return new Error(`Device with ID ${deviceId} not found`);
182
233
  }
183
234
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.ledLamp)) {
184
- return new Error(`Device with ID ${deviceId} is no dimmablelamp`);
235
+ return new Error(`Device with ID ${deviceId} is no LED`);
185
236
  }
186
- d.log(models_1.LogLevel.Info, `API Call to set LED to ${state} with brightness ${brightness} and color ${color} for ${timeout}ms`);
187
- d.setLight(new models_1.LedSetLightCommand(models_1.CommandSource.API, state, '', timeout, brightness, transitionTime, color, colorTemp));
237
+ d.log(models_1.LogLevel.Info, `Received ledSetLight API call.`);
238
+ d.setLight(command);
188
239
  return null;
189
240
  }
190
241
  /**
191
242
  * Changes the position of a given shutter
192
243
  * if needed this updates the window position as well
193
- * @param {string} deviceId The device Id of the shutter
194
- * @param {number} level The desired new level (0 being open, 100 being closed)
195
- * @returns {Error | null} Error if there is no shutter with the given id
244
+ * @param deviceId - The device Id of the shutter
245
+ * @param level - The desired new level (0 being open, 100 being closed)
246
+ * @returns Error if there is no shutter with the given id
247
+ * @deprecated Use "API.shutterSetLevel" instead
248
+ * TODO: Remove deprecated API method
196
249
  */
197
250
  static setShutter(deviceId, level) {
251
+ return this.shutterSetLevel(deviceId, new models_1.ShutterSetLevelCommand(models_1.CommandSource.API, level));
252
+ }
253
+ /**
254
+ * Changes the position of a given shutter
255
+ * if needed this updates the window position as well
256
+ * @param deviceId - The device Id of the shutter
257
+ * @param command - The command(stack) to perform on the shutter
258
+ * @returns Error if there is no shutter with the given id
259
+ */
260
+ static shutterSetLevel(deviceId, command) {
198
261
  const d = this.getDevice(deviceId);
199
262
  if (d === undefined) {
200
263
  return new Error(`Device with ID ${deviceId} not found`);
@@ -204,14 +267,15 @@ class API {
204
267
  }
205
268
  if (d.window) {
206
269
  // otherwise it will be overridden shortly after
207
- d.window.setDesiredPosition(new models_1.WindowSetDesiredPositionCommand(models_1.CommandSource.API, level));
270
+ d.window.setDesiredPosition(new models_1.WindowSetDesiredPositionCommand(command, command.level));
208
271
  }
209
272
  else {
210
- d.setLevel(new models_1.ShutterSetLevelCommand(models_1.CommandSource.API, level));
273
+ d.setLevel(command);
211
274
  }
212
- d.log(models_1.LogLevel.Info, `API Call to set Shutter to ${level}`);
275
+ d.log(models_1.LogLevel.Info, `Received shutterSetLevel API call.`);
213
276
  return null;
214
277
  }
278
+ // TODO: Missing Comment
215
279
  static speakOnDevice(deviceId, message, volume = 30) {
216
280
  const d = this.getDevice(deviceId);
217
281
  if (d === undefined) {
@@ -226,9 +290,9 @@ class API {
226
290
  }
227
291
  /**
228
292
  * Starts a specified scene
229
- * @param {string} deviceId The targeted scene
230
- * @param {number} turnOffTimeout If provided the time in ms after which the scene should end automatically
231
- * @returns {Error | null} In case it failed the Error containing the reason
293
+ * @param deviceId - The targeted scene
294
+ * @param turnOffTimeout - If provided the time in ms after which the scene should end automatically
295
+ * @returns In case it failed the Error containing the reason
232
296
  */
233
297
  static startScene(deviceId, turnOffTimeout) {
234
298
  const d = this.getDevice(deviceId);
@@ -262,9 +326,9 @@ class API {
262
326
  }
263
327
  /**
264
328
  * Changes the settings of a given device
265
- * @param {string} deviceId The id of the device to change the settings
266
- * @param settings A partial settings object containing the wanted settings properties
267
- * @returns {Error | null} In case it failed the Error containing the reason
329
+ * @param deviceId - The id of the device to change the settings
330
+ * @param settings - A partial settings object containing the wanted settings properties
331
+ * @returns In case it failed the Error containing the reason
268
332
  */
269
333
  static setDeviceSettings(deviceId, settings) {
270
334
  const d = this.getDevice(deviceId);
@@ -279,6 +343,7 @@ class API {
279
343
  d.settings.persist(d);
280
344
  return null;
281
345
  }
346
+ // TODO: Missing Comment
282
347
  static setGroupSettings(groupId, settings) {
283
348
  const g = this.getGroup(groupId);
284
349
  if (g === undefined) {
@@ -294,9 +359,9 @@ class API {
294
359
  }
295
360
  /**
296
361
  * Changes the settings of a given room
297
- * @param {string} roomName The id of the Room to change the settings
298
- * @param settings A partial settings object containing the wanted settings properties
299
- * @returns {Error | null} In case it failed the Error containing the reason
362
+ * @param roomName - The id of the Room to change the settings
363
+ * @param settings - A partial settings object containing the wanted settings properties
364
+ * @returns In case it failed the Error containing the reason
300
365
  */
301
366
  static setRoomSettings(roomName, settings) {
302
367
  const r = this.getRoom(roomName);
@@ -308,6 +373,7 @@ class API {
308
373
  r.settings.settingsContainer.persist(r);
309
374
  return null;
310
375
  }
376
+ // TODO: Missing Comment
311
377
  static getLastCameraImage(deviceId) {
312
378
  const d = this.getDevice(deviceId);
313
379
  if (d === undefined) {
@@ -318,6 +384,7 @@ class API {
318
384
  }
319
385
  return d.lastImage;
320
386
  }
387
+ // TODO: Missing Comment
321
388
  static persistAllDeviceSettings() {
322
389
  var _a;
323
390
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `API Call to persist all device settings`);
@@ -325,6 +392,7 @@ class API {
325
392
  (_a = device.settings) === null || _a === void 0 ? void 0 : _a.persist(device);
326
393
  }
327
394
  }
395
+ // TODO: Missing Comment
328
396
  static loadAllDeviceSettingsFromDb() {
329
397
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `API Call to load all device settings`);
330
398
  for (const device of Object.values(devices_1.Devices.alLDevices)) {
@@ -333,10 +401,21 @@ class API {
333
401
  }
334
402
  /**
335
403
  * Lifts a previously started Block of automatic
336
- * @param {string} deviceId The target device
337
- * @returns {Error | null} In case it failed the Error containing the reason
404
+ * @param deviceId - The target device
405
+ * @returns In case it failed the Error containing the reason
406
+ * @deprecated Use "API.blockAutomaticLiftAutomaticBlock" instead
407
+ * TODO: Remove deprecated API method
338
408
  */
339
409
  static liftAutomaticBlock(deviceId) {
410
+ return this.blockAutomaticLiftAutomaticBlock(deviceId, new models_1.BlockAutomaticLiftBlockCommand(models_1.CommandSource.API));
411
+ }
412
+ /**
413
+ * Lifts a previously started Block of automatic
414
+ * @param deviceId - The target device
415
+ * @param command - The command to lift the automatic block
416
+ * @returns In case it failed the Error containing the reason
417
+ */
418
+ static blockAutomaticLiftAutomaticBlock(deviceId, command) {
340
419
  const d = this.getDevice(deviceId);
341
420
  if (d === undefined) {
342
421
  return new Error(`Device with ID ${deviceId} not found`);
@@ -344,18 +423,30 @@ class API {
344
423
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.blockAutomatic)) {
345
424
  return new Error(`Device with ID ${deviceId} is not capable of blocking automatic`);
346
425
  }
347
- d.log(models_1.LogLevel.Info, `API Call to lift automatic block`);
348
- d.blockAutomationHandler.liftAutomaticBlock();
426
+ d.log(models_1.LogLevel.Info, `Received API Call to lift automatic block.`);
427
+ d.blockAutomationHandler.liftAutomaticBlock(command);
349
428
  return null;
350
429
  }
351
430
  /**
352
431
  * Blocks the automatic of the given device for provided Duration
353
- * @param {string} deviceId The target device
354
- * @param {number} duration The duration in ms for which the device should remain in current state
355
- * @param {CollisionSolving} onCollision The desired Collision Solving strategy, in case the automatic being blocked already
356
- * @returns {Error | null} In case it failed the Error containing the reason
432
+ * @param deviceId - The target device
433
+ * @param duration - The duration in ms for which the device should remain in current state
434
+ * @param onCollision - The desired Collision Solving strategy, in case the automatic being blocked already
435
+ * @returns In case it failed the Error containing the reason
436
+ * @deprecated Use "API.blockAutomaticDisable" instead
437
+ * TODO: Remove deprecated API method
357
438
  */
358
439
  static blockAutomatic(deviceId, duration, onCollision) {
440
+ this.blockAutomaticSetBlock(deviceId, new models_1.BlockAutomaticCommand(models_1.CommandSource.API, duration, '', onCollision));
441
+ return null;
442
+ }
443
+ /**
444
+ * Blocks the automatic of the given device for provided Duration
445
+ * @param deviceId - The target device
446
+ * @param command - The command to block the automatic
447
+ * @returns In case it failed the Error containing the reason
448
+ */
449
+ static blockAutomaticSetBlock(deviceId, command) {
359
450
  const d = this.getDevice(deviceId);
360
451
  if (d === undefined) {
361
452
  return new Error(`Device with ID ${deviceId} not found`);
@@ -363,10 +454,11 @@ class API {
363
454
  if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.blockAutomatic)) {
364
455
  return new Error(`Device with ID ${deviceId} is not capable of blocking automatic`);
365
456
  }
366
- d.log(models_1.LogLevel.Info, `API Call to block automatic for ${duration}ms with ${onCollision} on collision`);
367
- d.blockAutomationHandler.disableAutomatic(duration, onCollision);
457
+ d.log(models_1.LogLevel.Info, `Received API Call to block automatic.`);
458
+ d.blockAutomationHandler.disableAutomatic(command);
368
459
  return null;
369
460
  }
461
+ // TODO: Missing Comment
370
462
  static pressButtonSwitch(deviceId, position, pressType) {
371
463
  const d = this.getDevice(deviceId);
372
464
  if (d === undefined) {
@@ -1,17 +1,15 @@
1
- /// <reference types="node" />
2
- import { CollisionSolving, RestoreTargetAutomaticValueCommand } from '../../models';
1
+ import { BlockAutomaticCommand, BlockAutomaticLiftBlockCommand, BlockAutomaticUntilCommand, RestoreTargetAutomaticValueCommand } from '../../models';
3
2
  export declare class BlockAutomaticHandler {
4
3
  private readonly _restoreAutomatic;
5
- constructor(restoreAutomaticCb: (c: RestoreTargetAutomaticValueCommand) => void);
6
4
  private _automaticBlockedUntil;
5
+ private _restoreAutomaticStateTimeout;
6
+ constructor(restoreAutomaticCb: (c: RestoreTargetAutomaticValueCommand) => void);
7
7
  get automaticBlockedUntil(): Date;
8
8
  private set automaticBlockedUntil(value);
9
- private _restoreAutomaticStateTimeout;
10
- get restoreAutomaticStateTimeout(): NodeJS.Timeout | null;
11
9
  get automaticBlockActive(): boolean;
12
- disableAutomatic(durationMS: number, onCollideAction?: CollisionSolving): void;
13
- disableAutomaticUntil(targetDate: Date, onCollideAction?: CollisionSolving): void;
14
- liftAutomaticBlock(): void;
10
+ disableAutomatic(c: BlockAutomaticCommand): void;
11
+ disableAutomaticUntil(c: BlockAutomaticUntilCommand): void;
12
+ liftAutomaticBlock(c: BlockAutomaticLiftBlockCommand): void;
15
13
  private updateRestoreTimeout;
16
14
  toJSON(): Partial<BlockAutomaticHandler>;
17
15
  }
@@ -18,35 +18,37 @@ class BlockAutomaticHandler {
18
18
  }
19
19
  set automaticBlockedUntil(target) {
20
20
  this._automaticBlockedUntil = target;
21
- this.updateRestoreTimeout();
22
- }
23
- get restoreAutomaticStateTimeout() {
24
- return this._restoreAutomaticStateTimeout;
25
21
  }
26
22
  get automaticBlockActive() {
27
23
  return this._automaticBlockedUntil > new Date();
28
24
  }
29
- disableAutomatic(durationMS, onCollideAction = models_1.CollisionSolving.overrideIfGreater) {
30
- this.disableAutomaticUntil(new Date(utils_1.Utils.nowMS() + durationMS), onCollideAction);
25
+ disableAutomatic(c) {
26
+ this.disableAutomaticUntil(new models_1.BlockAutomaticUntilCommand(c, new Date(utils_1.Utils.nowMS() + c.durationMS), '', c.onCollideAction));
31
27
  }
32
- disableAutomaticUntil(targetDate, onCollideAction = models_1.CollisionSolving.overrideIfGreater) {
28
+ disableAutomaticUntil(c) {
33
29
  const now = new Date();
34
30
  if (this._automaticBlockedUntil > now &&
35
- onCollideAction != models_1.CollisionSolving.override &&
36
- (onCollideAction != models_1.CollisionSolving.overrideIfGreater || targetDate < this._automaticBlockedUntil)) {
31
+ c.onCollideAction != models_1.CollisionSolving.override &&
32
+ (c.onCollideAction != models_1.CollisionSolving.overrideIfGreater || c.targetDate < this._automaticBlockedUntil)) {
37
33
  return;
38
34
  }
39
- this.automaticBlockedUntil = targetDate;
35
+ this.automaticBlockedUntil = c.targetDate;
36
+ this.updateRestoreTimeout(new models_1.RestoreTargetAutomaticValueCommand(c, 'Restore to automatic state after block.'));
40
37
  }
41
- liftAutomaticBlock() {
38
+ liftAutomaticBlock(c) {
39
+ if (this._restoreAutomaticStateTimeout !== null) {
40
+ clearTimeout(this._restoreAutomaticStateTimeout);
41
+ }
42
+ this._restoreAutomaticStateTimeout = null;
42
43
  this.automaticBlockedUntil = new Date(0);
44
+ this._restoreAutomatic(new models_1.RestoreTargetAutomaticValueCommand(c));
43
45
  }
44
- updateRestoreTimeout() {
46
+ updateRestoreTimeout(c) {
45
47
  if (this._restoreAutomaticStateTimeout !== null) {
46
48
  clearTimeout(this._restoreAutomaticStateTimeout);
47
49
  }
48
50
  this._restoreAutomaticStateTimeout = utils_1.Utils.guardedTimeout(() => {
49
- this._restoreAutomatic(new models_1.RestoreTargetAutomaticValueCommand(models_1.CommandSource.Unknown, 'Automatic block restore timeout'));
51
+ this._restoreAutomatic(c);
50
52
  }, this._automaticBlockedUntil.getTime() - utils_1.Utils.nowMS() + 500, this);
51
53
  }
52
54
  toJSON() {
@@ -2,26 +2,122 @@ import { ButtonPressType, iAcDevice, iActuator, iBaseDevice, iBatteryDevice, iBu
2
2
  import { CountToday, DesiredShutterPosition, EnergyCalculation, RoomBase, ShutterCalibration } from '../../../models';
3
3
  export interface iPersist {
4
4
  initialized: boolean;
5
+ /**
6
+ * Adds a room to the database
7
+ * @param {RoomBase} room - The room to add
8
+ */
5
9
  addRoom(room: RoomBase): void;
10
+ /**
11
+ * Adds a device to the database
12
+ * @param {iBaseDevice} device - The device to add
13
+ */
6
14
  addDevice(device: iBaseDevice): void;
15
+ /**
16
+ * Gets the count of the motion sensor today
17
+ * @param {iMotionSensor} device - The device to get the count for
18
+ * @returns {Promise<CountToday>} - The count of the motion sensor today
19
+ */
7
20
  motionSensorTodayCount(device: iMotionSensor): Promise<CountToday>;
21
+ /**
22
+ * Gets the last desired position of the shutter
23
+ * @param {iShutter} device - The device to get the last desired position for
24
+ * @returns {Promise<DesiredShutterPosition>} - The last desired position of the shutter
25
+ */
8
26
  getLastDesiredPosition(device: iShutter): Promise<DesiredShutterPosition>;
27
+ /**
28
+ * Gets the shutter calibration
29
+ * @param {iShutter} device - The device to get the shutter calibration for
30
+ * @returns {Promise<ShutterCalibration>} - The shutter calibration
31
+ */
9
32
  getShutterCalibration(device: iShutter): Promise<ShutterCalibration>;
33
+ /**
34
+ * Initializes the database-connection and prepares the database
35
+ * @returns {Promise<void>} - The promise that resolves when the database is initialized
36
+ */
10
37
  initialize(): Promise<void>;
38
+ /**
39
+ * Persists the shutter calibration
40
+ * @param {ShutterCalibration} data - The shutter calibration data to persist
41
+ */
11
42
  persistShutterCalibration(data: ShutterCalibration): void;
43
+ /**
44
+ * Persists data for an illumination sensor
45
+ * @param {iIlluminationSensor} device - The device to persist data for
46
+ */
12
47
  persistIlluminationSensor(device: iIlluminationSensor): void;
48
+ /**
49
+ * Persists data for an energy manager
50
+ * @param {EnergyCalculation} energyData - The energy data to persist
51
+ */
13
52
  persistEnergyManager(energyData: EnergyCalculation): void;
53
+ /**
54
+ * Persists data of an AC device
55
+ * @param {iAcDevice} device - The device to persist data for
56
+ */
14
57
  persistAC(device: iAcDevice): void;
58
+ /**
59
+ * Persists data of an actuator
60
+ * @param {iActuator} device - The device to persist data for
61
+ */
15
62
  persistActuator(device: iActuator): void;
63
+ /**
64
+ * Persists data of a heater
65
+ * @param {iHeater} device - The device to persist data for
66
+ */
16
67
  persistHeater(device: iHeater): void;
68
+ /**
69
+ * Persists data of a motion sensor
70
+ * @param {iMotionSensor} device - The device to persist data for
71
+ */
17
72
  persistMotionSensor(device: iMotionSensor): void;
73
+ /**
74
+ * Persists data of a button switch action
75
+ * @param {iButtonSwitch} device - The device to persist data for
76
+ * @param {ButtonPressType} pressType - The type of button press
77
+ * @param {string} buttonName - The name of the button
78
+ */
18
79
  persistSwitchInput(device: iButtonSwitch, pressType: ButtonPressType, buttonName: string): void;
80
+ /**
81
+ * Persists data of a shutter
82
+ * @param {iShutter} device - The device to persist data for
83
+ */
19
84
  persistShutter(device: iShutter): void;
85
+ /**
86
+ * Persists data of a temperature sensor
87
+ * @param {iTemperatureSensor} device - The device to persist data for
88
+ */
20
89
  persistTemperatureSensor(device: iTemperatureSensor): void;
90
+ /**
91
+ * Persists data of a humidity sensor
92
+ * @param {iHumiditySensor} device - The device to persist data for
93
+ */
21
94
  persistHumiditySensor(device: iHumiditySensor): void;
95
+ /**
96
+ * Persists data of a handle sensor
97
+ * @param {iHandleSensor} device - The device to persist data for
98
+ */
22
99
  persistHandleSensor(device: iHandleSensor): void;
100
+ /**
101
+ * Persists data of a battery device
102
+ * @param {iBatteryDevice} device - The device to persist data for
103
+ */
23
104
  persistBatteryDevice(device: iBatteryDevice): void;
105
+ /**
106
+ * Persists data of a Zigbee device
107
+ * @param {ZigbeeDevice} device - The device to persist data for
108
+ */
24
109
  persistZigbeeDevice(device: ZigbeeDevice): void;
110
+ /**
111
+ * Persists settings for the given id
112
+ * @param {string} id - The id to persist settings for
113
+ * @param {string} settings - The settings to persist (as JSON string)
114
+ * @param {string} customname - The custom name of the device/object
115
+ */
25
116
  persistSettings(id: string, settings: string, customname: string): void;
117
+ /**
118
+ * Loads settings for the given id
119
+ * @param {string} id - The id of the object/device to load settings for
120
+ * @returns {Promise<string | undefined>} - The settings as JSON string or undefined if not found
121
+ */
26
122
  loadSettings(id: string): Promise<string | undefined>;
27
123
  }