iobroker.poolcontrol 0.3.0 → 0.4.0-alpha

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.
@@ -36,7 +36,10 @@ async function createRuntimeStates(adapter) {
36
36
  },
37
37
  native: {},
38
38
  });
39
- await adapter.setStateAsync('runtime.total', { val: '0h 0m 0s', ack: true });
39
+ const existingTotal = await adapter.getStateAsync('runtime.total');
40
+ if (!existingTotal || existingTotal.val === null || existingTotal.val === undefined) {
41
+ await adapter.setStateAsync('runtime.total', { val: '0h 0m 0s', ack: true }); // FIX: Nur setzen, wenn leer
42
+ }
40
43
 
41
44
  // Tageslaufzeit (formatiert)
42
45
  await adapter.setObjectNotExistsAsync('runtime.today', {
@@ -51,7 +54,10 @@ async function createRuntimeStates(adapter) {
51
54
  },
52
55
  native: {},
53
56
  });
54
- await adapter.setStateAsync('runtime.today', { val: '0h 0m 0s', ack: true });
57
+ const existingToday = await adapter.getStateAsync('runtime.today');
58
+ if (!existingToday || existingToday.val === null || existingToday.val === undefined) {
59
+ await adapter.setStateAsync('runtime.today', { val: '0h 0m 0s', ack: true }); // FIX
60
+ }
55
61
 
56
62
  // -------------------------------------------------------------------------
57
63
  // NEU: Pumpenstarts heute
@@ -67,7 +73,10 @@ async function createRuntimeStates(adapter) {
67
73
  },
68
74
  native: {},
69
75
  });
70
- await adapter.setStateAsync('runtime.start_count_today', { val: 0, ack: true });
76
+ const existingStartCount = await adapter.getStateAsync('runtime.start_count_today');
77
+ if (!existingStartCount || existingStartCount.val === null || existingStartCount.val === undefined) {
78
+ await adapter.setStateAsync('runtime.start_count_today', { val: 0, ack: true }); // FIX
79
+ }
71
80
 
72
81
  // NEU: Aktuelle Laufzeit (seit Einschalten)
73
82
  await adapter.setObjectNotExistsAsync('runtime.current_session', {
@@ -82,7 +91,10 @@ async function createRuntimeStates(adapter) {
82
91
  },
83
92
  native: {},
84
93
  });
85
- await adapter.setStateAsync('runtime.current_session', { val: '0h 0m 0s', ack: true });
94
+ const existingCurrent = await adapter.getStateAsync('runtime.current_session');
95
+ if (!existingCurrent || existingCurrent.val === null || existingCurrent.val === undefined) {
96
+ await adapter.setStateAsync('runtime.current_session', { val: '0h 0m 0s', ack: true }); // FIX
97
+ }
86
98
 
87
99
  // NEU: Gesamtlaufzeit der aktuellen Saison (formatiert)
88
100
  await adapter.setObjectNotExistsAsync('runtime.season_total', {
@@ -97,7 +109,10 @@ async function createRuntimeStates(adapter) {
97
109
  },
98
110
  native: {},
99
111
  });
100
- await adapter.setStateAsync('runtime.season_total', { val: '0h 0m 0s', ack: true });
112
+ const existingSeason = await adapter.getStateAsync('runtime.season_total');
113
+ if (!existingSeason || existingSeason.val === null || existingSeason.val === undefined) {
114
+ await adapter.setStateAsync('runtime.season_total', { val: '0h 0m 0s', ack: true }); // FIX
115
+ }
101
116
 
102
117
  // -------------------------------------------------------------------------
