iobroker.luxtronik2-controller 0.5.1 → 0.5.3
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/README.md +12 -10
- package/build/actionHandlers.js +11 -9
- package/build/actionHandlers.js.map +2 -2
- package/build/codes.js +121 -121
- package/build/codes.js.map +2 -2
- package/build/main.js +195 -61
- package/build/main.js.map +2 -2
- package/build/notificationManager.js +23 -24
- package/build/notificationManager.js.map +2 -2
- package/build/objectManager.js +44 -37
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +11 -11
- package/build/rawFunctions.js.map +2 -2
- package/build/stateMapping.js +1284 -1286
- package/build/stateMapping.js.map +2 -2
- package/build/virtualStates.js +74 -70
- package/build/virtualStates.js.map +2 -2
- package/build/zipManager.js +39 -16
- package/build/zipManager.js.map +2 -2
- package/io-package.json +30 -30
- package/package.json +1 -1
package/build/virtualStates.js
CHANGED
|
@@ -44,25 +44,25 @@ async function calculateSum(adapter, sourceId1, sourceId2, targetId, logName) {
|
|
|
44
44
|
await adapter.setStateChangedAsync(targetId, val1 + val2, true);
|
|
45
45
|
} catch (err) {
|
|
46
46
|
const msg = err instanceof Error ? err.message : String(err);
|
|
47
|
-
(0, import_logger.writeLog)(`
|
|
47
|
+
(0, import_logger.writeLog)(`Error calculating ${logName}: ${msg}`, "error");
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async function calculateTotalThermalEnergy(adapter) {
|
|
51
51
|
await calculateSum(
|
|
52
52
|
adapter,
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
53
|
+
(0, import_stateMapping.getDpPath)("thermalenergy_heating"),
|
|
54
|
+
(0, import_stateMapping.getDpPath)("thermalenergy_warmwater"),
|
|
55
|
+
(0, import_stateMapping.getDpPath)("thermalenergy_total"),
|
|
56
|
+
"Total Thermal Energy"
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
async function calculateTotalEnergy(adapter) {
|
|
60
60
|
await calculateSum(
|
|
61
61
|
adapter,
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
62
|
+
(0, import_stateMapping.getDpPath)("energy_heating"),
|
|
63
|
+
(0, import_stateMapping.getDpPath)("energy_warmwater"),
|
|
64
|
+
(0, import_stateMapping.getDpPath)("energy_total"),
|
|
65
|
+
"Total Energy"
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
async function updateHistory(adapter, rawValues, timeStartIndex, codeStartIndex, targetStateId, fallbackPrefix, codeMap) {
|
|
@@ -73,7 +73,7 @@ async function updateHistory(adapter, rawValues, timeStartIndex, codeStartIndex,
|
|
|
73
73
|
const timestamp = rawValues[timeStartIndex + i];
|
|
74
74
|
if (timestamp !== void 0 && timestamp > 0) {
|
|
75
75
|
const date = new Date(timestamp * 1e3);
|
|
76
|
-
const formattedDate = date.
|
|
76
|
+
const formattedDate = date.toISOString().replace("T", " ").substring(0, 19);
|
|
77
77
|
let beschreibung = `${fallbackPrefix} (${code})`;
|
|
78
78
|
if (codeMap[code] !== void 0) {
|
|
79
79
|
beschreibung = codeMap[code];
|
|
@@ -83,7 +83,6 @@ async function updateHistory(adapter, rawValues, timeStartIndex, codeStartIndex,
|
|
|
83
83
|
beschreibung,
|
|
84
84
|
datum: formattedDate,
|
|
85
85
|
timestamp
|
|
86
|
-
// Behoben: Timestamp ist wieder enthalten!
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -98,34 +97,24 @@ async function updateHistory(adapter, rawValues, timeStartIndex, codeStartIndex,
|
|
|
98
97
|
const jsonStr = JSON.stringify(cleanList);
|
|
99
98
|
const result = await adapter.setStateChangedAsync(targetStateId, { val: jsonStr, ack: true });
|
|
100
99
|
if (result && result.numChanges > 0) {
|
|
101
|
-
(0, import_logger.writeLog)(`
|
|
100
|
+
(0, import_logger.writeLog)(`History for ${targetStateId} updated from raw data.`, "info");
|
|
102
101
|
}
|
|
103
102
|
} catch (err) {
|
|
104
103
|
const msg = err instanceof Error ? err.message : String(err);
|
|
105
|
-
(0, import_logger.writeLog)(`
|
|
104
|
+
(0, import_logger.writeLog)(`Error updating history: ${msg}`, "error");
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
async function updateErrorHistory(adapter, rawValues) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
rawValues,
|
|
112
|
-
|
|
113
|
-
100,
|
|
114
|
-
"Informationen.06_Fehlerspeicher.Fehlerspeicher",
|
|
115
|
-
"Unbekannter Fehler",
|
|
116
|
-
import_codes.ERROR_CODES
|
|
117
|
-
);
|
|
108
|
+
const dpPath = (0, import_stateMapping.getDpPath)("Fehlerspeicher");
|
|
109
|
+
if (dpPath) {
|
|
110
|
+
await updateHistory(adapter, rawValues, 95, 100, dpPath, "Unknown error", import_codes.ERROR_CODES);
|
|
111
|
+
}
|
|
118
112
|
}
|
|
119
113
|
async function updateOutageHistory(adapter, rawValues) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
rawValues,
|
|
123
|
-
|
|
124
|
-
106,
|
|
125
|
-
"Informationen.07_Abschaltungen.Abschaltungen",
|
|
126
|
-
"Unbekannter Abschaltgrund",
|
|
127
|
-
import_codes.OUTAGE_CODES
|
|
128
|
-
);
|
|
114
|
+
const dpPath = (0, import_stateMapping.getDpPath)("Abschaltungen");
|
|
115
|
+
if (dpPath) {
|
|
116
|
+
await updateHistory(adapter, rawValues, 111, 106, dpPath, "Unknown outage cause", import_codes.OUTAGE_CODES);
|
|
117
|
+
}
|
|
129
118
|
}
|
|
130
119
|
async function calculateTemperatureSpread(adapter) {
|
|
131
120
|
try {
|
|
@@ -147,7 +136,7 @@ async function calculateTemperatureSpread(adapter) {
|
|
|
147
136
|
}
|
|
148
137
|
} catch (err) {
|
|
149
138
|
const msg = err instanceof Error ? err.message : String(err);
|
|
150
|
-
(0, import_logger.writeLog)(`
|
|
139
|
+
(0, import_logger.writeLog)(`Error calculating temperature spread: ${msg}`, "error");
|
|
151
140
|
}
|
|
152
141
|
}
|
|
153
142
|
async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
@@ -160,13 +149,13 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
160
149
|
const BetriebsartHeizung = rawParams[(0, import_stateMapping.getLuxIdByKey)("heating_operation_mode")] || 0;
|
|
161
150
|
const Au\u00DFentemperatur = (rawValues[(0, import_stateMapping.getLuxIdByKey)("temperature_outside")] || 0) / 10;
|
|
162
151
|
const Mitteltemperatur = (rawValues[(0, import_stateMapping.getLuxIdByKey)("Mitteltemperatur")] || 0) / 10;
|
|
163
|
-
let heatingStr = "
|
|
152
|
+
let heatingStr = "Unknown";
|
|
164
153
|
if (BetriebsartHeizung === 0 && Mitteltemperatur >= Heizgrenze && (R\u00FCcklaufSoll === R\u00FCcklaufSollMin || R\u00FCcklaufSoll === 20 && Au\u00DFentemperatur < 10)) {
|
|
165
|
-
heatingStr = Au\u00DFentemperatur >= 10 ? `
|
|
154
|
+
heatingStr = Au\u00DFentemperatur >= 10 ? `Heating limit (Target ${R\u00FCcklaufSollMin} \xB0C)` : "Frost protection (Target 20 \xB0C)";
|
|
166
155
|
} else {
|
|
167
|
-
heatingStr = import_codes.STATE_HEATING[BetriebsartHeizung] || `
|
|
156
|
+
heatingStr = import_codes.STATE_HEATING[BetriebsartHeizung] || `Unknown (${BetriebsartHeizung})`;
|
|
168
157
|
if (BetriebsartHeizung === 0) {
|
|
169
|
-
heatingStr = AbsenkungMax <= Au\u00DFentemperatur ? `${heatingStr} ${Absenkung} \xB0C` : `Normal
|
|
158
|
+
heatingStr = AbsenkungMax <= Au\u00DFentemperatur ? `${heatingStr} ${Absenkung} \xB0C` : `Normal as < ${AbsenkungMax} \xB0C`;
|
|
170
159
|
}
|
|
171
160
|
}
|
|
172
161
|
const dpHeating = (0, import_stateMapping.getDpPath)("opStateHeatingString");
|
|
@@ -177,35 +166,61 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
177
166
|
const codeZ2 = rawValues[118];
|
|
178
167
|
const codeZ3 = rawValues[119];
|
|
179
168
|
const zeitSec = rawValues[120];
|
|
169
|
+
let stateStr = "Unknown";
|
|
170
|
+
let extStateStr = "Unknown";
|
|
180
171
|
const hotWaterBoilerValve = rawValues[(0, import_stateMapping.getLuxIdByKey)("hotWaterBoilerValve")] || 0;
|
|
181
172
|
const opStateHotWaterOriginal = rawValues[124];
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
173
|
+
const isModernFirmware = (codeZ1 === void 0 || codeZ1 === 0) && (codeZ3 === void 0 || codeZ3 === 0);
|
|
174
|
+
if (!isModernFirmware) {
|
|
175
|
+
const h = Math.floor((zeitSec || 0) / 3600);
|
|
176
|
+
const m = Math.floor((zeitSec || 0) % 3600 / 60);
|
|
177
|
+
const s = (zeitSec || 0) % 60;
|
|
178
|
+
const zeitString = `${h < 10 ? "0" : ""}${h}:${m < 10 ? "0" : ""}${m}:${s < 10 ? "0" : ""}${s}`;
|
|
179
|
+
stateStr = import_codes.STATE_LINE_3[codeZ3] || "Unknown";
|
|
180
|
+
if (import_codes.STATE_LINE_1[codeZ1]) {
|
|
181
|
+
const textZ2 = import_codes.STATE_LINE_2[codeZ2] || "";
|
|
182
|
+
extStateStr = `${import_codes.STATE_LINE_1[codeZ1]} ${textZ2} ${zeitString}`.trim();
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
const bzMap = {
|
|
186
|
+
0: "Heating",
|
|
187
|
+
1: "Hot water",
|
|
188
|
+
2: "Swimming pool",
|
|
189
|
+
3: "Utility block",
|
|
190
|
+
4: "Defrosting",
|
|
191
|
+
5: "Idle",
|
|
192
|
+
6: "Ext. heat source",
|
|
193
|
+
7: "Cooling"
|
|
194
|
+
};
|
|
195
|
+
const currentStateCode = rawValues[(0, import_stateMapping.getLuxIdByKey)("WP_BZ_akt")] || 5;
|
|
196
|
+
const baseState = bzMap[currentStateCode] || `Status ${currentStateCode}`;
|
|
197
|
+
stateStr = baseState;
|
|
198
|
+
extStateStr = baseState;
|
|
199
|
+
if (zeitSec !== void 0 && zeitSec > 0) {
|
|
200
|
+
const h = Math.floor(zeitSec / 3600);
|
|
201
|
+
const m = Math.floor(zeitSec % 3600 / 60);
|
|
202
|
+
const s = zeitSec % 60;
|
|
203
|
+
const zeitString = `${h < 10 ? "0" : ""}${h}:${m < 10 ? "0" : ""}${m}:${s < 10 ? "0" : ""}${s}`;
|
|
204
|
+
extStateStr += ` (${zeitString})`;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
187
207
|
const dpExtState = (0, import_stateMapping.getDpPath)("heatpump_extendet_state_string");
|
|
188
208
|
if (dpExtState) {
|
|
189
209
|
await adapter.setStateChangedAsync(dpExtState, stateStr, true);
|
|
190
210
|
}
|
|
191
|
-
let extStateStr = "Unbekannt";
|
|
192
|
-
if (import_codes.STATE_ZEILE_1[codeZ1]) {
|
|
193
|
-
const textZ2 = import_codes.STATE_ZEILE_2[codeZ2] || "";
|
|
194
|
-
extStateStr = `${import_codes.STATE_ZEILE_1[codeZ1]} ${textZ2} ${zeitString}`.trim();
|
|
195
|
-
}
|
|
196
211
|
const dpState = (0, import_stateMapping.getDpPath)("heatpump_state_string");
|
|
197
212
|
if (dpState) {
|
|
198
213
|
await adapter.setStateChangedAsync(dpState, extStateStr, true);
|
|
199
214
|
}
|
|
200
|
-
let hotWaterStr = "
|
|
215
|
+
let hotWaterStr = "Unknown";
|
|
201
216
|
if (opStateHotWaterOriginal === 0) {
|
|
202
|
-
hotWaterStr = "
|
|
217
|
+
hotWaterStr = "Lock time";
|
|
203
218
|
} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 1) {
|
|
204
|
-
hotWaterStr = "
|
|
219
|
+
hotWaterStr = "Heating up";
|
|
205
220
|
} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 0) {
|
|
206
221
|
hotWaterStr = "Temp. OK";
|
|
207
222
|
} else if (opStateHotWaterOriginal === 3) {
|
|
208
|
-
hotWaterStr = "
|
|
223
|
+
hotWaterStr = "Off";
|
|
209
224
|
} else {
|
|
210
225
|
hotWaterStr = `Unknown [${opStateHotWaterOriginal}/${hotWaterBoilerValve}]`;
|
|
211
226
|
}
|
|
@@ -215,7 +230,7 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
215
230
|
}
|
|
216
231
|
} catch (err) {
|
|
217
232
|
const msg = err instanceof Error ? err.message : String(err);
|
|
218
|
-
(0, import_logger.writeLog)(`
|
|
233
|
+
(0, import_logger.writeLog)(`Error updating status strings: ${msg}`, "error");
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
236
|
async function updateTimerTables(adapter) {
|
|
@@ -263,8 +278,7 @@ async function updateTimerTables(adapter) {
|
|
|
263
278
|
}
|
|
264
279
|
};
|
|
265
280
|
const configs = [
|
|
266
|
-
|
|
267
|
-
{ target: "heatingOperationTimerTableWeek", prefix: "HZ_MoSo_", end: "End", slots: 3 },
|
|
281
|
+
{ target: "heatingOperationTimerTableWeek", prefix: "HZ_MoSo_", end: "End1", slots: 3 },
|
|
268
282
|
{ target: "heatingOperationTimerTable52MonFri", prefix: "HZ_MoFr_", end: "Ende", slots: 3 },
|
|
269
283
|
{ target: "heatingOperationTimerTable52SatSun", prefix: "HZ_SaSo_", end: "Ende", slots: 3 },
|
|
270
284
|
{ target: "heatingOperationTimerTableDayMonday", prefix: "HZ_Montag_", end: "Ende", slots: 3 },
|
|
@@ -274,7 +288,6 @@ async function updateTimerTables(adapter) {
|
|
|
274
288
|
{ target: "heatingOperationTimerTableDayFriday", prefix: "HZ_Freitag_", end: "Ende", slots: 3 },
|
|
275
289
|
{ target: "heatingOperationTimerTableDaySaturday", prefix: "HZ_Samstag_", end: "Ende", slots: 3 },
|
|
276
290
|
{ target: "heatingOperationTimerTableDaySunday", prefix: "HZ_Sonntag_", end: "Ende", slots: 3 },
|
|
277
|
-
// === WARMWASSER (5 Slots) ===
|
|
278
291
|
{ target: "hotWaterTableWeek", prefix: "WW_MoSo_", end: "End", slots: 5 },
|
|
279
292
|
{ target: "hotWaterTable52MonFri", prefix: "WW_MoFr_", end: "Ende", slots: 5 },
|
|
280
293
|
{ target: "hotWaterTable52SatSun", prefix: "WW_SaSo_", end: "Ende", slots: 5 },
|
|
@@ -285,7 +298,6 @@ async function updateTimerTables(adapter) {
|
|
|
285
298
|
{ target: "hotWaterTableDayFriday", prefix: "WW_Freitag_", end: "Ende", slots: 5 },
|
|
286
299
|
{ target: "hotWaterTableDaySaturday", prefix: "WW_Samstag_", end: "Ende", slots: 5 },
|
|
287
300
|
{ target: "hotWaterTableDaySunday", prefix: "WW_Sonntag_", end: "Ende", slots: 5 },
|
|
288
|
-
// === ZIRKULATION (5 Slots) ===
|
|
289
301
|
{ target: "hotWaterCircPumpTimerTableWeek", prefix: "Zirkulation_MoSo_", end: "End", slots: 5 },
|
|
290
302
|
{ target: "hotWaterCircPumpTimerTable52MonFri", prefix: "Zirkulation_MoFr_", end: "Ende", slots: 5 },
|
|
291
303
|
{ target: "hotWaterCircPumpTimerTable52SatSun", prefix: "Zirkulation_SaSo_", end: "Ende", slots: 5 },
|
|
@@ -310,7 +322,7 @@ async function updateTimerTables(adapter) {
|
|
|
310
322
|
await Promise.all(configs.map((cfg) => processTable(cfg.target, cfg.prefix, cfg.end, cfg.slots)));
|
|
311
323
|
} catch (err) {
|
|
312
324
|
const msg = err instanceof Error ? err.message : String(err);
|
|
313
|
-
(0, import_logger.writeLog)(`
|
|
325
|
+
(0, import_logger.writeLog)(`Error generating JSON timer tables: ${msg}`, "error");
|
|
314
326
|
}
|
|
315
327
|
}
|
|
316
328
|
async function updateCustomStates(adapter, rawValues, rawParams) {
|
|
@@ -337,28 +349,20 @@ async function updateCustomStates(adapter, rawValues, rawParams) {
|
|
|
337
349
|
} else if (custom.type === "datetime") {
|
|
338
350
|
const ts = Number(rawVal);
|
|
339
351
|
if (!isNaN(ts) && ts > 0) {
|
|
340
|
-
finalVal = new Date(ts * 1e3).
|
|
341
|
-
day: "2-digit",
|
|
342
|
-
month: "2-digit",
|
|
343
|
-
year: "numeric",
|
|
344
|
-
hour: "2-digit",
|
|
345
|
-
minute: "2-digit",
|
|
346
|
-
second: "2-digit",
|
|
347
|
-
hour12: false
|
|
348
|
-
});
|
|
352
|
+
finalVal = new Date(ts * 1e3).toISOString().replace("T", " ").substring(0, 19);
|
|
349
353
|
} else {
|
|
350
|
-
finalVal = "
|
|
354
|
+
finalVal = "Invalid";
|
|
351
355
|
}
|
|
352
356
|
} else {
|
|
353
357
|
finalVal = String(rawVal);
|
|
354
358
|
}
|
|
355
359
|
const cleanId = (0, import_objectManager.sanitizeName)(custom.name);
|
|
356
|
-
const stateId = `${adapter.namespace}.
|
|
360
|
+
const stateId = `${adapter.namespace}.Custom.${cleanId}`;
|
|
357
361
|
await adapter.setForeignStateChangedAsync(stateId, finalVal, true);
|
|
358
362
|
}
|
|
359
363
|
} catch (err) {
|
|
360
364
|
const msg = err instanceof Error ? err.message : String(err);
|
|
361
|
-
(0, import_logger.writeLog)(`
|
|
365
|
+
(0, import_logger.writeLog)(`Error updating custom values: ${msg}`, "error");
|
|
362
366
|
}
|
|
363
367
|
}
|
|
364
368
|
async function setChangedSystemState(adapter, key, value) {
|
|
@@ -385,12 +389,12 @@ async function updateSystemInfos(adapter, rawValues) {
|
|
|
385
389
|
await setChangedSystemState(adapter, "heatpump_type", hpTypeString);
|
|
386
390
|
} catch (err) {
|
|
387
391
|
const msg = err instanceof Error ? err.message : String(err);
|
|
388
|
-
(0, import_logger.writeLog)(`
|
|
392
|
+
(0, import_logger.writeLog)(`Error updating system information: ${msg}`, "error");
|
|
389
393
|
}
|
|
390
394
|
}
|
|
391
395
|
function createFirmwareString(buf) {
|
|
392
396
|
if (!buf || !Array.isArray(buf)) {
|
|
393
|
-
return "
|
|
397
|
+
return "Unknown";
|
|
394
398
|
}
|
|
395
399
|
return buf.filter((v) => v !== 0).map((v) => String.fromCharCode(v)).join("").trim();
|
|
396
400
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/virtualStates.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport {\n\tERROR_CODES,\n\tHP_TYPES,\n\tOUTAGE_CODES,\n\tSTATE_HEATING,\n\tSTATE_ZEILE_1,\n\tSTATE_ZEILE_2,\n\tSTATE_ZEILE_3,\n} from './codes';\nimport { writeLog } from './logger';\nimport { sanitizeName } from './objectManager';\nimport { getDpPath, getLuxIdByKey } from './stateMapping';\n\n// ==========================================\n// BERECHNUNGEN (DRY-Prinzip)\n// ==========================================\n\n/**\n * Universelle Hilfsfunktion, um zwei Werte aus dem ioBroker zu addieren.\n *\n * @param adapter - ioBroker Adapter-Instanz\n * @param sourceId1 - Pfad des ersten Quell-States\n * @param sourceId2 - Pfad des zweiten Quell-States\n * @param targetId - Pfad des Ziel-States, in den das Ergebnis geschrieben wird\n * @param logName - Name f\u00FCr Log-Eintr\u00E4ge\n */\nasync function calculateSum(\n\tadapter: AdapterInstance,\n\tsourceId1: string,\n\tsourceId2: string,\n\ttargetId: string,\n\tlogName: string,\n): Promise<void> {\n\ttry {\n\t\tconst [state1, state2] = await Promise.all([\n\t\t\tadapter.getStateAsync(sourceId1),\n\t\t\tadapter.getStateAsync(sourceId2),\n\t\t]);\n\n\t\tconst val1 = state1 && typeof state1.val === 'number' ? state1.val : 0;\n\t\tconst val2 = state2 && typeof state2.val === 'number' ? state2.val : 0;\n\n\t\tawait adapter.setStateChangedAsync(targetId, val1 + val2, true);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler bei der Berechnung der ${logName}: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Berechnet die gesamte W\u00E4rmemenge (Heizung + Warmwasser) und schreibt sie in den Ziel-State.\n *\n * @param adapter - ioBroker Adapter-Instanz\n * @returns void\n */\nexport async function calculateTotalThermalEnergy(adapter: AdapterInstance): Promise<void> {\n\tawait calculateSum(\n\t\tadapter,\n\t\t'Informationen.09_W\u00E4rmemenge.thermalenergy_heating',\n\t\t'Informationen.09_W\u00E4rmemenge.thermalenergy_warmwater',\n\t\t'Informationen.09_W\u00E4rmemenge.thermalenergy_total',\n\t\t'Gesamt-W\u00E4rmemenge',\n\t);\n}\n\n/**\n * Berechnet die gesamte Energie (Heizung + Warmwasser) und schreibt sie in den Ziel-State.\n *\n * @param adapter - ioBroker Adapter-Instanz\n * @returns void\n */\nexport async function calculateTotalEnergy(adapter: AdapterInstance): Promise<void> {\n\tawait calculateSum(\n\t\tadapter,\n\t\t'Informationen.10_Energie.energy_heating',\n\t\t'Informationen.10_Energie.energy_warmwater',\n\t\t'Informationen.10_Energie.energy_total',\n\t\t'Gesamt-Energie',\n\t);\n}\n\n// ==========================================\n// HISTORIEN & LOGS (DRY-Prinzip)\n// ==========================================\n\ninterface HistoryEntry {\n\tcode: number;\n\tbeschreibung: string;\n\tdatum: string;\n\ttimestamp: number;\n}\n\nasync function updateHistory(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\ttimeStartIndex: number,\n\tcodeStartIndex: number,\n\ttargetStateId: string,\n\tfallbackPrefix: string,\n\tcodeMap: Record<number, string>,\n): Promise<void> {\n\ttry {\n\t\tconst historyList: HistoryEntry[] = [];\n\n\t\tfor (let i = 0; i < 5; i++) {\n\t\t\tconst code = rawValues[codeStartIndex + i];\n\t\t\tconst timestamp = rawValues[timeStartIndex + i];\n\n\t\t\tif (timestamp !== undefined && timestamp > 0) {\n\t\t\t\tconst date = new Date(timestamp * 1000);\n\t\t\t\tconst formattedDate = date.toLocaleString('de-DE');\n\n\t\t\t\tlet beschreibung = `${fallbackPrefix} (${code})`;\n\t\t\t\tif (codeMap[code] !== undefined) {\n\t\t\t\t\tbeschreibung = codeMap[code];\n\t\t\t\t}\n\n\t\t\t\thistoryList.push({\n\t\t\t\t\tcode: code,\n\t\t\t\t\tbeschreibung: beschreibung,\n\t\t\t\t\tdatum: formattedDate,\n\t\t\t\t\ttimestamp: timestamp, // Behoben: Timestamp ist wieder enthalten!\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Sortiert die Liste absteigend nach Timestamp\n\t\thistoryList.sort((a, b) => b.timestamp - a.timestamp);\n\n\t\tconst cleanList = historyList.map((entry, idx) => ({\n\t\t\tindex: idx + 1,\n\t\t\tcode: entry.code,\n\t\t\tbeschreibung: entry.beschreibung,\n\t\t\tdatum: entry.datum,\n\t\t\ttimestamp: entry.timestamp,\n\t\t}));\n\t\tconst jsonStr = JSON.stringify(cleanList);\n\n\t\t// Performance-Optimierung: Direkt \u00FCber setStateChangedAsync regeln!\n\t\tconst result = await adapter.setStateChangedAsync(targetStateId, { val: jsonStr, ack: true });\n\t\tif (result && (result as any).numChanges > 0) {\n\t\t\twriteLog(`Historie f\u00FCr ${targetStateId} aus Rohdaten aktualisiert.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler beim Aktualisieren der Historie: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Updates the error history with the latest error codes.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values from the device.\n */\nexport async function updateErrorHistory(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\tawait updateHistory(\n\t\tadapter,\n\t\trawValues,\n\t\t95,\n\t\t100,\n\t\t'Informationen.06_Fehlerspeicher.Fehlerspeicher',\n\t\t'Unbekannter Fehler',\n\t\tERROR_CODES,\n\t);\n}\n\n/**\n * Updates the outage history with the latest outage codes.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values from the device.\n */\nexport async function updateOutageHistory(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\tawait updateHistory(\n\t\tadapter,\n\t\trawValues,\n\t\t111,\n\t\t106,\n\t\t'Informationen.07_Abschaltungen.Abschaltungen',\n\t\t'Unbekannter Abschaltgrund',\n\t\tOUTAGE_CODES,\n\t);\n}\n\n/**\n * Calculates the temperature spread between supply and return temperatures.\n *\n * @param adapter - The adapter instance.\n */\nexport async function calculateTemperatureSpread(adapter: AdapterInstance): Promise<void> {\n\ttry {\n\t\tconst vorlaufPath = getDpPath('temperature_supply');\n\t\tconst ruecklaufPath = getDpPath('temperature_return');\n\n\t\tif (!vorlaufPath || !ruecklaufPath) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [vorlaufState, ruecklaufState] = await Promise.all([\n\t\t\tadapter.getStateAsync(vorlaufPath),\n\t\t\tadapter.getStateAsync(ruecklaufPath),\n\t\t]);\n\n\t\tif (vorlaufState && ruecklaufState && vorlaufState.val !== null && ruecklaufState.val !== null) {\n\t\t\tconst spreizung = parseFloat((Number(vorlaufState.val) - Number(ruecklaufState.val)).toFixed(2));\n\t\t\tconst targetSpreadPath = getDpPath('spreizung_vorlauf_ruecklauf');\n\t\t\tif (targetSpreadPath) {\n\t\t\t\tawait adapter.setStateChangedAsync(targetSpreadPath, spreizung, true);\n\t\t\t}\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler bei der Berechnung der Temperatur-Spreizung: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Updates the status strings based on raw sensor values and parameters.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values array from the Luxtronik device.\n * @param rawParams - The raw parameters array from the Luxtronik device.\n */\nexport async function updateStatusStrings(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\trawParams: number[],\n): Promise<void> {\n\ttry {\n\t\tconst Heizgrenze = (rawParams[getLuxIdByKey('thresholdHeatingLimit')] || 0) / 10;\n\t\tconst Absenkung = (rawParams[getLuxIdByKey('deltaHeatingReduction')] || 0) / 10;\n\t\tconst AbsenkungMax = (rawParams[getLuxIdByKey('thresholdTemperatureSetBack')] || 0) / 10;\n\t\tconst R\u00FCcklaufSollMin = (rawParams[getLuxIdByKey('returnTemperatureTargetMin')] || 15) / 10;\n\t\tconst R\u00FCcklaufSoll = (rawValues[getLuxIdByKey('temperature_target_return')] || 15) / 10;\n\t\tconst BetriebsartHeizung = rawParams[getLuxIdByKey('heating_operation_mode')] || 0;\n\t\tconst Au\u00DFentemperatur = (rawValues[getLuxIdByKey('temperature_outside')] || 0) / 10;\n\t\tconst Mitteltemperatur = (rawValues[getLuxIdByKey('Mitteltemperatur')] || 0) / 10;\n\n\t\tlet heatingStr = 'Unbekannt';\n\n\t\tif (\n\t\t\tBetriebsartHeizung === 0 &&\n\t\t\tMitteltemperatur >= Heizgrenze &&\n\t\t\t(R\u00FCcklaufSoll === R\u00FCcklaufSollMin || (R\u00FCcklaufSoll === 20 && Au\u00DFentemperatur < 10))\n\t\t) {\n\t\t\theatingStr = Au\u00DFentemperatur >= 10 ? `Heizgrenze (Soll ${R\u00FCcklaufSollMin} \u00B0C)` : 'Frostschutz (Soll 20 \u00B0C)';\n\t\t} else {\n\t\t\theatingStr = STATE_HEATING[BetriebsartHeizung] || `unbekannt (${BetriebsartHeizung})`;\n\t\t\tif (BetriebsartHeizung === 0) {\n\t\t\t\theatingStr =\n\t\t\t\t\tAbsenkungMax <= Au\u00DFentemperatur\n\t\t\t\t\t\t? `${heatingStr} ${Absenkung} \u00B0C`\n\t\t\t\t\t\t: `Normal da < ${AbsenkungMax} \u00B0C`;\n\t\t\t}\n\t\t}\n\n\t\tconst dpHeating = getDpPath('opStateHeatingString');\n\t\tif (dpHeating) {\n\t\t\tawait adapter.setStateChangedAsync(dpHeating, heatingStr, true);\n\t\t}\n\n\t\tconst codeZ1 = rawValues[117];\n\t\tconst codeZ2 = rawValues[118];\n\t\tconst codeZ3 = rawValues[119];\n\t\tconst zeitSec = rawValues[120];\n\n\t\tconst hotWaterBoilerValve = rawValues[getLuxIdByKey('hotWaterBoilerValve')] || 0;\n\t\tconst opStateHotWaterOriginal = rawValues[124];\n\n\t\tconst h = Math.floor((zeitSec || 0) / 3600);\n\t\tconst m = Math.floor(((zeitSec || 0) % 3600) / 60);\n\t\tconst s = (zeitSec || 0) % 60;\n\t\tconst zeitString = `${h < 10 ? '0' : ''}${h}:${m < 10 ? '0' : ''}${m}:${s < 10 ? '0' : ''}${s}`;\n\n\t\tconst stateStr = STATE_ZEILE_3[codeZ3] || 'Unbekannt';\n\t\tconst dpExtState = getDpPath('heatpump_extendet_state_string');\n\t\tif (dpExtState) {\n\t\t\tawait adapter.setStateChangedAsync(dpExtState, stateStr, true);\n\t\t}\n\n\t\tlet extStateStr = 'Unbekannt';\n\t\tif (STATE_ZEILE_1[codeZ1]) {\n\t\t\tconst textZ2 = STATE_ZEILE_2[codeZ2] || '';\n\t\t\textStateStr = `${STATE_ZEILE_1[codeZ1]} ${textZ2} ${zeitString}`.trim();\n\t\t}\n\t\tconst dpState = getDpPath('heatpump_state_string');\n\t\tif (dpState) {\n\t\t\tawait adapter.setStateChangedAsync(dpState, extStateStr, true);\n\t\t}\n\n\t\tlet hotWaterStr = 'Unbekannt';\n\t\tif (opStateHotWaterOriginal === 0) {\n\t\t\thotWaterStr = 'Sperrzeit';\n\t\t} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 1) {\n\t\t\thotWaterStr = 'Aufheizen';\n\t\t} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 0) {\n\t\t\thotWaterStr = 'Temp. OK';\n\t\t} else if (opStateHotWaterOriginal === 3) {\n\t\t\thotWaterStr = 'Aus';\n\t\t} else {\n\t\t\thotWaterStr = `Unknown [${opStateHotWaterOriginal}/${hotWaterBoilerValve}]`;\n\t\t}\n\t\tconst dpHotWater = getDpPath('opStateHotWaterString');\n\t\tif (dpHotWater) {\n\t\t\tawait adapter.setStateChangedAsync(dpHotWater, hotWaterStr, true);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler beim Aktualisieren der Status-Strings: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Liest die einzelnen Start/Ende Zeiten aus den Einstellungen und erzeugt ein formatiertes JSON-Array.\n *\n * @param adapter The adapter instance\n */\nexport async function updateTimerTables(adapter: AdapterInstance): Promise<void> {\n\ttry {\n\t\t// Cache f\u00FCr gelesene Zeit-Datenpunkte, um mehrfache DB-Zugriffe zu reduzieren\n\t\tconst timeCache = new Map<string, string>();\n\n\t\tconst getTime = async (key: string): Promise<string> => {\n\t\t\tif (timeCache.has(key)) {\n\t\t\t\treturn timeCache.get(key) || '00:00';\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst dpPath = getDpPath(key);\n\t\t\t\tif (!dpPath) {\n\t\t\t\t\treturn '00:00';\n\t\t\t\t}\n\n\t\t\t\tconst state = await adapter.getStateAsync(dpPath);\n\t\t\t\tif (state && typeof state.val === 'string') {\n\t\t\t\t\tconst match = state.val.match(/^(\\d{1,2}):(\\d{1,2})/);\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tconst formatted = `${match[1].padStart(2, '0')}:${match[2].padStart(2, '0')}`;\n\t\t\t\t\t\ttimeCache.set(key, formatted);\n\t\t\t\t\t\treturn formatted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '00:00';\n\t\t\t} catch {\n\t\t\t\treturn '00:00';\n\t\t\t}\n\t\t};\n\n\t\tconst processTable = async (\n\t\t\ttargetKey: string,\n\t\t\tprefix: string,\n\t\t\tendStr: string,\n\t\t\tslots: number,\n\t\t): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tconst table: { on: string; off: string }[] = [];\n\n\t\t\t\tfor (let i = 1; i <= slots; i++) {\n\t\t\t\t\tconst [onTime, offTime] = await Promise.all([\n\t\t\t\t\t\tgetTime(`${prefix}Start${i}`),\n\t\t\t\t\t\tgetTime(`${prefix}${endStr}${i}`),\n\t\t\t\t\t]);\n\t\t\t\t\ttable.push({ on: onTime, off: offTime });\n\t\t\t\t}\n\n\t\t\t\tconst targetPath = getDpPath(targetKey);\n\t\t\t\tif (targetPath) {\n\t\t\t\t\tconst jsonStr = JSON.stringify(table, null, 2);\n\t\t\t\t\tawait adapter.setStateChangedAsync(targetPath, jsonStr, true);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignorieren, falls Ziel-Datenpunkt nicht existiert\n\t\t\t}\n\t\t};\n\n\t\tconst configs = [\n\t\t\t// === HEIZEN (3 Slots) ===\n\t\t\t{ target: 'heatingOperationTimerTableWeek', prefix: 'HZ_MoSo_', end: 'End', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTable52MonFri', prefix: 'HZ_MoFr_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTable52SatSun', prefix: 'HZ_SaSo_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayMonday', prefix: 'HZ_Montag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayTuesday', prefix: 'HZ_Dienstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayWednesday', prefix: 'HZ_Mittwoch_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayThursday', prefix: 'HZ_Donnerstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayFriday', prefix: 'HZ_Freitag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDaySaturday', prefix: 'HZ_Samstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDaySunday', prefix: 'HZ_Sonntag_', end: 'Ende', slots: 3 },\n\n\t\t\t// === WARMWASSER (5 Slots) ===\n\t\t\t{ target: 'hotWaterTableWeek', prefix: 'WW_MoSo_', end: 'End', slots: 5 },\n\t\t\t{ target: 'hotWaterTable52MonFri', prefix: 'WW_MoFr_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTable52SatSun', prefix: 'WW_SaSo_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayMonday', prefix: 'WW_Montag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayTuesday', prefix: 'WW_Dienstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayWednesday', prefix: 'WW_Mittwoch_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayThursday', prefix: 'WW_Donnerstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayFriday', prefix: 'WW_Freitag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDaySaturday', prefix: 'WW_Samstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDaySunday', prefix: 'WW_Sonntag_', end: 'Ende', slots: 5 },\n\n\t\t\t// === ZIRKULATION (5 Slots) ===\n\t\t\t{ target: 'hotWaterCircPumpTimerTableWeek', prefix: 'Zirkulation_MoSo_', end: 'End', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTable52MonFri', prefix: 'Zirkulation_MoFr_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTable52SatSun', prefix: 'Zirkulation_SaSo_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayMonday', prefix: 'Zirkulation_Montag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayTuesday', prefix: 'Zirkulation_Dienstag_', end: 'Ende', slots: 5 },\n\t\t\t{\n\t\t\t\ttarget: 'hotWaterCircPumpTimerTableDayWednesday',\n\t\t\t\tprefix: 'Zirkulation_Mittwoch_',\n\t\t\t\tend: 'Ende',\n\t\t\t\tslots: 5,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttarget: 'hotWaterCircPumpTimerTableDayThursday',\n\t\t\t\tprefix: 'Zirkulation_Donnerstag_',\n\t\t\t\tend: 'Ende',\n\t\t\t\tslots: 5,\n\t\t\t},\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayFriday', prefix: 'Zirkulation_Freitag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDaySaturday', prefix: 'Zirkulation_Samstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDaySunday', prefix: 'Zirkulation_Sonntag_', end: 'Ende', slots: 5 },\n\t\t];\n\n\t\t// Performance-Optimierung: Alle Tabellen-Generierungen parallel via Promise.all abarbeiten!\n\t\tawait Promise.all(configs.map(cfg => processTable(cfg.target, cfg.prefix, cfg.end, cfg.slots)));\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler beim Erstellen der JSON-Timer-Tabellen: ${msg}`, 'error');\n\t}\n}\n\ninterface CustomStateConfig {\n\tactive: boolean;\n\tluxId?: number;\n\tname: string;\n\tsource: 'parameter' | 'value';\n\ttype: 'number' | 'boolean' | 'datetime' | 'string';\n\tfactor?: number | null;\n}\n\n/**\n * Aktualisiert benutzerdefinierte Zust\u00E4nde basierend auf konfigurierten Luxtronik-IDs.\n *\n * @param adapter - ioBroker Adapter-Instanz\n * @param rawValues - Rohwerte aus der Luxtronik-Ger\u00E4tedaten\u00FCbertragung\n * @param rawParams - Rohparameter aus der Luxtronik-Ger\u00E4tedaten\u00FCbertragung\n */\nexport async function updateCustomStates(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\trawParams: number[],\n): Promise<void> {\n\ttry {\n\t\tconst customStates = ((adapter.config as any).custom_states as CustomStateConfig[]) || [];\n\t\tfor (const custom of customStates) {\n\t\t\tif (!custom.active || custom.luxId === undefined || !custom.name) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawArray = custom.source === 'parameter' ? rawParams : rawValues;\n\t\t\tconst rawVal = rawArray[custom.luxId];\n\n\t\t\tif (rawVal === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet finalVal: string | number | boolean; // Typsicherheit erh\u00F6ht (kein any mehr)\n\n\t\t\tif (custom.type === 'number') {\n\t\t\t\tfinalVal = Number(rawVal);\n\t\t\t\tif (custom.factor !== undefined && custom.factor !== null) {\n\t\t\t\t\tfinalVal = finalVal * custom.factor;\n\t\t\t\t\tfinalVal = Math.round(finalVal * 10000) / 10000;\n\t\t\t\t}\n\t\t\t} else if (custom.type === 'boolean') {\n\t\t\t\tfinalVal = rawVal === 1 || String(rawVal).toLowerCase() === 'true';\n\t\t\t} else if (custom.type === 'datetime') {\n\t\t\t\tconst ts = Number(rawVal);\n\t\t\t\tif (!isNaN(ts) && ts > 0) {\n\t\t\t\t\tfinalVal = new Date(ts * 1000).toLocaleString('de-DE', {\n\t\t\t\t\t\tday: '2-digit',\n\t\t\t\t\t\tmonth: '2-digit',\n\t\t\t\t\t\tyear: 'numeric',\n\t\t\t\t\t\thour: '2-digit',\n\t\t\t\t\t\tminute: '2-digit',\n\t\t\t\t\t\tsecond: '2-digit',\n\t\t\t\t\t\thour12: false,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tfinalVal = 'Ung\u00FCltig';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfinalVal = String(rawVal);\n\t\t\t}\n\n\t\t\tconst cleanId = sanitizeName(custom.name);\n\t\t\tconst stateId = `${adapter.namespace}.Benutzer.${cleanId}`;\n\n\t\t\tawait adapter.setForeignStateChangedAsync(stateId, finalVal, true);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler beim Aktualisieren der benutzerdefinierten Werte: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Universelle Hilfsfunktion, um System-Datenpunkte typsicher und effizient zu aktualisieren.\n *\n * @param adapter Adapter-Instanz des ioBroker-Adapters\n * @param key Schl\u00FCssel des System-Datenpunkts\n * @param value Neuer Wert f\u00FCr den Datenpunkt\n */\nasync function setChangedSystemState(adapter: AdapterInstance, key: string, value: string): Promise<void> {\n\tconst dp = getDpPath(key);\n\tif (dp) {\n\t\tawait adapter.setStateChangedAsync(dp, value, true);\n\t}\n}\n\n/**\n * Aktualisiert System-Informationen wie Firmware, IP-Adresse und W\u00E4rmepumpentyp.\n *\n * @param adapter Adapter-Instanz des ioBroker-Adapters\n * @param rawValues Array mit Rohdaten aus dem System\n */\nexport async function updateSystemInfos(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\ttry {\n\t\tconst firmwareBuf = rawValues.slice(81, 91);\n\t\tconst firmwareString = createFirmwareString(firmwareBuf);\n\t\tawait setChangedSystemState(adapter, 'firmware', firmwareString);\n\n\t\tconst ipAddress = int2ipAddress(rawValues[91]);\n\t\tawait setChangedSystemState(adapter, 'ip_address', ipAddress);\n\n\t\tconst subnet = int2ipAddress(rawValues[92]);\n\t\tawait setChangedSystemState(adapter, 'subnet', subnet);\n\n\t\tconst broadcastAddress = int2ipAddress(rawValues[93]);\n\t\tawait setChangedSystemState(adapter, 'broadcast_address', broadcastAddress);\n\n\t\tconst gateway = int2ipAddress(rawValues[94]);\n\t\tawait setChangedSystemState(adapter, 'standard_gateway', gateway);\n\n\t\tconst hpTypeIndex = rawValues[78];\n\t\tconst hpTypeString = createHeatPumpTypeString(hpTypeIndex);\n\t\tawait setChangedSystemState(adapter, 'heatpump_type', hpTypeString);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Fehler beim Aktualisieren der System-Infos: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Konvertiert ein Array von Luxtronik-ASCII-Zahlen in einen lesbaren Firmware-String\n *\n * @param buf Array von ASCII-Zahlen f\u00FCr den Firmware-String\n */\nfunction createFirmwareString(buf: number[]): string {\n\tif (!buf || !Array.isArray(buf)) {\n\t\treturn 'Unbekannt';\n\t}\n\t// Elegantere, moderne Array-Pipeline\n\treturn buf\n\t\t.filter(v => v !== 0)\n\t\t.map(v => String.fromCharCode(v))\n\t\t.join('')\n\t\t.trim();\n}\n\n/**\n * Konvertiert einen 32-Bit-Integer-Wert der Luxtronik in eine IPv4-Adresse\n *\n * @param value 32-Bit-Integer-Wert der Luxtronik\n */\nfunction int2ipAddress(value: number): string {\n\tif (value === undefined || value === null || isNaN(value)) {\n\t\treturn '0.0.0.0';\n\t}\n\n\tconst part1 = value & 255;\n\tconst part2 = (value >>> 8) & 255;\n\tconst part3 = (value >>> 16) & 255;\n\tconst part4 = (value >>> 24) & 255;\n\n\treturn `${part4}.${part3}.${part2}.${part1}`;\n}\n\n/**\n * Liest den Klarnamen des Anlagentyps aus dem Dictionary\n *\n * @param value Index des Anlagentyps im Dictionary\n */\nfunction createHeatPumpTypeString(value: number): string {\n\treturn HP_TYPES[value] || HP_TYPES[-1];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAQO;AACP,oBAAyB;AACzB,2BAA6B;AAC7B,0BAAyC;AAezC,eAAe,aACd,SACA,WACA,WACA,UACA,SACgB;AAChB,MAAI;AACH,UAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,QAAQ,cAAc,SAAS;AAAA,MAC/B,QAAQ,cAAc,SAAS;AAAA,IAChC,CAAC;AAED,UAAM,OAAO,UAAU,OAAO,OAAO,QAAQ,WAAW,OAAO,MAAM;AACrE,UAAM,OAAO,UAAU,OAAO,OAAO,QAAQ,WAAW,OAAO,MAAM;AAErE,UAAM,QAAQ,qBAAqB,UAAU,OAAO,MAAM,IAAI;AAAA,EAC/D,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,iCAAiC,OAAO,KAAK,GAAG,IAAI,OAAO;AAAA,EACrE;AACD;AAQA,eAAsB,4BAA4B,SAAyC;AAC1F,QAAM;AAAA,IAC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AAC1D,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,QAAQ;AACtB,QAAM,QAAS,UAAU,IAAK;AAC9B,QAAM,QAAS,UAAU,KAAM;AAC/B,QAAM,QAAS,UAAU,KAAM;AAE/B,SAAO,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK;AAC3C;AAOA,SAAS,yBAAyB,OAAuB;AACxD,SAAO,sBAAS,KAAK,KAAK,sBAAS,EAAE;AACtC;",
|
|
4
|
+
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport { ERROR_CODES, HP_TYPES, OUTAGE_CODES, STATE_HEATING, STATE_LINE_1, STATE_LINE_2, STATE_LINE_3 } from './codes';\nimport { writeLog } from './logger';\nimport { sanitizeName } from './objectManager';\nimport { getDpPath, getLuxIdByKey } from './stateMapping';\n\n// ==========================================\n// CALCULATIONS (DRY-Principle)\n// ==========================================\n\n/**\n * Universal helper function to add two values from the ioBroker state tree.\n *\n * @param adapter - ioBroker adapter instance\n * @param sourceId1 - Path of the first source state\n * @param sourceId2 - Path of the second source state\n * @param targetId - Path of the target state where the result will be written\n * @param logName - Name used for log entries\n * @returns A promise resolving after the addition completes\n */\nasync function calculateSum(\n\tadapter: AdapterInstance,\n\tsourceId1: string,\n\tsourceId2: string,\n\ttargetId: string,\n\tlogName: string,\n): Promise<void> {\n\ttry {\n\t\tconst [state1, state2] = await Promise.all([\n\t\t\tadapter.getStateAsync(sourceId1),\n\t\t\tadapter.getStateAsync(sourceId2),\n\t\t]);\n\n\t\tconst val1 = state1 && typeof state1.val === 'number' ? state1.val : 0;\n\t\tconst val2 = state2 && typeof state2.val === 'number' ? state2.val : 0;\n\n\t\tawait adapter.setStateChangedAsync(targetId, val1 + val2, true);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error calculating ${logName}: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Calculates the total thermal energy (heating + hot water) and writes it to the target state.\n *\n * @param adapter - ioBroker adapter instance\n * @returns A promise resolving upon completion\n */\nexport async function calculateTotalThermalEnergy(adapter: AdapterInstance): Promise<void> {\n\tawait calculateSum(\n\t\tadapter,\n\t\tgetDpPath('thermalenergy_heating'),\n\t\tgetDpPath('thermalenergy_warmwater'),\n\t\tgetDpPath('thermalenergy_total'),\n\t\t'Total Thermal Energy',\n\t);\n}\n\n/**\n * Calculates the total energy consumed (heating + hot water) and writes it to the target state.\n *\n * @param adapter - ioBroker adapter instance\n * @returns A promise resolving upon completion\n */\nexport async function calculateTotalEnergy(adapter: AdapterInstance): Promise<void> {\n\tawait calculateSum(\n\t\tadapter,\n\t\tgetDpPath('energy_heating'),\n\t\tgetDpPath('energy_warmwater'),\n\t\tgetDpPath('energy_total'),\n\t\t'Total Energy',\n\t);\n}\n\n// ==========================================\n// HISTORY & LOGS (DRY-Principle)\n// ==========================================\n\n/**\n * Structure of an entry in the error or outage history.\n */\ninterface HistoryEntry {\n\t/** The code of the registered error or outage */\n\tcode: number;\n\t/** The clear text description of the code */\n\tbeschreibung: string;\n\t/** The formatted date of occurrence */\n\tdatum: string;\n\t/** The raw Unix timestamp */\n\ttimestamp: number;\n}\n\n/**\n * Internal helper function to generate error and outage histories.\n *\n * @param adapter The adapter instance.\n * @param rawValues The raw values from the heat pump.\n * @param timeStartIndex Index of the first timestamp in the raw data.\n * @param codeStartIndex Index of the first code in the raw data.\n * @param targetStateId The ioBroker ID where the JSON should be written.\n * @param fallbackPrefix Fallback text for unknown codes.\n * @param codeMap The dictionary mapping codes to readable text.\n * @returns A promise resolving upon completion\n */\nasync function updateHistory(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\ttimeStartIndex: number,\n\tcodeStartIndex: number,\n\ttargetStateId: string,\n\tfallbackPrefix: string,\n\tcodeMap: Record<number, string>,\n): Promise<void> {\n\ttry {\n\t\tconst historyList: HistoryEntry[] = [];\n\n\t\tfor (let i = 0; i < 5; i++) {\n\t\t\tconst code = rawValues[codeStartIndex + i];\n\t\t\tconst timestamp = rawValues[timeStartIndex + i];\n\n\t\t\tif (timestamp !== undefined && timestamp > 0) {\n\t\t\t\tconst date = new Date(timestamp * 1000);\n\t\t\t\tconst formattedDate = date.toISOString().replace('T', ' ').substring(0, 19);\n\n\t\t\t\tlet beschreibung = `${fallbackPrefix} (${code})`;\n\t\t\t\tif (codeMap[code] !== undefined) {\n\t\t\t\t\tbeschreibung = codeMap[code];\n\t\t\t\t}\n\n\t\t\t\thistoryList.push({\n\t\t\t\t\tcode: code,\n\t\t\t\t\tbeschreibung: beschreibung,\n\t\t\t\t\tdatum: formattedDate,\n\t\t\t\t\ttimestamp: timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\thistoryList.sort((a, b) => b.timestamp - a.timestamp);\n\n\t\tconst cleanList = historyList.map((entry, idx) => ({\n\t\t\tindex: idx + 1,\n\t\t\tcode: entry.code,\n\t\t\tbeschreibung: entry.beschreibung,\n\t\t\tdatum: entry.datum,\n\t\t\ttimestamp: entry.timestamp,\n\t\t}));\n\t\tconst jsonStr = JSON.stringify(cleanList);\n\n\t\tconst result = await adapter.setStateChangedAsync(targetStateId, { val: jsonStr, ack: true });\n\t\tif (result && (result as any).numChanges > 0) {\n\t\t\twriteLog(`History for ${targetStateId} updated from raw data.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error updating history: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Updates the error history with the latest error codes.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values from the device.\n * @returns A promise resolving upon completion\n */\nexport async function updateErrorHistory(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\tconst dpPath = getDpPath('Fehlerspeicher');\n\tif (dpPath) {\n\t\tawait updateHistory(adapter, rawValues, 95, 100, dpPath, 'Unknown error', ERROR_CODES);\n\t}\n}\n\n/**\n * Updates the outage history with the latest outage codes.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values from the device.\n * @returns A promise resolving upon completion\n */\nexport async function updateOutageHistory(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\tconst dpPath = getDpPath('Abschaltungen');\n\tif (dpPath) {\n\t\tawait updateHistory(adapter, rawValues, 111, 106, dpPath, 'Unknown outage cause', OUTAGE_CODES);\n\t}\n}\n\n/**\n * Calculates the temperature spread between supply and return temperatures.\n *\n * @param adapter - The adapter instance.\n * @returns A promise resolving upon completion\n */\nexport async function calculateTemperatureSpread(adapter: AdapterInstance): Promise<void> {\n\ttry {\n\t\tconst vorlaufPath = getDpPath('temperature_supply');\n\t\tconst ruecklaufPath = getDpPath('temperature_return');\n\n\t\tif (!vorlaufPath || !ruecklaufPath) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [vorlaufState, ruecklaufState] = await Promise.all([\n\t\t\tadapter.getStateAsync(vorlaufPath),\n\t\t\tadapter.getStateAsync(ruecklaufPath),\n\t\t]);\n\n\t\tif (vorlaufState && ruecklaufState && vorlaufState.val !== null && ruecklaufState.val !== null) {\n\t\t\tconst spreizung = parseFloat((Number(vorlaufState.val) - Number(ruecklaufState.val)).toFixed(2));\n\t\t\tconst targetSpreadPath = getDpPath('spreizung_vorlauf_ruecklauf');\n\t\t\tif (targetSpreadPath) {\n\t\t\t\tawait adapter.setStateChangedAsync(targetSpreadPath, spreizung, true);\n\t\t\t}\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error calculating temperature spread: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Updates the status strings based on raw sensor values and parameters.\n *\n * @param adapter - The adapter instance.\n * @param rawValues - The raw values array from the Luxtronik device.\n * @param rawParams - The raw parameters array from the Luxtronik device.\n * @returns A promise resolving upon completion\n */\nexport async function updateStatusStrings(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\trawParams: number[],\n): Promise<void> {\n\ttry {\n\t\tconst Heizgrenze = (rawParams[getLuxIdByKey('thresholdHeatingLimit')] || 0) / 10;\n\t\tconst Absenkung = (rawParams[getLuxIdByKey('deltaHeatingReduction')] || 0) / 10;\n\t\tconst AbsenkungMax = (rawParams[getLuxIdByKey('thresholdTemperatureSetBack')] || 0) / 10;\n\t\tconst R\u00FCcklaufSollMin = (rawParams[getLuxIdByKey('returnTemperatureTargetMin')] || 15) / 10;\n\t\tconst R\u00FCcklaufSoll = (rawValues[getLuxIdByKey('temperature_target_return')] || 15) / 10;\n\t\tconst BetriebsartHeizung = rawParams[getLuxIdByKey('heating_operation_mode')] || 0;\n\t\tconst Au\u00DFentemperatur = (rawValues[getLuxIdByKey('temperature_outside')] || 0) / 10;\n\t\tconst Mitteltemperatur = (rawValues[getLuxIdByKey('Mitteltemperatur')] || 0) / 10;\n\n\t\tlet heatingStr = 'Unknown';\n\n\t\tif (\n\t\t\tBetriebsartHeizung === 0 &&\n\t\t\tMitteltemperatur >= Heizgrenze &&\n\t\t\t(R\u00FCcklaufSoll === R\u00FCcklaufSollMin || (R\u00FCcklaufSoll === 20 && Au\u00DFentemperatur < 10))\n\t\t) {\n\t\t\theatingStr =\n\t\t\t\tAu\u00DFentemperatur >= 10\n\t\t\t\t\t? `Heating limit (Target ${R\u00FCcklaufSollMin} \u00B0C)`\n\t\t\t\t\t: 'Frost protection (Target 20 \u00B0C)';\n\t\t} else {\n\t\t\theatingStr = STATE_HEATING[BetriebsartHeizung] || `Unknown (${BetriebsartHeizung})`;\n\t\t\tif (BetriebsartHeizung === 0) {\n\t\t\t\theatingStr =\n\t\t\t\t\tAbsenkungMax <= Au\u00DFentemperatur\n\t\t\t\t\t\t? `${heatingStr} ${Absenkung} \u00B0C`\n\t\t\t\t\t\t: `Normal as < ${AbsenkungMax} \u00B0C`;\n\t\t\t}\n\t\t}\n\n\t\tconst dpHeating = getDpPath('opStateHeatingString');\n\t\tif (dpHeating) {\n\t\t\tawait adapter.setStateChangedAsync(dpHeating, heatingStr, true);\n\t\t}\n\n\t\tconst codeZ1 = rawValues[117];\n\t\tconst codeZ2 = rawValues[118];\n\t\tconst codeZ3 = rawValues[119];\n\t\tconst zeitSec = rawValues[120];\n\t\tlet stateStr = 'Unknown';\n\t\tlet extStateStr = 'Unknown';\n\t\tconst hotWaterBoilerValve = rawValues[getLuxIdByKey('hotWaterBoilerValve')] || 0;\n\t\tconst opStateHotWaterOriginal = rawValues[124];\n\n\t\t// Erkennung von FW 3.x (LCD-Display Register sind leer oder 0)\n\t\tconst isModernFirmware = (codeZ1 === undefined || codeZ1 === 0) && (codeZ3 === undefined || codeZ3 === 0);\n\n\t\tif (!isModernFirmware) {\n\t\t\t// Klassische Logik f\u00FCr FW 1.x und 2.x\n\t\t\tconst h = Math.floor((zeitSec || 0) / 3600);\n\t\t\tconst m = Math.floor(((zeitSec || 0) % 3600) / 60);\n\t\t\tconst s = (zeitSec || 0) % 60;\n\t\t\tconst zeitString = `${h < 10 ? '0' : ''}${h}:${m < 10 ? '0' : ''}${m}:${s < 10 ? '0' : ''}${s}`;\n\n\t\t\tstateStr = STATE_LINE_3[codeZ3] || 'Unknown';\n\n\t\t\tif (STATE_LINE_1[codeZ1]) {\n\t\t\t\tconst textZ2 = STATE_LINE_2[codeZ2] || '';\n\t\t\t\textStateStr = `${STATE_LINE_1[codeZ1]} ${textZ2} ${zeitString}`.trim();\n\t\t\t}\n\t\t} else {\n\t\t\t// Fallback-Logik f\u00FCr FW 3.x (nutzt den generellen Betriebszustand WP_BZ_akt aus Index 80)\n\t\t\tconst bzMap: Record<number, string> = {\n\t\t\t\t0: 'Heating',\n\t\t\t\t1: 'Hot water',\n\t\t\t\t2: 'Swimming pool',\n\t\t\t\t3: 'Utility block',\n\t\t\t\t4: 'Defrosting',\n\t\t\t\t5: 'Idle',\n\t\t\t\t6: 'Ext. heat source',\n\t\t\t\t7: 'Cooling',\n\t\t\t};\n\n\t\t\tconst currentStateCode = rawValues[getLuxIdByKey('WP_BZ_akt')] || 5;\n\t\t\tconst baseState = bzMap[currentStateCode] || `Status ${currentStateCode}`;\n\n\t\t\t// Wir bef\u00FCllen beide Strings mit sinnvollen Werten\n\t\t\tstateStr = baseState;\n\t\t\textStateStr = baseState;\n\n\t\t\t// Wenn ein Timer mitgesendet wird, h\u00E4ngen wir ihn an\n\t\t\tif (zeitSec !== undefined && zeitSec > 0) {\n\t\t\t\tconst h = Math.floor(zeitSec / 3600);\n\t\t\t\tconst m = Math.floor((zeitSec % 3600) / 60);\n\t\t\t\tconst s = zeitSec % 60;\n\t\t\t\tconst zeitString = `${h < 10 ? '0' : ''}${h}:${m < 10 ? '0' : ''}${m}:${s < 10 ? '0' : ''}${s}`;\n\t\t\t\textStateStr += ` (${zeitString})`;\n\t\t\t}\n\t\t}\n\n\t\tconst dpExtState = getDpPath('heatpump_extendet_state_string');\n\t\tif (dpExtState) {\n\t\t\tawait adapter.setStateChangedAsync(dpExtState, stateStr, true);\n\t\t}\n\n\t\tconst dpState = getDpPath('heatpump_state_string');\n\t\tif (dpState) {\n\t\t\tawait adapter.setStateChangedAsync(dpState, extStateStr, true);\n\t\t}\n\n\t\tlet hotWaterStr = 'Unknown';\n\t\tif (opStateHotWaterOriginal === 0) {\n\t\t\thotWaterStr = 'Lock time';\n\t\t} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 1) {\n\t\t\thotWaterStr = 'Heating up';\n\t\t} else if (opStateHotWaterOriginal === 1 && hotWaterBoilerValve === 0) {\n\t\t\thotWaterStr = 'Temp. OK';\n\t\t} else if (opStateHotWaterOriginal === 3) {\n\t\t\thotWaterStr = 'Off';\n\t\t} else {\n\t\t\thotWaterStr = `Unknown [${opStateHotWaterOriginal}/${hotWaterBoilerValve}]`;\n\t\t}\n\t\tconst dpHotWater = getDpPath('opStateHotWaterString');\n\t\tif (dpHotWater) {\n\t\t\tawait adapter.setStateChangedAsync(dpHotWater, hotWaterStr, true);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error updating status strings: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Reads individual start/end times from the settings and generates a formatted JSON array.\n *\n * @param adapter The adapter instance\n * @returns A promise resolving upon completion\n */\nexport async function updateTimerTables(adapter: AdapterInstance): Promise<void> {\n\ttry {\n\t\tconst timeCache = new Map<string, string>();\n\n\t\t/**\n\t\t * Internal helper to fetch and parse a specific time string.\n\t\t *\n\t\t * @param key The state key to fetch\n\t\t * @returns A promise resolving to the formatted time string\n\t\t */\n\t\tconst getTime = async (key: string): Promise<string> => {\n\t\t\tif (timeCache.has(key)) {\n\t\t\t\treturn timeCache.get(key) || '00:00';\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst dpPath = getDpPath(key);\n\t\t\t\tif (!dpPath) {\n\t\t\t\t\treturn '00:00';\n\t\t\t\t}\n\n\t\t\t\tconst state = await adapter.getStateAsync(dpPath);\n\t\t\t\tif (state && typeof state.val === 'string') {\n\t\t\t\t\tconst match = state.val.match(/^(\\d{1,2}):(\\d{1,2})/);\n\t\t\t\t\tif (match) {\n\t\t\t\t\t\tconst formatted = `${match[1].padStart(2, '0')}:${match[2].padStart(2, '0')}`;\n\t\t\t\t\t\ttimeCache.set(key, formatted);\n\t\t\t\t\t\treturn formatted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '00:00';\n\t\t\t} catch {\n\t\t\t\treturn '00:00';\n\t\t\t}\n\t\t};\n\n\t\t/**\n\t\t * Internal helper to compile and save a single timer table array.\n\t\t *\n\t\t * @param targetKey The target state key for the JSON string\n\t\t * @param prefix The prefix identifying the associated timer slots\n\t\t * @param endStr The suffix indicating an end-time parameter\n\t\t * @param slots The total number of slots to iterate over\n\t\t * @returns A promise resolving when processing finishes\n\t\t */\n\t\tconst processTable = async (\n\t\t\ttargetKey: string,\n\t\t\tprefix: string,\n\t\t\tendStr: string,\n\t\t\tslots: number,\n\t\t): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tconst table: { on: string; off: string }[] = [];\n\n\t\t\t\tfor (let i = 1; i <= slots; i++) {\n\t\t\t\t\tconst [onTime, offTime] = await Promise.all([\n\t\t\t\t\t\tgetTime(`${prefix}Start${i}`),\n\t\t\t\t\t\tgetTime(`${prefix}${endStr}${i}`),\n\t\t\t\t\t]);\n\t\t\t\t\ttable.push({ on: onTime, off: offTime });\n\t\t\t\t}\n\n\t\t\t\tconst targetPath = getDpPath(targetKey);\n\t\t\t\tif (targetPath) {\n\t\t\t\t\tconst jsonStr = JSON.stringify(table, null, 2);\n\t\t\t\t\tawait adapter.setStateChangedAsync(targetPath, jsonStr, true);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\tvoid 0;\n\t\t\t}\n\t\t};\n\n\t\tconst configs = [\n\t\t\t{ target: 'heatingOperationTimerTableWeek', prefix: 'HZ_MoSo_', end: 'End1', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTable52MonFri', prefix: 'HZ_MoFr_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTable52SatSun', prefix: 'HZ_SaSo_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayMonday', prefix: 'HZ_Montag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayTuesday', prefix: 'HZ_Dienstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayWednesday', prefix: 'HZ_Mittwoch_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayThursday', prefix: 'HZ_Donnerstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDayFriday', prefix: 'HZ_Freitag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDaySaturday', prefix: 'HZ_Samstag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'heatingOperationTimerTableDaySunday', prefix: 'HZ_Sonntag_', end: 'Ende', slots: 3 },\n\t\t\t{ target: 'hotWaterTableWeek', prefix: 'WW_MoSo_', end: 'End', slots: 5 },\n\t\t\t{ target: 'hotWaterTable52MonFri', prefix: 'WW_MoFr_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTable52SatSun', prefix: 'WW_SaSo_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayMonday', prefix: 'WW_Montag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayTuesday', prefix: 'WW_Dienstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayWednesday', prefix: 'WW_Mittwoch_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayThursday', prefix: 'WW_Donnerstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDayFriday', prefix: 'WW_Freitag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDaySaturday', prefix: 'WW_Samstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterTableDaySunday', prefix: 'WW_Sonntag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableWeek', prefix: 'Zirkulation_MoSo_', end: 'End', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTable52MonFri', prefix: 'Zirkulation_MoFr_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTable52SatSun', prefix: 'Zirkulation_SaSo_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayMonday', prefix: 'Zirkulation_Montag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayTuesday', prefix: 'Zirkulation_Dienstag_', end: 'Ende', slots: 5 },\n\t\t\t{\n\t\t\t\ttarget: 'hotWaterCircPumpTimerTableDayWednesday',\n\t\t\t\tprefix: 'Zirkulation_Mittwoch_',\n\t\t\t\tend: 'Ende',\n\t\t\t\tslots: 5,\n\t\t\t},\n\t\t\t{\n\t\t\t\ttarget: 'hotWaterCircPumpTimerTableDayThursday',\n\t\t\t\tprefix: 'Zirkulation_Donnerstag_',\n\t\t\t\tend: 'Ende',\n\t\t\t\tslots: 5,\n\t\t\t},\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDayFriday', prefix: 'Zirkulation_Freitag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDaySaturday', prefix: 'Zirkulation_Samstag_', end: 'Ende', slots: 5 },\n\t\t\t{ target: 'hotWaterCircPumpTimerTableDaySunday', prefix: 'Zirkulation_Sonntag_', end: 'Ende', slots: 5 },\n\t\t];\n\n\t\tawait Promise.all(configs.map(cfg => processTable(cfg.target, cfg.prefix, cfg.end, cfg.slots)));\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error generating JSON timer tables: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Configuration of a custom data point based on the adapter settings.\n */\ninterface CustomStateConfig {\n\t/** Indicates whether the custom state is enabled */\n\tactive: boolean;\n\t/** The corresponding Luxtronik internal ID */\n\tluxId?: number;\n\t/** The user-defined display name */\n\tname: string;\n\t/** The source classification (parameter or value) */\n\tsource: 'parameter' | 'value';\n\t/** The intended ioBroker data type */\n\ttype: 'number' | 'boolean' | 'datetime' | 'string';\n\t/** Optional factor for numerical conversion */\n\tfactor?: number | null;\n}\n\n/**\n * Updates custom states based on configured Luxtronik IDs.\n *\n * @param adapter - ioBroker adapter instance\n * @param rawValues - Raw telemetry values\n * @param rawParams - Raw parameters\n * @returns A promise resolving upon completion\n */\nexport async function updateCustomStates(\n\tadapter: AdapterInstance,\n\trawValues: number[],\n\trawParams: number[],\n): Promise<void> {\n\ttry {\n\t\tconst customStates = ((adapter.config as any).custom_states as CustomStateConfig[]) || [];\n\t\tfor (const custom of customStates) {\n\t\t\tif (!custom.active || custom.luxId === undefined || !custom.name) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst rawArray = custom.source === 'parameter' ? rawParams : rawValues;\n\t\t\tconst rawVal = rawArray[custom.luxId];\n\n\t\t\tif (rawVal === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet finalVal: string | number | boolean;\n\n\t\t\tif (custom.type === 'number') {\n\t\t\t\tfinalVal = Number(rawVal);\n\t\t\t\tif (custom.factor !== undefined && custom.factor !== null) {\n\t\t\t\t\tfinalVal = finalVal * custom.factor;\n\t\t\t\t\tfinalVal = Math.round(finalVal * 10000) / 10000;\n\t\t\t\t}\n\t\t\t} else if (custom.type === 'boolean') {\n\t\t\t\tfinalVal = rawVal === 1 || String(rawVal).toLowerCase() === 'true';\n\t\t\t} else if (custom.type === 'datetime') {\n\t\t\t\tconst ts = Number(rawVal);\n\t\t\t\tif (!isNaN(ts) && ts > 0) {\n\t\t\t\t\tfinalVal = new Date(ts * 1000).toISOString().replace('T', ' ').substring(0, 19);\n\t\t\t\t} else {\n\t\t\t\t\tfinalVal = 'Invalid';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfinalVal = String(rawVal);\n\t\t\t}\n\n\t\t\tconst cleanId = sanitizeName(custom.name);\n\t\t\tconst stateId = `${adapter.namespace}.Custom.${cleanId}`;\n\n\t\t\tawait adapter.setForeignStateChangedAsync(stateId, finalVal, true);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error updating custom values: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Universal helper function to update system data points securely.\n *\n * @param adapter Adapter instance\n * @param key Key of the system data point\n * @param value New value\n * @returns A promise resolving upon completion\n */\nasync function setChangedSystemState(adapter: AdapterInstance, key: string, value: string): Promise<void> {\n\tconst dp = getDpPath(key);\n\tif (dp) {\n\t\tawait adapter.setStateChangedAsync(dp, value, true);\n\t}\n}\n\n/**\n * Updates system information such as firmware, IP address, and heat pump type.\n *\n * @param adapter Adapter instance\n * @param rawValues Array with raw data\n * @returns A promise resolving upon completion\n */\nexport async function updateSystemInfos(adapter: AdapterInstance, rawValues: number[]): Promise<void> {\n\ttry {\n\t\tconst firmwareBuf = rawValues.slice(81, 91);\n\t\tconst firmwareString = createFirmwareString(firmwareBuf);\n\t\tawait setChangedSystemState(adapter, 'firmware', firmwareString);\n\n\t\tconst ipAddress = int2ipAddress(rawValues[91]);\n\t\tawait setChangedSystemState(adapter, 'ip_address', ipAddress);\n\n\t\tconst subnet = int2ipAddress(rawValues[92]);\n\t\tawait setChangedSystemState(adapter, 'subnet', subnet);\n\n\t\tconst broadcastAddress = int2ipAddress(rawValues[93]);\n\t\tawait setChangedSystemState(adapter, 'broadcast_address', broadcastAddress);\n\n\t\tconst gateway = int2ipAddress(rawValues[94]);\n\t\tawait setChangedSystemState(adapter, 'standard_gateway', gateway);\n\n\t\tconst hpTypeIndex = rawValues[78];\n\t\tconst hpTypeString = createHeatPumpTypeString(hpTypeIndex);\n\t\tawait setChangedSystemState(adapter, 'heatpump_type', hpTypeString);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error updating system information: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Converts an array of ASCII numbers into a readable firmware string.\n *\n * @param buf Array of ASCII numbers\n * @returns Cleaned firmware string\n */\nfunction createFirmwareString(buf: number[]): string {\n\tif (!buf || !Array.isArray(buf)) {\n\t\treturn 'Unknown';\n\t}\n\treturn buf\n\t\t.filter(v => v !== 0)\n\t\t.map(v => String.fromCharCode(v))\n\t\t.join('')\n\t\t.trim();\n}\n\n/**\n * Converts a 32-bit integer into an IPv4 address.\n *\n * @param value 32-bit integer\n * @returns IPv4 address as a string\n */\nfunction int2ipAddress(value: number): string {\n\tif (value === undefined || value === null || isNaN(value)) {\n\t\treturn '0.0.0.0';\n\t}\n\n\tconst part1 = value & 255;\n\tconst part2 = (value >>> 8) & 255;\n\tconst part3 = (value >>> 16) & 255;\n\tconst part4 = (value >>> 24) & 255;\n\n\treturn `${part4}.${part3}.${part2}.${part1}`;\n}\n\n/**\n * Retrieves the clear text name of the system type from the dictionary.\n *\n * @param value Index of the system type\n * @returns Clear text string of the system type\n */\nfunction createHeatPumpTypeString(value: number): string {\n\treturn HP_TYPES[value] || HP_TYPES[-1];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA6G;AAC7G,oBAAyB;AACzB,2BAA6B;AAC7B,0BAAyC;AAgBzC,eAAe,aACd,SACA,WACA,WACA,UACA,SACgB;AAChB,MAAI;AACH,UAAM,CAAC,QAAQ,MAAM,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC1C,QAAQ,cAAc,SAAS;AAAA,MAC/B,QAAQ,cAAc,SAAS;AAAA,IAChC,CAAC;AAED,UAAM,OAAO,UAAU,OAAO,OAAO,QAAQ,WAAW,OAAO,MAAM;AACrE,UAAM,OAAO,UAAU,OAAO,OAAO,QAAQ,WAAW,OAAO,MAAM;AAErE,UAAM,QAAQ,qBAAqB,UAAU,OAAO,MAAM,IAAI;AAAA,EAC/D,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,qBAAqB,OAAO,KAAK,GAAG,IAAI,OAAO;AAAA,EACzD;AACD;AAQA,eAAsB,4BAA4B,SAAyC;AAC1F,QAAM;AAAA,IACL;AAAA,QACA,+BAAU,uBAAuB;AAAA,QACjC,+BAAU,yBAAyB;AAAA,QACnC,+BAAU,qBAAqB;AAAA,IAC/B;AAAA,EACD;AACD;AAQA,eAAsB,qBAAqB,SAAyC;AACnF,QAAM;AAAA,IACL;AAAA,QACA,+BAAU,gBAAgB;AAAA,QAC1B,+BAAU,kBAAkB;AAAA,QAC5B,+BAAU,cAAc;AAAA,IACxB;AAAA,EACD;AACD;AAgCA,eAAe,cACd,SACA,WACA,gBACA,gBACA,eACA,gBACA,SACgB;AAChB,MAAI;A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Ae,yBAAyB,WAAW;AACzD,UAAM,sBAAsB,SAAS,iBAAiB,YAAY;AAAA,EACnE,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,sCAAsC,GAAG,IAAI,OAAO;AAAA,EAC9D;AACD;AAQA,SAAS,qBAAqB,KAAuB;AACpD,MAAI,CAAC,OAAO,CAAC,MAAM,QAAQ,GAAG,GAAG;AAChC,WAAO;AAAA,EACR;AACA,SAAO,IACL,OAAO,OAAK,MAAM,CAAC,EACnB,IAAI,OAAK,OAAO,aAAa,CAAC,CAAC,EAC/B,KAAK,EAAE,EACP,KAAK;AACR;AAQA,SAAS,cAAc,OAAuB;AAC7C,MAAI,UAAU,UAAa,UAAU,QAAQ,MAAM,KAAK,GAAG;AAC1D,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,QAAQ;AACtB,QAAM,QAAS,UAAU,IAAK;AAC9B,QAAM,QAAS,UAAU,KAAM;AAC/B,QAAM,QAAS,UAAU,KAAM;AAE/B,SAAO,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK;AAC3C;AAQA,SAAS,yBAAyB,OAAuB;AACxD,SAAO,sBAAS,KAAK,KAAK,sBAAS,EAAE;AACtC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/zipManager.js
CHANGED
|
@@ -26,12 +26,14 @@ module.exports = __toCommonJS(zipManager_exports);
|
|
|
26
26
|
var import_logger = require("./logger");
|
|
27
27
|
var import_stateMapping = require("./stateMapping");
|
|
28
28
|
const CONSTANTS = {
|
|
29
|
+
/** Command ID for the deaeration program */
|
|
29
30
|
CMD_DEAERATE: 158,
|
|
31
|
+
/** Command ID for the circulation pump (ZIP) */
|
|
30
32
|
CMD_ZIP: 684,
|
|
33
|
+
/** Seconds representing the end of a day (23:59:00) */
|
|
31
34
|
END_OF_DAY: 86340,
|
|
32
|
-
|
|
35
|
+
/** Delay in milliseconds between consecutive hardware write operations */
|
|
33
36
|
WRITE_DELAY: 100
|
|
34
|
-
// 100ms Pause zwischen Schreibvorgängen
|
|
35
37
|
};
|
|
36
38
|
function clearZipTimer(adapter) {
|
|
37
39
|
if (!adapter.zipTimer) {
|
|
@@ -69,12 +71,16 @@ async function restoreOriginalZipConfig(adapter) {
|
|
|
69
71
|
const luxId = Number(def.luxWriteId);
|
|
70
72
|
if (!isNaN(luxId)) {
|
|
71
73
|
await adapter.queueWrite(luxId, Number(rawVal));
|
|
72
|
-
await new Promise((resolve) =>
|
|
74
|
+
await new Promise((resolve) => {
|
|
75
|
+
adapter.setTimeout(() => {
|
|
76
|
+
resolve();
|
|
77
|
+
}, CONSTANTS.WRITE_DELAY);
|
|
78
|
+
});
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
} catch (err) {
|
|
76
82
|
const msg = err instanceof Error ? err.message : String(err);
|
|
77
|
-
(0, import_logger.writeLog)(`
|
|
83
|
+
(0, import_logger.writeLog)(`Error restoring ZIP configuration: ${msg}`, "error");
|
|
78
84
|
} finally {
|
|
79
85
|
adapter.originalZipConfig = null;
|
|
80
86
|
}
|
|
@@ -87,16 +93,24 @@ async function stopZipAndDeaeration(adapter) {
|
|
|
87
93
|
const isDeaerateActive = (runDeaerateState == null ? void 0 : runDeaerateState.val) === 1 || (runDeaerateState == null ? void 0 : runDeaerateState.val) === true;
|
|
88
94
|
if (isZipActive || isDeaerateActive) {
|
|
89
95
|
if (adapter.isDebugLogActive) {
|
|
90
|
-
(0, import_logger.writeLog)("
|
|
96
|
+
(0, import_logger.writeLog)("Conditions met: Stopping active ZIP macro and deaeration program...", "info");
|
|
91
97
|
}
|
|
92
98
|
clearZipTimer(adapter);
|
|
93
99
|
await restoreOriginalZipConfig(adapter);
|
|
94
100
|
await adapter.queueWrite(CONSTANTS.CMD_DEAERATE, 0);
|
|
95
|
-
await new Promise((resolve) =>
|
|
101
|
+
await new Promise((resolve) => {
|
|
102
|
+
adapter.setTimeout(() => {
|
|
103
|
+
resolve();
|
|
104
|
+
}, CONSTANTS.WRITE_DELAY);
|
|
105
|
+
});
|
|
96
106
|
await adapter.queueWrite(CONSTANTS.CMD_ZIP, 0);
|
|
97
|
-
await new Promise((resolve) =>
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
await new Promise((resolve) => {
|
|
108
|
+
adapter.setTimeout(() => {
|
|
109
|
+
resolve();
|
|
110
|
+
}, CONSTANTS.WRITE_DELAY);
|
|
111
|
+
});
|
|
112
|
+
await adapter.syncConfigValue("runDeaerate", false);
|
|
113
|
+
await adapter.syncConfigValue("hotWaterCircPumpDeaerate", false);
|
|
100
114
|
const dpZip = (0, import_stateMapping.getDpPath)("Activate_Zip");
|
|
101
115
|
if (dpZip) {
|
|
102
116
|
await adapter.setOwnStateIfDifferent(dpZip, false, true);
|
|
@@ -104,13 +118,14 @@ async function stopZipAndDeaeration(adapter) {
|
|
|
104
118
|
}
|
|
105
119
|
} catch (err) {
|
|
106
120
|
const msg = err instanceof Error ? err.message : String(err);
|
|
107
|
-
(0, import_logger.writeLog)(`
|
|
121
|
+
(0, import_logger.writeLog)(`Error stopping ZIP/Deaeration: ${msg}`, "error");
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
async function handleActivateZip(adapter, id, durationSeconds) {
|
|
111
|
-
|
|
125
|
+
const localId = id.replace(`${adapter.namespace}.`, "");
|
|
126
|
+
await adapter.setStateAsync(localId, { val: true, ack: true });
|
|
112
127
|
if (durationSeconds <= 0) {
|
|
113
|
-
await adapter.
|
|
128
|
+
await adapter.setStateAsync(localId, { val: false, ack: true });
|
|
114
129
|
return;
|
|
115
130
|
}
|
|
116
131
|
const safeDurationSeconds = Math.max(1, isNaN(durationSeconds) ? 60 : durationSeconds);
|
|
@@ -128,10 +143,14 @@ async function handleActivateZip(adapter, id, durationSeconds) {
|
|
|
128
143
|
clearZipTimer(adapter);
|
|
129
144
|
if (useDeaeration) {
|
|
130
145
|
await adapter.queueWrite(CONSTANTS.CMD_DEAERATE, 1);
|
|
131
|
-
await new Promise((resolve) =>
|
|
146
|
+
await new Promise((resolve) => {
|
|
147
|
+
adapter.setTimeout(() => {
|
|
148
|
+
resolve();
|
|
149
|
+
}, CONSTANTS.WRITE_DELAY);
|
|
150
|
+
});
|
|
132
151
|
await adapter.queueWrite(CONSTANTS.CMD_ZIP, 1);
|
|
133
|
-
await adapter.syncConfigValue("runDeaerate",
|
|
134
|
-
await adapter.syncConfigValue("hotWaterCircPumpDeaerate",
|
|
152
|
+
await adapter.syncConfigValue("runDeaerate", true);
|
|
153
|
+
await adapter.syncConfigValue("hotWaterCircPumpDeaerate", true);
|
|
135
154
|
} else {
|
|
136
155
|
const onTimeMinutes = Math.ceil(safeDurationSeconds / 60);
|
|
137
156
|
if (!adapter.originalZipConfig) {
|
|
@@ -171,7 +190,11 @@ async function handleActivateZip(adapter, id, durationSeconds) {
|
|
|
171
190
|
const def = import_stateMapping.STATE_MAPPING[u.key];
|
|
172
191
|
if (def && def.luxWriteId) {
|
|
173
192
|
await adapter.queueWrite(parseInt(def.luxWriteId, 10), u.raw);
|
|
174
|
-
await new Promise((resolve) =>
|
|
193
|
+
await new Promise((resolve) => {
|
|
194
|
+
adapter.setTimeout(() => {
|
|
195
|
+
resolve();
|
|
196
|
+
}, CONSTANTS.WRITE_DELAY);
|
|
197
|
+
});
|
|
175
198
|
}
|
|
176
199
|
}
|
|
177
200
|
}
|