iobroker.luxtronik2-controller 0.12.1 → 0.13.0
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 +9 -5
- package/build/actionHandlers.js +1 -1
- package/build/actionHandlers.js.map +2 -2
- package/build/backupManager.js +6 -7
- package/build/backupManager.js.map +2 -2
- package/build/hupManager.js.map +2 -2
- package/build/main.js +3 -3
- package/build/main.js.map +2 -2
- package/build/notificationManager.js.map +2 -2
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +6 -1
- package/build/rawFunctions.js.map +2 -2
- package/build/types.js +17 -0
- package/build/types.js.map +7 -0
- package/build/zipManager.js.map +2 -2
- package/io-package.json +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,15 @@ Bug reports, compatibility notes for specific firmware versions, or feature requ
|
|
|
85
85
|
## Changelog
|
|
86
86
|
|
|
87
87
|
// ### **WORK IN PROGRESS**
|
|
88
|
+
### 0.13.0 (2026-10-02)
|
|
89
|
+
|
|
90
|
+
- **Bugfixes:**
|
|
91
|
+
- **Critical DHW Target Fix:** Fixed an issue where the hot water target temperature was incorrectly written to parameter 2 instead of 105. This resolves unexpected temperature jumps (e.g., to 65°C) and socket timeouts on various heat pump models.
|
|
92
|
+
- **Write Queue Timeout:** Added a maximum wait timeout to the write queue lock for legacy V1.x firmware to prevent potential infinite loops during read-write collisions.
|
|
93
|
+
- **Backup Manager Multi-Instance Fix:** The automated DTA backup cron job is now safely scoped to the specific adapter instance, preventing conflicts when running multiple heat pumps on the same ioBroker host.
|
|
94
|
+
- **Under the Hood / Refactoring:**
|
|
95
|
+
- **Centralized Typings:** Completely refactored the TypeScript architecture by introducing a centralized `LuxtronikAdapter` interface (`types.ts`). Replaced all fragmented, local interfaces across sub-modules to ensure strict, project-wide type safety and better maintainability.
|
|
96
|
+
|
|
88
97
|
### 0.12.1 (2026-09-30)
|
|
89
98
|
|
|
90
99
|
- **Bugfixes:**
|
|
@@ -117,11 +126,6 @@ Bug reports, compatibility notes for specific firmware versions, or feature requ
|
|
|
117
126
|
|
|
118
127
|
- Resolve issues which are reported by repository checker
|
|
119
128
|
|
|
120
|
-
### 0.11.0 (2026-09-21)
|
|
121
|
-
|
|
122
|
-
- **Improvements:**
|
|
123
|
-
- Added global rounding to 2 decimal places for all calculated telemetry values (e.g., converting operating seconds to hours). This provides a cleaner ioBroker state tree and prevents excessively long floating-point numbers from cluttering history databases (like InfluxDB).
|
|
124
|
-
|
|
125
129
|
## License
|
|
126
130
|
|
|
127
131
|
MIT License
|
package/build/actionHandlers.js
CHANGED
|
@@ -56,7 +56,7 @@ async function handleZwangswarmwasser(adapter, id) {
|
|
|
56
56
|
forceSoll = MAX_WW_TEMP;
|
|
57
57
|
}
|
|
58
58
|
forceSoll = Math.round(forceSoll * 10) / 10;
|
|
59
|
-
await adapter.syncConfigValue("
|
|
59
|
+
await adapter.syncConfigValue("temperature_hot_water_target", forceSoll);
|
|
60
60
|
(0, import_logger.writeLog)(
|
|
61
61
|
`Forced hot water: Triggered - Actual (${wwIst}\xB0C) < Target-1 (${wwSoll - 1}\xB0C). Target temperature temporarily set to ${forceSoll}\xB0C.`,
|
|
62
62
|
"info"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/actionHandlers.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\nimport { getNumber } from './utils';\n\n// =========================================================\n// TYPEN & KONSTANTEN\n// =========================================================\n\nconst CONSTANTS = {\n\t/** Status-Code f\u00FCr den Ruhezustand der Anlage */\n\tSTATE_IDLE: 5,\n\t/** Befehlswert f\u00FCr den Fu\u00DFpunkt beim Zwangsheizen */\n\tFORCE_HEATING_OFFSET: 35,\n};\n\n// =========================================================\n// AKTIONEN\n// =========================================================\n\n/**\n * Erzwingt die Warmwasserbereitung durch tempor\u00E4re Erh\u00F6hung des Sollwerts.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangswarmwasser(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\t// Hysterese zus\u00E4tzlich auslesen, um den perfekten Zielwert zu berechnen\n\t\tconst [wwIstState, wwSollState, wwHystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\tadapter.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst wwIst = getNumber(wwIstState);\n\t\tconst wwSoll = getNumber(wwSollState);\n\t\tconst wwHysterese = getNumber(wwHystereseState, 2); // Fallback auf 2K, falls nicht gefunden\n\n\t\tif (wwIst >= wwSoll - 1) {\n\t\t\twriteLog(\n\t\t\t\t`Forced hot water: Ignored - Actual (${wwIst}\u00B0C) is already sufficient (Target: ${wwSoll}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Neuen Sollwert berechnen: Ist-Wert + aktuelle Hysterese + 1.5K Puffer\n\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t// Sicherheitspr\u00FCfung: Maximaltemperatur kappen, um Regler-Fehler zu vermeiden\n\t\tconst MAX_WW_TEMP = 70;\n\t\tif (forceSoll > MAX_WW_TEMP) {\n\t\t\tforceSoll = MAX_WW_TEMP;\n\t\t}\n\n\t\t// Auf eine Nachkommastelle runden f\u00FCr saubere \u00DCbergabe\n\t\tforceSoll = Math.round(forceSoll * 10) / 10;\n\n\t\t// Statt der Hysterese wird nun der Warmwasser-Sollwert \u00FCberschrieben\n\t\tawait adapter.syncConfigValue('temperature_hot_water_target', forceSoll);\n\n\t\twriteLog(\n\t\t\t`Forced hot water: Triggered - Actual (${wwIst}\u00B0C) < Target-1 (${wwSoll - 1}\u00B0C). Target temperature temporarily set to ${forceSoll}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced hot water: Error during execution - ${msg}`, 'error');\n\t}\n}\n\n/**\n * Erzwingt den Heizbetrieb durch tempor\u00E4re Erh\u00F6hung des Fu\u00DFpunktes.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangsheizen(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\tconst [bzState, ruecklaufState, ruecklaufSollState, hystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('WP_BZ_akt')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_return')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\tadapter.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst bzVal = getNumber(bzState, -1);\n\t\tconst ruecklauf = getNumber(ruecklaufState);\n\t\tconst ruecklaufSoll = getNumber(ruecklaufSollState);\n\t\tconst hysterese = getNumber(hystereseState);\n\n\t\tif (bzVal !== CONSTANTS.STATE_IDLE) {\n\t\t\twriteLog(`Forced heating: Ignored - System is not idle (Status: ${bzVal}).`, 'info');\n\t\t\treturn;\n\t\t}\n\n\t\tif (ruecklauf >= ruecklaufSoll + hysterese) {\n\t\t\twriteLog(\n\t\t\t\t`Forced heating: Ignored - Return temperature high enough (${ruecklauf}\u00B0C >= ${ruecklaufSoll + hysterese}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait adapter.syncConfigValue('heating_curve_parallel_offset', CONSTANTS.FORCE_HEATING_OFFSET);\n\t\twriteLog(\n\t\t\t`Forced heating: Triggered - Base point temporarily set to ${CONSTANTS.FORCE_HEATING_OFFSET}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced heating: Error during execution - ${msg}`, 'error');\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAE1B,mBAA0B;AAM1B,MAAM,YAAY;AAAA;AAAA,EAEjB,YAAY;AAAA;AAAA,EAEZ,sBAAsB;AACvB;AAYA,eAAsB,uBAAuB,SAA2B,IAA2B;AAClG,MAAI;AACH,UAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,SAAS,KAAK,EAAE;AACtD,UAAM,QAAQ,SAAS,SAAS,EAAE,KAAK,OAAO,KAAK,KAAK,CAAC;AAGzD,UAAM,CAAC,YAAY,aAAa,gBAAgB,IAAI,MAAM,QAAQ,IAAI;AAAA,MACrE,QAAQ,kBAAc,+BAAU,yBAAyB,CAAC;AAAA,MAC1D,QAAQ,kBAAc,+BAAU,0BAA0B,CAAC;AAAA,MAC3D,QAAQ,kBAAc,+BAAU,+BAA+B,CAAC;AAAA,IACjE,CAAC;AAED,UAAM,YAAQ,wBAAU,UAAU;AAClC,UAAM,aAAS,wBAAU,WAAW;AACpC,UAAM,kBAAc,wBAAU,kBAAkB,CAAC;AAEjD,QAAI,SAAS,SAAS,GAAG;AACxB;AAAA,QACC,uCAAuC,KAAK,yCAAsC,MAAM;AAAA,QACxF;AAAA,MACD;AACA;AAAA,IACD;AAGA,QAAI,YAAY,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AgB,iCAAiC,UAAU,oBAAoB;AAC7F;AAAA,MACC,6DAA6D,UAAU,oBAAoB;AAAA,MAC3F;AAAA,IACD;AAAA,EACD,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,4CAA4C,GAAG,IAAI,OAAO;AAAA,EACpE;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/backupManager.js
CHANGED
|
@@ -35,13 +35,12 @@ __export(backupManager_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(backupManager_exports);
|
|
36
36
|
var schedule = __toESM(require("node-schedule"));
|
|
37
37
|
var import_logger = require("./logger");
|
|
38
|
-
let backupJob = null;
|
|
39
38
|
function initAutoBackup(adapter) {
|
|
40
39
|
const config = adapter.config;
|
|
41
|
-
stopAutoBackup();
|
|
40
|
+
stopAutoBackup(adapter);
|
|
42
41
|
if (config.autoBackupActive && config.autoBackupCron) {
|
|
43
42
|
(0, import_logger.writeLog)(`Initializing automated DTA backup with cron schedule: ${config.autoBackupCron}`, "info");
|
|
44
|
-
backupJob = schedule.scheduleJob(config.autoBackupCron, async () => {
|
|
43
|
+
adapter.backupJob = schedule.scheduleJob(config.autoBackupCron, async () => {
|
|
45
44
|
await executeDtaBackup(adapter);
|
|
46
45
|
});
|
|
47
46
|
}
|
|
@@ -90,10 +89,10 @@ async function executeDtaBackup(adapter) {
|
|
|
90
89
|
(0, import_logger.writeLog)(`Failed to execute automated DTA backup: ${msg}`, "error");
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
|
-
function stopAutoBackup() {
|
|
94
|
-
if (backupJob) {
|
|
95
|
-
backupJob.cancel();
|
|
96
|
-
backupJob = null;
|
|
92
|
+
function stopAutoBackup(adapter) {
|
|
93
|
+
if (adapter.backupJob) {
|
|
94
|
+
adapter.backupJob.cancel();
|
|
95
|
+
adapter.backupJob = null;
|
|
97
96
|
(0, import_logger.writeLog)("Automated DTA backup schedule stopped.", "debug");
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/backupManager.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as schedule from 'node-schedule';\nimport { writeLog } from './logger';\nimport type { LuxtronikAdapter } from './types';\n\n/**\n * Initialisiert den automatischen Backup-Zeitplan basierend auf der ioBroker-Konfiguration.\n *\n * @param adapter Die ioBroker Adapter-Instanz\n */\nexport function initAutoBackup(adapter: LuxtronikAdapter): void {\n\tconst config = adapter.config;\n\tstopAutoBackup(adapter); // <- Adapter muss jetzt \u00FCbergeben werden\n\n\tif (config.autoBackupActive && config.autoBackupCron) {\n\t\twriteLog(`Initializing automated DTA backup with cron schedule: ${config.autoBackupCron}`, 'info');\n\t\t// Den Job direkt IN der Adapter-Instanz speichern\n\t\tadapter.backupJob = schedule.scheduleJob(config.autoBackupCron, async () => {\n\t\t\tawait executeDtaBackup(adapter);\n\t\t});\n\t}\n}\n\n/**\n * F\u00FChrt den automatischen DTA-Download von der Luxtronik-W\u00E4rmepumpe aus\n * und speichert die Datei sicher im globalen ioBroker-Dateisystem (0_userdata.0).\n * Nutzt prim\u00E4r den direkten Datei-Stream \u00FCber /NewProc ohne k\u00FCnstliche Verz\u00F6gerung.\n *\n * @param adapter Die ioBroker Adapter-Instanz (f\u00FCr Konfiguration, Logs und Dateisystemzugriff)\n * @returns Ein Promise, das nach Abschluss des Downloads aufgel\u00F6st wird\n */\nexport async function executeDtaBackup(adapter: LuxtronikAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst ip = config.host;\n\n\tif (!ip) {\n\t\twriteLog('Backup aborted: No IP address configured.', 'warn');\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog('Fetching live DTA file (/NewProc)...', 'debug');\n\n\t\tconst isLive = true;\n\t\tlet arrayBuffer: ArrayBuffer | null = null;\n\n\t\t// 1. NewProc liefert den DTA-Speicher als direkten Datei-Stream\n\t\tlet response = await fetch(`http://${ip}/NewProc`).catch(() => null);\n\t\tif (response && response.ok) {\n\t\t\tarrayBuffer = await response.arrayBuffer();\n\t\t}\n\n\t\t// 2. Fallbacks, falls NewProc leer ist oder fehlt\n\t\tif (!arrayBuffer || arrayBuffer.byteLength < 1000) {\n\t\t\twriteLog('/NewProc did not return a valid file. Trying /procdta...', 'debug');\n\t\t\tresponse = await fetch(`http://${ip}/procdta`).catch(() => null);\n\t\t\tif (response && response.ok) {\n\t\t\t\tarrayBuffer = await response.arrayBuffer();\n\t\t\t}\n\t\t}\n\n\t\tif (!arrayBuffer || arrayBuffer.byteLength < 1000) {\n\t\t\tthrow new Error(`HTTP Error - No valid DTA file found on heat pump webserver.`);\n\t\t}\n\n\t\t// 3. Datei f\u00FCr das Dateisystem vorbereiten\n\t\tconst buffer = Buffer.from(arrayBuffer);\n\t\tconst now = new Date();\n\t\tconst y = now.getFullYear();\n\t\tconst m = String(now.getMonth() + 1).padStart(2, '0');\n\t\tconst d = String(now.getDate()).padStart(2, '0');\n\t\tconst h = String(now.getHours()).padStart(2, '0');\n\t\tconst min = String(now.getMinutes()).padStart(2, '0');\n\t\tconst s = String(now.getSeconds()).padStart(2, '0');\n\t\tconst timestamp = `${y}-${m}-${d}T${h}-${min}-${s}`;\n\t\tconst filePrefix = isLive ? 'dta_live' : 'dta_history';\n\n\t\t// DER KUGELSICHERE WEG: Speichern in 0_userdata.0\n\t\tconst targetId = '0_userdata.0';\n\t\tconst fileName = `luxtronik_backups/${filePrefix}_${timestamp}.dta`;\n\n\t\t// Speichern im ioBroker-Dateisystem\n\t\tawait adapter.writeFileAsync(targetId, fileName, buffer);\n\n\t\tadapter.log.info(`DTA Backup successfully saved as ${fileName} in folder ${targetId}.`);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Failed to execute automated DTA backup: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Stoppt den laufenden Cronjob (wichtig f\u00FCr den Adapter-Neustart).\n *\n * @param adapter Die ioBroker Adapter-Instanz\n */\nexport function stopAutoBackup(adapter: LuxtronikAdapter): void {\n\tif (adapter.backupJob) {\n\t\tadapter.backupJob.cancel();\n\t\tadapter.backupJob = null;\n\t\twriteLog('Automated DTA backup schedule stopped.', 'debug');\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAA0B;AAC1B,oBAAyB;AAQlB,SAAS,eAAe,SAAiC;AAC/D,QAAM,SAAS,QAAQ;AACvB,iBAAe,OAAO;AAEtB,MAAI,OAAO,oBAAoB,OAAO,gBAAgB;AACrD,gCAAS,yDAAyD,OAAO,cAAc,IAAI,MAAM;AAEjG,YAAQ,YAAY,SAAS,YAAY,OAAO,gBAAgB,YAAY;AAC3E,YAAM,iBAAiB,OAAO;AAAA,IAC/B,CAAC;AAAA,EACF;AACD;AAUA,eAAsB,iBAAiB,SAA0C;AAChF,QAAM,SAAS,QAAQ;AACvB,QAAM,KAAK,OAAO;AAElB,MAAI,CAAC,IAAI;AACR,gCAAS,6CAA6C,MAAM;AAC5D;AAAA,EACD;AAEA,MAAI;AACH,gCAAS,wCAAwC,OAAO;AAExD,UAAM,SAAS;AACf,QAAI,cAAkC;AAGtC,QAAI,WAAW,MAAM,MAAM,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,IAAI;AACnE,QAAI,YAAY,SAAS,IAAI;AAC5B,oBAAc,MAAM,SAAS,YAAY;AAAA,IAC1C;AAGA,QAAI,CAAC,eAAe,YAAY,aAAa,KAAM;AAClD,kCAAS,4DAA4D,OAAO;AAC5E,iBAAW,MAAM,MAAM,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,I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Manager.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hupManager.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport type { LuxtronikAdapter } from './types';\n\n/**\n * \u00DCbernimmt die dynamische Regelung der Heizungsumw\u00E4lzpumpe (HUP) anhand der Spreizung.\n *\n * @param adapter - Die erweiterte Adapter-Instanz\n * @param istHeizen - Boolean, ob sich die Anlage aktuell im Heizbetrieb befindet\n * @param spreizung - Die aktuell berechnete Temperaturspreizung (Vorlauf - R\u00FCcklauf)\n * @param hupAktiv - Die aktuell anliegende Nominalspannung der HUP\n * @param lastPumpOptimization - Timestamp der letzten Anpassung (f\u00FCr Intervall-Sperre)\n * @returns Den aktualisierten Timestamp der letzten Anpassung\n */\nexport async function handleHupOptimization(\n\tadapter: LuxtronikAdapter,\n\tistHeizen: boolean,\n\tspreizung: number,\n\thupAktiv: number,\n\tlastPumpOptimization: number,\n): Promise<number> {\n\tconst config = adapter.config;\n\n\t// Abbruch, wenn nicht geheizt wird oder das Feature deaktiviert ist\n\tif (!istHeizen || config.hup_optimierung_aktiv !== true) {\n\t\treturn lastPumpOptimization;\n\t}\n\n\tconst now = Date.now();\n\tconst checkIntervalMs = (config.hup_interval_min ?? 10) * 60000;\n\n\t// Pr\u00FCfen, ob das Schutz-Intervall abgelaufen ist\n\tif (now - lastPumpOptimization > checkIntervalMs) {\n\t\tconst minSpreizung = config.hup_spreizung_min ?? 6.5;\n\t\tconst maxSpreizung = config.hup_spreizung_max ?? 7.5;\n\t\tconst step = config.hup_voltage_step ?? 0.25;\n\t\tconst minVolt = config.hup_voltage_limit_min ?? 3.0;\n\t\tconst maxVolt = config.hup_voltage_limit_max ?? 10.0;\n\n\t\tif (spreizung < minSpreizung && hupAktiv > minVolt) {\n\t\t\tconst newVolt = Math.max(minVolt, Math.round((hupAktiv - step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too low (${spreizung}K < ${minSpreizung}K). Scaling nominal voltage down to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t} else if (spreizung > maxSpreizung && hupAktiv < maxVolt) {\n\t\t\tconst newVolt = Math.min(maxVolt, Math.round((hupAktiv + step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too high (${spreizung}K > ${maxSpreizung}K). Scaling nominal voltage up to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t}\n\t}\n\n\treturn lastPumpOptimization;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AAazB,eAAsB,sBACrB,SACA,WACA,WACA,UACA,sBACkB;AAnBnB;AAoBC,QAAM,SAAS,QAAQ;AAGvB,MAAI,CAAC,aAAa,OAAO,0BAA0B,MAAM;AACxD,WAAO;AAAA,EACR;AAEA,QAAM,MAAM,KAAK,IAAI;AACrB,QAAM,oBAAmB,YAAO,qBAAP,YAA2B,MAAM;AAG1D,MAAI,MAAM,uBAAuB,iBAAiB;AACjD,UAAM,gBAAe,YAAO,sBAAP,YAA4B;AACjD,UAAM,gBAAe,YAAO,sBAAP,YAA4B;AACjD,UAAM,QAAO,YAAO,qBAAP,YAA2B;AACxC,UAAM,WAAU,YAAO,0BAAP,YAAgC;AAChD,UAAM,WAAU,YAAO,0BAAP,YAAgC;AAEhD,QAAI,YAAY,gBAAgB,WAAW,SAAS;AACnD,YAAM,UAAU,KAAK,IAAI,SAAS,KAAK,OAAO,WAAW,QAAQ,GAAG,IAAI,GAAG;AAC3E,YAAM,QAAQ,gBAAgB,4CAA4C,OAAO;AACjF;AAAA,QACC,oCAAoC,SAAS,OAAO,YAAY,uCAAuC,OAAO;AAAA,QAC9G;AAAA,MACD;AACA,aAAO;AAAA,IACR,WAAW,YAAY,gBAAgB,WAAW,SAAS;AAC1D,YAAM,UAAU,KAAK,IAAI,SAAS,KAAK,OAAO,WAAW,QAAQ,GAAG,IAAI,GAAG;AAC3E,YAAM,QAAQ,gBAAgB,4CAA4C,OAAO;AACjF;AAAA,QACC,qCAAqC,SAAS,OAAO,YAAY,qCAAqC,OAAO;AAAA,QAC7G;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
|
@@ -303,7 +303,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
303
303
|
"heating_system_circ_pump_voltage_nominal",
|
|
304
304
|
(_d = config.sync_heating_system_circ_pump_voltage_nominal_heating) != null ? _d : 7
|
|
305
305
|
);
|
|
306
|
-
await this.syncConfigValue("
|
|
306
|
+
await this.syncConfigValue("temperature_hot_water_target", (_e = config.sync_warmwater_target_temperature) != null ? _e : 54);
|
|
307
307
|
await this.syncConfigValue("returnTemperatureHysteresis", (_f = config.sync_return_temperature_hysteresis) != null ? _f : 1.5);
|
|
308
308
|
await this.syncConfigValue("zip_aktiv", (_g = config.zip_aktiv) != null ? _g : 0);
|
|
309
309
|
await this.syncConfigValue("Heizen_nach_Wasser", (_h = config.Heating_after_warmwater) != null ? _h : false);
|
|
@@ -474,7 +474,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
474
474
|
forceSoll = 70;
|
|
475
475
|
}
|
|
476
476
|
forceSoll = Math.round(forceSoll * 10) / 10;
|
|
477
|
-
await this.syncConfigValue("
|
|
477
|
+
await this.syncConfigValue("temperature_hot_water_target", forceSoll);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
}
|
|
@@ -684,7 +684,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
684
684
|
if (this.zipTimer) {
|
|
685
685
|
clearTimeout(this.zipTimer);
|
|
686
686
|
}
|
|
687
|
-
(0, import_backupManager.stopAutoBackup)();
|
|
687
|
+
(0, import_backupManager.stopAutoBackup)(this);
|
|
688
688
|
if (this.midnightTimer) {
|
|
689
689
|
this.clearTimeout(this.midnightTimer);
|
|
690
690
|
}
|
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 {\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 {\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('warmwater_temperature', 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// Ausgelagerte HUP-Optimierung aufrufen\n\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\tthis,\n\t\t\t\t\tistHeizen,\n\t\t\t\t\tspreizung,\n\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\tthis.lastPumpOptimization,\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('warmwater_temperature', 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();\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;AACrC,2BAUO;AACP,wBAMO;AAKP,MAAM,6BAA6B,MAAM,QAAQ;AAAA;AAAA,EAEzC,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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AAM,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 { 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// Ausgelagerte HUP-Optimierung aufrufen\n\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\tthis,\n\t\t\t\t\tistHeizen,\n\t\t\t\t\tspreizung,\n\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\tthis.lastPumpOptimization,\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,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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AqF,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/notificationManager.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\n\n// =========================================================\n// TYPES & INTERFACES\n// =========================================================\n\n/**\n * Structure of an entry in the error or outage history.\n */\nexport interface ErrorHistoryEntry {\n\t/** The code of the registered error or outage */\n\tcode: number;\n\t/** The clear text description of the code */\n\tbeschreibung: string;\n\t/** The formatted date of occurrence */\n\tdatum: string;\n\t/** The raw Unix timestamp */\n\ttimestamp?: number;\n}\n\n/**\n * Extended adapter interface to provide type safety for dynamic properties and methods.\n */\nexport interface ExtendedAdapter extends AdapterInstance {\n\t/** The adapter configuration from io-package.json combined with dynamic values */\n\tconfig: ioBroker.AdapterConfig & Record<string, any>;\n\t/** Stores the timestamp of the last reported error to prevent duplicate alerts */\n\tlastKnownErrorTimestamp?: number | null;\n\t/** Stores the timestamp of the last reported outage to prevent duplicate alerts */\n\tlastKnownOutageTimestamp?: number | null;\n\t/** Timestamp of the last sent flow warning (Spam protection cooldown) */\n\tlastFlowNotificationTime?: number;\n}\n\n// =========================================================\n// HELPER FUNCTIONS\n// =========================================================\n\n/**\n * Parses a JSON string in a type-safe manner and silently handles parsing errors.\n *\n * @param value - The JSON string to parse.\n * @returns The parsed object of type T, or null if parsing fails.\n */\nfunction safeParse<T>(value: string): T | null {\n\ttry {\n\t\treturn JSON.parse(value) as T;\n\t} catch {\n\t\tvoid 0;\n\t\treturn null;\n\t}\n}\n\n/**\n * Sends a notification message via the configured channels (ioBroker Notification Center & Telegram).\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n * @returns A promise resolving to an array of successful delivery channel names.\n */\nasync function sendNotification(adapter: ExtendedAdapter, message: string): Promise<string[]> {\n\tconst config = adapter.config;\n\tconst successMessages: string[] = [];\n\n\tif (config.notification_bell === true) {\n\t\tif (typeof adapter.registerNotification === 'function') {\n\t\t\tawait adapter.registerNotification('luxtronik2-controller', 'lwpError', message);\n\t\t\twriteLog('Notification sent to ioBroker notification center.', 'info');\n\t\t\tsuccessMessages.push('Notification Center');\n\t\t} else {\n\t\t\twriteLog(`\uD83D\uDEA8 ioBroker notification center unavailable. Message: ${message}`, 'warn');\n\t\t}\n\t}\n\n\tconst telegramInstance = config.telegram_instance;\n\tconst isTelegramActive =\n\t\tconfig.telegram_enabled === true && typeof telegramInstance === 'string' && telegramInstance !== 'none';\n\n\tif (isTelegramActive) {\n\t\tconst sendObj: Record<string, any> = { text: message };\n\t\tconst receiver = config.telegram_receiver?.trim();\n\n\t\tif (receiver) {\n\t\t\tif (/^-?\\d+$/.test(receiver)) {\n\t\t\t\tsendObj.chatId = Number(receiver);\n\t\t\t} else {\n\t\t\t\tsendObj.user = receiver;\n\t\t\t}\n\t\t}\n\n\t\tadapter.sendTo(telegramInstance, 'send', sendObj);\n\t\twriteLog(`Telegram message sent to ${telegramInstance}`, 'info');\n\t\tsuccessMessages.push('Telegram');\n\t}\n\n\treturn successMessages;\n}\n\n// =========================================================\n// MAIN EXPORTS\n// =========================================================\n\n/**\n * Backwards-compatible wrapper to send Telegram notifications explicitly.\n * Forwards the request to the universal notification function.\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n */\nexport function sendTelegramNotification(adapter: ExtendedAdapter, message: string): void {\n\tvoid sendNotification(adapter, message);\n}\n\n/**\n * Handles the 'testTelegram' message from the ioBroker Admin UI.\n *\n * @param adapter - The extended adapter instance.\n * @param obj - The standardized ioBroker message structure.\n * @returns A promise resolving when the test message has been processed.\n */\nexport async function handleTestMessage(adapter: ExtendedAdapter, obj: ioBroker.Message): Promise<void> {\n\ttry {\n\t\twriteLog('Test button triggered!', 'info');\n\t\tconst config = adapter.config;\n\n\t\tconst isTelegramActive =\n\t\t\tconfig.telegram_enabled === true && config.telegram_instance && config.telegram_instance !== 'none';\n\t\tconst isIoBrokerNotifyActive = config.notification_bell === true;\n\n\t\tif (!isTelegramActive && !isIoBrokerNotifyActive) {\n\t\t\tif (obj.callback) {\n\t\t\t\tadapter.sendTo(\n\t\t\t\t\tobj.from,\n\t\t\t\t\tobj.command,\n\t\t\t\t\t{\n\t\t\t\t\t\terror: 'Error: Neither Telegram nor Notification Center are active! Please save settings first.',\n\t\t\t\t\t},\n\t\t\t\t\tobj.callback,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst errorPath = getDpPath('Fehlerspeicher');\n\t\tconst lastErrorState = errorPath ? await adapter.getStateAsync(errorPath) : null;\n\t\tlet msg = '';\n\n\t\tif (lastErrorState && typeof lastErrorState.val === 'string') {\n\t\t\tconst errorList = safeParse<ErrorHistoryEntry[]>(lastErrorState.val);\n\n\t\t\tif (errorList && errorList.length > 0) {\n\t\t\t\tconst newestError = errorList[0];\n\t\t\t\tmsg = `\uD83D\uDEA8 *Test Alarm: Error Log*\\n\\nMost recent error:\\nCode: ${newestError.code}\\nError: ${newestError.beschreibung}\\nDate: ${newestError.datum}\\n\\n`;\n\n\t\t\t\tif (errorList.length > 1) {\n\t\t\t\t\tconst history = errorList\n\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t.map(e => `Date: ${e.datum}\\nCode: ${e.code}\\nError: ${e.beschreibung}`)\n\t\t\t\t\t\t.join('\\n\\n');\n\t\t\t\t\tmsg += `History:\\n${history}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (msg === '') {\n\t\t\tmsg =\n\t\t\t\t'\u2705 *Successful Test*\\n\\nThis is a generated test message. Communication via Telegram and ioBroker works perfectly! (There are currently no real heat pump errors).';\n\t\t}\n\n\t\tconst successMessages = await sendNotification(adapter, msg);\n\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(\n\t\t\t\tobj.from,\n\t\t\t\tobj.command,\n\t\t\t\t{ result: `Successfully triggered: ${successMessages.join(' & ')}` },\n\t\t\t\tobj.callback,\n\t\t\t);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error processing test button: ${errorMessage}`, 'error');\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(obj.from, obj.command, { error: `Script error: ${errorMessage}` }, obj.callback);\n\t\t}\n\t}\n}\n\n/**\n * Checks for changes in the error log, filters out known errors,\n * and triggers an alarm for new, genuine heat pump errors.\n *\n * @param adapter - The extended adapter instance.\n * @param oldFehlerVal - The previous state of the error memory as a JSON string.\n * @param newFehlerVal - The new state of the error memory as a JSON string.\n * @returns A promise resolving when the check finishes.\n */\nexport async function checkAndSendErrorNotifications(\n\tadapter: ExtendedAdapter,\n\toldFehlerVal: string | undefined,\n\tnewFehlerVal: string | undefined,\n): Promise<void> {\n\tif (!newFehlerVal || newFehlerVal === oldFehlerVal) {\n\t\treturn;\n\t}\n\n\tconst newList = safeParse<ErrorHistoryEntry[]>(newFehlerVal);\n\tif (!newList || newList.length === 0) {\n\t\treturn;\n\t}\n\n\tconst newestError = newList[0];\n\tconst currentErrorTimestamp = newestError.timestamp;\n\tconst currentErrorCode = newestError.code;\n\n\tif (currentErrorTimestamp === undefined || currentErrorCode === 0) {\n\t\treturn;\n\t}\n\n\tif (adapter.lastKnownErrorTimestamp === undefined || adapter.lastKnownErrorTimestamp === null) {\n\t\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\t\twriteLog('Error monitoring initialized. Last known error timestamp set silently.', 'debug');\n\t\treturn;\n\t}\n\n\tif (currentErrorTimestamp <= adapter.lastKnownErrorTimestamp) {\n\t\treturn;\n\t}\n\n\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\n\tconst msg = `\uD83D\uDEA8 *Heat Pump Malfunction!*\\nAn error was registered on the heat pump:\\n\\n*Code:* ${currentErrorCode}\\n*Error:* ${newestError.beschreibung}\\n*Date:* ${newestError.datum}`;\n\n\tawait sendNotification(adapter, msg);\n}\n\n/**\n * \u00DCberwacht den Abschalt-Speicher gezielt auf kritische Durchfluss-Probleme,\n * die von der W\u00E4rmepumpe nicht sofort als \"Fehler\" gewertet werden.\n *\n * @param adapter - Die erweiterte Adapter-Instanz.\n * @param oldOutageVal - Der vorherige State der Abschaltungen (JSON).\n * @param newOutageVal - Der neue State der Abschaltungen (JSON).\n */\nexport async function checkAndSendOutageNotifications(\n\tadapter: ExtendedAdapter,\n\toldOutageVal: string | undefined,\n\tnewOutageVal: string | undefined,\n): Promise<void> {\n\tif (!newOutageVal || newOutageVal === oldOutageVal) {\n\t\treturn;\n\t}\n\n\tconst newList = safeParse<ErrorHistoryEntry[]>(newOutageVal);\n\tif (!newList || newList.length === 0) {\n\t\treturn;\n\t}\n\n\tconst newestOutage = newList[0];\n\tconst currentOutageTimestamp = newestOutage.timestamp;\n\tconst currentOutageCode = newestOutage.code;\n\n\tif (currentOutageTimestamp === undefined || currentOutageCode === 0) {\n\t\treturn;\n\t}\n\n\t// Wir filtern gezielt nach Durchfluss / Flow Problemen\n\tconst descLower = newestOutage.beschreibung.toLowerCase();\n\tconst isFlowIssue = descLower.includes('durchfluss') || descLower.includes('flow');\n\n\tif (!isFlowIssue) {\n\t\treturn;\n\t}\n\n\tif (adapter.lastKnownOutageTimestamp === undefined || adapter.lastKnownOutageTimestamp === null) {\n\t\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp;\n\t\twriteLog('Outage monitoring initialized. Last known outage timestamp set silently.', 'debug');\n\t\treturn;\n\t}\n\n\tif (currentOutageTimestamp <= adapter.lastKnownOutageTimestamp) {\n\t\treturn; // Kein neuer Eintrag\n\t}\n\n\t// Spam-Schutz: Max 1 Nachricht pro Stunde f\u00FCr denselben Abschalt-Typ\n\tconst now = Date.now();\n\tif (adapter.lastFlowNotificationTime && now - adapter.lastFlowNotificationTime < 60 * 60 * 1000) {\n\t\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp; // Zeitstempel trotzdem merken\n\t\twriteLog('Flow outage registered, but notification skipped due to 60-minute cooldown spam protection.', 'info');\n\t\treturn;\n\t}\n\n\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp;\n\tadapter.lastFlowNotificationTime = now;\n\n\tconst msg = `\u26A0\uFE0F *Warnung: Durchfluss-Problem!*\\nDie W\u00E4rmepumpe hat sich wegen geringem Durchfluss abgeschaltet:\\n\\n*Code:* ${currentOutageCode}\\n*Grund:* ${newestOutage.beschreibung}\\n*Datum:* ${newestOutage.datum}\\n\\n_Hinweis: Die Anlage versucht meist einen Neustart. Bitte Heizkreis-Druck und Stellventile pr\u00FCfen._`;\n\n\tawait sendNotification(adapter, msg);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\n// =========================================================\n// TYPES & INTERFACES\n// =========================================================\n\n/**\n * Structure of an entry in the error or outage history.\n */\nexport interface ErrorHistoryEntry {\n\t/** The code of the registered error or outage */\n\tcode: number;\n\t/** The clear text description of the code */\n\tbeschreibung: string;\n\t/** The formatted date of occurrence */\n\tdatum: string;\n\t/** The raw Unix timestamp */\n\ttimestamp?: number;\n}\n\n// =========================================================\n// HELPER FUNCTIONS\n// =========================================================\n\n/**\n * Parses a JSON string in a type-safe manner and silently handles parsing errors.\n *\n * @param value - The JSON string to parse.\n * @returns The parsed object of type T, or null if parsing fails.\n */\nfunction safeParse<T>(value: string): T | null {\n\ttry {\n\t\treturn JSON.parse(value) as T;\n\t} catch {\n\t\tvoid 0;\n\t\treturn null;\n\t}\n}\n\n/**\n * Sends a notification message via the configured channels (ioBroker Notification Center & Telegram).\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n * @returns A promise resolving to an array of successful delivery channel names.\n */\nasync function sendNotification(adapter: LuxtronikAdapter, message: string): Promise<string[]> {\n\tconst config = adapter.config;\n\tconst successMessages: string[] = [];\n\n\tif (config.notification_bell === true) {\n\t\tif (typeof adapter.registerNotification === 'function') {\n\t\t\tawait adapter.registerNotification('luxtronik2-controller', 'lwpError', message);\n\t\t\twriteLog('Notification sent to ioBroker notification center.', 'info');\n\t\t\tsuccessMessages.push('Notification Center');\n\t\t} else {\n\t\t\twriteLog(`\uD83D\uDEA8 ioBroker notification center unavailable. Message: ${message}`, 'warn');\n\t\t}\n\t}\n\n\tconst telegramInstance = config.telegram_instance;\n\tconst isTelegramActive =\n\t\tconfig.telegram_enabled === true && typeof telegramInstance === 'string' && telegramInstance !== 'none';\n\n\tif (isTelegramActive) {\n\t\tconst sendObj: Record<string, any> = { text: message };\n\t\tconst receiver = config.telegram_receiver?.trim();\n\n\t\tif (receiver) {\n\t\t\tif (/^-?\\d+$/.test(receiver)) {\n\t\t\t\tsendObj.chatId = Number(receiver);\n\t\t\t} else {\n\t\t\t\tsendObj.user = receiver;\n\t\t\t}\n\t\t}\n\n\t\tadapter.sendTo(telegramInstance, 'send', sendObj);\n\t\twriteLog(`Telegram message sent to ${telegramInstance}`, 'info');\n\t\tsuccessMessages.push('Telegram');\n\t}\n\n\treturn successMessages;\n}\n\n// =========================================================\n// MAIN EXPORTS\n// =========================================================\n\n/**\n * Backwards-compatible wrapper to send Telegram notifications explicitly.\n * Forwards the request to the universal notification function.\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n */\nexport function sendTelegramNotification(adapter: LuxtronikAdapter, message: string): void {\n\tvoid sendNotification(adapter, message);\n}\n\n/**\n * Handles the 'testTelegram' message from the ioBroker Admin UI.\n *\n * @param adapter - The extended adapter instance.\n * @param obj - The standardized ioBroker message structure.\n * @returns A promise resolving when the test message has been processed.\n */\nexport async function handleTestMessage(adapter: LuxtronikAdapter, obj: ioBroker.Message): Promise<void> {\n\ttry {\n\t\twriteLog('Test button triggered!', 'info');\n\t\tconst config = adapter.config;\n\n\t\tconst isTelegramActive =\n\t\t\tconfig.telegram_enabled === true && config.telegram_instance && config.telegram_instance !== 'none';\n\t\tconst isIoBrokerNotifyActive = config.notification_bell === true;\n\n\t\tif (!isTelegramActive && !isIoBrokerNotifyActive) {\n\t\t\tif (obj.callback) {\n\t\t\t\tadapter.sendTo(\n\t\t\t\t\tobj.from,\n\t\t\t\t\tobj.command,\n\t\t\t\t\t{\n\t\t\t\t\t\terror: 'Error: Neither Telegram nor Notification Center are active! Please save settings first.',\n\t\t\t\t\t},\n\t\t\t\t\tobj.callback,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst errorPath = getDpPath('Fehlerspeicher');\n\t\tconst lastErrorState = errorPath ? await adapter.getStateAsync(errorPath) : null;\n\t\tlet msg = '';\n\n\t\tif (lastErrorState && typeof lastErrorState.val === 'string') {\n\t\t\tconst errorList = safeParse<ErrorHistoryEntry[]>(lastErrorState.val);\n\n\t\t\tif (errorList && errorList.length > 0) {\n\t\t\t\tconst newestError = errorList[0];\n\t\t\t\tmsg = `\uD83D\uDEA8 *Test Alarm: Error Log*\\n\\nMost recent error:\\nCode: ${newestError.code}\\nError: ${newestError.beschreibung}\\nDate: ${newestError.datum}\\n\\n`;\n\n\t\t\t\tif (errorList.length > 1) {\n\t\t\t\t\tconst history = errorList\n\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t.map(e => `Date: ${e.datum}\\nCode: ${e.code}\\nError: ${e.beschreibung}`)\n\t\t\t\t\t\t.join('\\n\\n');\n\t\t\t\t\tmsg += `History:\\n${history}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (msg === '') {\n\t\t\tmsg =\n\t\t\t\t'\u2705 *Successful Test*\\n\\nThis is a generated test message. Communication via Telegram and ioBroker works perfectly! (There are currently no real heat pump errors).';\n\t\t}\n\n\t\tconst successMessages = await sendNotification(adapter, msg);\n\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(\n\t\t\t\tobj.from,\n\t\t\t\tobj.command,\n\t\t\t\t{ result: `Successfully triggered: ${successMessages.join(' & ')}` },\n\t\t\t\tobj.callback,\n\t\t\t);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error processing test button: ${errorMessage}`, 'error');\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(obj.from, obj.command, { error: `Script error: ${errorMessage}` }, obj.callback);\n\t\t}\n\t}\n}\n\n/**\n * Checks for changes in the error log, filters out known errors,\n * and triggers an alarm for new, genuine heat pump errors.\n *\n * @param adapter - The extended adapter instance.\n * @param oldFehlerVal - The previous state of the error memory as a JSON string.\n * @param newFehlerVal - The new state of the error memory as a JSON string.\n * @returns A promise resolving when the check finishes.\n */\nexport async function checkAndSendErrorNotifications(\n\tadapter: LuxtronikAdapter,\n\toldFehlerVal: string | undefined,\n\tnewFehlerVal: string | undefined,\n): Promise<void> {\n\tif (!newFehlerVal || newFehlerVal === oldFehlerVal) {\n\t\treturn;\n\t}\n\n\tconst newList = safeParse<ErrorHistoryEntry[]>(newFehlerVal);\n\tif (!newList || newList.length === 0) {\n\t\treturn;\n\t}\n\n\tconst newestError = newList[0];\n\tconst currentErrorTimestamp = newestError.timestamp;\n\tconst currentErrorCode = newestError.code;\n\n\tif (currentErrorTimestamp === undefined || currentErrorCode === 0) {\n\t\treturn;\n\t}\n\n\tif (adapter.lastKnownErrorTimestamp === undefined || adapter.lastKnownErrorTimestamp === null) {\n\t\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\t\twriteLog('Error monitoring initialized. Last known error timestamp set silently.', 'debug');\n\t\treturn;\n\t}\n\n\tif (currentErrorTimestamp <= adapter.lastKnownErrorTimestamp) {\n\t\treturn;\n\t}\n\n\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\n\tconst msg = `\uD83D\uDEA8 *Heat Pump Malfunction!*\\nAn error was registered on the heat pump:\\n\\n*Code:* ${currentErrorCode}\\n*Error:* ${newestError.beschreibung}\\n*Date:* ${newestError.datum}`;\n\n\tawait sendNotification(adapter, msg);\n}\n\n/**\n * \u00DCberwacht den Abschalt-Speicher gezielt auf kritische Durchfluss-Probleme,\n * die von der W\u00E4rmepumpe nicht sofort als \"Fehler\" gewertet werden.\n *\n * @param adapter - Die erweiterte Adapter-Instanz.\n * @param oldOutageVal - Der vorherige State der Abschaltungen (JSON).\n * @param newOutageVal - Der neue State der Abschaltungen (JSON).\n */\nexport async function checkAndSendOutageNotifications(\n\tadapter: LuxtronikAdapter,\n\toldOutageVal: string | undefined,\n\tnewOutageVal: string | undefined,\n): Promise<void> {\n\tif (!newOutageVal || newOutageVal === oldOutageVal) {\n\t\treturn;\n\t}\n\n\tconst newList = safeParse<ErrorHistoryEntry[]>(newOutageVal);\n\tif (!newList || newList.length === 0) {\n\t\treturn;\n\t}\n\n\tconst newestOutage = newList[0];\n\tconst currentOutageTimestamp = newestOutage.timestamp;\n\tconst currentOutageCode = newestOutage.code;\n\n\tif (currentOutageTimestamp === undefined || currentOutageCode === 0) {\n\t\treturn;\n\t}\n\n\t// Wir filtern gezielt nach Durchfluss / Flow Problemen\n\tconst descLower = newestOutage.beschreibung.toLowerCase();\n\tconst isFlowIssue = descLower.includes('durchfluss') || descLower.includes('flow');\n\n\tif (!isFlowIssue) {\n\t\treturn;\n\t}\n\n\tif (adapter.lastKnownOutageTimestamp === undefined || adapter.lastKnownOutageTimestamp === null) {\n\t\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp;\n\t\twriteLog('Outage monitoring initialized. Last known outage timestamp set silently.', 'debug');\n\t\treturn;\n\t}\n\n\tif (currentOutageTimestamp <= adapter.lastKnownOutageTimestamp) {\n\t\treturn; // Kein neuer Eintrag\n\t}\n\n\t// Spam-Schutz: Max 1 Nachricht pro Stunde f\u00FCr denselben Abschalt-Typ\n\tconst now = Date.now();\n\tif (adapter.lastFlowNotificationTime && now - adapter.lastFlowNotificationTime < 60 * 60 * 1000) {\n\t\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp; // Zeitstempel trotzdem merken\n\t\twriteLog('Flow outage registered, but notification skipped due to 60-minute cooldown spam protection.', 'info');\n\t\treturn;\n\t}\n\n\tadapter.lastKnownOutageTimestamp = currentOutageTimestamp;\n\tadapter.lastFlowNotificationTime = now;\n\n\tconst msg = `\u26A0\uFE0F *Warnung: Durchfluss-Problem!*\\nDie W\u00E4rmepumpe hat sich wegen geringem Durchfluss abgeschaltet:\\n\\n*Code:* ${currentOutageCode}\\n*Grund:* ${newestOutage.beschreibung}\\n*Datum:* ${newestOutage.datum}\\n\\n_Hinweis: Die Anlage versucht meist einen Neustart. Bitte Heizkreis-Druck und Stellventile pr\u00FCfen._`;\n\n\tawait sendNotification(adapter, msg);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AA+B1B,SAAS,UAAa,OAAyB;AAC9C,MAAI;AACH,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB,QAAQ;AAEP,WAAO;AAAA,EACR;AACD;AASA,eAAe,iBAAiB,SAA2B,SAAoC;AAhD/F;AAiDC,QAAM,SAAS,QAAQ;AACvB,QAAM,kBAA4B,CAAC;AAEnC,MAAI,OAAO,sBAAsB,MAAM;AACtC,QAAI,OAAO,QAAQ,yBAAyB,YAAY;AACvD,YAAM,QAAQ,qBAAqB,yBAAyB,YAAY,OAAO;AAC/E,kCAAS,sDAAsD,MAAM;AACrE,sBAAgB,KAAK,qBAAqB;AAAA,IAC3C,OAAO;AACN,kCAAS,gEAAyD,OAAO,IA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