hoffmation-base 3.0.0-alpha.93 → 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.
- package/lib/server/devices/dachs/dachs.d.ts +1 -0
- package/lib/server/devices/dachs/dachs.js +51 -31
- package/lib/server/devices/sharedFunctions/handleSensor.js +1 -1
- package/lib/server/services/weather/weather-service.d.ts +4 -3
- package/lib/server/services/weather/weather-service.js +20 -9
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
|
@@ -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 (
|
|
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 (
|
|
246
|
-
desiredState =
|
|
247
|
-
reason =
|
|
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;
|
|
@@ -64,7 +64,7 @@ class HandleSensor {
|
|
|
64
64
|
if (heatgroup !== undefined) {
|
|
65
65
|
const desiredTemp = heatgroup.desiredTemp;
|
|
66
66
|
const currentTemp = heatgroup.temperature;
|
|
67
|
-
const outSideTemp = services_1.WeatherService.
|
|
67
|
+
const outSideTemp = services_1.WeatherService.currentTemp;
|
|
68
68
|
// Check if any of these values are unavailable
|
|
69
69
|
if (desiredTemp > -99 && currentTemp > -99 && outSideTemp > -99) {
|
|
70
70
|
const wouldHelp = (desiredTemp < currentTemp && outSideTemp < currentTemp) ||
|
|
@@ -15,7 +15,7 @@ export declare class WeatherService {
|
|
|
15
15
|
/**
|
|
16
16
|
* The last weather response
|
|
17
17
|
*/
|
|
18
|
-
static lastResponse: WeatherResponse;
|
|
18
|
+
static lastResponse: WeatherResponse | undefined;
|
|
19
19
|
/**
|
|
20
20
|
* The sun horizontal degree (0 is North)
|
|
21
21
|
*/
|
|
@@ -31,8 +31,9 @@ export declare class WeatherService {
|
|
|
31
31
|
static update(): void;
|
|
32
32
|
static stopInterval(): void;
|
|
33
33
|
static playWeatherInfo(speaker: iSpeaker, volume?: number, short?: boolean, retries?: number): void;
|
|
34
|
-
static processHourlyWeather(): void;
|
|
35
|
-
static
|
|
34
|
+
static processHourlyWeather(response: WeatherResponse): void;
|
|
35
|
+
static get currentHumidity(): number;
|
|
36
|
+
static get currentTemp(): number;
|
|
36
37
|
static willOutsideBeWarmer(referenceTemperature: number, logger: (level: LogLevel, message: string, debugType?: LogDebugType) => void): boolean;
|
|
37
38
|
static weatherRolloPosition(normalPos: number, desiredTemperatur: number, currentTemperatur: number, logger: (level: LogLevel, message: string, debugType?: LogDebugType) => void, shutterSettings: ShutterSettings): number;
|
|
38
39
|
static getCurrentCloudiness(): number;
|
|
@@ -105,7 +105,8 @@ class WeatherService {
|
|
|
105
105
|
speaker.speakOnDevice('Für heute liegt keine Unwetterwarnungen vor', volume, false);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
static processHourlyWeather() {
|
|
108
|
+
static processHourlyWeather(response) {
|
|
109
|
+
this.lastResponse = response;
|
|
109
110
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Es sind gerade ${this.lastResponse.current.temp} Grad (gefühlt ${this.lastResponse.current.feels_like}).`);
|
|
110
111
|
if (this.lastResponse.alerts !== undefined && this.lastResponse.alerts.length > 0) {
|
|
111
112
|
const message = ['Es gibt folgende Wetterwarnungen:'];
|
|
@@ -115,13 +116,21 @@ class WeatherService {
|
|
|
115
116
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, message.join('\n'));
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
static
|
|
119
|
-
|
|
120
|
-
if (
|
|
119
|
+
static get currentHumidity() {
|
|
120
|
+
var _a;
|
|
121
|
+
if (((_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.current) === undefined) {
|
|
122
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, 'WeatherService.currentHumidity: There is no data yet');
|
|
123
|
+
return -1;
|
|
124
|
+
}
|
|
125
|
+
return WeatherService.lastResponse.current.humidity;
|
|
126
|
+
}
|
|
127
|
+
static get currentTemp() {
|
|
128
|
+
var _a;
|
|
129
|
+
if (((_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.current) === undefined) {
|
|
121
130
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, 'WeatherService.isOutsideWarmer(): There are no data yet');
|
|
122
131
|
return -99;
|
|
123
132
|
}
|
|
124
|
-
return
|
|
133
|
+
return WeatherService.lastResponse.current.temp;
|
|
125
134
|
}
|
|
126
135
|
static willOutsideBeWarmer(referenceTemperature, logger) {
|
|
127
136
|
const wData = WeatherService.lastResponse;
|
|
@@ -171,7 +180,8 @@ class WeatherService {
|
|
|
171
180
|
return wData.current.clouds;
|
|
172
181
|
}
|
|
173
182
|
static getRainNextMinutes() {
|
|
174
|
-
|
|
183
|
+
var _a;
|
|
184
|
+
const minutes = (_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.minutely;
|
|
175
185
|
let minutesUsed = 0;
|
|
176
186
|
let precipitation = 0;
|
|
177
187
|
if (minutes !== undefined) {
|
|
@@ -186,8 +196,9 @@ class WeatherService {
|
|
|
186
196
|
return { minutes: minutesUsed, precipitation: precipitation };
|
|
187
197
|
}
|
|
188
198
|
static getActiveAlerts() {
|
|
199
|
+
var _a;
|
|
189
200
|
const result = [];
|
|
190
|
-
if (WeatherService.lastResponse.alerts === undefined || WeatherService.lastResponse.alerts.length === 0) {
|
|
201
|
+
if (((_a = WeatherService.lastResponse) === null || _a === void 0 ? void 0 : _a.alerts) === undefined || WeatherService.lastResponse.alerts.length === 0) {
|
|
191
202
|
return result;
|
|
192
203
|
}
|
|
193
204
|
const now = new Date().getTime();
|
|
@@ -212,8 +223,8 @@ class WeatherService {
|
|
|
212
223
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Debug, 'WeatherAPi Response erhalten');
|
|
213
224
|
log_service_1.ServerLogService.writeLog(models_1.LogLevel.DeepTrace, `WeatherAPi Response: ${response}`);
|
|
214
225
|
utils_1.Utils.guardedFunction(() => {
|
|
215
|
-
|
|
216
|
-
WeatherService.processHourlyWeather();
|
|
226
|
+
const responseObj = JSON.parse(response);
|
|
227
|
+
WeatherService.processHourlyWeather(responseObj);
|
|
217
228
|
for (const dataUpdateCbsKey in this._dataUpdateCbs) {
|
|
218
229
|
this._dataUpdateCbs[dataUpdateCbsKey]();
|
|
219
230
|
}
|