103
118
  // --- Kanal circulation ---
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * statisticsStates.js
5
+ * -------------------
6
+ * Erstellt alle States für die Tagesstatistik der Temperatursensoren.
7
+ * Struktur: analytics.statistics.temperature.today.*
8
+ *
9
+ * - Sechs Sensorbereiche (outside, ground, surface, flow, return, collector)
10
+ * - Je Sensor: Min/Max/Avg + Zeitstempel + JSON/HTML-Ausgabe
11
+ * - Zusätzlich: Gesamt-Ausgabe (summary_all_json / summary_all_html)
12
+ *
13
+ * Alle States sind persistiert, schreibgeschützt und überinstallationssicher.
14
+ */
15
+
16
+ /**
17
+ * @param {ioBroker.Adapter} adapter - Instanz des ioBroker-Adapters
18
+ */
19
+ async function createStatisticsStates(adapter) {
20
+ adapter.log.debug('statisticsStates: Initialisierung der Tagesstatistik (Temperatur) gestartet.');
21
+
22
+ // Oberstruktur
23
+ await adapter.setObjectNotExistsAsync('analytics', {
24
+ type: 'channel',
25
+ common: { name: 'Analysen & Auswertungen (Statistik, Historie, Berichte)' },
26
+ native: {},
27
+ });
28
+
29
+ await adapter.setObjectNotExistsAsync('analytics.statistics', {
30
+ type: 'channel',
31
+ common: { name: 'Statistische Auswertungen' },
32
+ native: {},
33
+ });
34
+
35
+ await adapter.setObjectNotExistsAsync('analytics.statistics.temperature', {
36
+ type: 'channel',
37
+ common: { name: 'Temperaturstatistik' },
38
+ native: {},
39
+ });
40
+
41
+ await adapter.setObjectNotExistsAsync('analytics.statistics.temperature.today', {
42
+ type: 'channel',
43
+ common: { name: 'Tagesstatistik (Temperaturen)' },
44
+ native: {},
45
+ });
46
+
47
+ // Definierte Sensoren
48
+ const sensors = [
49
+ { id: 'outside', name: 'Außentemperatur' },
50
+ { id: 'ground', name: 'Bodentemperatur' },
51
+ { id: 'surface', name: 'Pooloberfläche' },
52
+ { id: 'flow', name: 'Vorlauf' },
53
+ { id: 'return', name: 'Rücklauf' },
54
+ { id: 'collector', name: 'Kollektor (Solar)' },
55
+ ];
56
+
57
+ for (const sensor of sensors) {
58
+ const basePath = `analytics.statistics.temperature.today.${sensor.id}`;
59
+
60
+ await adapter.setObjectNotExistsAsync(basePath, {
61
+ type: 'channel',
62
+ common: { name: `${sensor.name} (Tagesstatistik)` },
63
+ native: {},
64
+ });
65
+
66
+ const stateDefs = [
67
+ { id: 'temp_min', name: 'Niedrigste Temperatur', type: 'number', role: 'value.temperature', unit: '°C' },
68
+ { id: 'temp_max', name: 'Höchste Temperatur', type: 'number', role: 'value.temperature', unit: '°C' },
69
+ { id: 'temp_min_time', name: 'Zeitpunkt Minimum', type: 'string', role: 'value.time' },
70
+ { id: 'temp_max_time', name: 'Zeitpunkt Maximum', type: 'string', role: 'value.time' },
71
+ { id: 'temp_avg', name: 'Durchschnittstemperatur', type: 'number', role: 'value.temperature', unit: '°C' },
72
+ { id: 'data_points_count', name: 'Anzahl Messwerte', type: 'number', role: 'value' },
73
+ { id: 'last_update', name: 'Letzte Aktualisierung', type: 'string', role: 'value.time' },
74
+ { id: 'summary_json', name: 'Tageszusammenfassung (JSON)', type: 'string', role: 'json' },
75
+ { id: 'summary_html', name: 'Tageszusammenfassung (HTML)', type: 'string', role: 'html' },
76
+ ];
77
+
78
+ for (const def of stateDefs) {
79
+ await adapter.setObjectNotExistsAsync(`${basePath}.${def.id}`, {
80
+ type: 'state',
81
+ common: {
82
+ name: def.name,
83
+ type: def.type,
84
+ role: def.role,
85
+ unit: def.unit || undefined,
86
+ read: true,
87
+ write: false,
88
+ def: def.type === 'number' ? null : '',
89
+ persist: true,
90
+ },
91
+ native: {},
92
+ });
93
+ }
94
+ }
95
+
96
+ // Gesamt-Ausgabe (Outputs)
97
+ const outputBase = 'analytics.statistics.temperature.today.outputs';
98
+ await adapter.setObjectNotExistsAsync(outputBase, {
99
+ type: 'channel',
100
+ common: { name: 'Gesamtausgaben (alle Sensoren)' },
101
+ native: {},
102
+ });
103
+
104
+ const outputs = [
105
+ {
106
+ id: 'summary_all_json',
107
+ name: 'Gesamtzusammenfassung aller Sensoren (JSON)',
108
+ role: 'json',
109
+ },
110
+ {
111
+ id: 'summary_all_html',
112
+ name: 'Gesamtzusammenfassung aller Sensoren (HTML)',
113
+ role: 'html',
114
+ },
115
+ ];
116
+
117
+ for (const out of outputs) {
118
+ await adapter.setObjectNotExistsAsync(`${outputBase}.${out.id}`, {
119
+ type: 'state',
120
+ common: {
121
+ name: out.name,
122
+ type: 'string',
123
+ role: out.role,
124
+ read: true,
125
+ write: false,
126
+ def: '',
127
+ persist: true,
128
+ },
129
+ native: {},
130
+ });
131
+ }
132
+
133
+ adapter.log.debug('statisticsStates: Tagesstatistik (Temperatur) erfolgreich angelegt.');
134
+ }
135
+
136
+ module.exports = {
137
+ createStatisticsStates,
138
+ };
package/main.js CHANGED
@@ -8,6 +8,7 @@ const utils = require('@iobroker/adapter-core');
8
8
  const temperatureHelper = require('./lib/helpers/temperatureHelper');
