hoffmation-base 3.0.0-alpha.92 → 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) ||
@@ -11,7 +11,7 @@ export declare class Utils {
11
11
  static get anyDboActive(): boolean;
12
12
  static get timeTilMidnight(): number;
13
13
  static catchEm<T>(promise: Promise<T>): Promise<CatchEmResult<T>>;
14
- static guardedFunction(func: (...args: unknown[]) => void, thisContext: unknown | undefined): void;
14
+ static guardedFunction(func: (...args: unknown[]) => void, thisContext: unknown | undefined, additionalErrorMsg?: string): void;
15
15
  static nowMS(): number;
16
16
  static delay(ms: number): Promise<void>;
17
17
  static guardedNewThread(func: (...args: unknown[]) => void, thisContext?: unknown | undefined): void;
@@ -29,7 +29,7 @@ class Utils {
29
29
  data: null,
30
30
  }));
31
31
  }
32
- static guardedFunction(func, thisContext) {
32
+ static guardedFunction(func, thisContext, additionalErrorMsg) {
33
33
  try {
34
34
  if (thisContext) {
35
35
  func.bind(thisContext)();
@@ -39,6 +39,11 @@ class Utils {
39
39
  }
40
40
  }
41
41
  catch (e) {
42
+ const message = `Guarded Function failed: ${e.message}\n Stack: ${e.stack}`;
43
+ if (additionalErrorMsg) {
44
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Error, `${message}\n${additionalErrorMsg}`);
45
+ return;
46
+ }
42
47
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Error, `Guarded Function failed: ${e.message}\n Stack: ${e.stack}`);
43
48
  }
44
49
  }
@@ -13,11 +13,15 @@ export interface WeatherCurrent {
13
13
  dew_point: number;
14
14
  uvi: number;
15
15
  clouds: number;
16
- rain?: number;
17
- snow?: number;
16
+ rain?: {
17
+ '1h': number;
18
+ };
19
+ snow?: {
20
+ '1h': number;
21
+ };
18
22
  visibility: number;
19
23
  wind_speed: number;
20
24
  wind_deg: number;
21
25
  wind_gust: number;
22
- weather: WeatherItem[];
26
+ weather: WeatherItem;
23
27
  }
@@ -5,6 +5,10 @@ export interface WeatherDaily {
5
5
  dt: number;
6
6
  sunrise: number;
7
7
  sunset: number;
8
+ moonrise: number;
9
+ moonset: number;
10
+ moon_phase: number;
11
+ summary: string;
8
12
  pressure: number;
9
13
  humidity: number;
10
14
  dew_point: number;
@@ -13,4 +13,10 @@ export interface WeatherHourly {
13
13
  wind_deg: number;
14
14
  weather: WeatherItem[];
15
15
  pop: number;
16
+ rain?: {
17
+ '1h': number;
18
+ };
19
+ snow?: {
20
+ '1h': number;
21
+ };
16
22
  }
@@ -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();
@@ -206,16 +217,18 @@ class WeatherService {
206
217
  if (!this.appID) {
207
218
  return;
208
219
  }
209
- https_service_1.HTTPSService.request(new HTTPSOptions_1.HTTPSOptions('api.openweathermap.org', `/data/2.5/onecall?lat=${WeatherService.latitude}&lon=${WeatherService.longitude}&appid=${WeatherService.appID}&units=metric&lang=de`, {}, 'GET', 443), '', 5, (response) => {
220
+ const host = 'api.openweathermap.org';
221
+ const path = `/data/3.0/onecall?lat=${WeatherService.latitude}&lon=${WeatherService.longitude}&appid=${WeatherService.appID}&units=metric&lang=de`;
222
+ https_service_1.HTTPSService.request(new HTTPSOptions_1.HTTPSOptions(host, path, {}, 'GET', 443), '', 5, (response) => {
210
223
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Debug, 'WeatherAPi Response erhalten');
211
224
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.DeepTrace, `WeatherAPi Response: ${response}`);
212
225
  utils_1.Utils.guardedFunction(() => {
213
- WeatherService.lastResponse = JSON.parse(response);
214
- WeatherService.processHourlyWeather();
226
+ const responseObj = JSON.parse(response);
227
+ WeatherService.processHourlyWeather(responseObj);
215
228
  for (const dataUpdateCbsKey in this._dataUpdateCbs) {
216
229
  this._dataUpdateCbs[dataUpdateCbsKey]();
217
230
  }
218
- }, this);
231
+ }, this, `Response from Weather API call at https://${host}/${path}: ${response}`);
219
232
  });
220
233
  }
221
234
  static recalcAzimuth() {