iobroker.poolcontrol 1.3.28 → 1.3.29

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.
Files changed (39) hide show
  1. package/README.md +16 -6
  2. package/admin/i18n/de/translations.json +4 -0
  3. package/admin/i18n/en/translations.json +8 -2
  4. package/admin/i18n/es/translations.json +4 -0
  5. package/admin/i18n/fr/translations.json +4 -0
  6. package/admin/i18n/it/translations.json +4 -0
  7. package/admin/i18n/nl/translations.json +4 -0
  8. package/admin/i18n/pl/translations.json +4 -0
  9. package/admin/i18n/pt/translations.json +4 -0
  10. package/admin/i18n/ru/translations.json +4 -0
  11. package/admin/i18n/uk/translations.json +4 -0
  12. package/admin/i18n/zh-cn/translations.json +4 -0
  13. package/admin/jsonConfig.json +31 -1
  14. package/io-package.json +14 -14
  15. package/lib/helpers/aiHelper.js +5 -5
  16. package/lib/helpers/consumptionHelper.js +47 -5
  17. package/lib/helpers/heatHelper.js +12 -9
  18. package/lib/helpers/infoHelper.js +11 -11
  19. package/lib/helpers/poolInsightsHelper.js +620 -0
  20. package/lib/helpers/pumpHelper.js +1 -4
  21. package/lib/helpers/statisticsHelper.js +7 -3
  22. package/lib/helpers/statisticsHelperMonth.js +19 -15
  23. package/lib/helpers/statisticsHelperWeek.js +11 -5
  24. package/lib/i18n/de.json +31 -1
  25. package/lib/i18n/en.json +34 -4
  26. package/lib/i18n/es.json +31 -1
  27. package/lib/i18n/fr.json +31 -1
  28. package/lib/i18n/it.json +31 -1
  29. package/lib/i18n/nl.json +31 -1
  30. package/lib/i18n/pl.json +31 -1
  31. package/lib/i18n/pt.json +31 -1
  32. package/lib/i18n/ru.json +31 -1
  33. package/lib/i18n/uk.json +31 -1
  34. package/lib/i18n/zh-cn.json +31 -1
  35. package/lib/stateDefinitions/poolInsightsStates.js +289 -0
  36. package/lib/stateDefinitions/solarStates.js +12 -3
  37. package/lib/stateDefinitions/statusStates.js +1 -1
  38. package/main.js +20 -0
  39. package/package.json +1 -1