9
9
  const timeHelper = require('./lib/helpers/timeHelper');
10
10
  const runtimeHelper = require('./lib/helpers/runtimeHelper');
11
+ const statisticsHelper = require('./lib/helpers/statisticsHelper');
11
12
  const pumpHelper = require('./lib/helpers/pumpHelper');
12
13
  const pumpHelper2 = require('./lib/helpers/pumpHelper2');
13
14
  const pumpHelper3 = require('./lib/helpers/pumpHelper3');
@@ -29,6 +30,7 @@ const { createSolarStates } = require('./lib/stateDefinitions/solarStates');
29
30
  const { createGeneralStates } = require('./lib/stateDefinitions/generalStates');
30
31
  const { createTimeStates } = require('./lib/stateDefinitions/timeStates');
31
32
  const { createRuntimeStates } = require('./lib/stateDefinitions/runtimeStates');
33
+ const { createStatisticsStates } = require('./lib/stateDefinitions/statisticsStates');
32
34
  const { createSpeechStates } = require('./lib/stateDefinitions/speechStates');
33
35
  const { createConsumptionStates } = require('./lib/stateDefinitions/consumptionStates');
34
36
  const { createStatusStates } = require('./lib/stateDefinitions/statusStates');
@@ -69,6 +71,9 @@ class Poolcontrol extends utils.Adapter {
69
71
  // --- Laufzeitsteuerung ---
70
72
  await createRuntimeStates(this);
71
73
 
74
+ // Statistik-States (Temperaturen)
75
+ await createStatisticsStates(this);
76
+
72
77
  // --- Sprachausgaben ---
73
78
  await createSpeechStates(this);
74
79
 
@@ -87,7 +92,7 @@ class Poolcontrol extends utils.Adapter {
87
92
  // --- Control States ---
88
93
  await createControlStates(this);
89
94
 
90
- // --- DebugLog Staets ---
95
+ // --- DebugLog States ---
91
96
  await createDebugLogStates(this);
92
97
 
93
98
  // --- Migration Helper zuletzt starten ---
@@ -97,6 +102,7 @@ class Poolcontrol extends utils.Adapter {
97
102
  temperatureHelper.init(this);
98
103
  timeHelper.init(this);
99
104
  runtimeHelper.init(this);
105
+ statisticsHelper.init(this);
100
106
  pumpHelper.init(this);
101
107
  pumpHelper2.init(this);
102
108
  pumpHelper3.init(this);
@@ -122,6 +128,9 @@ class Poolcontrol extends utils.Adapter {
122
128
  if (runtimeHelper.cleanup) {
123
129
  runtimeHelper.cleanup();
124
130
  }
131
+ if (statisticsHelper.cleanup) {
132
+ statisticsHelper.cleanup();
133
+ }
125
134
  if (pumpHelper.cleanup) {
126
135
  pumpHelper.cleanup();
127
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.poolcontrol",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-alpha",
4
4
  "description": "Steuerung & Automatisierung für den Pool (Pumpe, Heizung, Ventile, Sensoren).",
5
5
  "author": "DasBo1975 <dasbo1975@outlook.de>",
6
6
  "homepage": "https://github.com/DasBo1975/ioBroker.poolcontrol",
@@ -30,7 +30,8 @@
30
30
  "@iobroker/testing": "^5.1.1",
31
31
  "eslint": "^9.36.0",
32
32
  "prettier": "^3.6.2",
33
- "proxyquire": "^2.1.3"
33
+ "proxyquire": "^2.1.3",
34
+ "release-it": "^19.0.5"
34
35
  },
35
36
  "main": "main.js",
36
37
  "files": [
@@ -48,7 +49,8 @@
48
49
  "test:integration": "mocha test/integration.cjs --exit",
49
50
  "test": "npm run test:js && npm run test:package",
50
51
  "lint": "eslint .",
51
- "translate": "translate-adapter"
52
+ "translate": "translate-adapter",
53
+ "release": "release-it"
52
54
  },
53
55
  "bugs": {
54
56
  "url": "https://github.com/DasBo1975/ioBroker.poolcontrol/issues"