hoffmation-base 3.0.0-alpha.94 → 3.0.0-alpha.96
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.
|
@@ -34,6 +34,10 @@ export declare class Dachs implements iBaseDevice, iActuator {
|
|
|
34
34
|
* An external actuator to prevent the Dachs from starting.
|
|
35
35
|
*/
|
|
36
36
|
blockDachsStart?: iActuator;
|
|
37
|
+
/**
|
|
38
|
+
* An external actuator controlling some device to heat the warm water while the Dachs is prohibited from starting.
|
|
39
|
+
*/
|
|
40
|
+
warmWaterDachsAlternativeActuator?: iActuator;
|
|
37
41
|
private readonly client;
|
|
38
42
|
private readonly config;
|
|
39
43
|
/** @inheritDoc */
|
|
@@ -84,4 +88,6 @@ export declare class Dachs implements iBaseDevice, iActuator {
|
|
|
84
88
|
private onBatteryLevelChange;
|
|
85
89
|
private onTempChange;
|
|
86
90
|
private checkHeatingRod;
|
|
91
|
+
private shouldDachsBeStarted;
|
|
92
|
+
private checkAlternativeActuator;
|
|
87
93
|
}
|
|
@@ -107,6 +107,7 @@ class Dachs {
|
|
|
107
107
|
'warmWaterPump',
|
|
108
108
|
'heatingRod',
|
|
109
109
|
'blockDachsStart',
|
|
110
|
+
'warmWaterDachsAlternativeActuator',
|
|
110
111
|
]));
|
|
111
112
|
}
|
|
112
113
|
/** @inheritDoc */
|
|
@@ -158,6 +159,10 @@ class Dachs {
|
|
|
158
159
|
/** @inheritDoc */
|
|
159
160
|
setActuator(c) {
|
|
160
161
|
devices_1.LampUtils.setActuator(this, c);
|
|
162
|
+
if (c.on && this.warmWaterPump && (this.queuedValue === true || this._dachsOn)) {
|
|
163
|
+
const startPumpCommand = new models_1.ActuatorSetStateCommand(c, true, 'Dachs is starting/on');
|
|
164
|
+
this.warmWaterPump.setActuator(startPumpCommand);
|
|
165
|
+
}
|
|
161
166
|
}
|
|
162
167
|
/** @inheritDoc */
|
|
163
168
|
toggleActuator(c) {
|
|
@@ -198,35 +203,10 @@ class Dachs {
|
|
|
198
203
|
* @param {BatteryLevelChangeAction} action - The action containing the new level
|
|
199
204
|
*/
|
|
200
205
|
onBatteryLevelChange(action) {
|
|
206
|
+
const shouldDachsBeStarted = this.shouldDachsBeStarted(action);
|
|
201
207
|
this.checkHeatingRod(action);
|
|
202
|
-
|
|
203
|
-
|
|
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
|
|
208
|
+
this.checkAlternativeActuator(shouldDachsBeStarted, action);
|
|
209
|
+
if (!shouldDachsBeStarted) {
|
|
230
210
|
return;
|
|
231
211
|
}
|
|
232
212
|
const setStateCommand = new models_1.ActuatorSetStateCommand(action, true, 'Energy Level of battery dropped to critical level', null);
|
|
@@ -234,39 +214,52 @@ class Dachs {
|
|
|
234
214
|
this.setActuator(setStateCommand);
|
|
235
215
|
}
|
|
236
216
|
onTempChange(action) {
|
|
217
|
+
var _a, _b;
|
|
237
218
|
if (this.warmWaterPump === undefined) {
|
|
238
219
|
// We have no control over the warm water pump --> nothing to do
|
|
239
220
|
return;
|
|
240
221
|
}
|
|
241
222
|
const wwTemp = this._tempWarmWater;
|
|
242
223
|
const heatStorageTemp = this._tempHeatStorage;
|
|
243
|
-
let
|
|
224
|
+
let desiredWwPumpState = false;
|
|
244
225
|
let reason = '';
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
reason =
|
|
226
|
+
if (((_a = this.warmWaterDachsAlternativeActuator) === null || _a === void 0 ? void 0 : _a.actuatorOn) === true) {
|
|
227
|
+
desiredWwPumpState = false;
|
|
228
|
+
reason = 'Alternative heating source is on';
|
|
229
|
+
}
|
|
230
|
+
else if (this._dachsOn) {
|
|
231
|
+
desiredWwPumpState = true;
|
|
232
|
+
reason = 'Dachs is on anyways';
|
|
248
233
|
}
|
|
249
234
|
else if (wwTemp > heatStorageTemp) {
|
|
250
|
-
|
|
235
|
+
desiredWwPumpState = false;
|
|
251
236
|
reason = `Temperature of warm water pump ${wwTemp}°C is higher than temperature of heat storage ${heatStorageTemp}°C`;
|
|
252
237
|
}
|
|
238
|
+
else if (((_b = this.blockDachsStart) === null || _b === void 0 ? void 0 : _b.actuatorOn) === false) {
|
|
239
|
+
desiredWwPumpState = true;
|
|
240
|
+
reason = 'Dachs is not blocked --> lowering storage temp might trigger it.';
|
|
241
|
+
}
|
|
242
|
+
else if (wwTemp > this.settings.warmWaterDesiredMinTemp + 3) {
|
|
243
|
+
desiredWwPumpState = false;
|
|
244
|
+
reason = `Temperature of warm water pump ${wwTemp}°C is above desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`;
|
|
245
|
+
}
|
|
253
246
|
else if (heatStorageTemp < this.settings.warmWaterDesiredMinTemp - 4) {
|
|
254
|
-
|
|
247
|
+
desiredWwPumpState = false;
|
|
255
248
|
reason = `Temperature of heat storage ${heatStorageTemp}°C is too low to heat water.`;
|
|
256
249
|
}
|
|
257
250
|
else if (wwTemp < this.settings.warmWaterDesiredMinTemp) {
|
|
258
|
-
|
|
251
|
+
desiredWwPumpState = true;
|
|
259
252
|
reason = `Temperature of warm water pump ${wwTemp}°C is lower than desired minimum temperature ${this.settings.warmWaterDesiredMinTemp}°C`;
|
|
260
253
|
}
|
|
261
254
|
else {
|
|
262
255
|
// We are somewhere between states, let's not change anything
|
|
263
256
|
return;
|
|
264
257
|
}
|
|
265
|
-
if (
|
|
258
|
+
if (desiredWwPumpState === this.warmWaterPump.actuatorOn) {
|
|
266
259
|
// Nothing to do
|
|
267
260
|
return;
|
|
268
261
|
}
|
|
269
|
-
const setAction = new models_1.ActuatorSetStateCommand(action,
|
|
262
|
+
const setAction = new models_1.ActuatorSetStateCommand(action, desiredWwPumpState, reason, null);
|
|
270
263
|
this.warmWaterPump.setActuator(setAction);
|
|
271
264
|
}
|
|
272
265
|
checkHeatingRod(action) {
|
|
@@ -280,5 +273,60 @@ class Dachs {
|
|
|
280
273
|
const setAction = new models_1.ActuatorSetStateCommand(action, !shouldBeOff, `Battery reached ${action.newLevel}%, heating rod should be turned ${shouldBeOff ? 'off' : 'on'}`, null);
|
|
281
274
|
this.heatingRod.setActuator(setAction);
|
|
282
275
|
}
|
|
276
|
+
shouldDachsBeStarted(action) {
|
|
277
|
+
if (this.blockDachsStart !== undefined) {
|
|
278
|
+
if (action.newLevel > this.settings.batteryLevelPreventStartThreshold) {
|
|
279
|
+
const blockAction = new models_1.ActuatorSetStateCommand(action, true, `Battery reached ${action.newLevel}%, Dachs should not run any more`, null);
|
|
280
|
+
blockAction.overrideCommandSource = models_1.CommandSource.Force;
|
|
281
|
+
this.blockDachsStart.setActuator(blockAction);
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
else if (action.newLevel < this.settings.batteryLevelAllowStartThreshold) {
|
|
285
|
+
const liftAction = new models_1.ActuatorSetStateCommand(action, false, `Battery reached ${action.newLevel}%, Dachs is now allowed to run if needed`, null);
|
|
286
|
+
this.blockDachsStart.setActuator(liftAction);
|
|
287
|
+
}
|
|
288
|
+
else if (this.blockDachsStart.actuatorOn) {
|
|
289
|
+
// We haven't reached the lower threshold yet --> nothing to do
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (this._dachsOn) {
|
|
294
|
+
// We are already running
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
const dayType = services_1.TimeCallbackService.dayType(new services_1.SunTimeOffsets());
|
|
298
|
+
if ((dayType === models_1.TimeOfDay.Daylight || dayType === models_1.TimeOfDay.BeforeSunrise) &&
|
|
299
|
+
action.newLevel > this.settings.batteryLevelTurnOnThreshold) {
|
|
300
|
+
// It is daytime (maybe solar power) and it is no critical battery level
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
if (action.newLevel > this.settings.batteryLevelBeforeNightTurnOnThreshold) {
|
|
304
|
+
// It is not daylight but battery level is high enough
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
checkAlternativeActuator(shouldDachsBeStarted, action) {
|
|
310
|
+
var _a, _b;
|
|
311
|
+
if (!this.warmWaterDachsAlternativeActuator) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
let desiredState = false;
|
|
315
|
+
let reason = 'Dachs is allowed to run --> Block alternative heating source';
|
|
316
|
+
if (shouldDachsBeStarted || this._dachsOn) {
|
|
317
|
+
reason = 'Dachs is running or should be started';
|
|
318
|
+
desiredState = false;
|
|
319
|
+
}
|
|
320
|
+
else if (((_a = this.blockDachsStart) === null || _a === void 0 ? void 0 : _a.actuatorOn) === true || ((_b = this.blockDachsStart) === null || _b === void 0 ? void 0 : _b.queuedValue) === true) {
|
|
321
|
+
reason = 'Dachs is blocked --> Allow Alternative Heating Source';
|
|
322
|
+
desiredState = true;
|
|
323
|
+
}
|
|
324
|
+
if (this.warmWaterDachsAlternativeActuator.actuatorOn === desiredState) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const command = new models_1.ActuatorSetStateCommand(action, desiredState, reason, null);
|
|
328
|
+
command.overrideCommandSource = models_1.CommandSource.Force;
|
|
329
|
+
this.warmWaterDachsAlternativeActuator.setActuator(command);
|
|
330
|
+
}
|
|
283
331
|
}
|
|
284
332
|
exports.Dachs = Dachs;
|