hoffmation-base 3.0.0-alpha.94 → 3.0.0-alpha.95

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.
@@ -84,4 +84,5 @@ export declare class Dachs implements iBaseDevice, iActuator {
84
84
  private onBatteryLevelChange;
85
85
  private onTempChange;
86
86
  private checkHeatingRod;
87
+ private shouldDachsBeStarted;
87
88
  }
@@ -158,6 +158,10 @@ class Dachs {
158
158
  /** @inheritDoc */
159
159
  setActuator(c) {
160
160
  devices_1.LampUtils.setActuator(this, c);
161
+ if (c.on && this.warmWaterPump && (this.queuedValue === true || this._dachsOn)) {
162
+ const startPumpCommand = new models_1.ActuatorSetStateCommand(c, true, 'Dachs is starting/on');
163
+ this.warmWaterPump.setActuator(startPumpCommand);
164
+ }
161
165
  }
162
166
  /** @inheritDoc */
163
167
  toggleActuator(c) {
@@ -198,35 +202,9 @@ class Dachs {
198
202
  * @param {BatteryLevelChangeAction} action - The action containing the new level
199
203
  */
200
204
  onBatteryLevelChange(action) {
205
+ const shouldDachsBeStarted = this.shouldDachsBeStarted(action);
201
206
  this.checkHeatingRod(action);
202
- if (this.blockDachsStart !== undefined) {
203
- if (action.newLevel > this.settings.batteryLevelPreventStartThreshold) {
204
- const blockAction = new models_1.ActuatorSetStateCommand(action, true, `Battery reached ${action.newLevel}%, Dachs should not run any more`, null);
205
- blockAction.overrideCommandSource = models_1.CommandSource.Force;
206
- this.blockDachsStart.setActuator(blockAction);
207
- return;
208
- }
209
- else if (action.newLevel < this.settings.batteryLevelAllowStartThreshold) {
210
- const liftAction = new models_1.ActuatorSetStateCommand(action, false, `Battery reached ${action.newLevel}%, Dachs is now allowed to run if needed`, null);
211
- this.blockDachsStart.setActuator(liftAction);
212
- }
213
- else if (this.blockDachsStart.actuatorOn) {
214
- // We haven't reached the lower threshold yet --> nothing to do
215
- return;
216
- }
217
- }
218
- if (this._dachsOn) {
219
- // We are already running
220
- return;
221
- }
222
- const dayType = services_1.TimeCallbackService.dayType(new services_1.SunTimeOffsets());
223
- if ((dayType === models_1.TimeOfDay.Daylight || dayType === models_1.TimeOfDay.BeforeSunrise) &&
224
- action.newLevel > this.settings.batteryLevelTurnOnThreshold) {
225
- // It is daytime (maybe solar power) and it is no critical battery level
226
- return;
227
- }
228
- if (action.newLevel > this.settings.batteryLevelBeforeNightTurnOnThreshold) {
229
- // It is not daylight but battery level is high enough
207
+ if (!shouldDachsBeStarted) {
230
208
  return;
231
209
  }
232
210
  const setStateCommand = new models_1.ActuatorSetStateCommand(action, true, 'Energy Level of battery dropped to critical level', null);
@@ -234,6 +212,7 @@ class Dachs {
234
212
  this.setActuator(setStateCommand);
235
213
  }
236
214
  onTempChange(action) {
215
+ var _a;
237
216
  if (this.warmWaterPump === undefined) {
238
217
  // We have no control over the warm water pump --> nothing to do
239
218
  return;
@@ -242,14 +221,22 @@ class Dachs {
242
221
  const heatStorageTemp = this._tempHeatStorage;
243
222
  let desiredState = false;
244
223
  let reason = '';
245
- if (wwTemp > this.settings.warmWaterDesiredMinTemp + 3) {
246
- desiredState = false;
247
- reason = `Temperature of warm water pump ${wwTemp}°C is above desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`;
224
+ if (this._dachsOn) {
225
+ desiredState = true;
226
+ reason = 'Dachs is on anyways';
248
227
  }
249
228
  else if (wwTemp > heatStorageTemp) {
250
229
  desiredState = false;
251
230
  reason = `Temperature of warm water pump ${wwTemp}°C is higher than temperature of heat storage ${heatStorageTemp}°C`;
252
231
  }
232
+ else if (((_a = this.blockDachsStart) === null || _a === void 0 ? void 0 : _a.actuatorOn) === false) {
233
+ desiredState = true;
234
+ reason = 'Dachs is not blocked --> lowering storage temp might trigger it.';
235
+ }
236
+ else if (wwTemp > this.settings.warmWaterDesiredMinTemp + 3) {
237
+ desiredState = false;
238
+ reason = `Temperature of warm water pump ${wwTemp}°C is above desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`;
239
+ }
253
240
  else if (heatStorageTemp < this.settings.warmWaterDesiredMinTemp - 4) {
254
241
  desiredState = false;
255
242
  reason = `Temperature of heat storage ${heatStorageTemp}°C is too low to heat water.`;
@@ -280,5 +267,38 @@ class Dachs {
280
267
  const setAction = new models_1.ActuatorSetStateCommand(action, !shouldBeOff, `Battery reached ${action.newLevel}%, heating rod should be turned ${shouldBeOff ? 'off' : 'on'}`, null);
281
268
  this.heatingRod.setActuator(setAction);
282
269
  }
270
+ shouldDachsBeStarted(action) {
271
+ if (this.blockDachsStart !== undefined) {
272
+ if (action.newLevel > this.settings.batteryLevelPreventStartThreshold) {
273
+ const blockAction = new models_1.ActuatorSetStateCommand(action, true, `Battery reached ${action.newLevel}%, Dachs should not run any more`, null);
274
+ blockAction.overrideCommandSource = models_1.CommandSource.Force;
275
+ this.blockDachsStart.setActuator(blockAction);
276
+ return false;
277
+ }
278
+ else if (action.newLevel < this.settings.batteryLevelAllowStartThreshold) {
279
+ const liftAction = new models_1.ActuatorSetStateCommand(action, false, `Battery reached ${action.newLevel}%, Dachs is now allowed to run if needed`, null);
280
+ this.blockDachsStart.setActuator(liftAction);
281
+ }
282
+ else if (this.blockDachsStart.actuatorOn) {
283
+ // We haven't reached the lower threshold yet --> nothing to do
284
+ return false;
285
+ }
286
+ }
287
+ if (this._dachsOn) {
288
+ // We are already running
289
+ return false;
290
+ }
291
+ const dayType = services_1.TimeCallbackService.dayType(new services_1.SunTimeOffsets());
292
+ if ((dayType === models_1.TimeOfDay.Daylight || dayType === models_1.TimeOfDay.BeforeSunrise) &&
293
+ action.newLevel > this.settings.batteryLevelTurnOnThreshold) {
294
+ // It is daytime (maybe solar power) and it is no critical battery level
295
+ return false;
296
+ }
297
+ if (action.newLevel > this.settings.batteryLevelBeforeNightTurnOnThreshold) {
298
+ // It is not daylight but battery level is high enough
299
+ return false;
300
+ }
301
+ return true;
302
+ }
283
303
  }
284
304
  exports.Dachs = Dachs;