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

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.
@@ -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.getCurrentTemp();
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 getCurrentTemp(): number;
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 getCurrentTemp() {
119
- const wData = WeatherService.lastResponse;
120
- if (wData === undefined || wData.current === undefined) {
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 wData.current.temp;
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
- const minutes = WeatherService.lastResponse.minutely;
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
- WeatherService.lastResponse = JSON.parse(response);
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
  }