@@ -15,6 +15,9 @@ const consumptionHelper = {
15
15
  price: 0,
16
16
  baselines: {},
17
17
  resetTimer: null,
18
+ weeklyResetTimer: null,
19
+ monthlyResetTimer: null,
20
+ yearlyResetTimer: null,
18
21
 
19
22
  lastKnownPrice: 0,
20
23
  baseTotalKwh: 0,
@@ -252,7 +255,12 @@ const consumptionHelper = {
252
255
  nextMidnight.setHours(24, 0, 0, 0);
253
256
  const msUntilMidnight = nextMidnight - now;
254
257
 
255
- this.resetTimer = setTimeout(async () => {
258
+ if (this.resetTimer) {
259
+ this.adapter.clearTimeout(this.resetTimer);
260
+ this.resetTimer = null;
261
+ }
262
+
263
+ this.resetTimer = this.adapter.setTimeout(async () => {
256
264
  try {
257
265
  this.adapter.log.info('[consumptionHelper] daily counter reset (midnight)');
258
266
  await this.adapter.setStateAsync('consumption.day_kwh', { val: 0, ack: true });
@@ -261,6 +269,7 @@ const consumptionHelper = {
261
269
  } catch (err) {
262
270
  this.adapter.log.warn(`[consumptionHelper] error during midnight reset: ${err.message}`);
263
271
  }
272
+ this.resetTimer = null;
264
273
  this._scheduleDailyReset(); // Timer erneut setzen
265
274
  }, msUntilMidnight);
266
275
  },
@@ -280,7 +289,12 @@ const consumptionHelper = {
280
289
 
281
290
  const delay = next - now;
282
291
 
283
- setTimeout(async () => {
292
+ if (this.weeklyResetTimer) {
293
+ this.adapter.clearTimeout(this.weeklyResetTimer);
294
+ this.weeklyResetTimer = null;
295
+ }
296
+
297
+ this.weeklyResetTimer = this.adapter.setTimeout(async () => {
284
298
  try {
285
299
  const nowCheck = new Date();
286
300
 
@@ -296,6 +310,7 @@ const consumptionHelper = {
296
310
  }
297
311
 
298
312
  // Morgen wieder planen
313
+ this.weeklyResetTimer = null;
299
314
  this._scheduleWeeklyReset();
300
315
  }, delay);
301
316
  },
@@ -315,7 +330,12 @@ const consumptionHelper = {
315
330
 
316
331
  const delay = next - now;
317
332
 
318
- setTimeout(async () => {
333
+ if (this.monthlyResetTimer) {
334
+ this.adapter.clearTimeout(this.monthlyResetTimer);
335
+ this.monthlyResetTimer = null;
336
+ }
337
+
338
+ this.monthlyResetTimer = this.adapter.setTimeout(async () => {
319
339
  try {
320
340
  const nowCheck = new Date();
321
341
 
@@ -331,6 +351,7 @@ const consumptionHelper = {
331
351
  }
332
352
 
333
353
  // Morgen wieder planen
354
+ this.monthlyResetTimer = null;
334
355
  this._scheduleMonthlyReset();
335
356
  }, delay);
336
357
  },
@@ -350,7 +371,12 @@ const consumptionHelper = {
350
371
 
351
372
  const delay = next - now;
352
373
 
353
- setTimeout(async () => {
374
+ if (this.yearlyResetTimer) {
375
+ this.adapter.clearTimeout(this.yearlyResetTimer);
376
+ this.yearlyResetTimer = null;
377
+ }
378
+
379
+ this.yearlyResetTimer = this.adapter.setTimeout(async () => {
354
380
  try {
355
381
  const nowCheck = new Date();
356
382
 
@@ -366,15 +392,31 @@ const consumptionHelper = {
366
392
  }
367
393
 
368
394
  // Morgen wieder prüfen
395
+ this.yearlyResetTimer = null;
369
396
  this._scheduleYearlyReset();
370
397
  }, delay);
371
398
  },
372
399
 
373
400
  cleanup() {
374
401
  if (this.resetTimer) {
375
- clearTimeout(this.resetTimer);
402
+ this.adapter.clearTimeout(this.resetTimer);
376
403
  this.resetTimer = null;
377
404
  }
405
+
406
+ if (this.weeklyResetTimer) {
407
+ this.adapter.clearTimeout(this.weeklyResetTimer);
408
+ this.weeklyResetTimer = null;
409
+ }
410
+
411
+ if (this.monthlyResetTimer) {
412
+ this.adapter.clearTimeout(this.monthlyResetTimer);
413
+ this.monthlyResetTimer = null;
414
+ }
415
+
416
+ if (this.yearlyResetTimer) {
417
+ this.adapter.clearTimeout(this.yearlyResetTimer);
418
+ this.yearlyResetTimer = null;
419
+ }
378
420
  },
379
421
  };
380
422
 
@@ -246,7 +246,7 @@ const heatHelper = {
246
246
 
247
247
  const holdMs = Math.round(prerunMin * 60 * 1000);
248
248
 
249
- this._prerunTimer = setTimeout(async () => {
249
+ this._prerunTimer = this.adapter.setTimeout(async () => {
250
250
  this._prerunTimer = null;
251
251
 
252
252
  await this.adapter.setStateAsync('heat.prerun_active', { val: false, ack: true });
@@ -261,9 +261,8 @@ const heatHelper = {
261
261
 
262
262
  this._desiredHeat = true;
263
263
 
264
- // Nachlauf ggf. abbrechen
265
264
  if (this._afterrunTimer) {
266
- clearTimeout(this._afterrunTimer);
265
+ this.adapter.clearTimeout(this._afterrunTimer);
267
266
  this._afterrunTimer = null;
268
267
  }
269
268
 
@@ -323,7 +322,7 @@ const heatHelper = {
323
322
  async _applyBlockedState(mode, reason, afterrunMin) {
324
323
  // NEU: laufenden Prerun abbrechen
325
324
  if (this._prerunTimer) {
326
- clearTimeout(this._prerunTimer);
325
+ this.adapter.clearTimeout(this._prerunTimer);
327
326
  this._prerunTimer = null;
328
327
  await this.adapter.setStateAsync('heat.prerun_active', { val: false, ack: true });
329
328
  }
@@ -347,7 +346,7 @@ const heatHelper = {
347
346
  async _applyOffState(mode, reason, afterrunMin) {
348
347
  // NEU: laufenden Prerun abbrechen
349
348
  if (this._prerunTimer) {
350
- clearTimeout(this._prerunTimer);
349
+ this.adapter.clearTimeout(this._prerunTimer);
351
350
  this._prerunTimer = null;
352
351
  await this.adapter.setStateAsync('heat.prerun_active', { val: false, ack: true });
353
352
  }
@@ -401,7 +400,7 @@ const heatHelper = {
401
400
 
402
401
  // Timer neu starten
403
402
  if (this._afterrunTimer) {
404
- clearTimeout(this._afterrunTimer);
403
+ this.adapter.clearTimeout(this._afterrunTimer);
405
404
  this._afterrunTimer = null;
406
405
  }
407
406
 
@@ -410,12 +409,15 @@ const heatHelper = {
410
409
  const holdMs = Math.round(afterrunMin * 60 * 1000);
411
410
  this.adapter.log.debug(`[heatHelper] Pump after-run started: ${afterrunMin} min (${reason})`);
412
411
 
413
- this._afterrunTimer = setTimeout(async () => {
412
+ this._afterrunTimer = this.adapter.setTimeout(async () => {
413
+ this._afterrunTimer = null;
414
+
414
415
  // Wenn inzwischen wieder Heizbedarf aktiv ist -> Nachlauf abbrechen
415
416
  if (this._desiredHeat === true) {
416
417
  this.adapter.log.debug('[heatHelper] After-run cancelled - heating is active again.');
417
418
  return;
418
419
  }
420
+
419
421
  await this._stopPumpNow('afterrun_done');
420
422
  }, holdMs);
421
423
  },
@@ -497,11 +499,12 @@ const heatHelper = {
497
499
 
498
500
  cleanup() {
499
501
  if (this._afterrunTimer) {
500
- clearTimeout(this._afterrunTimer);
502
+ this.adapter.clearTimeout(this._afterrunTimer);
501
503
  this._afterrunTimer = null;
502
504
  }
505
+
503
506
  if (this._prerunTimer) {
504
- clearTimeout(this._prerunTimer);
507
+ this.adapter.clearTimeout(this._prerunTimer);
505
508
  this._prerunTimer = null;
506
509
  }
507
510
 
@@ -121,6 +121,11 @@ const infoHelper = {
121
121
  * Startet den täglichen Update-Intervall (Update 00:01 Uhr)
122
122
  */
123
123
  _startDailyTimer() {
124
+ if (this.dailyTimer) {
125
+ this.adapter.clearTimeout(this.dailyTimer);
126
+ this.dailyTimer = null;
127
+ }
128
+
124
129
  // nächsten Trigger für morgen 00:01 berechnen
125
130
  const now = new Date();
126
131
  const next = new Date(now);
@@ -130,17 +135,13 @@ const infoHelper = {
130
135
 
131
136
  const delay = next.getTime() - now.getTime();
132
137
 
133
- // einmaliger Timer bis 00:01
134
- this.dailyTimer = setTimeout(() => {
138
+ this.dailyTimer = this.adapter.setTimeout(() => {
139
+ this.dailyTimer = null;
140
+
135
141
  this._updateDeveloperGreeting();
136
142
 
137
- // danach täglich um 24h
138
- this.dailyTimer = setInterval(
139
- () => {
140
- this._updateDeveloperGreeting();
141
- },
142
- 24 * 60 * 60 * 1000,
143
- );
143
+ // Danach neu planen, damit kein dauerhaftes setInterval nötig ist.
144
+ this._startDailyTimer();
144
145
  }, delay);
145
146
  },
146
147
 
@@ -149,8 +150,7 @@ const infoHelper = {
149
150
  */
150
151
  cleanup() {
151
152
  if (this.dailyTimer) {
152
- clearTimeout(this.dailyTimer);
153
- clearInterval(this.dailyTimer);
153
+ this.adapter.clearTimeout(this.dailyTimer);
154
154
  this.dailyTimer = null;
155
155
  }
156
156
  },