iobroker.luxtronik2-controller 0.15.1 → 0.17.1
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 +35 -34
- package/admin/jsonConfig.json +8555 -1036
- package/build/copManager.js +254 -0
- package/build/copManager.js.map +7 -0
- package/build/main.js +6 -0
- package/build/main.js.map +2 -2
- package/build/mapping/actions.js +11 -0
- package/build/mapping/actions.js.map +2 -2
- package/build/mapping/info.js +91 -2
- package/build/mapping/info.js.map +2 -2
- package/build/objectManager.js +10 -3
- package/build/objectManager.js.map +2 -2
- package/build/scripts/generateConfig.js +285 -0
- package/build/scripts/generateConfig.js.map +7 -0
- package/io-package.json +59 -54
- package/package.json +4 -3
- package/build/stateMapping_old.js +0 -4712
- package/build/stateMapping_old.js.map +0 -7
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var copManager_exports = {};
|
|
20
|
+
__export(copManager_exports, {
|
|
21
|
+
processCopData: () => processCopData
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(copManager_exports);
|
|
24
|
+
var import_logger = require("./logger");
|
|
25
|
+
var import_stateMapping = require("./stateMapping");
|
|
26
|
+
let lastPowerTotal = 0;
|
|
27
|
+
let lastThermalTotal = 0;
|
|
28
|
+
let isInitialized = false;
|
|
29
|
+
async function processCopData(adapter, bzVal) {
|
|
30
|
+
const config = adapter.config;
|
|
31
|
+
if (!config.cop_calculation_active) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
(0, import_logger.writeLog)(`COP Manager gestartet. Modus: ${bzVal}`, "debug");
|
|
36
|
+
let currentPower = 0;
|
|
37
|
+
if (config.cop_source_power === "external" && config.cop_oid_power_total) {
|
|
38
|
+
const state = await adapter.getForeignStateAsync(config.cop_oid_power_total);
|
|
39
|
+
if (state && typeof state.val === "number") {
|
|
40
|
+
currentPower = state.val;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
const state = await adapter.getStateAsync((0, import_stateMapping.getDpPath)("energy_total"));
|
|
44
|
+
if (state && typeof state.val === "number") {
|
|
45
|
+
currentPower = state.val;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
let currentThermal = 0;
|
|
49
|
+
if (config.cop_source_thermal === "external" && config.cop_oid_thermal_total) {
|
|
50
|
+
const state = await adapter.getForeignStateAsync(config.cop_oid_thermal_total);
|
|
51
|
+
if (state && typeof state.val === "number") {
|
|
52
|
+
currentThermal = state.val;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
const state = await adapter.getStateAsync((0, import_stateMapping.getDpPath)("thermalenergy_total"));
|
|
56
|
+
if (state && typeof state.val === "number") {
|
|
57
|
+
currentThermal = state.val;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!isInitialized) {
|
|
61
|
+
lastPowerTotal = currentPower;
|
|
62
|
+
lastThermalTotal = currentThermal;
|
|
63
|
+
isInitialized = true;
|
|
64
|
+
await handleTimeRollover(adapter);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const deltaPower = currentPower - lastPowerTotal;
|
|
68
|
+
const deltaThermal = currentThermal - lastThermalTotal;
|
|
69
|
+
lastPowerTotal = currentPower;
|
|
70
|
+
lastThermalTotal = currentThermal;
|
|
71
|
+
await handleTimeRollover(adapter);
|
|
72
|
+
if (deltaPower > 0 || deltaThermal > 0) {
|
|
73
|
+
await addDeltaToBucket(adapter, "Total", deltaPower, deltaThermal);
|
|
74
|
+
if (bzVal === "0") {
|
|
75
|
+
await addDeltaToBucket(adapter, "Heating", deltaPower, deltaThermal);
|
|
76
|
+
} else if (bzVal === "1") {
|
|
77
|
+
await addDeltaToBucket(adapter, "HotWater", deltaPower, deltaThermal);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
await calculateAndWriteCop(adapter, "Total");
|
|
81
|
+
await calculateAndWriteCop(adapter, "Heating");
|
|
82
|
+
await calculateAndWriteCop(adapter, "HotWater");
|
|
83
|
+
} catch (err) {
|
|
84
|
+
(0, import_logger.writeLog)(`Fehler bei der COP-Berechnung: ${err.message}`, "error");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function handleTimeRollover(adapter) {
|
|
88
|
+
(0, import_logger.writeLog)(`Pr\xFCfe Tageswechsel und lege Ordner an...`, "debug");
|
|
89
|
+
const dateStateId = "hidden.cop_buckets.last_date";
|
|
90
|
+
await adapter.setObjectNotExistsAsync("hidden", {
|
|
91
|
+
type: "folder",
|
|
92
|
+
common: { name: "Hidden System Data" },
|
|
93
|
+
native: {}
|
|
94
|
+
});
|
|
95
|
+
await adapter.setObjectNotExistsAsync("hidden.cop_buckets", {
|
|
96
|
+
type: "folder",
|
|
97
|
+
common: { name: "COP Data Buckets" },
|
|
98
|
+
native: {}
|
|
99
|
+
});
|
|
100
|
+
await adapter.setObjectNotExistsAsync(dateStateId, {
|
|
101
|
+
type: "state",
|
|
102
|
+
common: { name: "Last calculation date", type: "string", role: "date", read: true, write: false },
|
|
103
|
+
native: {}
|
|
104
|
+
});
|
|
105
|
+
const state = await adapter.getStateAsync(dateStateId);
|
|
106
|
+
const lastDate = state && typeof state.val === "string" ? state.val : "";
|
|
107
|
+
const now = /* @__PURE__ */ new Date();
|
|
108
|
+
const currentDate = now.toISOString().split("T")[0];
|
|
109
|
+
const currentMonth = currentDate.substring(0, 7);
|
|
110
|
+
const currentYear = currentDate.substring(0, 4);
|
|
111
|
+
if (lastDate !== currentDate) {
|
|
112
|
+
const lastMonth = lastDate ? lastDate.substring(0, 7) : "";
|
|
113
|
+
const lastYear = lastDate ? lastDate.substring(0, 4) : "";
|
|
114
|
+
const categories = ["Total", "Heating", "HotWater"];
|
|
115
|
+
for (const cat of categories) {
|
|
116
|
+
const powerAbs = await getAbsoluteValue(adapter, cat, "power");
|
|
117
|
+
const thermalAbs = await getAbsoluteValue(adapter, cat, "thermal");
|
|
118
|
+
await setSnapshot(adapter, cat, "today", powerAbs, thermalAbs);
|
|
119
|
+
await update7DaysHistory(adapter, cat, powerAbs, thermalAbs);
|
|
120
|
+
if (lastMonth !== currentMonth) {
|
|
121
|
+
await setSnapshot(adapter, cat, "month", powerAbs, thermalAbs);
|
|
122
|
+
}
|
|
123
|
+
if (lastYear !== currentYear) {
|
|
124
|
+
await setSnapshot(adapter, cat, "year", powerAbs, thermalAbs);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
await adapter.setState(dateStateId, { val: currentDate, ack: true });
|
|
128
|
+
(0, import_logger.writeLog)(`Tageswechsel erkannt. COP-Snapshots f\xFCr ${currentDate} wurden gesichert.`, "info");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async function getAbsoluteValue(adapter, category, type) {
|
|
132
|
+
const id = `hidden.cop_buckets.${category}_${type}_absolute`;
|
|
133
|
+
await adapter.setObjectNotExistsAsync(id, {
|
|
134
|
+
type: "state",
|
|
135
|
+
common: { name: `${category} ${type} Absolute`, type: "number", role: "value", read: true, write: false },
|
|
136
|
+
native: {}
|
|
137
|
+
});
|
|
138
|
+
const state = await adapter.getStateAsync(id);
|
|
139
|
+
return state && typeof state.val === "number" ? state.val : 0;
|
|
140
|
+
}
|
|
141
|
+
async function setSnapshot(adapter, category, timeframe, power, thermal) {
|
|
142
|
+
const powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;
|
|
143
|
+
const thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;
|
|
144
|
+
await adapter.setObjectNotExistsAsync(powerId, {
|
|
145
|
+
type: "state",
|
|
146
|
+
common: {
|
|
147
|
+
name: `${category} Power Start ${timeframe}`,
|
|
148
|
+
type: "number",
|
|
149
|
+
role: "value",
|
|
150
|
+
read: true,
|
|
151
|
+
write: false
|
|
152
|
+
},
|
|
153
|
+
native: {}
|
|
154
|
+
});
|
|
155
|
+
await adapter.setObjectNotExistsAsync(thermalId, {
|
|
156
|
+
type: "state",
|
|
157
|
+
common: {
|
|
158
|
+
name: `${category} Thermal Start ${timeframe}`,
|
|
159
|
+
type: "number",
|
|
160
|
+
role: "value",
|
|
161
|
+
read: true,
|
|
162
|
+
write: false
|
|
163
|
+
},
|
|
164
|
+
native: {}
|
|
165
|
+
});
|
|
166
|
+
await adapter.setState(powerId, { val: power, ack: true });
|
|
167
|
+
await adapter.setState(thermalId, { val: thermal, ack: true });
|
|
168
|
+
}
|
|
169
|
+
async function update7DaysHistory(adapter, category, currentPower, currentThermal) {
|
|
170
|
+
const historyId = `hidden.cop_buckets.${category}_history_7d`;
|
|
171
|
+
await adapter.setObjectNotExistsAsync(historyId, {
|
|
172
|
+
type: "state",
|
|
173
|
+
common: { name: `${category} 7 Days History`, type: "string", role: "json", read: true, write: false },
|
|
174
|
+
native: {}
|
|
175
|
+
});
|
|
176
|
+
const state = await adapter.getStateAsync(historyId);
|
|
177
|
+
let history = [];
|
|
178
|
+
if (state && typeof state.val === "string" && state.val !== "") {
|
|
179
|
+
try {
|
|
180
|
+
history = JSON.parse(state.val);
|
|
181
|
+
} catch {
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
history.push({ power: currentPower, thermal: currentThermal });
|
|
185
|
+
if (history.length > 7) {
|
|
186
|
+
history.shift();
|
|
187
|
+
}
|
|
188
|
+
await adapter.setState(historyId, { val: JSON.stringify(history), ack: true });
|
|
189
|
+
}
|
|
190
|
+
async function addDeltaToBucket(adapter, category, deltaPower, deltaThermal) {
|
|
191
|
+
const powerId = `hidden.cop_buckets.${category}_power_absolute`;
|
|
192
|
+
const thermalId = `hidden.cop_buckets.${category}_thermal_absolute`;
|
|
193
|
+
const currentPower = await getAbsoluteValue(adapter, category, "power");
|
|
194
|
+
const currentThermal = await getAbsoluteValue(adapter, category, "thermal");
|
|
195
|
+
await adapter.setState(powerId, { val: currentPower + deltaPower, ack: true });
|
|
196
|
+
await adapter.setState(thermalId, { val: currentThermal + deltaThermal, ack: true });
|
|
197
|
+
}
|
|
198
|
+
async function calculateAndWriteCop(adapter, category) {
|
|
199
|
+
const currentPower = await getAbsoluteValue(adapter, category, "power");
|
|
200
|
+
const currentThermal = await getAbsoluteValue(adapter, category, "thermal");
|
|
201
|
+
const dpMap = {
|
|
202
|
+
Total: { today: "cop_total_today", "7d": "cop_total_7d", month: "cop_total_month", year: "cop_total_year" },
|
|
203
|
+
Heating: {
|
|
204
|
+
today: "cop_heating_today",
|
|
205
|
+
"7d": "cop_heating_7d",
|
|
206
|
+
month: "cop_heating_month",
|
|
207
|
+
year: "cop_heating_year"
|
|
208
|
+
},
|
|
209
|
+
HotWater: { today: "cop_water_today", "7d": "cop_water_7d", month: "cop_water_month", year: "cop_water_year" }
|
|
210
|
+
};
|
|
211
|
+
const timeframes = ["today", "month", "year"];
|
|
212
|
+
for (const tf of timeframes) {
|
|
213
|
+
const powerStartId = `hidden.cop_buckets.${category}_power_start_${tf}`;
|
|
214
|
+
const thermalStartId = `hidden.cop_buckets.${category}_thermal_start_${tf}`;
|
|
215
|
+
const pState = await adapter.getStateAsync(powerStartId);
|
|
216
|
+
const tState = await adapter.getStateAsync(thermalStartId);
|
|
217
|
+
const pStart = pState && typeof pState.val === "number" ? pState.val : currentPower;
|
|
218
|
+
const tStart = tState && typeof tState.val === "number" ? tState.val : currentThermal;
|
|
219
|
+
const pUsed = currentPower - pStart;
|
|
220
|
+
const tGen = currentThermal - tStart;
|
|
221
|
+
if (pUsed > 0) {
|
|
222
|
+
const cop = Math.round(tGen / pUsed * 100) / 100;
|
|
223
|
+
const targetId = (0, import_stateMapping.getDpPath)(dpMap[category][tf]);
|
|
224
|
+
if (targetId) {
|
|
225
|
+
await adapter.setState(targetId, { val: cop, ack: true });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const historyId = `hidden.cop_buckets.${category}_history_7d`;
|
|
230
|
+
const hState = await adapter.getStateAsync(historyId);
|
|
231
|
+
if (hState && typeof hState.val === "string" && hState.val !== "") {
|
|
232
|
+
try {
|
|
233
|
+
const history = JSON.parse(hState.val);
|
|
234
|
+
if (history.length > 0) {
|
|
235
|
+
const oldest = history[0];
|
|
236
|
+
const pUsed = currentPower - oldest.power;
|
|
237
|
+
const tGen = currentThermal - oldest.thermal;
|
|
238
|
+
if (pUsed > 0) {
|
|
239
|
+
const cop = Math.round(tGen / pUsed * 100) / 100;
|
|
240
|
+
const targetId = (0, import_stateMapping.getDpPath)(dpMap[category]["7d"]);
|
|
241
|
+
if (targetId) {
|
|
242
|
+
await adapter.setState(targetId, { val: cop, ack: true });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} catch {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
251
|
+
0 && (module.exports = {
|
|
252
|
+
processCopData
|
|
253
|
+
});
|
|
254
|
+
//# sourceMappingURL=copManager.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/copManager.ts"],
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\n// Lokaler Cache f\u00FCr den Z\u00E4hlerstand des letzten Pollings\nlet lastPowerTotal = 0;\nlet lastThermalTotal = 0;\nlet isInitialized = false; // NEU: Sicheres Flag f\u00FCr den Start\n\n/**\n * Verarbeitet die COP-Daten und berechnet Live-Werte anhand von absoluten Z\u00E4hlern und Snapshots.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param bzVal Der aktuelle Betriebszustand der W\u00E4rmepumpe als String.\n * @returns Ein Promise, das nach Abschluss der Berechnung aufgel\u00F6st wird.\n */\nexport async function processCopData(adapter: LuxtronikAdapter, bzVal: string): Promise<void> {\n\tconst config = adapter.config as any;\n\tif (!config.cop_calculation_active) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog(`COP Manager gestartet. Modus: ${bzVal}`, 'debug');\n\t\t// 1. STROMVERBRAUCH ABRUFEN\n\t\tlet currentPower = 0;\n\t\tif (config.cop_source_power === 'external' && config.cop_oid_power_total) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_power_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPower = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('energy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPower = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// 2. W\u00C4RMEMENGE ABRUFEN\n\t\tlet currentThermal = 0;\n\t\tif (config.cop_source_thermal === 'external' && config.cop_oid_thermal_total) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_thermal_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('thermalenergy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermal = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// Initialisierung beim ersten Durchlauf\n\t\tif (!isInitialized) {\n\t\t\tlastPowerTotal = currentPower;\n\t\t\tlastThermalTotal = currentThermal;\n\t\t\tisInitialized = true;\n\t\t\t// WICHTIG: Beim ersten Start pr\u00FCfen wir direkt, ob wir Tageswechsel ansto\u00DFen m\u00FCssen\n\t\t\tawait handleTimeRollover(adapter);\n\t\t\treturn;\n\t\t}\n\n\t\t// 3. DELTA BERECHNEN (Zuwachs seit letztem Polling in kWh)\n\t\tconst deltaPower = currentPower - lastPowerTotal;\n\n\t\tconst deltaThermal = currentThermal - lastThermalTotal;\n\n\t\tlastPowerTotal = currentPower;\n\t\tlastThermalTotal = currentThermal;\n\n\t\t// 4. ZEITWECHSEL PR\u00DCFEN (Hat ein neuer Tag/Monat/Jahr begonnen?)\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// Wenn sich die Z\u00E4hler nicht bewegt haben, keine Eimer f\u00FCllen\n\t\tif (deltaPower > 0 || deltaThermal > 0) {\n\t\t\t// 5. WERTE IN DIE ENDLOS-Z\u00C4HLER VERTEILEN\n\t\t\tawait addDeltaToBucket(adapter, 'Total', deltaPower, deltaThermal);\n\n\t\t\tif (bzVal === '0') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'Heating', deltaPower, deltaThermal);\n\t\t\t} else if (bzVal === '1') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'HotWater', deltaPower, deltaThermal);\n\t\t\t}\n\t\t}\n\n\t\t// 6. LIVE COP BERECHNEN UND SCHREIBEN (Endlosz\u00E4hler minus Snapshot)\n\t\tawait calculateAndWriteCop(adapter, 'Total');\n\t\tawait calculateAndWriteCop(adapter, 'Heating');\n\t\tawait calculateAndWriteCop(adapter, 'HotWater');\n\t} catch (err: any) {\n\t\twriteLog(`Fehler bei der COP-Berechnung: ${err.message}`, 'error');\n\t}\n}\n\n/**\n * Pr\u00FCft auf Tages-, Monats- oder Jahreswechsel und erstellt Snapshots der Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n */\nasync function handleTimeRollover(adapter: LuxtronikAdapter): Promise<void> {\n\twriteLog(`Pr\u00FCfe Tageswechsel und lege Ordner an...`, 'debug');\n\tconst dateStateId = 'hidden.cop_buckets.last_date';\n\tawait adapter.setObjectNotExistsAsync('hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync('hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync(dateStateId, {\n\t\ttype: 'state',\n\t\tcommon: { name: 'Last calculation date', type: 'string', role: 'date', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(dateStateId);\n\tconst lastDate = state && typeof state.val === 'string' ? state.val : '';\n\n\tconst now = new Date();\n\tconst currentDate = now.toISOString().split('T')[0]; // Format: YYYY-MM-DD\n\tconst currentMonth = currentDate.substring(0, 7); // Format: YYYY-MM\n\tconst currentYear = currentDate.substring(0, 4); // Format: YYYY\n\n\tif (lastDate !== currentDate) {\n\t\tconst lastMonth = lastDate ? lastDate.substring(0, 7) : '';\n\t\tconst lastYear = lastDate ? lastDate.substring(0, 4) : '';\n\t\tconst categories = ['Total', 'Heating', 'HotWater'];\n\n\t\tfor (const cat of categories) {\n\t\t\tconst powerAbs = await getAbsoluteValue(adapter, cat, 'power');\n\t\t\tconst thermalAbs = await getAbsoluteValue(adapter, cat, 'thermal');\n\n\t\t\t// IMMER: Tageswechsel Snapshot\n\t\t\tawait setSnapshot(adapter, cat, 'today', powerAbs, thermalAbs);\n\n\t\t\t// Historie f\u00FCr 7-Tage-COP aktualisieren\n\t\t\tawait update7DaysHistory(adapter, cat, powerAbs, thermalAbs);\n\n\t\t\t// Monatswechsel Snapshot\n\t\t\tif (lastMonth !== currentMonth) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'month', powerAbs, thermalAbs);\n\t\t\t}\n\n\t\t\t// Jahreswechsel Snapshot\n\t\t\tif (lastYear !== currentYear) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'year', powerAbs, thermalAbs);\n\t\t\t}\n\t\t}\n\n\t\tawait adapter.setState(dateStateId, { val: currentDate, ack: true });\n\t\twriteLog(`Tageswechsel erkannt. COP-Snapshots f\u00FCr ${currentDate} wurden gesichert.`, 'info');\n\t}\n}\n\n/**\n * Liest den Endlosz\u00E4hler f\u00FCr eine spezifische Kategorie aus.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie (Total, Heating, HotWater).\n * @param type Art der Energie (power oder thermal).\n * @returns Der absolute Wert in kWh.\n */\nasync function getAbsoluteValue(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttype: 'power' | 'thermal',\n): Promise<number> {\n\tconst id = `hidden.cop_buckets.${category}_${type}_absolute`;\n\tawait adapter.setObjectNotExistsAsync(id, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} ${type} Absolute`, type: 'number', role: 'value', read: true, write: false },\n\t\tnative: {},\n\t});\n\tconst state = await adapter.getStateAsync(id);\n\treturn state && typeof state.val === 'number' ? state.val : 0;\n}\n\n/**\n * Schreibt einen Snapshot-Wert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param timeframe Der Zeitraum (today, month, year).\n * @param power Der zu sichernde Stromwert.\n * @param thermal Der zu sichernde W\u00E4rmewert.\n */\nasync function setSnapshot(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttimeframe: string,\n\tpower: number,\n\tthermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;\n\n\tawait adapter.setObjectNotExistsAsync(powerId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Power Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync(thermalId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Thermal Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\n\tawait adapter.setState(powerId, { val: power, ack: true });\n\tawait adapter.setState(thermalId, { val: thermal, ack: true });\n}\n\n/**\n * Verwaltet einen rollierenden 7-Tage-Speicher als JSON.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param currentPower Der absolute Stromz\u00E4hler.\n * @param currentThermal Der absolute W\u00E4rmez\u00E4hler.\n */\nasync function update7DaysHistory(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tcurrentPower: number,\n\tcurrentThermal: number,\n): Promise<void> {\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tawait adapter.setObjectNotExistsAsync(historyId, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} 7 Days History`, type: 'string', role: 'json', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(historyId);\n\tlet history: { power: number; thermal: number }[] = [];\n\n\tif (state && typeof state.val === 'string' && state.val !== '') {\n\t\ttry {\n\t\t\thistory = JSON.parse(state.val);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n\n\thistory.push({ power: currentPower, thermal: currentThermal });\n\tif (history.length > 7) {\n\t\thistory.shift(); // \u00C4ltesten Eintrag entfernen (Ringpuffer)\n\t}\n\n\tawait adapter.setState(historyId, { val: JSON.stringify(history), ack: true });\n}\n\n/**\n * Addiert die neuen kWh-Deltas auf die internen Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die zu aktualisierende Kategorie.\n * @param deltaPower Die verbrauchte elektrische Energie.\n * @param deltaThermal Die erzeugte thermische Energie.\n */\nasync function addDeltaToBucket(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tdeltaPower: number,\n\tdeltaThermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_absolute`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_absolute`;\n\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tawait adapter.setState(powerId, { val: currentPower + deltaPower, ack: true });\n\tawait adapter.setState(thermalId, { val: currentThermal + deltaThermal, ack: true });\n}\n\n/**\n * Liest die Endlosz\u00E4hler und Snapshots aus, berechnet die Differenz und schreibt den COP.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die auszulesende Kategorie (Total, Heating, HotWater).\n */\nasync function calculateAndWriteCop(adapter: LuxtronikAdapter, category: string): Promise<void> {\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\t// Mapping der Ziel-Datenpunkte\n\tconst dpMap: Record<string, Record<string, string>> = {\n\t\tTotal: { today: 'cop_total_today', '7d': 'cop_total_7d', month: 'cop_total_month', year: 'cop_total_year' },\n\t\tHeating: {\n\t\t\ttoday: 'cop_heating_today',\n\t\t\t'7d': 'cop_heating_7d',\n\t\t\tmonth: 'cop_heating_month',\n\t\t\tyear: 'cop_heating_year',\n\t\t},\n\t\tHotWater: { today: 'cop_water_today', '7d': 'cop_water_7d', month: 'cop_water_month', year: 'cop_water_year' },\n\t};\n\n\t// 1. Berechnung f\u00FCr Heute, Monat, Jahr\n\tconst timeframes = ['today', 'month', 'year'];\n\tfor (const tf of timeframes) {\n\t\tconst powerStartId = `hidden.cop_buckets.${category}_power_start_${tf}`;\n\t\tconst thermalStartId = `hidden.cop_buckets.${category}_thermal_start_${tf}`;\n\n\t\tconst pState = await adapter.getStateAsync(powerStartId);\n\t\tconst tState = await adapter.getStateAsync(thermalStartId);\n\n\t\tconst pStart = pState && typeof pState.val === 'number' ? pState.val : currentPower;\n\t\tconst tStart = tState && typeof tState.val === 'number' ? tState.val : currentThermal;\n\n\t\tconst pUsed = currentPower - pStart;\n\t\tconst tGen = currentThermal - tStart;\n\n\t\tif (pUsed > 0) {\n\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\tconst targetId = getDpPath(dpMap[category][tf]);\n\t\t\tif (targetId) {\n\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Berechnung f\u00FCr rollierende 7 Tage\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tconst hState = await adapter.getStateAsync(historyId);\n\tif (hState && typeof hState.val === 'string' && hState.val !== '') {\n\t\ttry {\n\t\t\tconst history = JSON.parse(hState.val);\n\t\t\tif (history.length > 0) {\n\t\t\t\tconst oldest = history[0]; // Das ist der Stand vor bis zu 7 Tagen\n\t\t\t\tconst pUsed = currentPower - oldest.power;\n\t\t\t\tconst tGen = currentThermal - oldest.thermal;\n\t\t\t\tif (pUsed > 0) {\n\t\t\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\t\t\tconst targetId = getDpPath(dpMap[category]['7d']);\n\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAI1B,IAAI,iBAAiB;AACrB,IAAI,mBAAmB;AACvB,IAAI,gBAA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I,QAAQ,GAAG;AACd,YAAM,MAAM,KAAK,MAAO,OAAO,QAAS,GAAG,IAAI;AAC/C,YAAM,eAAW,+BAAU,MAAM,QAAQ,EAAE,EAAE,CAAC;AAC9C,UAAI,UAAU;AACb,cAAM,QAAQ,SAAS,UAAU,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC;AAAA,MACzD;AAAA,IACD;AAAA,EACD;AAGA,QAAM,YAAY,sBAAsB,QAAQ;AAChD,QAAM,SAAS,MAAM,QAAQ,cAAc,SAAS;AACpD,MAAI,UAAU,OAAO,OAAO,QAAQ,YAAY,OAAO,QAAQ,IAAI;AAClE,QAAI;AACH,YAAM,UAAU,KAAK,MAAM,OAAO,GAAG;AACrC,UAAI,QAAQ,SAAS,GAAG;AACvB,cAAM,SAAS,QAAQ,CAAC;AACxB,cAAM,QAAQ,eAAe,OAAO;AACpC,cAAM,OAAO,iBAAiB,OAAO;AACrC,YAAI,QAAQ,GAAG;AACd,gBAAM,MAAM,KAAK,MAAO,OAAO,QAAS,GAAG,IAAI;AAC/C,gBAAM,eAAW,+BAAU,MAAM,QAAQ,EAAE,IAAI,CAAC;AAChD,cAAI,UAAU;AACb,kBAAM,QAAQ,SAAS,UAAU,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC;AAAA,UACzD;AAAA,QACD;AAAA,MACD;AAAA,IACD,QAAQ;AAAA,IAER;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/main.js
CHANGED
|
@@ -25,6 +25,7 @@ var utils = __toESM(require("@iobroker/adapter-core"));
|
|
|
25
25
|
var import_actionHandlers = require("./actionHandlers");
|
|
26
26
|
var import_backupManager = require("./backupManager");
|
|
27
27
|
var import_convert = require("./convert");
|
|
28
|
+
var import_copManager = require("./copManager");
|
|
28
29
|
var import_hupManager = require("./hupManager");
|
|
29
30
|
var import_logger = require("./logger");
|
|
30
31
|
var import_notificationManager = require("./notificationManager");
|
|
@@ -542,6 +543,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
542
543
|
}
|
|
543
544
|
this.errorCount = 0;
|
|
544
545
|
await this.setState("info.connection", { val: true, ack: true });
|
|
546
|
+
await this.setState("info.lastUpdate", { val: (/* @__PURE__ */ new Date()).toISOString(), ack: true });
|
|
545
547
|
const statePromises = [];
|
|
546
548
|
const config = this.config;
|
|
547
549
|
for (const [key, definition] of Object.entries(import_stateMapping.STATE_MAPPING)) {
|
|
@@ -654,6 +656,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
654
656
|
await (0, import_virtualStates.updateCustomStates)(this, rawValues, rawParams);
|
|
655
657
|
await (0, import_virtualStates.updateTimerTables)(this);
|
|
656
658
|
await (0, import_virtualStates.updateSystemInfos)(this, rawValues);
|
|
659
|
+
const bzState = await this.getStateAsync((0, import_stateMapping.getDpPath)("WP_BZ_akt"));
|
|
660
|
+
const currentBzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : "";
|
|
661
|
+
this.log.debug(`=> Rufe jetzt den COP Manager auf. BZ ist: ${currentBzVal}`);
|
|
662
|
+
await (0, import_copManager.processCopData)(this, currentBzVal);
|
|
657
663
|
await this.runOptimizationSchedule();
|
|
658
664
|
} catch (err) {
|
|
659
665
|
this.errorCount++;
|
package/build/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v3.1.5\n */\nimport * as utils from '@iobroker/adapter-core';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initAutoBackup, stopAutoBackup } from './backupManager';\nimport { formatTimerSecondsToTime, timeStringToSeconds } from './convert';\nimport { handleHupOptimization } from './hupManager';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport {\n\tcheckAndSendErrorNotifications,\n\tcheckAndSendOutageNotifications,\n\thandleTestMessage,\n\tsendTelegramNotification,\n} from './notificationManager';\nimport {\n\tcleanupCustomStates,\n\tcleanupEmptyFolders,\n\tcleanupStates,\n\tensureAllObjectsExist,\n\tensureCustomObjectsExist,\n\tisStateEnabled,\n} from './objectManager';\nimport { dumpAllRawToLog, queueWrite, readAllRaw } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport { generateHeatCurveSVG } from './svgGenerator';\nimport type { LuxtronikAdapter } from './types';\nimport {\n\tcalculateTemperatureSpread,\n\tcalculateTotalEnergy,\n\tcalculateTotalThermalEnergy,\n\tupdateCustomStates,\n\tupdateErrorHistory,\n\tupdateOutageHistory,\n\tupdateStatusStrings,\n\tupdateSystemInfos,\n\tupdateTimerTables,\n} from './virtualStates';\nimport {\n\tcheckAndHandleMotionSensor,\n\tdisableHardwareZipTimer,\n\thandleActivateZip,\n\tstopZipAndDeaeration,\n\tsubscribeMotionSensors,\n} from './zipManager';\n\n/**\n * Main class for the Luxtronik2 Controller ioBroker Adapter.\n */\nclass Luxtronik2Controller extends utils.Adapter implements LuxtronikAdapter {\n\t/** Set of all active namespaced state IDs created or managed by the adapter */\n\tpublic createdStates: Set<string> = new Set<string>();\n\t/** ioBroker timeout handle for the hot water circulation pump macro */\n\tpublic zipTimer?: ioBroker.Timeout;\n\t/** Cached copy of the original circulation pump settings before macro activation */\n\tpublic originalZipConfig: Record<string, any> | null = null;\n\t/** Unix timestamp of the last error dispatched to prevent duplicate notification triggers */\n\tpublic lastKnownErrorTimestamp: number | null = null;\n\t/** Determines whether verbose debugging output is enabled */\n\tpublic isDebugLogActive: boolean = false;\n\t//* Known Visibilities */\n\tpublic currentVisibilities: number[] = [];\n\t// Cache f\u00FCr den globalen Schreibschutz\n\tpublic currentRawParams: number[] = [];\n\t/** ioBroker interval handle for the main data polling loop */\n\tprivate pollingInterval: ioBroker.Interval | undefined;\n\t/** Cache for the last evaluated heat pump operating state code */\n\tprivate lastBzVal: string = '';\n\t/** Lock flag preventing concurrent execution of the polling updates */\n\tpublic updateRunning: boolean = false;\n\t/** Timestamp tracking the last dynamic pump voltage optimization execution */\n\tprivate lastPumpOptimization: number = 0;\n\n\t/** Internal array storing pending serial hardware write tasks */\n\tpublic writeQueue: (() => Promise<void>)[] = [];\n\t/** Lock flag indicating that the write queue is currently being processed */\n\tpublic isWriting: boolean = false;\n\t/** Counter tracking sequential communication timeouts/failures */\n\tprivate errorCount: number = 0;\n\t/** Maximum allowed sequential request failures before connection is flagged as interrupted */\n\tprivate readonly MAX_ERRORS: number = 3;\n\tpublic writeCyclesToday: number = 0;\n\tpublic writeCyclesTotal: number = 0;\n\tprivate midnightTimer?: ioBroker.Timeout;\n\n\t/**\n\t * Initializes a new instance of the Luxtronik2Controller class.\n\t *\n\t * @param options - Optional core configuration overrides passed by the ioBroker host.\n\t */\n\tpublic constructor(options: Partial<utils.AdapterOptions> = {}) {\n\t\tsuper({\n\t\t\t...options,\n\t\t\tname: 'luxtronik2-controller',\n\t\t});\n\t\tinitLogger(this);\n\n\t\tthis.on('ready', this.onReady.bind(this));\n\t\tthis.on('stateChange', this.onStateChange.bind(this));\n\t\tthis.on('unload', this.onUnload.bind(this));\n\t\tthis.on('message', this.onMessage.bind(this));\n\t}\n\n\tprivate async onMessage(obj: ioBroker.Message): Promise<void> {\n\t\tif (obj.command === 'testTelegram') {\n\t\t\tawait handleTestMessage(this, obj);\n\t\t} else if (obj.command === 'getHeatCurve') {\n\t\t\ttry {\n\t\t\t\tlet fp = 21.7;\n\t\t\t\tlet ep = 23.0;\n\n\t\t\t\t// Werte aus der Config-UI auslesen\n\t\t\t\tif (obj.message && typeof obj.message === 'object') {\n\t\t\t\t\tconst msg = obj.message as Record<string, any>;\n\t\t\t\t\tif (msg.fusspunkt !== undefined) {\n\t\t\t\t\t\tfp = parseFloat(msg.fusspunkt);\n\t\t\t\t\t}\n\t\t\t\t\tif (msg.endpunkt !== undefined) {\n\t\t\t\t\t\tep = parseFloat(msg.endpunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Fallbacks, falls der Nutzer Quatsch eintippt\n\t\t\t\tif (isNaN(fp)) {\n\t\t\t\t\tfp = 21.7;\n\t\t\t\t}\n\t\t\t\tif (isNaN(ep)) {\n\t\t\t\t\tep = 23.0;\n\t\t\t\t}\n\n\t\t\t\t// SVG generieren und als Base64-Bild verpacken\n\t\t\t\tconst svg = generateHeatCurveSVG(fp, ep);\n\t\t\t\tconst base64 = `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;\n\n\t\t\t\t// Bild zur\u00FCck an die Benutzeroberfl\u00E4che schicken!\n\t\t\t\tif (obj.callback) {\n\t\t\t\t\tthis.sendTo(obj.from, obj.command, base64, obj.callback);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\tthis.log.error(`Error generating heat curve: ${err.message}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Callback executed once the ioBroker host framework completely initializes the adapter subsystem.\n\t * Sets up database objects, applies configurations, subscribes to states, and triggers the polling loop.\n\t *\n\t * @returns A promise that resolves when initialization completes.\n\t */\n\tprivate async onReady(): Promise<void> {\n\t\tconst config = this.config as Record<string, any>;\n\t\tconst ip = config.host;\n\t\tconst port = config.port || 8889;\n\n\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\twriteLog(`Connecting to heat pump at ${ip}:${port}...`, 'info');\n\n\t\t// Visibilities einmalig beim Start abfragen f\u00FCr den intelligenten Objekt-Filter\n\t\t// (Wird nur ausgef\u00FChrt, wenn der Nutzer die Funktion in den Settings nicht deaktiviert hat)\n\t\tif (config.filter_visibility !== false) {\n\t\t\ttry {\n\t\t\t\tthis.currentVisibilities = await readAllRaw(this, 3005);\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Successfully loaded ${this.currentVisibilities.length} visibility flags from heat pump.`,\n\t\t\t\t\t\t'debug',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`Could not load visibility flags (Command 3005). Assuming all parameters are visible. Error: ${err.message}`,\n\t\t\t\t\t'warn',\n\t\t\t\t);\n\t\t\t\tthis.currentVisibilities = [];\n\t\t\t}\n\t\t} else {\n\t\t\t// Nutzer hat den Filter deaktiviert -> Array bleibt leer, alles wird angezeigt\n\t\t\tthis.currentVisibilities = [];\n\t\t}\n\n\t\tawait cleanupStates(this);\n\t\tawait cleanupCustomStates(this);\n\t\tawait cleanupEmptyFolders(this);\n\t\tawait ensureAllObjectsExist(this);\n\t\tawait ensureCustomObjectsExist(this);\n\t\tinitAutoBackup(this);\n\n\t\t// Strikte \"Opt-In\" Pr\u00FCfung beim Start\n\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\n\t\tconst debugState = await this.getStateAsync(getDpPath('Schreibe_Debug_Log'));\n\t\tthis.isDebugLogActive = debugState?.val === true;\n\t\tsetCustomDebug(this.isDebugLogActive);\n\n\t\tawait disableHardwareZipTimer(this);\n\n\t\t// Schreib-Z\u00E4hler aus ioBroker laden (sichert den Stand bei einem Adapter-Neustart)\n\t\tconst cycleTodayState = await this.getStateAsync(getDpPath('write_cycles_today'));\n\t\tthis.writeCyclesToday = cycleTodayState && typeof cycleTodayState.val === 'number' ? cycleTodayState.val : 0;\n\n\t\tconst cycleTotalState = await this.getStateAsync(getDpPath('write_cycles_total'));\n\t\tthis.writeCyclesTotal = cycleTotalState && typeof cycleTotalState.val === 'number' ? cycleTotalState.val : 0;\n\n\t\tthis.scheduleMidnightReset(); // Startet den 00:00 Uhr Timer (nur f\u00FCr den Tagesz\u00E4hler!)\n\t\tsubscribeMotionSensors(this);\n\n\t\tthis.subscribeStates('*');\n\n\t\ttry {\n\t\t\tawait this.updateData();\n\t\t} catch (error: any) {\n\t\t\tthis.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);\n\t\t}\n\n\t\t// Virtuelle ZIP-Datenpunkte beim Start initialisieren, um 'null' Werte zu vermeiden\n\t\tconst dpActivateZip = getDpPath('Activate_Zip');\n\t\tif (dpActivateZip) {\n\t\t\tawait this.setState(dpActivateZip, { val: false, ack: true });\n\t\t}\n\n\t\tconst dpVirtualZipStatus = getDpPath('Virtual_ZIP_Status');\n\t\tif (dpVirtualZipStatus) {\n\t\t\tawait this.setState(dpVirtualZipStatus, { val: false, ack: true });\n\t\t}\n\n\t\tlet intervalSeconds = this.config.interval ? Number(this.config.interval) : 45;\n\t\tif (intervalSeconds < 10) {\n\t\t\tintervalSeconds = 10;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval was too short. Forced to minimum threshold of 10 seconds for protection.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\t\tif (intervalSeconds > 3600) {\n\t\t\tintervalSeconds = 3600;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval exceeded maximum boundary. Restricted to 3600 seconds to prevent overflow issues.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\n\t\tthis.pollingInterval = this.setInterval(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.updateData();\n\t\t\t} catch (error: any) {\n\t\t\t\tthis.log.error(`Error during cyclic data retrieval loop: ${error.message}`);\n\t\t\t}\n\t\t}, intervalSeconds * 1000);\n\n\t\tawait this.setState('info.connection', true, true);\n\t}\n\n\t/**\n\t * Berechnet die Zeit bis Mitternacht und setzt NUR den heutigen Schreibz\u00E4hler auf 0 zur\u00FCck.\n\t */\n\tprivate scheduleMidnightReset(): void {\n\t\tconst now = new Date();\n\t\tconst night = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);\n\t\tconst msToMidnight = night.getTime() - now.getTime();\n\n\t\tthis.midnightTimer = this.setTimeout(() => {\n\t\t\tthis.writeCyclesToday = 0;\n\t\t\tvoid this.setState(getDpPath('write_cycles_today'), { val: 0, ack: true });\n\n\t\t\t// Timer f\u00FCr den n\u00E4chsten Tag neu aufziehen\n\t\t\tthis.scheduleMidnightReset();\n\t\t}, msToMidnight);\n\t}\n\n\t/**\n\t * Synchronizes a single state configuration parameter with the Luxtronik physical controller.\n\t *\n\t * @param mappingKey - The unique key identifier within the STATE_MAPPING structure.\n\t * @param val - The raw or parsed value to apply.\n\t * @returns A promise that resolves when the synchronization task finishes.\n\t */\n\tpublic async syncConfigValue(mappingKey: keyof typeof STATE_MAPPING, val: any): Promise<void> {\n\t\tif (val === undefined || val === null) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tif (!state || state.val !== val) {\n\t\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\t\tif (!definition) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(id, { val: val, ack: true });\n\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\twriteLog(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, 'info');\n\t\t\t}\n\n\t\t\tif (definition.write === true && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\tlet valueToWrite: any = val;\n\t\t\t\tif (definition.factor && typeof val === 'number') {\n\t\t\t\t\tvalueToWrite = val * definition.factor;\n\t\t\t\t}\n\n\t\t\t\tconst isRawWrite =\n\t\t\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\t\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !definition.factor) {\n\t\t\t\t\tvalueToWrite = val * 10;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\t\t\tconst writeId = isRawWrite ? parseInt(targetWriteId, 10) : targetWriteId;\n\t\t\t\t\tawait queueWrite(this, writeId, valueToWrite);\n\t\t\t\t\tawait new Promise(r => global.setTimeout(r, 200));\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Failed to transmit ${mappingKey} to the heat pump hardware interface: ${err.message}`,\n\t\t\t\t\t\t'error',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Safely updates an internal database state value only if the newly supplied value differs from the existing entry.\n\t *\n\t * @param id - The relative state path ID.\n\t * @param val - The updated value to process.\n\t * @param ack - Explicit acknowledgment flag status to set.\n\t * @returns A promise that resolves when the verification and write operation completes.\n\t */\n\tpublic async setOwnStateIfDifferent(id: string, val: any, ack = false): Promise<void> {\n\t\ttry {\n\t\t\tif (val === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = await this.getStateAsync(id);\n\t\t\tif (!state || state.val !== val) {\n\t\t\t\tawait this.setState(id, { val: val, ack: ack });\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(`Applying specific update for local state ${id}: ${val}`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Configures fallback factory parameter baselines for the heat pump when in an idle state.\n\t *\n\t * @returns A promise that resolves when all default configuration tasks resolve.\n\t */\n\tprivate async setIdleDefaults(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tawait this.syncConfigValue('heating_curve_end_point', config.endpunkt ?? 23);\n\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', config.fusspunkt ?? 21.7);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('temperature_hot_water_target', config.sync_warmwater_target_temperature ?? 54);\n\t\t\tawait this.syncConfigValue('returnTemperatureHysteresis', config.sync_return_temperature_hysteresis ?? 1.5);\n\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Failed to apply the baseline idle configuration defaults: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Evaluates whether the current active operating state timestamp is older than ten minutes.\n\t *\n\t * @returns A promise that resolves to true if the state has remained unaltered for at least 10 minutes.\n\t */\n\tprivate async istBetriebszustandAelterAls10Min(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst state = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst lastChange = state?.lc ?? 0;\n\t\t\treturn (Date.now() - lastChange) / 60000 >= 10;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Primary intelligent engine analyzing live telemetry values to execute continuous performance optimizations.\n\t * Manages dynamic heating curves, anti-cycling protective delays, and voltage scaling algorithms.\n\t *\n\t * @returns A promise that resolves when the execution cycle finishes.\n\t */\n\tprivate async runOptimizationSchedule(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\t// Live-Status des ioBroker Schalters \"Regelung_Aktiv\" auslesen\n\t\t\tconst regelungAktivState = await this.getStateAsync(getDpPath('Regelung_Aktiv'));\n\t\t\tconst isRegelungAktiv = regelungAktivState?.val === true;\n\n\t\t\tconst istHeizen = bzVal === '0';\n\t\t\tconst istWarmwasser = bzVal === '1';\n\t\t\tconst istAbtauen = bzVal === '4';\n\t\t\tconst istLeerlauf = bzVal === '5';\n\n\t\t\tif (!istHeizen && !istWarmwasser && !istLeerlauf && !istAbtauen) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// =========================================================\n\t\t\t// 1. DYNAMIC PARAMETER ADJUSTMENT UPON STATE SWITCH\n\t\t\t// =========================================================\n\t\t\tif (bzVal !== this.lastBzVal) {\n\t\t\t\tif (istLeerlauf) {\n\t\t\t\t\tif (config.idle_defaults_aktiv === true) {\n\t\t\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\t\t}\n\t\t\t\t} else if (istHeizen) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\t\t\t}\n\t\t\t\t\tif (config.hup_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t\t\t\t}\n\t\t\t\t} else if (istWarmwasser) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\t\t// Pr\u00FCfen, ob externe Aktoren konfiguriert sind\n\t\t\t\t\t\tconst actors = config.actors || [];\n\t\t\t\t\t\tconst validActors = actors.filter(\n\t\t\t\t\t\t\t(a: any) => a.zip_external_relay_id && a.zip_external_relay_id.trim() !== '',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Wenn Aktoren da sind, k\u00F6nnen wir die Zirkulation bedenkenlos starten (0 Flash-Schreibvorg\u00E4nge!)\n\t\t\t\t\t\tif (validActors.length > 0) {\n\t\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\t\tthis.log.debug(\n\t\t\t\t\t\t\t\t\t'[ZIP] Externe Aktoren gefunden. Starte Zirkulation synchron zur Warmwasserbereitung.',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Dauer aus der Config holen (mit einem sinnvollen Fallback von z.B. 120 Sekunden)\n\t\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 120);\n\t\t\t\t\t\t\t// Makro \u00FCber den Trigger-Datenpunkt ausl\u00F6sen\n\t\t\t\t\t\t\tawait this.setOwnStateIfDifferent(getDpPath('Activate_Zip'), true, false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (config.hup_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_water ?? 3,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_water ?? 10,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.lastBzVal = bzVal;\n\t\t\t}\n\n\t\t\tconst [\n\t\t\t\twwSollState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\n\t\t\t\theatingStateStrState,\n\t\t\t\tvd1State,\n\t\t\t\twwHystereseState,\n\t\t\t\truecklaufSollState,\n\t\t\t\tcurrentHupVoltState,\n\t\t\t\theizenHystereseState,\n\t\t\t\tnachWasserState,\n\t\t\t\tmitteltempState,\n\t\t\t\tthresholdHeatingLimitstate,\n\t\t\t\theatingLimitState,\n\t\t\t\taelterAls10,\n\t\t\t] = await Promise.all([\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('spreizung_vorlauf_ruecklauf')),\n\t\t\t\tthis.getStateAsync(getDpPath('opStateHeatingString')),\n\t\t\t\tthis.getStateAsync(getDpPath('VD1out')),\n\t\t\t\tthis.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('heating_system_circ_pump_voltage_nominal')),\n\t\t\t\tthis.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('Heizen_nach_Wasser')),\n\t\t\t\tthis.getStateAsync(getDpPath('Mitteltemperatur')),\n\t\t\t\tthis.getStateAsync(getDpPath('thresholdHeatingLimit')),\n\t\t\t\tthis.getStateAsync(getDpPath('heatingLimit')),\n\t\t\t\tthis.istBetriebszustandAelterAls10Min(),\n\t\t\t]);\n\n\t\t\tconst wwSoll = (wwSollState?.val as number) ?? 0;\n\t\t\tconst wwIst = (wwIstState?.val as number) ?? 0;\n\t\t\tconst ruecklauf = (ruecklaufState?.val as number) ?? 0;\n\t\t\tconst spreizung = (spreizungState?.val as number) ?? 0;\n\t\t\tconst heatingStateStr = String(heatingStateStrState?.val || '').trim();\n\t\t\tconst vd1 = vd1State?.val === 1;\n\t\t\tconst wwHysterese = (wwHystereseState?.val as number) ?? 0;\n\t\t\tconst ruecklaufSoll = (ruecklaufSollState?.val as number) ?? 0;\n\t\t\tconst currentHupVolt = (currentHupVoltState?.val as number) ?? 7.0;\n\t\t\tconst heizenHysterese = (heizenHystereseState?.val as number) ?? 0;\n\t\t\tconst mitteltemperatur = (mitteltempState?.val as number) ?? 0;\n\t\t\tconst thresholdHeatingLimit = (thresholdHeatingLimitstate?.val as number) ?? 0;\n\t\t\tconst heatingLimit = (heatingLimitState?.val as number) ?? 0;\n\t\t\tconst nachWasser = nachWasserState?.val;\n\n\t\t\t// =========================================================\n\t\t\t// 2. CONTINUOUS IN-SERVICE TELEMETRY EVALUATION\n\t\t\t// =========================================================\n\t\t\tif (istHeizen) {\n\t\t\t\tif (isRegelungAktiv && aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunkt = (await this.getStateAsync(getDpPath('heating_curve_parallel_offset')))?.val;\n\t\t\t\t\tif (fusspunkt === 35) {\n\t\t\t\t\t\tconst fallbackFusspunkt = config.fusspunkt ?? 21.7;\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', fallbackFusspunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// FIX: HUP-Optimierung nur aufrufen, wenn die Anlage mindestens 10 Minuten heizt\n\t\t\t\t// UND der Verdichter (vd1) l\u00E4uft. Vorher ist die Spreizung physikalisch nicht aussagekr\u00E4ftig.\n\t\t\t\tif (aelterAls10 && vd1) {\n\t\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\tistHeizen,\n\t\t\t\t\t\tspreizung,\n\t\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\t\tthis.lastPumpOptimization,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\t// WICHTIG: Heizen_nach_Wasser Logik (Reset & Setzen)\n\t\t\t\t\tif (ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\tif (aelterAls10) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', false);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!nachWasser && config.Heating_after_warmwater === true) {\n\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', true);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Warmwassertakt erzwingen\n\t\t\t\t\tif (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\t// Neuen Sollwert berechnen: Ist-Wert + aktuelle Hysterese + 1.5K Puffer\n\t\t\t\t\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t\t\t\t\t// Sicherheitspr\u00FCfung: Maximaltemperatur kappen (Passend zu actionHandlers = 70\u00B0C)\n\t\t\t\t\t\tif (forceSoll > 70) {\n\t\t\t\t\t\t\tforceSoll = 70;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tforceSoll = Math.round(forceSoll * 10) / 10;\n\n\t\t\t\t\t\t// Statt Hysterese wird nun der Sollwert tempor\u00E4r erh\u00F6ht, um den WW-Takt k\u00FCnstlich anzusto\u00DFen\n\t\t\t\t\t\tawait this.syncConfigValue('temperature_hot_water_target', forceSoll);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\tif ((heatingLimit === 1 && mitteltemperatur < thresholdHeatingLimit) || heatingLimit === 0) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istLeerlauf) {\n\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\tif (wwIst <= wwSoll - wwHysterese || ruecklauf <= ruecklaufSoll - heizenHysterese) {\n\t\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\tif (\n\t\t\t\t\t\twwSoll - wwIst >= wwHysterese - 1.5 &&\n\t\t\t\t\t\truecklauf <= ruecklaufSoll &&\n\t\t\t\t\t\theatingStateStr !== 'Heating limit'\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during runOptimizationSchedule loop execution: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Fetches, parses, converts types, and populates live data registries over the configured TCP socket.\n\t * Dispatches calculation and history logging subroutines accordingly.\n\t *\n\t * @returns A promise that resolves when the internal update registers conclude.\n\t */\n\tprivate async updateData(): Promise<void> {\n\t\tif (this.updateRunning) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Schreibvorg\u00E4nge haben absolute Priorit\u00E4t!\n\t\t// Wenn gerade geschrieben wird, \u00FCberspringen wir den Lese-Zyklus,\n\t\t// um alte Anlagen vor abst\u00FCrzenden Netzwerk-Sockets zu sch\u00FCtzen.\n\t\tif (this.isWriting) {\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\tthis.log.debug('Skipping read cycle because a write operation is currently in progress.');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateRunning = true;\n\t\ttry {\n\t\t\tconst delayHelper = (ms: number): Promise<void> => new Promise(resolve => this.setTimeout(resolve, ms));\n\n\t\t\tlet rawParams: number[] = [];\n\t\t\tlet rawValues: number[] = [];\n\n\t\t\ttry {\n\t\t\t\trawParams = await readAllRaw(this, 3003);\n\t\t\t\tthis.currentRawParams = rawParams; //Cache f\u00FCr Schreibschutz aktuell halten\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait delayHelper(200);\n\n\t\t\ttry {\n\t\t\t\trawValues = await readAllRaw(this, 3004);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tfor (const [key, definition] of Object.entries(STATE_MAPPING)) {\n\t\t\t\tif (definition.isVirtual) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!isStateEnabled(key, definition, config, this.currentVisibilities)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst luxId = definition.luxWriteId || key;\n\t\t\t\tlet value: any = undefined;\n\n\t\t\t\t// DYNAMISCHER FAKTOR F\u00DCR HUP\n\t\t\t\tlet appliedFactor = definition.factor;\n\t\t\t\tif (\n\t\t\t\t\tkey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\t\t\tkey === 'heating_system_circ_pump_voltage_minimal'\n\t\t\t\t) {\n\t\t\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t\t\t}\n\n\t\t\t\tif (definition.dataSource) {\n\t\t\t\t\tswitch (definition.dataSource) {\n\t\t\t\t\t\tcase 'raw_parameter':\n\t\t\t\t\t\t\tvalue = rawParams?.[parseInt(luxId, 10)];\n\t\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'raw_value':\n\t\t\t\t\t\t\tvalue = rawValues?.[parseInt(luxId, 10)];\n\t\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'parameter':\n\t\t\t\t\t\tcase 'value':\n\t\t\t\t\t\tcase 'additional':\n\t\t\t\t\t\t\tvalue = undefined;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (/^\\d+$/.test(luxId)) {\n\t\t\t\t\t\tconst idx = parseInt(luxId, 10);\n\t\t\t\t\t\tvalue = definition.folder.startsWith('Settings') ? rawParams?.[idx] : rawValues?.[idx];\n\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (value !== undefined && typeof value === 'number' && appliedFactor) {\n\t\t\t\t\tvalue = Math.round(value * 100) / 100;\n\t\t\t\t}\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tif (definition.type === 'number' && typeof value === 'string') {\n\t\t\t\t\t\tvalue =\n\t\t\t\t\t\t\tvalue.toLowerCase() === 'ein' ? 1 : value.toLowerCase() === 'aus' ? 0 : parseFloat(value);\n\t\t\t\t\t} else if (definition.type === 'boolean') {\n\t\t\t\t\t\tvalue =\n\t\t\t\t\t\t\tvalue === true ||\n\t\t\t\t\t\t\tvalue === 1 ||\n\t\t\t\t\t\t\tString(value).toLowerCase() === 'ein' ||\n\t\t\t\t\t\t\tString(value).toLowerCase() === 'true';\n\t\t\t\t\t} else if (definition.type === 'json' && typeof value === 'object') {\n\t\t\t\t\t\tvalue = JSON.stringify(value);\n\t\t\t\t\t}\n\n\t\t\t\t\t// INTERNER HACK F\u00DCR DEN LUXTRONIK ANZEIGEFEHLER (1 Sekunde -> 0 Sekunden)\n\t\t\t\t\tlet finalSeconds = Number(value);\n\t\t\t\t\tif (definition.isDurationFormat && key === 'Time_WPein_akt' && finalSeconds === 1) {\n\t\t\t\t\t\tfinalSeconds = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (definition.isDurationFormat) {\n\t\t\t\t\t\tvalue = formatTimerSecondsToTime(finalSeconds);\n\t\t\t\t\t} else if (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\tconst totalSeconds = typeof value === 'number' ? value : parseInt(value as string, 10);\n\t\t\t\t\t\tif (!isNaN(totalSeconds) && totalSeconds >= 0) {\n\t\t\t\t\t\t\tif (totalSeconds < 86400) {\n\t\t\t\t\t\t\t\tconst h = Math.floor(totalSeconds / 3600)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tconst m = Math.floor((totalSeconds % 3600) / 60)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tvalue = `${h}:${m}`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = new Date(totalSeconds * 1000).toISOString().replace('T', ' ').substring(0, 19);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet targetIoBrokerType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\ttargetIoBrokerType = 'string';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (targetIoBrokerType === 'string' && typeof value !== 'string') {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'number' && typeof value !== 'number') {\n\t\t\t\t\t\tvalue = Number(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'boolean' && typeof value !== 'boolean') {\n\t\t\t\t\t\tvalue = Boolean(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this);\n\t\t\tawait calculateTotalEnergy(this);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Fehler-Historie abarbeiten & Alarmieren\n\t\t\t// ----------------------------------------------------\n\t\t\tconst fehlerDp = getDpPath('Fehlerspeicher');\n\t\t\tconst oldFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst oldFehlerVal = oldFehlerState?.val as string | undefined;\n\n\t\t\tawait updateErrorHistory(this, rawValues);\n\n\t\t\tconst newFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst newFehlerVal = newFehlerState?.val as string | undefined;\n\n\t\t\tawait checkAndSendErrorNotifications(this, oldFehlerVal, newFehlerVal);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Abschalt-Historie abarbeiten & Alarmieren (Durchfluss)\n\t\t\t// ----------------------------------------------------\n\t\t\tconst abschaltungDp = getDpPath('Abschaltungen');\n\t\t\tconst oldAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst oldAbschaltungVal = oldAbschaltungState?.val as string | undefined;\n\n\t\t\tawait updateOutageHistory(this, rawValues);\n\n\t\t\tconst newAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst newAbschaltungVal = newAbschaltungState?.val as string | undefined;\n\n\t\t\tawait checkAndSendOutageNotifications(this, oldAbschaltungVal, newAbschaltungVal);\n\t\t\t// ----------------------------------------------------\n\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\t\t\tawait this.runOptimizationSchedule();\n\t\t} catch (err: any) {\n\t\t\tthis.errorCount++;\n\t\t\twriteLog(\n\t\t\t\t`Communication error encountered (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\n\t\t\tif (this.errorCount >= this.MAX_ERRORS) {\n\t\t\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\t\t\twriteLog('Heat pump controller unreachable. Flagging connection status as disconnected.', 'warn');\n\t\t\t\tsendTelegramNotification(\n\t\t\t\t\tthis,\n\t\t\t\t\t'Heat pump controller unreachable. Flagging connection status as disconnected.',\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.updateRunning = false;\n\t\t}\n\t}\n\n\t/**\n\t * Callback issued by the ioBroker framework during adapter shutdown sequences.\n\t *\n\t * @param callback - Termination completion trigger function.\n\t */\n\tprivate onUnload(callback: () => void): void {\n\t\ttry {\n\t\t\tif (this.pollingInterval) {\n\t\t\t\tclearInterval(this.pollingInterval);\n\t\t\t}\n\t\t\tif (this.zipTimer) {\n\t\t\t\tclearTimeout(this.zipTimer);\n\t\t\t}\n\n\t\t\tstopAutoBackup(this);\n\n\t\t\tif (this.midnightTimer) {\n\t\t\t\tthis.clearTimeout(this.midnightTimer);\n\t\t\t}\n\n\t\t\tvoid this.setState('info.connection', { val: false, ack: true });\n\n\t\t\twriteLog(\n\t\t\t\t'Adapter is shutting down. Cleared all active intervals and terminated open socket configurations cleanly.',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tcallback();\n\t\t} catch {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\t/**\n\t * Central observer callback executed whenever a subscribed state receives an update.\n\t *\n\t * @param id - The explicit full namespaced state identifier path.\n\t * @param state - The newly applied state context or null context if dropped.\n\t * @returns A promise that resolves when operations complete.\n\t */\n\tprivate async onStateChange(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bewegungsmelder an den Manager auslagern\n\t\tconst isMotionSensor = await checkAndHandleMotionSensor(this, id, state);\n\t\tif (isMotionSensor) {\n\t\t\treturn; // Der zipManager hat das Event verarbeitet, wir sind hier fertig\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (id.startsWith(`${this.namespace}.Custom.`)) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getObjectAsync(id);\n\n\t\t\t\tif (obj && obj.native && obj.native.source === 'parameter') {\n\t\t\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\t\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\t\t\tif (obj.native.customType === 'boolean') {\n\t\t\t\t\t\tvalueToWrite = state.val ? 1 : 0;\n\t\t\t\t\t} else if (obj.native.customType === 'number' && typeof state.val === 'number') {\n\t\t\t\t\t\tif (obj.native.factor) {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val / obj.native.factor);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst targetWriteId = parseInt(obj.native.luxId, 10);\n\t\t\t\t\tif (!isNaN(targetWriteId)) {\n\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,\n\t\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait queueWrite(this, targetWriteId, valueToWrite);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, 'error');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tif (!mappingKey) {\n\t\t\treturn;\n\t\t}\n\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\tif (!definition) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\t\twriteLog(\n\t\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Regelung_Aktiv' || mappingKey === 'zip_aktiv') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Setze_Vorgabewerte' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait dumpAllRawToLog(this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangswarmwasser') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangswarmwasser(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangsheizen') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangsheizen(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Activate_Zip') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tconst durationState = await this.getStateAsync(getDpPath('zip_aktiv'));\n\t\t\t\t\tconst durationSeconds =\n\t\t\t\t\t\tdurationState && typeof durationState.val === 'number' ? durationState.val : 120;\n\t\t\t\t\tawait handleActivateZip(this, id, durationSeconds);\n\t\t\t\t} else {\n\t\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!definition.luxWriteId || definition.write !== true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (\n\t\t\t\tdefinition.isDurationFormat ||\n\t\t\t\tdefinition.role === 'value.datetime' ||\n\t\t\t\tdefinition.role === 'value.time'\n\t\t\t) {\n\t\t\t\tvalueToWrite = timeStringToSeconds(state.val);\n\t\t\t} else if (definition.factor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * definition.factor;\n\t\t\t}\n\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !definition.factor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\tawait queueWrite(this, parseInt(targetWriteId, 10), valueToWrite);\n\t\t} catch (err: any) {\n\t\t\twriteLog(\n\t\t\t\t`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\t\t}\n\t}\n}\n\nif (require.main !== module) {\n\tmodule.exports = (options: Partial<utils.AdapterOptions> | undefined) => new Luxtronik2Controller(options);\n} else {\n\t(() => new Luxtronik2Controller())();\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAuB;AACvB,4BAA2D;AAC3D,2BAA+C;AAC/C,qBAA8D;AAC9D,wBAAsC;AACtC,oBAAqD;AACrD,iCAKO;AACP,2BAOO;AACP,0BAAwD;AACxD,0BAAyC;AACzC,0BAAqC;AAErC,2BAUO;AACP,wBAMO;AAKP,MAAM,6BAA6B,MAAM,QAAoC;AAAA;AAAA,EAErE,gBAA6B,oBAAI,IAAY;AAAA;AAAA,EAE7C;AAAA;AAAA,EAEA,oBA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c,MAAM;AAC9E,oBAAM,qCAAkB,MAAM,IAAI,eAAe;AAAA,QAClD,OAAO;AACN,gBAAM,KAAK,SAAS,YAAY,EAAE,KAAK,OAAO,KAAK,KAAK,CAAC;AACzD,oBAAM,wCAAqB,IAAI;AAAA,QAChC;AACA;AAAA,MACD;AAEA,UAAI,CAAC,WAAW,cAAc,WAAW,UAAU,MAAM;AACxD;AAAA,MACD;AAEA,YAAM,KAAK,SAAS,YAAY,EAAE,KAAK,MAAM,KAAK,KAAK,KAAK,CAAC;AAE7D,UAAI,eAAoB,MAAM;AAE9B,UACC,WAAW,oBACX,WAAW,SAAS,oBACpB,WAAW,SAAS,cACnB;AACD,2BAAe,oCAAoB,MAAM,GAAG;AAAA,MAC7C,WAAW,WAAW,UAAU,OAAO,MAAM,QAAQ,UAAU;AAC9D,uBAAe,MAAM,MAAM,WAAW;AAAA,MACvC;AAEA,UAAI,WAAW,SAAS,WAAQ,OAAO,MAAM,QAAQ,YAAY,CAAC,WAAW,QAAQ;AACpF,uBAAe,MAAM,MAAM;AAAA,MAC5B;AAEA,YAAM,gBAAgB,WAAW;AACjC,gBAAM,gCAAW,MAAM,SAAS,eAAe,EAAE,GAAG,YAAY;AAAA,IACjE,SAAS,KAAU;AAClB;AAAA,QACC,qFAAqF,IAAI,OAAO;AAAA,QAChG;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,SAAO,UAAU,CAAC,YAAuD,IAAI,qBAAqB,OAAO;AAC1G,OAAO;AACN,GAAC,MAAM,IAAI,qBAAqB,GAAG;AACpC;",
|
|
4
|
+
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v3.1.5\n */\nimport * as utils from '@iobroker/adapter-core';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initAutoBackup, stopAutoBackup } from './backupManager';\nimport { formatTimerSecondsToTime, timeStringToSeconds } from './convert';\nimport { processCopData } from './copManager';\nimport { handleHupOptimization } from './hupManager';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport {\n\tcheckAndSendErrorNotifications,\n\tcheckAndSendOutageNotifications,\n\thandleTestMessage,\n\tsendTelegramNotification,\n} from './notificationManager';\nimport {\n\tcleanupCustomStates,\n\tcleanupEmptyFolders,\n\tcleanupStates,\n\tensureAllObjectsExist,\n\tensureCustomObjectsExist,\n\tisStateEnabled,\n} from './objectManager';\nimport { dumpAllRawToLog, queueWrite, readAllRaw } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport { generateHeatCurveSVG } from './svgGenerator';\nimport type { LuxtronikAdapter } from './types';\nimport {\n\tcalculateTemperatureSpread,\n\tcalculateTotalEnergy,\n\tcalculateTotalThermalEnergy,\n\tupdateCustomStates,\n\tupdateErrorHistory,\n\tupdateOutageHistory,\n\tupdateStatusStrings,\n\tupdateSystemInfos,\n\tupdateTimerTables,\n} from './virtualStates';\nimport {\n\tcheckAndHandleMotionSensor,\n\tdisableHardwareZipTimer,\n\thandleActivateZip,\n\tstopZipAndDeaeration,\n\tsubscribeMotionSensors,\n} from './zipManager';\n\n/**\n * Main class for the Luxtronik2 Controller ioBroker Adapter.\n */\nclass Luxtronik2Controller extends utils.Adapter implements LuxtronikAdapter {\n\t/** Set of all active namespaced state IDs created or managed by the adapter */\n\tpublic createdStates: Set<string> = new Set<string>();\n\t/** ioBroker timeout handle for the hot water circulation pump macro */\n\tpublic zipTimer?: ioBroker.Timeout;\n\t/** Cached copy of the original circulation pump settings before macro activation */\n\tpublic originalZipConfig: Record<string, any> | null = null;\n\t/** Unix timestamp of the last error dispatched to prevent duplicate notification triggers */\n\tpublic lastKnownErrorTimestamp: number | null = null;\n\t/** Determines whether verbose debugging output is enabled */\n\tpublic isDebugLogActive: boolean = false;\n\t//* Known Visibilities */\n\tpublic currentVisibilities: number[] = [];\n\t// Cache f\u00FCr den globalen Schreibschutz\n\tpublic currentRawParams: number[] = [];\n\t/** ioBroker interval handle for the main data polling loop */\n\tprivate pollingInterval: ioBroker.Interval | undefined;\n\t/** Cache for the last evaluated heat pump operating state code */\n\tprivate lastBzVal: string = '';\n\t/** Lock flag preventing concurrent execution of the polling updates */\n\tpublic updateRunning: boolean = false;\n\t/** Timestamp tracking the last dynamic pump voltage optimization execution */\n\tprivate lastPumpOptimization: number = 0;\n\n\t/** Internal array storing pending serial hardware write tasks */\n\tpublic writeQueue: (() => Promise<void>)[] = [];\n\t/** Lock flag indicating that the write queue is currently being processed */\n\tpublic isWriting: boolean = false;\n\t/** Counter tracking sequential communication timeouts/failures */\n\tprivate errorCount: number = 0;\n\t/** Maximum allowed sequential request failures before connection is flagged as interrupted */\n\tprivate readonly MAX_ERRORS: number = 3;\n\tpublic writeCyclesToday: number = 0;\n\tpublic writeCyclesTotal: number = 0;\n\tprivate midnightTimer?: ioBroker.Timeout;\n\n\t/**\n\t * Initializes a new instance of the Luxtronik2Controller class.\n\t *\n\t * @param options - Optional core configuration overrides passed by the ioBroker host.\n\t */\n\tpublic constructor(options: Partial<utils.AdapterOptions> = {}) {\n\t\tsuper({\n\t\t\t...options,\n\t\t\tname: 'luxtronik2-controller',\n\t\t});\n\t\tinitLogger(this);\n\n\t\tthis.on('ready', this.onReady.bind(this));\n\t\tthis.on('stateChange', this.onStateChange.bind(this));\n\t\tthis.on('unload', this.onUnload.bind(this));\n\t\tthis.on('message', this.onMessage.bind(this));\n\t}\n\n\tprivate async onMessage(obj: ioBroker.Message): Promise<void> {\n\t\tif (obj.command === 'testTelegram') {\n\t\t\tawait handleTestMessage(this, obj);\n\t\t} else if (obj.command === 'getHeatCurve') {\n\t\t\ttry {\n\t\t\t\tlet fp = 21.7;\n\t\t\t\tlet ep = 23.0;\n\n\t\t\t\t// Werte aus der Config-UI auslesen\n\t\t\t\tif (obj.message && typeof obj.message === 'object') {\n\t\t\t\t\tconst msg = obj.message as Record<string, any>;\n\t\t\t\t\tif (msg.fusspunkt !== undefined) {\n\t\t\t\t\t\tfp = parseFloat(msg.fusspunkt);\n\t\t\t\t\t}\n\t\t\t\t\tif (msg.endpunkt !== undefined) {\n\t\t\t\t\t\tep = parseFloat(msg.endpunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Fallbacks, falls der Nutzer Quatsch eintippt\n\t\t\t\tif (isNaN(fp)) {\n\t\t\t\t\tfp = 21.7;\n\t\t\t\t}\n\t\t\t\tif (isNaN(ep)) {\n\t\t\t\t\tep = 23.0;\n\t\t\t\t}\n\n\t\t\t\t// SVG generieren und als Base64-Bild verpacken\n\t\t\t\tconst svg = generateHeatCurveSVG(fp, ep);\n\t\t\t\tconst base64 = `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;\n\n\t\t\t\t// Bild zur\u00FCck an die Benutzeroberfl\u00E4che schicken!\n\t\t\t\tif (obj.callback) {\n\t\t\t\t\tthis.sendTo(obj.from, obj.command, base64, obj.callback);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\tthis.log.error(`Error generating heat curve: ${err.message}`);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Callback executed once the ioBroker host framework completely initializes the adapter subsystem.\n\t * Sets up database objects, applies configurations, subscribes to states, and triggers the polling loop.\n\t *\n\t * @returns A promise that resolves when initialization completes.\n\t */\n\tprivate async onReady(): Promise<void> {\n\t\tconst config = this.config as Record<string, any>;\n\t\tconst ip = config.host;\n\t\tconst port = config.port || 8889;\n\n\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\twriteLog(`Connecting to heat pump at ${ip}:${port}...`, 'info');\n\n\t\t// Visibilities einmalig beim Start abfragen f\u00FCr den intelligenten Objekt-Filter\n\t\t// (Wird nur ausgef\u00FChrt, wenn der Nutzer die Funktion in den Settings nicht deaktiviert hat)\n\t\tif (config.filter_visibility !== false) {\n\t\t\ttry {\n\t\t\t\tthis.currentVisibilities = await readAllRaw(this, 3005);\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Successfully loaded ${this.currentVisibilities.length} visibility flags from heat pump.`,\n\t\t\t\t\t\t'debug',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`Could not load visibility flags (Command 3005). Assuming all parameters are visible. Error: ${err.message}`,\n\t\t\t\t\t'warn',\n\t\t\t\t);\n\t\t\t\tthis.currentVisibilities = [];\n\t\t\t}\n\t\t} else {\n\t\t\t// Nutzer hat den Filter deaktiviert -> Array bleibt leer, alles wird angezeigt\n\t\t\tthis.currentVisibilities = [];\n\t\t}\n\n\t\tawait cleanupStates(this);\n\t\tawait cleanupCustomStates(this);\n\t\tawait cleanupEmptyFolders(this);\n\t\tawait ensureAllObjectsExist(this);\n\t\tawait ensureCustomObjectsExist(this);\n\t\tinitAutoBackup(this);\n\n\t\t// Strikte \"Opt-In\" Pr\u00FCfung beim Start\n\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\n\t\tconst debugState = await this.getStateAsync(getDpPath('Schreibe_Debug_Log'));\n\t\tthis.isDebugLogActive = debugState?.val === true;\n\t\tsetCustomDebug(this.isDebugLogActive);\n\n\t\tawait disableHardwareZipTimer(this);\n\n\t\t// Schreib-Z\u00E4hler aus ioBroker laden (sichert den Stand bei einem Adapter-Neustart)\n\t\tconst cycleTodayState = await this.getStateAsync(getDpPath('write_cycles_today'));\n\t\tthis.writeCyclesToday = cycleTodayState && typeof cycleTodayState.val === 'number' ? cycleTodayState.val : 0;\n\n\t\tconst cycleTotalState = await this.getStateAsync(getDpPath('write_cycles_total'));\n\t\tthis.writeCyclesTotal = cycleTotalState && typeof cycleTotalState.val === 'number' ? cycleTotalState.val : 0;\n\n\t\tthis.scheduleMidnightReset(); // Startet den 00:00 Uhr Timer (nur f\u00FCr den Tagesz\u00E4hler!)\n\t\tsubscribeMotionSensors(this);\n\n\t\tthis.subscribeStates('*');\n\n\t\ttry {\n\t\t\tawait this.updateData();\n\t\t} catch (error: any) {\n\t\t\tthis.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);\n\t\t}\n\n\t\t// Virtuelle ZIP-Datenpunkte beim Start initialisieren, um 'null' Werte zu vermeiden\n\t\tconst dpActivateZip = getDpPath('Activate_Zip');\n\t\tif (dpActivateZip) {\n\t\t\tawait this.setState(dpActivateZip, { val: false, ack: true });\n\t\t}\n\n\t\tconst dpVirtualZipStatus = getDpPath('Virtual_ZIP_Status');\n\t\tif (dpVirtualZipStatus) {\n\t\t\tawait this.setState(dpVirtualZipStatus, { val: false, ack: true });\n\t\t}\n\n\t\tlet intervalSeconds = this.config.interval ? Number(this.config.interval) : 45;\n\t\tif (intervalSeconds < 10) {\n\t\t\tintervalSeconds = 10;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval was too short. Forced to minimum threshold of 10 seconds for protection.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\t\tif (intervalSeconds > 3600) {\n\t\t\tintervalSeconds = 3600;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval exceeded maximum boundary. Restricted to 3600 seconds to prevent overflow issues.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\n\t\tthis.pollingInterval = this.setInterval(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.updateData();\n\t\t\t} catch (error: any) {\n\t\t\t\tthis.log.error(`Error during cyclic data retrieval loop: ${error.message}`);\n\t\t\t}\n\t\t}, intervalSeconds * 1000);\n\n\t\tawait this.setState('info.connection', true, true);\n\t}\n\n\t/**\n\t * Berechnet die Zeit bis Mitternacht und setzt NUR den heutigen Schreibz\u00E4hler auf 0 zur\u00FCck.\n\t */\n\tprivate scheduleMidnightReset(): void {\n\t\tconst now = new Date();\n\t\tconst night = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);\n\t\tconst msToMidnight = night.getTime() - now.getTime();\n\n\t\tthis.midnightTimer = this.setTimeout(() => {\n\t\t\tthis.writeCyclesToday = 0;\n\t\t\tvoid this.setState(getDpPath('write_cycles_today'), { val: 0, ack: true });\n\n\t\t\t// Timer f\u00FCr den n\u00E4chsten Tag neu aufziehen\n\t\t\tthis.scheduleMidnightReset();\n\t\t}, msToMidnight);\n\t}\n\n\t/**\n\t * Synchronizes a single state configuration parameter with the Luxtronik physical controller.\n\t *\n\t * @param mappingKey - The unique key identifier within the STATE_MAPPING structure.\n\t * @param val - The raw or parsed value to apply.\n\t * @returns A promise that resolves when the synchronization task finishes.\n\t */\n\tpublic async syncConfigValue(mappingKey: keyof typeof STATE_MAPPING, val: any): Promise<void> {\n\t\tif (val === undefined || val === null) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tif (!state || state.val !== val) {\n\t\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\t\tif (!definition) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(id, { val: val, ack: true });\n\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\twriteLog(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, 'info');\n\t\t\t}\n\n\t\t\tif (definition.write === true && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\tlet valueToWrite: any = val;\n\t\t\t\tif (definition.factor && typeof val === 'number') {\n\t\t\t\t\tvalueToWrite = val * definition.factor;\n\t\t\t\t}\n\n\t\t\t\tconst isRawWrite =\n\t\t\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\t\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !definition.factor) {\n\t\t\t\t\tvalueToWrite = val * 10;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\t\t\tconst writeId = isRawWrite ? parseInt(targetWriteId, 10) : targetWriteId;\n\t\t\t\t\tawait queueWrite(this, writeId, valueToWrite);\n\t\t\t\t\tawait new Promise(r => global.setTimeout(r, 200));\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Failed to transmit ${mappingKey} to the heat pump hardware interface: ${err.message}`,\n\t\t\t\t\t\t'error',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Safely updates an internal database state value only if the newly supplied value differs from the existing entry.\n\t *\n\t * @param id - The relative state path ID.\n\t * @param val - The updated value to process.\n\t * @param ack - Explicit acknowledgment flag status to set.\n\t * @returns A promise that resolves when the verification and write operation completes.\n\t */\n\tpublic async setOwnStateIfDifferent(id: string, val: any, ack = false): Promise<void> {\n\t\ttry {\n\t\t\tif (val === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = await this.getStateAsync(id);\n\t\t\tif (!state || state.val !== val) {\n\t\t\t\tawait this.setState(id, { val: val, ack: ack });\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(`Applying specific update for local state ${id}: ${val}`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Configures fallback factory parameter baselines for the heat pump when in an idle state.\n\t *\n\t * @returns A promise that resolves when all default configuration tasks resolve.\n\t */\n\tprivate async setIdleDefaults(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tawait this.syncConfigValue('heating_curve_end_point', config.endpunkt ?? 23);\n\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', config.fusspunkt ?? 21.7);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('temperature_hot_water_target', config.sync_warmwater_target_temperature ?? 54);\n\t\t\tawait this.syncConfigValue('returnTemperatureHysteresis', config.sync_return_temperature_hysteresis ?? 1.5);\n\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Failed to apply the baseline idle configuration defaults: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Evaluates whether the current active operating state timestamp is older than ten minutes.\n\t *\n\t * @returns A promise that resolves to true if the state has remained unaltered for at least 10 minutes.\n\t */\n\tprivate async istBetriebszustandAelterAls10Min(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst state = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst lastChange = state?.lc ?? 0;\n\t\t\treturn (Date.now() - lastChange) / 60000 >= 10;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Primary intelligent engine analyzing live telemetry values to execute continuous performance optimizations.\n\t * Manages dynamic heating curves, anti-cycling protective delays, and voltage scaling algorithms.\n\t *\n\t * @returns A promise that resolves when the execution cycle finishes.\n\t */\n\tprivate async runOptimizationSchedule(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\t// Live-Status des ioBroker Schalters \"Regelung_Aktiv\" auslesen\n\t\t\tconst regelungAktivState = await this.getStateAsync(getDpPath('Regelung_Aktiv'));\n\t\t\tconst isRegelungAktiv = regelungAktivState?.val === true;\n\n\t\t\tconst istHeizen = bzVal === '0';\n\t\t\tconst istWarmwasser = bzVal === '1';\n\t\t\tconst istAbtauen = bzVal === '4';\n\t\t\tconst istLeerlauf = bzVal === '5';\n\n\t\t\tif (!istHeizen && !istWarmwasser && !istLeerlauf && !istAbtauen) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// =========================================================\n\t\t\t// 1. DYNAMIC PARAMETER ADJUSTMENT UPON STATE SWITCH\n\t\t\t// =========================================================\n\t\t\tif (bzVal !== this.lastBzVal) {\n\t\t\t\tif (istLeerlauf) {\n\t\t\t\t\tif (config.idle_defaults_aktiv === true) {\n\t\t\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\t\t}\n\t\t\t\t} else if (istHeizen) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\t\t\t}\n\t\t\t\t\tif (config.hup_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t\t\t\t}\n\t\t\t\t} else if (istWarmwasser) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\t\t// Pr\u00FCfen, ob externe Aktoren konfiguriert sind\n\t\t\t\t\t\tconst actors = config.actors || [];\n\t\t\t\t\t\tconst validActors = actors.filter(\n\t\t\t\t\t\t\t(a: any) => a.zip_external_relay_id && a.zip_external_relay_id.trim() !== '',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Wenn Aktoren da sind, k\u00F6nnen wir die Zirkulation bedenkenlos starten (0 Flash-Schreibvorg\u00E4nge!)\n\t\t\t\t\t\tif (validActors.length > 0) {\n\t\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\t\tthis.log.debug(\n\t\t\t\t\t\t\t\t\t'[ZIP] Externe Aktoren gefunden. Starte Zirkulation synchron zur Warmwasserbereitung.',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Dauer aus der Config holen (mit einem sinnvollen Fallback von z.B. 120 Sekunden)\n\t\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 120);\n\t\t\t\t\t\t\t// Makro \u00FCber den Trigger-Datenpunkt ausl\u00F6sen\n\t\t\t\t\t\t\tawait this.setOwnStateIfDifferent(getDpPath('Activate_Zip'), true, false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (config.hup_optimierung_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_water ?? 3,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_water ?? 10,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.lastBzVal = bzVal;\n\t\t\t}\n\n\t\t\tconst [\n\t\t\t\twwSollState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\n\t\t\t\theatingStateStrState,\n\t\t\t\tvd1State,\n\t\t\t\twwHystereseState,\n\t\t\t\truecklaufSollState,\n\t\t\t\tcurrentHupVoltState,\n\t\t\t\theizenHystereseState,\n\t\t\t\tnachWasserState,\n\t\t\t\tmitteltempState,\n\t\t\t\tthresholdHeatingLimitstate,\n\t\t\t\theatingLimitState,\n\t\t\t\taelterAls10,\n\t\t\t] = await Promise.all([\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('spreizung_vorlauf_ruecklauf')),\n\t\t\t\tthis.getStateAsync(getDpPath('opStateHeatingString')),\n\t\t\t\tthis.getStateAsync(getDpPath('VD1out')),\n\t\t\t\tthis.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('heating_system_circ_pump_voltage_nominal')),\n\t\t\t\tthis.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('Heizen_nach_Wasser')),\n\t\t\t\tthis.getStateAsync(getDpPath('Mitteltemperatur')),\n\t\t\t\tthis.getStateAsync(getDpPath('thresholdHeatingLimit')),\n\t\t\t\tthis.getStateAsync(getDpPath('heatingLimit')),\n\t\t\t\tthis.istBetriebszustandAelterAls10Min(),\n\t\t\t]);\n\n\t\t\tconst wwSoll = (wwSollState?.val as number) ?? 0;\n\t\t\tconst wwIst = (wwIstState?.val as number) ?? 0;\n\t\t\tconst ruecklauf = (ruecklaufState?.val as number) ?? 0;\n\t\t\tconst spreizung = (spreizungState?.val as number) ?? 0;\n\t\t\tconst heatingStateStr = String(heatingStateStrState?.val || '').trim();\n\t\t\tconst vd1 = vd1State?.val === 1;\n\t\t\tconst wwHysterese = (wwHystereseState?.val as number) ?? 0;\n\t\t\tconst ruecklaufSoll = (ruecklaufSollState?.val as number) ?? 0;\n\t\t\tconst currentHupVolt = (currentHupVoltState?.val as number) ?? 7.0;\n\t\t\tconst heizenHysterese = (heizenHystereseState?.val as number) ?? 0;\n\t\t\tconst mitteltemperatur = (mitteltempState?.val as number) ?? 0;\n\t\t\tconst thresholdHeatingLimit = (thresholdHeatingLimitstate?.val as number) ?? 0;\n\t\t\tconst heatingLimit = (heatingLimitState?.val as number) ?? 0;\n\t\t\tconst nachWasser = nachWasserState?.val;\n\n\t\t\t// =========================================================\n\t\t\t// 2. CONTINUOUS IN-SERVICE TELEMETRY EVALUATION\n\t\t\t// =========================================================\n\t\t\tif (istHeizen) {\n\t\t\t\tif (isRegelungAktiv && aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunkt = (await this.getStateAsync(getDpPath('heating_curve_parallel_offset')))?.val;\n\t\t\t\t\tif (fusspunkt === 35) {\n\t\t\t\t\t\tconst fallbackFusspunkt = config.fusspunkt ?? 21.7;\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', fallbackFusspunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// FIX: HUP-Optimierung nur aufrufen, wenn die Anlage mindestens 10 Minuten heizt\n\t\t\t\t// UND der Verdichter (vd1) l\u00E4uft. Vorher ist die Spreizung physikalisch nicht aussagekr\u00E4ftig.\n\t\t\t\tif (aelterAls10 && vd1) {\n\t\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\tistHeizen,\n\t\t\t\t\t\tspreizung,\n\t\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\t\tthis.lastPumpOptimization,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\t// WICHTIG: Heizen_nach_Wasser Logik (Reset & Setzen)\n\t\t\t\t\tif (ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\tif (aelterAls10) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', false);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (!nachWasser && config.Heating_after_warmwater === true) {\n\t\t\t\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', true);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Warmwassertakt erzwingen\n\t\t\t\t\tif (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\t// Neuen Sollwert berechnen: Ist-Wert + aktuelle Hysterese + 1.5K Puffer\n\t\t\t\t\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t\t\t\t\t// Sicherheitspr\u00FCfung: Maximaltemperatur kappen (Passend zu actionHandlers = 70\u00B0C)\n\t\t\t\t\t\tif (forceSoll > 70) {\n\t\t\t\t\t\t\tforceSoll = 70;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tforceSoll = Math.round(forceSoll * 10) / 10;\n\n\t\t\t\t\t\t// Statt Hysterese wird nun der Sollwert tempor\u00E4r erh\u00F6ht, um den WW-Takt k\u00FCnstlich anzusto\u00DFen\n\t\t\t\t\t\tawait this.syncConfigValue('temperature_hot_water_target', forceSoll);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\tif ((heatingLimit === 1 && mitteltemperatur < thresholdHeatingLimit) || heatingLimit === 0) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istLeerlauf) {\n\t\t\t\tif (config.zip_optimierung_aktiv === true) {\n\t\t\t\t\tif (wwIst <= wwSoll - wwHysterese || ruecklauf <= ruecklaufSoll - heizenHysterese) {\n\t\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\tif (\n\t\t\t\t\t\twwSoll - wwIst >= wwHysterese - 1.5 &&\n\t\t\t\t\t\truecklauf <= ruecklaufSoll &&\n\t\t\t\t\t\theatingStateStr !== 'Heating limit'\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during runOptimizationSchedule loop execution: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Fetches, parses, converts types, and populates live data registries over the configured TCP socket.\n\t * Dispatches calculation and history logging subroutines accordingly.\n\t *\n\t * @returns A promise that resolves when the internal update registers conclude.\n\t */\n\tprivate async updateData(): Promise<void> {\n\t\tif (this.updateRunning) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Schreibvorg\u00E4nge haben absolute Priorit\u00E4t!\n\t\t// Wenn gerade geschrieben wird, \u00FCberspringen wir den Lese-Zyklus,\n\t\t// um alte Anlagen vor abst\u00FCrzenden Netzwerk-Sockets zu sch\u00FCtzen.\n\t\tif (this.isWriting) {\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\tthis.log.debug('Skipping read cycle because a write operation is currently in progress.');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.updateRunning = true;\n\t\ttry {\n\t\t\tconst delayHelper = (ms: number): Promise<void> => new Promise(resolve => this.setTimeout(resolve, ms));\n\n\t\t\tlet rawParams: number[] = [];\n\t\t\tlet rawValues: number[] = [];\n\n\t\t\ttry {\n\t\t\t\trawParams = await readAllRaw(this, 3003);\n\t\t\t\tthis.currentRawParams = rawParams; //Cache f\u00FCr Schreibschutz aktuell halten\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait delayHelper(200);\n\n\t\t\ttry {\n\t\t\t\trawValues = await readAllRaw(this, 3004);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\t\t\tawait this.setState('info.lastUpdate', { val: new Date().toISOString(), ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tfor (const [key, definition] of Object.entries(STATE_MAPPING)) {\n\t\t\t\tif (definition.isVirtual) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!isStateEnabled(key, definition, config, this.currentVisibilities)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst luxId = definition.luxWriteId || key;\n\t\t\t\tlet value: any = undefined;\n\n\t\t\t\t// DYNAMISCHER FAKTOR F\u00DCR HUP\n\t\t\t\tlet appliedFactor = definition.factor;\n\t\t\t\tif (\n\t\t\t\t\tkey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\t\t\tkey === 'heating_system_circ_pump_voltage_minimal'\n\t\t\t\t) {\n\t\t\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t\t\t}\n\n\t\t\t\tif (definition.dataSource) {\n\t\t\t\t\tswitch (definition.dataSource) {\n\t\t\t\t\t\tcase 'raw_parameter':\n\t\t\t\t\t\t\tvalue = rawParams?.[parseInt(luxId, 10)];\n\t\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'raw_value':\n\t\t\t\t\t\t\tvalue = rawValues?.[parseInt(luxId, 10)];\n\t\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'parameter':\n\t\t\t\t\t\tcase 'value':\n\t\t\t\t\t\tcase 'additional':\n\t\t\t\t\t\t\tvalue = undefined;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (/^\\d+$/.test(luxId)) {\n\t\t\t\t\t\tconst idx = parseInt(luxId, 10);\n\t\t\t\t\t\tvalue = definition.folder.startsWith('Settings') ? rawParams?.[idx] : rawValues?.[idx];\n\t\t\t\t\t\tif (value !== undefined && appliedFactor) {\n\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (value !== undefined && typeof value === 'number' && appliedFactor) {\n\t\t\t\t\tvalue = Math.round(value * 100) / 100;\n\t\t\t\t}\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tif (definition.type === 'number' && typeof value === 'string') {\n\t\t\t\t\t\tvalue =\n\t\t\t\t\t\t\tvalue.toLowerCase() === 'ein' ? 1 : value.toLowerCase() === 'aus' ? 0 : parseFloat(value);\n\t\t\t\t\t} else if (definition.type === 'boolean') {\n\t\t\t\t\t\tvalue =\n\t\t\t\t\t\t\tvalue === true ||\n\t\t\t\t\t\t\tvalue === 1 ||\n\t\t\t\t\t\t\tString(value).toLowerCase() === 'ein' ||\n\t\t\t\t\t\t\tString(value).toLowerCase() === 'true';\n\t\t\t\t\t} else if (definition.type === 'json' && typeof value === 'object') {\n\t\t\t\t\t\tvalue = JSON.stringify(value);\n\t\t\t\t\t}\n\n\t\t\t\t\t// INTERNER HACK F\u00DCR DEN LUXTRONIK ANZEIGEFEHLER (1 Sekunde -> 0 Sekunden)\n\t\t\t\t\tlet finalSeconds = Number(value);\n\t\t\t\t\tif (definition.isDurationFormat && key === 'Time_WPein_akt' && finalSeconds === 1) {\n\t\t\t\t\t\tfinalSeconds = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (definition.isDurationFormat) {\n\t\t\t\t\t\tvalue = formatTimerSecondsToTime(finalSeconds);\n\t\t\t\t\t} else if (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\tconst totalSeconds = typeof value === 'number' ? value : parseInt(value as string, 10);\n\t\t\t\t\t\tif (!isNaN(totalSeconds) && totalSeconds >= 0) {\n\t\t\t\t\t\t\tif (totalSeconds < 86400) {\n\t\t\t\t\t\t\t\tconst h = Math.floor(totalSeconds / 3600)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tconst m = Math.floor((totalSeconds % 3600) / 60)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tvalue = `${h}:${m}`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = new Date(totalSeconds * 1000).toISOString().replace('T', ' ').substring(0, 19);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet targetIoBrokerType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\ttargetIoBrokerType = 'string';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (targetIoBrokerType === 'string' && typeof value !== 'string') {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'number' && typeof value !== 'number') {\n\t\t\t\t\t\tvalue = Number(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'boolean' && typeof value !== 'boolean') {\n\t\t\t\t\t\tvalue = Boolean(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this);\n\t\t\tawait calculateTotalEnergy(this);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Fehler-Historie abarbeiten & Alarmieren\n\t\t\t// ----------------------------------------------------\n\t\t\tconst fehlerDp = getDpPath('Fehlerspeicher');\n\t\t\tconst oldFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst oldFehlerVal = oldFehlerState?.val as string | undefined;\n\n\t\t\tawait updateErrorHistory(this, rawValues);\n\n\t\t\tconst newFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst newFehlerVal = newFehlerState?.val as string | undefined;\n\n\t\t\tawait checkAndSendErrorNotifications(this, oldFehlerVal, newFehlerVal);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Abschalt-Historie abarbeiten & Alarmieren (Durchfluss)\n\t\t\t// ----------------------------------------------------\n\t\t\tconst abschaltungDp = getDpPath('Abschaltungen');\n\t\t\tconst oldAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst oldAbschaltungVal = oldAbschaltungState?.val as string | undefined;\n\n\t\t\tawait updateOutageHistory(this, rawValues);\n\n\t\t\tconst newAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst newAbschaltungVal = newAbschaltungState?.val as string | undefined;\n\n\t\t\tawait checkAndSendOutageNotifications(this, oldAbschaltungVal, newAbschaltungVal);\n\t\t\t// ----------------------------------------------------\n\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\n\t\t\t// Aktuellen Betriebszustand aus dem Cache oder live holen\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst currentBzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\tthis.log.debug(`=> Rufe jetzt den COP Manager auf. BZ ist: ${currentBzVal}`);\n\t\t\tawait processCopData(this, currentBzVal);\n\n\t\t\tawait this.runOptimizationSchedule();\n\t\t} catch (err: any) {\n\t\t\tthis.errorCount++;\n\t\t\twriteLog(\n\t\t\t\t`Communication error encountered (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\n\t\t\tif (this.errorCount >= this.MAX_ERRORS) {\n\t\t\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\t\t\twriteLog('Heat pump controller unreachable. Flagging connection status as disconnected.', 'warn');\n\t\t\t\tsendTelegramNotification(\n\t\t\t\t\tthis,\n\t\t\t\t\t'Heat pump controller unreachable. Flagging connection status as disconnected.',\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.updateRunning = false;\n\t\t}\n\t}\n\n\t/**\n\t * Callback issued by the ioBroker framework during adapter shutdown sequences.\n\t *\n\t * @param callback - Termination completion trigger function.\n\t */\n\tprivate onUnload(callback: () => void): void {\n\t\ttry {\n\t\t\tif (this.pollingInterval) {\n\t\t\t\tclearInterval(this.pollingInterval);\n\t\t\t}\n\t\t\tif (this.zipTimer) {\n\t\t\t\tclearTimeout(this.zipTimer);\n\t\t\t}\n\n\t\t\tstopAutoBackup(this);\n\n\t\t\tif (this.midnightTimer) {\n\t\t\t\tthis.clearTimeout(this.midnightTimer);\n\t\t\t}\n\n\t\t\tvoid this.setState('info.connection', { val: false, ack: true });\n\n\t\t\twriteLog(\n\t\t\t\t'Adapter is shutting down. Cleared all active intervals and terminated open socket configurations cleanly.',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tcallback();\n\t\t} catch {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\t/**\n\t * Central observer callback executed whenever a subscribed state receives an update.\n\t *\n\t * @param id - The explicit full namespaced state identifier path.\n\t * @param state - The newly applied state context or null context if dropped.\n\t * @returns A promise that resolves when operations complete.\n\t */\n\tprivate async onStateChange(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bewegungsmelder an den Manager auslagern\n\t\tconst isMotionSensor = await checkAndHandleMotionSensor(this, id, state);\n\t\tif (isMotionSensor) {\n\t\t\treturn; // Der zipManager hat das Event verarbeitet, wir sind hier fertig\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (id.startsWith(`${this.namespace}.Custom.`)) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getObjectAsync(id);\n\n\t\t\t\tif (obj && obj.native && obj.native.source === 'parameter') {\n\t\t\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\t\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\t\t\tif (obj.native.customType === 'boolean') {\n\t\t\t\t\t\tvalueToWrite = state.val ? 1 : 0;\n\t\t\t\t\t} else if (obj.native.customType === 'number' && typeof state.val === 'number') {\n\t\t\t\t\t\tif (obj.native.factor) {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val / obj.native.factor);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst targetWriteId = parseInt(obj.native.luxId, 10);\n\t\t\t\t\tif (!isNaN(targetWriteId)) {\n\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,\n\t\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait queueWrite(this, targetWriteId, valueToWrite);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, 'error');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tif (!mappingKey) {\n\t\t\treturn;\n\t\t}\n\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\tif (!definition) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\t\twriteLog(\n\t\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Regelung_Aktiv' || mappingKey === 'zip_aktiv') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Setze_Vorgabewerte' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait dumpAllRawToLog(this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangswarmwasser') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangswarmwasser(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangsheizen') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangsheizen(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Activate_Zip') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tconst durationState = await this.getStateAsync(getDpPath('zip_aktiv'));\n\t\t\t\t\tconst durationSeconds =\n\t\t\t\t\t\tdurationState && typeof durationState.val === 'number' ? durationState.val : 120;\n\t\t\t\t\tawait handleActivateZip(this, id, durationSeconds);\n\t\t\t\t} else {\n\t\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!definition.luxWriteId || definition.write !== true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (\n\t\t\t\tdefinition.isDurationFormat ||\n\t\t\t\tdefinition.role === 'value.datetime' ||\n\t\t\t\tdefinition.role === 'value.time'\n\t\t\t) {\n\t\t\t\tvalueToWrite = timeStringToSeconds(state.val);\n\t\t\t} else if (definition.factor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * definition.factor;\n\t\t\t}\n\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !definition.factor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\tawait queueWrite(this, parseInt(targetWriteId, 10), valueToWrite);\n\t\t} catch (err: any) {\n\t\t\twriteLog(\n\t\t\t\t`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\t\t}\n\t}\n}\n\nif (require.main !== module) {\n\tmodule.exports = (options: Partial<utils.AdapterOptions> | undefined) => new Luxtronik2Controller(options);\n} else {\n\t(() => new Luxtronik2Controller())();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAuB;AACvB,4BAA2D;AAC3D,2BAA+C;AAC/C,qBAA8D;AAC9D,wBAA+B;AAC/B,wBAAsC;AACtC,oBAAqD;AACrD,iCAKO;AACP,2BAOO;AACP,0BAAwD;AACxD,0BAAyC;AACzC,0BAAqC;AAErC,2BAUO;AACP,wBAMO;AAKP,MAAM,6BAA6B,MAAM,QAAoC;AAAA;AAAA,EAErE,gBAA6B,oBAAI,IAAY;AAAA;AAAA,EAE7C;AAAA;AAAA,EAEA,oBAAgD;AAAA;AAAA,EAEhD,0BAAyC;AAAA;AAAA,EAEzC,mBAA4B;AAAA;AAAA,EAE5B,sBAAgC,CAAC;AAAA;AAAA,EAEjC,mBAA6B,CAAC;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA,YAAoB;AAAA;AAAA,EAErB,gBAAyB;AAAA;AAAA,EAExB,uBAA+B;AAAA;AAAA,EAGhC,aAAsC,CAAC;AAAA;AAAA,EAEvC,YAAqB;AAAA;AAAA,EAEpB,aAAqB;AAAA;AAAA,EAEZ,aAAqB;AAAA,EAC/B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOD,YAAY,UAAyC,CAAC,GAAG;AAC/D,UAAM;AAAA,MACL,GAAG;AAAA,MACH,MAAM;AAAA,IACP,CAAC;AACD,kCAAW,IAAI;AAEf,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AACpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAC1C,SAAK,GAAG,WAAW,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EAC7C;AAAA,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