iobroker.luxtronik2-controller 0.24.0 → 0.25.0-alpha.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 CHANGED
@@ -102,6 +102,24 @@ You might see red error messages in the installation log related to `node-gyp`,
102
102
  //### **WORK IN PROGRESS**
103
103
 
104
104
  ## Changelog
105
+
106
+ **WORK IN PROGRESS**
107
+ ### 0.25.0-alpha.0 (2026-11-15)
108
+
109
+ - **Operating Mode & UI Protection (`jsonConfig.json`, `main.ts`):**
110
+ - **Explicit Operating Mode Selection:** Added a central selector in the Connection tab with color-coded status banners to clearly distinguish between **Read-Only (Monitoring)**, **Read & Write without Modbus (Native via Port 8889)**, and **Read & Write with Modbus TCP (Hybrid RAM access)**.
111
+ - **Dynamic UI & Backend Write Locking:** In Read-Only mode, all write-related configuration tabs (Modbus, Idle Defaults, Cycle Optimization, HUP, ZIP, PV Surplus) are automatically grayed out and all hardware write commands are strictly blocked in the backend.
112
+ - **Automatic Config Migration:** Existing installations are seamlessly migrated on startup to the matching operating mode based on previously active settings.
113
+ - **Modbus V3.9x Smart Home Interface (SHI) & Diagnostics (`modbusManager.ts`, `settings.ts`, `info.ts`):**
114
+ - **Dual-Protocol Auto-Detection:** The Modbus manager now automatically detects and supports both the classic Modbus register mapping (`0..23`) and the modern **V3.90+ / V3.92.x Smart Home Interface (SHI)** register architecture (`10000+`).
115
+ - **Automated SHI Mode-Gating:** Writing to SHI setpoints and offsets (`10001`, `10002`, `10006`) automatically activates the required SHI control mode registers (`10000`, `10005`, `10065`) and releases heating curve control (`mode = 0`) when the offset returns to `0 K`.
116
+ - **Granular Register Polling & Diagnostic Scanner:** Replaced rigid block reads with individual register polling to prevent `Exception 2 (Illegal data address)` crashes on unsupported registers, and integrated a full Modbus register scanner into `Dump_Raw_To_Log`.
117
+ - **Core Stability, COP & Pure TCP Communication (`main.ts`, `rawFunctions.ts`, `copManager.ts`):**
118
+ - **Pure Native TCP Architecture:** Removed deprecated WebSocket (port 8214) code in favor of stable, password-free native TCP communication over port `8889`.
119
+ - **Isolated COP & Energy Tracking:** Enforced strict separation of reference states for heating, hot water, and total consumption with fallback logic for controllers affected by zero-value firmware bugs.
120
+ - **Bug Fixes:** Fixed Modbus RAM vs. EEPROM sync loops (`hardwareOutOfSync`), unified `°C` temperature scaling across all data sources, and fixed offline detection (`info.connection` & `errorCount`) when telemetry reads fail.
121
+ - **Repository Checker & i18n:** Completed missing 11-language translations in `jsonConfig.json` and updated `@iobroker/testing` to `6.3.2`.
122
+
105
123
  ### 0.24.0 (2026-11-09)
106
124
 
107
125
  **🐛 Bugfixes & Tweaks**
@@ -133,15 +151,6 @@ You might see red error messages in the installation log related to `node-gyp`,
133
151
  - **Custom Heating Offset Baseline:** Added a new configuration field in the "Idle Defaults" tab for the default heating target temperature offset (Parallelverschiebung)[cite: 10].
134
152
  - **Preserved Baselines:** The idle reset mechanism (`main.ts`) and the PV surplus manager (`pvManager.ts`) now respect this custom baseline (e.g., +1 K) instead of hard-resetting the offset to `0 K`[cite: 7, 13]. This ensures that your manual baseline heating curve is perfectly preserved when returning from a PV boost or entering standby.
135
153
 
136
- ### 0.22.8 (2026-11-07)
137
-
138
- **🐛 Bugfixes & Tweaks**
139
-
140
- - **COP & Efficiency Calculation (`copManager.ts`):**
141
- - **Hot Water Hardware Bug Fallback:** Added a dynamic fallback mechanism to bypass a hardware bug present in several Luxtronik and Novelan firmwares where the internal electrical meter for hot water (`energy_warmwater`) permanently reports `0`.
142
- - **Smart Delta Routing:** When the heat pump is actively generating hot water (`WP_BZ_akt === 1`), the COP manager now checks if the internal DHW power meter is stuck at zero. If so, it automatically intercepts the delta from the total energy meter (`energy_total`) over the last polling interval and securely routes it into the Hot Water COP bucket.
143
- - **Continuous Standby Sync:** Enhanced the database tracking to ensure the total energy fallback counter is continuously synced even during standby or heating modes. This prevents idle power consumption from accumulating in the background and falsely distorting the next hot water efficiency calculation.
144
-
145
154
  ## License
146
155
 
147
156
  MIT License
@@ -44,8 +44,8 @@
44
44
  "de": "Wärmepumpen Port"
45
45
  },
46
46
  "help": {
47
- "en": "Standard TCP: 8889 | Firmware > 3.81 (WebSockets): 8214",
48
- "de": "Standard TCP: 8889 | Firmware > 3.81 (WebSockets): 8214"
47
+ "en": "Standard Native TCP: 8889 (For very old V1.x firmwares: 8888)",
48
+ "de": "Standard Native TCP: 8889 (Bei sehr alten V1.x Firmwares: 8888)"
49
49
  },
50
50
  "min": 1,
51
51
  "max": 65535,
@@ -116,30 +116,18 @@
116
116
  },
117
117
  "operation_mode": {
118
118
  "type": "select",
119
- "label": {
120
- "en": "Select Operating Mode",
121
- "de": "Betriebsmodus auswählen"
122
- },
119
+ "label": "Select Operating Mode",
123
120
  "options": [
124
121
  {
125
- "label": {
126
- "en": "🔒 Read-Only (Monitoring only – 0% flash wear, all optimizations disabled)",
127
- "de": "🔒 Nur Lesend (Reines Monitoring – 0% Flash-Verschleiß, alle Optimierungen deaktiviert)"
128
- },
122
+ "label": "🔒 Read-Only (Monitoring only – 0% flash wear, all optimizations disabled)",
129
123
  "value": "readonly"
130
124
  },
131
125
  {
132
- "label": {
133
- "en": "✍️ Read & Write: Without Modbus (Native via Port 8889 – writes to EEPROM)",
134
- "de": "✍️ Schreibend: Ohne Modbus (Nativ über Port 8889 – schreibt in EEPROM)"
135
- },
126
+ "label": "✍️ Read & Write: Without Modbus (Native via Port 8889 – writes to EEPROM)",
136
127
  "value": "native"
137
128
  },
138
129
  {
139
- "label": {
140
- "en": "⚡ Read & Write: With Modbus TCP (Hybrid – wear-free RAM access)",
141
- "de": "⚡ Schreibend: Mit Modbus TCP (Hybrid – verschleißfreier RAM-Zugriff)"
142
- },
130
+ "label": "⚡ Read & Write: With Modbus TCP (Hybrid – wear-free RAM access)",
143
131
  "value": "modbus"
144
132
  }
145
133
  ],
@@ -366,8 +354,8 @@
366
354
  "sync_modbus_holding_1": {
367
355
  "type": "checkbox",
368
356
  "label": {
369
- "en": "Target return temperature (Holding 1)",
370
- "de": "Rücklauf Soll (Holding 1)"
357
+ "en": "Target temp room thermostat (Holding 10060)",
358
+ "de": "Zieltemperatur Raumthermostat (Holding 10060)"
371
359
  },
372
360
  "default": false,
373
361
  "disabled": "!data.modbus_active",
package/build/main.js CHANGED
@@ -298,7 +298,6 @@ class Luxtronik2Controller extends utils.Adapter {
298
298
  this.log.error(`Error during cyclic data retrieval loop: ${error.message}`);
299
299
  }
300
300
  }, intervalSeconds * 1e3);
301
- await this.setState("info.connection", true, true);
302
301
  }
303
302
  /**
304
303
  * Berechnet die Zeit bis Mitternacht und setzt NUR den heutigen Schreibzähler auf 0 zurück.
@@ -349,16 +348,16 @@ class Luxtronik2Controller extends utils.Adapter {
349
348
  if (isRawWrite && definition.unit === "\xB0C" && typeof val === "number" && !appliedFactor) {
350
349
  valueToWrite = val * 10;
351
350
  }
351
+ const isModbusEnabled = Boolean(
352
+ this.modbusManager && this.modbusManager.isAvailable && config.modbus_active && definition.modbus && config[definition.modbus.configKey] === true
353
+ );
352
354
  const writeId = definition.luxWriteId ? parseInt(definition.luxWriteId, 10) : NaN;
353
- const hardwareOutOfSync = !definition.isVirtual && !isNaN(writeId) && writeId < 9990 && this.currentRawParams.length > writeId && this.currentRawParams[writeId] !== Math.round(Number(valueToWrite));
355
+ const hardwareOutOfSync = !isModbusEnabled && !definition.isVirtual && !isNaN(writeId) && writeId < 9990 && this.currentRawParams.length > writeId && this.currentRawParams[writeId] !== Math.round(Number(valueToWrite));
354
356
  if (!state || state.val !== val || hardwareOutOfSync) {
355
357
  await this.setState(id, { val, ack: true });
356
358
  if (this.isDebugLogActive) {
357
359
  (0, import_logger.writeLog)(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, "info");
358
360
  }
359
- const isModbusEnabled = Boolean(
360
- this.modbusManager && this.modbusManager.isAvailable && config.modbus_active && definition.modbus && config[definition.modbus.configKey] === true
361
- );
362
361
  if ((definition.write === true || isModbusEnabled) && !definition.isVirtual && definition.luxWriteId) {
363
362
  try {
364
363
  if (isModbusEnabled && definition.modbus) {
@@ -677,20 +676,26 @@ class Luxtronik2Controller extends utils.Adapter {
677
676
  const delayHelper = (ms) => new Promise((resolve) => this.setTimeout(resolve, ms));
678
677
  let rawParams = [];
679
678
  let rawValues = [];
679
+ let lastReadError = "";
680
680
  try {
681
681
  rawParams = await (0, import_rawFunctions.readAllRaw)(this, 3003);
682
- this.currentRawParams = rawParams;
682
+ if (rawParams.length > 0) {
683
+ this.currentRawParams = rawParams;
684
+ }
683
685
  } catch (err) {
684
- this.log.debug(
685
- `Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`
686
- );
686
+ lastReadError = err instanceof Error ? err.message : String(err);
687
+ this.log.debug(`Raw parameter acquisition response error (Command 3003): ${lastReadError}`);
687
688
  }
688
689
  await delayHelper(200);
689
690
  try {
690
691
  rawValues = await (0, import_rawFunctions.readAllRaw)(this, 3004);
691
692
  } catch (err) {
692
- this.log.debug(
693
- `Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`
693
+ lastReadError = err instanceof Error ? err.message : String(err);
694
+ this.log.debug(`Raw telemetry value acquisition response error (Command 3004): ${lastReadError}`);
695
+ }
696
+ if (rawParams.length === 0 && rawValues.length === 0) {
697
+ throw new Error(
698
+ `No telemetry or parameter data received from heat pump (${lastReadError || "empty response"}).`
694
699
  );
695
700
  }
696
701
  const config = this.config;
@@ -716,14 +721,22 @@ class Luxtronik2Controller extends utils.Adapter {
716
721
  switch (definition.dataSource) {
717
722
  case "raw_parameter":
718
723
  value = rawParams == null ? void 0 : rawParams[parseInt(luxId, 10)];
719
- if (value !== void 0 && appliedFactor) {
720
- value /= appliedFactor;
724
+ if (value !== void 0) {
725
+ if (appliedFactor) {
726
+ value /= appliedFactor;
727
+ } else if (definition.unit === "\xB0C") {
728
+ value /= 10;
729
+ }
721
730
  }
722
731
  break;
723
732
  case "raw_value":
724
733
  value = rawValues == null ? void 0 : rawValues[parseInt(luxId, 10)];
725
- if (value !== void 0 && appliedFactor) {
726
- value /= appliedFactor;
734
+ if (value !== void 0) {
735
+ if (appliedFactor) {
736
+ value /= appliedFactor;
737
+ } else if (definition.unit === "\xB0C") {
738
+ value /= 10;
739
+ }
727
740
  }
728
741
  break;
729
742
  case "parameter":
@@ -736,8 +749,12 @@ class Luxtronik2Controller extends utils.Adapter {
736
749
  if (/^\d+$/.test(luxId)) {
737
750
  const idx = parseInt(luxId, 10);
738
751
  value = definition.folder.startsWith("Settings") ? rawParams == null ? void 0 : rawParams[idx] : rawValues == null ? void 0 : rawValues[idx];
739
- if (value !== void 0 && appliedFactor) {
740
- value /= appliedFactor;
752
+ if (value !== void 0) {
753
+ if (appliedFactor) {
754
+ value /= appliedFactor;
755
+ } else if (definition.unit === "\xB0C") {
756
+ value /= 10;
757
+ }
741
758
  }
742
759
  } else {
743
760
  value = void 0;
@@ -756,7 +773,7 @@ class Luxtronik2Controller extends utils.Adapter {
756
773
  value = modbusData.coils[reg] ? 1 : 0;
757
774
  }
758
775
  }
759
- if (value !== void 0 && typeof value === "number" && appliedFactor) {
776
+ if (value !== void 0 && typeof value === "number" && (appliedFactor || definition.unit === "\xB0C")) {
760
777
  value = Math.round(value * 100) / 100;
761
778
  }
762
779
  if (value !== void 0) {
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 * as schedule from 'node-schedule';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initAutoBackup, stopAutoBackup } from './backupManager';\nimport { formatTimerSecondsToTime, timeStringToSeconds } from './convert';\nimport { processCopData } from './copManager';\nimport { handleHupOptimization } from './hupManager';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport { ModbusManager } from './modbusManager';\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 {\n\tevaluatePvBoost,\n\tforceResetPvBoost,\n\thandlePvCycleCheck,\n\thandlePvFeedInChange,\n\tinitPvManagement,\n\tpvIsBoostActive,\n} from './pvManager';\n\nimport { dumpAllRawToLog, queueWrite, readAllRaw } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport { generateHeatCurveSVG } from './svgGenerator';\nimport type { LuxtronikAdapter } from './types';\nimport { checkFirmwareUpdate } from './updateManager';\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\t/** Modbus Manager f\u00FCr hybride Schreib- und Lesevorg\u00E4nge (SmartGrid / Vorlauf / ZIP) */\n\tpublic modbusManager!: ModbusManager;\n\t/** ioBroker interval handle for the ZIP remaining time countdown */\n\tpublic zipCountdownInterval?: ioBroker.Interval;\n\t/** Target timestamp when the current ZIP run finishes */\n\tpublic zipEndTime?: number;\n\t/** Cron-Job Handle f\u00FCr die Firmware-Update-Pr\u00FCfung */\n\tpublic updateCronJob?: schedule.Job;\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\t// 1. Config als Record casten, um TypeScript-Fehler zu vermeiden\n\t\tconst config = this.config as Record<string, any>;\n\n\t\t// =========================================================\n\t\t// MIGRATION: ZIP Control Mode & Operation Mode (Bestandsnutzer)\n\t\t// =========================================================\n\t\tlet configUpdated = false;\n\t\tif (config.zip_control_mode === undefined) {\n\t\t\tlet migratedMode = 'controller'; // Default\n\n\t\t\tconst actors = config.actors || [];\n\t\t\tconst validActors = actors.filter(\n\t\t\t\t(a: any) => a.zip_external_relay_id && a.zip_external_relay_id.trim() !== '',\n\t\t\t);\n\n\t\t\tif (validActors.length > 0) {\n\t\t\t\tmigratedMode = 'actor';\n\t\t\t} else if (config.modbus_active && config.sync_modbus_coil_7) {\n\t\t\t\tmigratedMode = 'modbus';\n\t\t\t}\n\n\t\t\tconfig.zip_control_mode = migratedMode;\n\t\t\tconfigUpdated = true;\n\t\t\twriteLog(`[Migration] Updated zip_control_mode to '${migratedMode}' based on legacy settings.`, 'info');\n\t\t}\n\n\t\tif (config.operation_mode === undefined) {\n\t\t\tif (config.modbus_active === true) {\n\t\t\t\tconfig.operation_mode = 'modbus';\n\t\t\t} else if (\n\t\t\t\tconfig.idle_defaults_aktiv === true ||\n\t\t\t\tconfig.regelung_aktiv === true ||\n\t\t\t\tconfig.hup_optimierung_aktiv === true ||\n\t\t\t\tconfig.pv_active === true ||\n\t\t\t\tconfig.zip_optimierung_aktiv === true\n\t\t\t) {\n\t\t\t\tconfig.operation_mode = 'native';\n\t\t\t} else {\n\t\t\t\tconfig.operation_mode = 'readonly';\n\t\t\t}\n\t\t\tconfigUpdated = true;\n\t\t\twriteLog(`[Migration] Set operation_mode to '${config.operation_mode}' based on legacy settings.`, 'info');\n\t\t}\n\n\t\t// Halte modbus_active immer synchron zu operation_mode\n\t\tconst shouldModbusBeActive = config.operation_mode === 'modbus';\n\t\tif (config.modbus_active !== shouldModbusBeActive) {\n\t\t\tconfig.modbus_active = shouldModbusBeActive;\n\t\t\tconfigUpdated = true;\n\t\t}\n\n\t\t// Falls migriert wurde -> direkt in der ioBroker-Datenbank speichern\n\t\tif (configUpdated) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getForeignObjectAsync(`system.adapter.${this.namespace}`);\n\t\t\t\tif (obj && obj.native) {\n\t\t\t\t\tobj.native.zip_control_mode = config.zip_control_mode;\n\t\t\t\t\tobj.native.operation_mode = config.operation_mode;\n\t\t\t\t\tobj.native.modbus_active = config.modbus_active;\n\t\t\t\t\tawait this.setForeignObject(`system.adapter.${this.namespace}`, obj);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`[Migration] Failed to save updated config: ${err.message}`, 'error');\n\t\t\t}\n\t\t}\n\t\t// =========================================================\n\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\t\tawait this.subscribeStatesAsync('Information.12_SystemInfo.check_firmware');\n\n\t\tconst isReadOnly = config.operation_mode === 'readonly';\n\n\t\t// Strikte Pr\u00FCfung des Betriebsmodus beim Start\n\t\tif (isReadOnly) {\n\t\t\twriteLog(\n\t\t\t\t'\uD83D\uDD12 Operating Mode: READ-ONLY. All hardware write operations and optimizations are disabled.',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: false, ack: true });\n\t\t} else if (config.operation_mode === 'modbus') {\n\t\t\twriteLog('\u26A1 Operating Mode: READ/WRITE WITH MODBUS TCP (Hybrid).', 'info');\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\t\t} else {\n\t\t\twriteLog('\u270D\uFE0F Operating Mode: READ/WRITE WITHOUT MODBUS (Native TCP Port 8889).', 'info');\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\t\t}\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\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\n\t\tif (!isReadOnly) {\n\t\t\tawait disableHardwareZipTimer(this);\n\t\t\tsubscribeMotionSensors(this);\n\t\t\t// PV-Steuerung initialisieren\n\t\t\tawait initPvManagement(this);\n\t\t}\n\n\t\tthis.subscribeStates('*');\n\n\t\t// --- MODBUS HYBRID INITIALISIERUNG (Vor dem ersten updateData-Aufruf) ---\n\t\tthis.modbusManager = new ModbusManager(this);\n\t\tif (!isReadOnly && config.modbus_active) {\n\t\t\twriteLog('Checking Modbus TCP availability for hybrid operations...', 'info');\n\t\t\tawait this.modbusManager.checkAvailability();\n\t\t}\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\tconst dpVirtualZipRemaining = getDpPath('Virtual_ZIP_Remaining_Time');\n\t\tif (dpVirtualZipRemaining) {\n\t\t\tawait this.setState(dpVirtualZipRemaining, { val: 0, 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\t// --- FIRMWARE UPDATE TIMER ---\n\t\tif (config.update_check_active === true) {\n\t\t\t// Erste Pr\u00FCfung 15 Sekunden nach Adapter-Start (damit die aktuelle Firmware bereits gelesen wurde)\n\t\t\tthis.setTimeout(() => {\n\t\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\t}, 15000);\n\n\t\t\t// Cronjob f\u00FCr regelm\u00E4\u00DFige Pr\u00FCfungen einrichten\n\t\t\tconst cronString = config.update_check_cron || '0 12 * * *';\n\t\t\ttry {\n\t\t\t\tthis.updateCronJob = schedule.scheduleJob(cronString, () => {\n\t\t\t\t\tthis.log.info('F\u00FChre geplante Firmware-Update-Pr\u00FCfung aus (Cron)...');\n\t\t\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\t\t});\n\t\t\t} catch (err: any) {\n\t\t\t\tthis.log.error(`Fehler beim Einrichten des Firmware-Update-Crons (${cronString}): ${err.message}`);\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 * Automatically routes via Modbus TCP if hybrid mode is enabled for the target datapoint.\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\tconst config = this.config as Record<string, any>;\n\t\tif (config.operation_mode === 'readonly') {\n\t\t\treturn;\n\t\t}\n\t\tif (val === undefined || val === null) {\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\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tlet appliedFactor = definition.factor;\n\t\tif (\n\t\t\tmappingKey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\tmappingKey === 'heating_system_circ_pump_voltage_minimal'\n\t\t) {\n\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t}\n\n\t\tlet valueToWrite: any = val;\n\t\tif (typeof valueToWrite === 'boolean') {\n\t\t\tvalueToWrite = valueToWrite ? 1 : 0;\n\t\t} else if (appliedFactor && typeof val === 'number') {\n\t\t\tvalueToWrite = val * appliedFactor;\n\t\t}\n\n\t\tconst isRawWrite =\n\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !appliedFactor) {\n\t\t\tvalueToWrite = val * 10;\n\t\t}\n\n\t\tconst writeId = definition.luxWriteId ? parseInt(definition.luxWriteId, 10) : NaN;\n\t\tconst hardwareOutOfSync =\n\t\t\t!definition.isVirtual &&\n\t\t\t!isNaN(writeId) &&\n\t\t\twriteId < 9990 &&\n\t\t\tthis.currentRawParams.length > writeId &&\n\t\t\tthis.currentRawParams[writeId] !== Math.round(Number(valueToWrite));\n\n\t\tif (!state || state.val !== val || hardwareOutOfSync) {\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\tconst isModbusEnabled = Boolean(\n\t\t\t\tthis.modbusManager &&\n\t\t\t\tthis.modbusManager.isAvailable &&\n\t\t\t\tconfig.modbus_active &&\n\t\t\t\tdefinition.modbus &&\n\t\t\t\tconfig[definition.modbus.configKey] === true,\n\t\t\t);\n\n\t\t\tif ((definition.write === true || isModbusEnabled) && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\ttry {\n\t\t\t\t\tif (isModbusEnabled && definition.modbus) {\n\t\t\t\t\t\tconst isCoil = definition.modbus.type === 'coil';\n\t\t\t\t\t\tawait this.modbusManager.writeRegister(\n\t\t\t\t\t\t\tdefinition.modbus.register,\n\t\t\t\t\t\t\tNumber(valueToWrite),\n\t\t\t\t\t\t\tisCoil,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (!isNaN(writeId) && writeId < 9990) {\n\t\t\t\t\t\tawait queueWrite(this, writeId, valueToWrite);\n\t\t\t\t\t}\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\n\t\t\t// FIX: Hier nicht mehr hart auf 0, sondern auf deinen eigenen Config-Wert setzen\n\t\t\tawait this.syncConfigValue('heating_temperature', config.sync_heating_temperature ?? 0);\n\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\n\t\t\t// WICHTIG: Wenn der PV-Boost aktiv ist, PV-Sollwerte sofort wieder \u00FCber die Leerlauf-Werte b\u00FCgeln!\n\t\t\tif (pvIsBoostActive) {\n\t\t\t\tawait evaluatePvBoost(this, true);\n\t\t\t}\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 * @param rawValues - Optional raw telemetry values array from command 3004 as fallback.\n\t * @param rawParams - Optional raw parameters array from command 3003 as fallback.\n\t * @returns A promise that resolves when the execution cycle finishes.\n\t */\n\tprivate async runOptimizationSchedule(rawValues: number[] = [], rawParams: number[] = []): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tif (config.operation_mode === 'readonly') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal =\n\t\t\t\tbzState && bzState.val !== null\n\t\t\t\t\t? String(bzState.val).trim()\n\t\t\t\t\t: rawValues[80] !== undefined\n\t\t\t\t\t\t? String(rawValues[80])\n\t\t\t\t\t\t: '';\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 (this.lastBzVal === '1' && config.idle_defaults_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'temperature_hot_water_target',\n\t\t\t\t\t\t\tconfig.sync_warmwater_target_temperature ?? 54,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (pvIsBoostActive) {\n\t\t\t\t\t\t\tawait evaluatePvBoost(this, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\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\tconst mode = config.zip_control_mode || 'controller';\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\tconst canRunWearFree =\n\t\t\t\t\t\t\t(mode === 'actor' && validActors.length > 0) ||\n\t\t\t\t\t\t\t(mode === 'modbus' && this.modbusManager?.isAvailable);\n\n\t\t\t\t\t\tif (canRunWearFree) {\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] Wear-free mode (${mode}) active. Starting circulation synchronous to hot water generation.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 120);\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\twwTargetParamState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\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('temperature_hot_water_target')),\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('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\t// Sichere Auswertung mit Rohdaten-Fallback (falls Datenpunkte im Objektbaum deaktiviert sind)\n\t\t\tconst wwSoll =\n\t\t\t\ttypeof wwSollState?.val === 'number'\n\t\t\t\t\t? wwSollState.val\n\t\t\t\t\t: typeof wwTargetParamState?.val === 'number'\n\t\t\t\t\t\t? wwTargetParamState.val\n\t\t\t\t\t\t: rawValues[18] !== undefined\n\t\t\t\t\t\t\t? rawValues[18] / 10\n\t\t\t\t\t\t\t: rawParams[105] !== undefined\n\t\t\t\t\t\t\t\t? rawParams[105] / 10\n\t\t\t\t\t\t\t\t: 54;\n\t\t\tconst wwIst =\n\t\t\t\ttypeof wwIstState?.val === 'number'\n\t\t\t\t\t? wwIstState.val\n\t\t\t\t\t: rawValues[17] !== undefined\n\t\t\t\t\t\t? rawValues[17] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst ruecklauf =\n\t\t\t\ttypeof ruecklaufState?.val === 'number'\n\t\t\t\t\t? ruecklaufState.val\n\t\t\t\t\t: rawValues[11] !== undefined\n\t\t\t\t\t\t? rawValues[11] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst ruecklaufSoll =\n\t\t\t\ttypeof ruecklaufSollState?.val === 'number'\n\t\t\t\t\t? ruecklaufSollState.val\n\t\t\t\t\t: rawValues[12] !== undefined\n\t\t\t\t\t\t? rawValues[12] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst spreizung =\n\t\t\t\ttypeof spreizungState?.val === 'number'\n\t\t\t\t\t? spreizungState.val\n\t\t\t\t\t: rawValues[10] !== undefined && rawValues[11] !== undefined\n\t\t\t\t\t\t? (rawValues[10] - rawValues[11]) / 10\n\t\t\t\t\t\t: 0;\n\n\t\t\t// FIX: VD1out kann im State als boolean (true) oder number (1) vorliegen!\n\t\t\tconst vd1 =\n\t\t\t\tvd1State?.val !== undefined && vd1State?.val !== null\n\t\t\t\t\t? vd1State.val === 1 || vd1State.val === true || String(vd1State.val).toLowerCase() === 'true'\n\t\t\t\t\t: rawValues[44] === 1;\n\n\t\t\tconst wwHysterese =\n\t\t\t\ttypeof wwHystereseState?.val === 'number'\n\t\t\t\t\t? wwHystereseState.val\n\t\t\t\t\t: rawParams[74] !== undefined\n\t\t\t\t\t\t? rawParams[74] / 10\n\t\t\t\t\t\t: 2.0;\n\t\t\tconst currentHupVolt = (currentHupVoltState?.val as number) ?? 7.0;\n\t\t\tconst heizenHysterese =\n\t\t\t\ttypeof heizenHystereseState?.val === 'number'\n\t\t\t\t\t? heizenHystereseState.val\n\t\t\t\t\t: rawParams[88] !== undefined\n\t\t\t\t\t\t? rawParams[88] / 10\n\t\t\t\t\t\t: 1.5;\n\t\t\tconst mitteltemperatur =\n\t\t\t\ttypeof mitteltempState?.val === 'number'\n\t\t\t\t\t? mitteltempState.val\n\t\t\t\t\t: rawValues[16] !== undefined\n\t\t\t\t\t\t? rawValues[16] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst thresholdHeatingLimit =\n\t\t\t\ttypeof thresholdHeatingLimitState?.val === 'number'\n\t\t\t\t\t? thresholdHeatingLimitState.val\n\t\t\t\t\t: rawParams[700] !== undefined\n\t\t\t\t\t\t? rawParams[700] / 10\n\t\t\t\t\t\t: 15;\n\n\t\t\t// FIX: heatingLimit typsicher auf Boolean (true/false) UND Number (1/0) pr\u00FCfen!\n\t\t\tconst isHeatingLimitEnabled =\n\t\t\t\theatingLimitState?.val !== undefined && heatingLimitState?.val !== null\n\t\t\t\t\t? heatingLimitState.val === 1 ||\n\t\t\t\t\t\theatingLimitState.val === true ||\n\t\t\t\t\t\tString(heatingLimitState.val) === '1' ||\n\t\t\t\t\t\tString(heatingLimitState.val).toLowerCase() === 'true'\n\t\t\t\t\t: rawParams[699] === 1;\n\n\t\t\tconst nachWasser = Boolean(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 (aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunktState = await this.getStateAsync(getDpPath('heating_curve_parallel_offset'));\n\t\t\t\t\tconst currentFusspunkt =\n\t\t\t\t\t\ttypeof fusspunktState?.val === 'number'\n\t\t\t\t\t\t\t? fusspunktState.val\n\t\t\t\t\t\t\t: rawParams[13] !== undefined\n\t\t\t\t\t\t\t\t? rawParams[13] / 10\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tif (currentFusspunkt === 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\tif (aelterAls10 && vd1) {\n\t\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\tistHeizen,\n\t\t\t\t\t\tspreizung,\n\t\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\t\tthis.lastPumpOptimization,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\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 am Ende des Heiztaktes erzwingen\n\t\t\t\t\tif (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t\t\t\t\t// Handshake mit dem PV-Manager:\n\t\t\t\t\t\t// Wenn PV aktiv ist, stellen wir sicher, dass der Takt mindestens bis zum PV-Sollwert gefahren wird\n\t\t\t\t\t\tif (pvIsBoostActive) {\n\t\t\t\t\t\t\tconst baseWw =\n\t\t\t\t\t\t\t\tparseFloat(String(config.sync_warmwater_target_temperature).replace(',', '.')) || 54;\n\t\t\t\t\t\t\tconst boostWw = parseFloat(String(config.pv_boost_ww).replace(',', '.')) || 0;\n\t\t\t\t\t\t\tconst pvTarget = baseWw + boostWw;\n\n\t\t\t\t\t\t\t// Nimmt den h\u00F6heren Wert: Entweder das regul\u00E4re PV-Ziel (z.B. 60) oder\n\t\t\t\t\t\t\t// den Wert, der minimal n\u00F6tig ist, um den Takt jetzt k\u00FCnstlich anzusto\u00DFen (z.B. 60.5)\n\t\t\t\t\t\t\tforceSoll = Math.max(forceSoll, pvTarget);\n\t\t\t\t\t\t}\n\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\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\t// Typsichere Pr\u00FCfung, ob die Heizgrenze das Heizen erlaubt\n\t\t\tconst isHeatingAllowedByLimit = !isHeatingLimitEnabled || mitteltemperatur < thresholdHeatingLimit;\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\tif (isRegelungAktiv && isHeatingAllowedByLimit) {\n\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\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 (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll && isHeatingAllowedByLimit) {\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`[CycleOpt] Pre-starting heating before WW (WW: ${wwIst}/${wwSoll}\u00B0C, Hyst: ${wwHysterese}K, RL: ${ruecklauf}/${ruecklaufSoll}\u00B0C). Setting base point to 35\u00B0C.`,\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 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\tconst config = this.config as Record<string, any>;\n\n\t\t\t// Alle Modbus-Register (Holdings 0..23 & Coils 0..13) in einem Batch aus dem RAM lesen\n\t\t\tconst modbusData =\n\t\t\t\tconfig.modbus_active && this.modbusManager?.isAvailable\n\t\t\t\t\t? await this.modbusManager.readAllRegisters()\n\t\t\t\t\t: null;\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\t\t\tawait this.setState('info.lastUpdate', { val: new Date().toISOString(), ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\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\n\t\t\t\t// =========================================================\n\t\t\t\t// MODBUS LIVE-SYNC (Aktualisiert alle aktivierten Modbus-Werte)\n\t\t\t\t// =========================================================\n\t\t\t\tif (\n\t\t\t\t\tmodbusData &&\n\t\t\t\t\tconfig.modbus_active &&\n\t\t\t\t\tdefinition.modbus &&\n\t\t\t\t\tconfig[definition.modbus.configKey] === true\n\t\t\t\t) {\n\t\t\t\t\tconst reg = definition.modbus.register;\n\t\t\t\t\tif (definition.modbus.type === 'holding' && modbusData.holdings[reg] !== undefined) {\n\t\t\t\t\t\tvalue = modbusData.holdings[reg];\n\t\t\t\t\t\tif (appliedFactor) {\n\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t} else if (definition.unit === '\u00B0C') {\n\t\t\t\t\t\t\tvalue /= 10;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (definition.modbus.type === 'coil' && modbusData.coils[reg] !== undefined) {\n\t\t\t\t\t\tvalue = modbusData.coils[reg] ? 1 : 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// =========================================================\n\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\n\t\t\t\t\t// ANTI-FLAPPING-SCHUTZ: Verhindert, dass die Hauptschleife Energiez\u00E4hler auf 0 st\u00FCrzen l\u00E4sst\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value === 'number' &&\n\t\t\t\t\t\t(key.toLowerCase().includes('energy') ||\n\t\t\t\t\t\t\tkey.toLowerCase().includes('w\u00E4rme') ||\n\t\t\t\t\t\t\tkey.toLowerCase().includes('power'))\n\t\t\t\t\t) {\n\t\t\t\t\t\tstatePromises.push(\n\t\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\t\tconst oldState = await this.getStateAsync(stateId);\n\t\t\t\t\t\t\t\tif (oldState && typeof oldState.val === 'number' && value < oldState.val) {\n\t\t\t\t\t\t\t\t\treturn; // T\u00FCrsteher: Der neue Wert ist kleiner als der alte -> Ignorieren!\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tawait this.setState(stateId, { val: value, ack: true });\n\t\t\t\t\t\t\t})(),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this, rawValues);\n\t\t\tawait calculateTotalEnergy(this, rawValues);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Fehler-Historie abarbeiten & Alarmieren\n\t\t\t// ----------------------------------------------------\n\t\t\tconst fehlerDp = getDpPath('Fehlerspeicher');\n\t\t\tconst oldFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst oldFehlerVal = oldFehlerState?.val as string | undefined;\n\n\t\t\tawait updateErrorHistory(this, rawValues);\n\n\t\t\tconst newFehlerState = fehlerDp ? await this.getStateAsync(fehlerDp) : null;\n\t\t\tconst newFehlerVal = newFehlerState?.val as string | undefined;\n\n\t\t\tawait checkAndSendErrorNotifications(this, oldFehlerVal, newFehlerVal);\n\n\t\t\t// ----------------------------------------------------\n\t\t\t// Abschalt-Historie abarbeiten & Alarmieren (Durchfluss)\n\t\t\t// ----------------------------------------------------\n\t\t\tconst abschaltungDp = getDpPath('Abschaltungen');\n\t\t\tconst oldAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst oldAbschaltungVal = oldAbschaltungState?.val as string | undefined;\n\n\t\t\tawait updateOutageHistory(this, rawValues);\n\n\t\t\tconst newAbschaltungState = abschaltungDp ? await this.getStateAsync(abschaltungDp) : null;\n\t\t\tconst newAbschaltungVal = newAbschaltungState?.val as string | undefined;\n\n\t\t\tawait checkAndSendOutageNotifications(this, oldAbschaltungVal, newAbschaltungVal);\n\t\t\t// ----------------------------------------------------\n\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\n\t\t\t// Aktuellen Betriebszustand aus dem Cache oder live holen\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst currentBzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\twriteLog(`=> Rufe jetzt den COP Manager auf. BZ ist: ${currentBzVal}`, 'debug');\n\t\t\tawait processCopData(this, currentBzVal);\n\n\t\t\tawait this.runOptimizationSchedule(rawValues, rawParams);\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\tthis.clearTimeout(this.zipTimer);\n\t\t\t}\n\t\t\tif (this.zipCountdownInterval) {\n\t\t\t\tthis.clearInterval(this.zipCountdownInterval);\n\t\t\t}\n\n\t\t\tif (this.updateCronJob) {\n\t\t\t\tthis.updateCronJob.cancel();\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\tconst config = this.config as Record<string, any>;\n\t\tconst isReadOnly = config.operation_mode === 'readonly';\n\n\t\t// 1. Fremd-Datenpunkte (PV-\u00DCberschuss etc.) abfangen\n\t\tif (!id.startsWith(`${this.namespace}.`)) {\n\t\t\tif (isReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// An PV-Manager weiterleiten (wird synchron verarbeitet)\n\t\t\thandlePvFeedInChange(this, id, state);\n\t\t}\n\n\t\t// Bewegungsmelder an den Manager auslagern (k\u00F6nnen technisch eigene oder fremde OIDs sein)\n\t\tif (!isReadOnly) {\n\t\t\tconst isMotionSensor = await checkAndHandleMotionSensor(this, id, state);\n\t\t\tif (isMotionSensor) {\n\t\t\t\treturn; // Der zipManager hat das Event verarbeitet, wir sind hier fertig\n\t\t\t}\n\t\t}\n\n\t\t// Falls wir hier noch bei einem Fremd-Datenpunkt sind, brechen wir ab\n\t\t// (eigene Logik unten ist nur f\u00FCr den internen Adapter-Namespace!)\n\t\tif (!id.startsWith(`${this.namespace}.`)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\t// PV-Sicherheits-Check beim Verdichter-Status (nur bei Ack=true, wenn der Wert echt von der WP kommt)\n\t\t\tif (!isReadOnly && id.endsWith('WP_BZ_akt')) {\n\t\t\t\tawait handlePvCycleCheck(this, Number(state.val));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Diagnose-Aktionen (auch im Read-Only Modus erlaubt, da kein Schreibzugriff auf die W\u00E4rmepumpe erfolgt)\n\t\tif (id.endsWith('check_firmware') && state.val === true) {\n\t\t\tthis.log.info('Manuelle Firmware-Update-Pr\u00FCfung durch Benutzer gestartet...');\n\n\t\t\t// Button direkt wieder auf false zur\u00FCcksetzen, um Doppel-Trigger zu blockieren\n\t\t\tvoid this.setState(id, false, true);\n\n\t\t\t// Update-Pr\u00FCfung starten\n\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\twriteLog(\n\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\tawait dumpAllRawToLog(this);\n\t\t\treturn;\n\t\t}\n\n\t\t// GLOBALE SCHREIBSPERRE IM READ-ONLY MODUS\n\t\tif (isReadOnly) {\n\t\t\twriteLog(\n\t\t\t\t`[Read-Only] Write attempt to '${id}' blocked! Change Operating Mode in adapter settings to enable hardware writes.`,\n\t\t\t\t'warn',\n\t\t\t);\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\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\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\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\n\t\t\t\t// FIX: Bricht einen eventuell laufenden PV-Boost hart ab, bevor die Standardwerte geladen werden\n\t\t\t\tawait forceResetPvBoost(this);\n\n\t\t\t\tawait this.setIdleDefaults();\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\tconst isModbusEnabled = Boolean(\n\t\t\t\tthis.modbusManager &&\n\t\t\t\tthis.modbusManager.isAvailable &&\n\t\t\t\tconfig.modbus_active &&\n\t\t\t\tdefinition.modbus &&\n\t\t\t\tconfig[definition.modbus.configKey] === true,\n\t\t\t);\n\n\t\t\tif (!definition.luxWriteId || (definition.write !== true && !isModbusEnabled)) {\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 appliedFactor = definition.factor;\n\t\t\tif (\n\t\t\t\tmappingKey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\t\tmappingKey === 'heating_system_circ_pump_voltage_minimal'\n\t\t\t) {\n\t\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t\t}\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (typeof valueToWrite === 'boolean') {\n\t\t\t\tvalueToWrite = valueToWrite ? 1 : 0;\n\t\t\t} else if (\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 (appliedFactor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * appliedFactor;\n\t\t\t}\n\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !appliedFactor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\t// =========================================================\n\t\t\t// HYBRIDE SCHREIB-WEICHE (MODBUS VS. NATIV PORT 8889)\n\t\t\t// =========================================================\n\t\t\tif (isModbusEnabled && definition.modbus) {\n\t\t\t\tconst isCoil = definition.modbus.type === 'coil';\n\t\t\t\tconst register = definition.modbus.register;\n\n\t\t\t\tawait this.modbusManager.writeRegister(register, Number(valueToWrite), isCoil);\n\t\t\t\treturn; // NATIVE ROUTE 8889 UMGEHEN!\n\t\t\t}\n\n\t\t\t// =========================================================\n\t\t\t// NATIVE ROUTE (Fallback oder Standard-Parameter via 8889)\n\t\t\t// =========================================================\n\t\t\tconst targetWriteId = parseInt(definition.luxWriteId, 10);\n\t\t\t// Platzhalter-IDs (>= 9990) niemals nativ \u00FCber Port 8889 senden\n\t\t\tif (isNaN(targetWriteId) || targetWriteId >= 9990) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait queueWrite(this, targetWriteId, 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,eAA0B;AAC1B,4BAA2D;AAC3D,2BAA+C;AAC/C,qBAA8D;AAC9D,wBAA+B;AAC/B,wBAAsC;AACtC,oBAAqD;AACrD,2BAA8B;AAC9B,iCAKO;AACP,2BAOO;AACP,uBAOO;AAEP,0BAAwD;AACxD,0BAAyC;AACzC,0BAAqC;AAErC,2BAAoC;AACpC,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,E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AC,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 * as schedule from 'node-schedule';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initAutoBackup, stopAutoBackup } from './backupManager';\nimport { formatTimerSecondsToTime, timeStringToSeconds } from './convert';\nimport { processCopData } from './copManager';\nimport { handleHupOptimization } from './hupManager';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport { ModbusManager } from './modbusManager';\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 {\n\tevaluatePvBoost,\n\tforceResetPvBoost,\n\thandlePvCycleCheck,\n\thandlePvFeedInChange,\n\tinitPvManagement,\n\tpvIsBoostActive,\n} from './pvManager';\n\nimport { dumpAllRawToLog, queueWrite, readAllRaw } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport { generateHeatCurveSVG } from './svgGenerator';\nimport type { LuxtronikAdapter } from './types';\nimport { checkFirmwareUpdate } from './updateManager';\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\t/** Modbus Manager f\u00FCr hybride Schreib- und Lesevorg\u00E4nge (SmartGrid / Vorlauf / ZIP) */\n\tpublic modbusManager!: ModbusManager;\n\t/** ioBroker interval handle for the ZIP remaining time countdown */\n\tpublic zipCountdownInterval?: ioBroker.Interval;\n\t/** Target timestamp when the current ZIP run finishes */\n\tpublic zipEndTime?: number;\n\t/** Cron-Job Handle f\u00FCr die Firmware-Update-Pr\u00FCfung */\n\tpublic updateCronJob?: schedule.Job;\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\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\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\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\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\n\t\t// =========================================================\n\t\t// MIGRATION: ZIP Control Mode & Operation Mode (Bestandsnutzer)\n\t\t// =========================================================\n\t\tlet configUpdated = false;\n\t\tif (config.zip_control_mode === undefined) {\n\t\t\tlet migratedMode = 'controller';\n\n\t\t\tconst actors = config.actors || [];\n\t\t\tconst validActors = actors.filter(\n\t\t\t\t(a: any) => a.zip_external_relay_id && a.zip_external_relay_id.trim() !== '',\n\t\t\t);\n\n\t\t\tif (validActors.length > 0) {\n\t\t\t\tmigratedMode = 'actor';\n\t\t\t} else if (config.modbus_active && config.sync_modbus_coil_7) {\n\t\t\t\tmigratedMode = 'modbus';\n\t\t\t}\n\n\t\t\tconfig.zip_control_mode = migratedMode;\n\t\t\tconfigUpdated = true;\n\t\t\twriteLog(`[Migration] Updated zip_control_mode to '${migratedMode}' based on legacy settings.`, 'info');\n\t\t}\n\n\t\tif (config.operation_mode === undefined) {\n\t\t\tif (config.modbus_active === true) {\n\t\t\t\tconfig.operation_mode = 'modbus';\n\t\t\t} else if (\n\t\t\t\tconfig.idle_defaults_aktiv === true ||\n\t\t\t\tconfig.regelung_aktiv === true ||\n\t\t\t\tconfig.hup_optimierung_aktiv === true ||\n\t\t\t\tconfig.pv_active === true ||\n\t\t\t\tconfig.zip_optimierung_aktiv === true\n\t\t\t) {\n\t\t\t\tconfig.operation_mode = 'native';\n\t\t\t} else {\n\t\t\t\tconfig.operation_mode = 'readonly';\n\t\t\t}\n\t\t\tconfigUpdated = true;\n\t\t\twriteLog(`[Migration] Set operation_mode to '${config.operation_mode}' based on legacy settings.`, 'info');\n\t\t}\n\n\t\tconst shouldModbusBeActive = config.operation_mode === 'modbus';\n\t\tif (config.modbus_active !== shouldModbusBeActive) {\n\t\t\tconfig.modbus_active = shouldModbusBeActive;\n\t\t\tconfigUpdated = true;\n\t\t}\n\n\t\tif (configUpdated) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getForeignObjectAsync(`system.adapter.${this.namespace}`);\n\t\t\t\tif (obj && obj.native) {\n\t\t\t\t\tobj.native.zip_control_mode = config.zip_control_mode;\n\t\t\t\t\tobj.native.operation_mode = config.operation_mode;\n\t\t\t\t\tobj.native.modbus_active = config.modbus_active;\n\t\t\t\t\tawait this.setForeignObject(`system.adapter.${this.namespace}`, obj);\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`[Migration] Failed to save updated config: ${err.message}`, 'error');\n\t\t\t}\n\t\t}\n\t\t// =========================================================\n\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\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\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\t\tawait this.subscribeStatesAsync('Information.12_SystemInfo.check_firmware');\n\n\t\tconst isReadOnly = config.operation_mode === 'readonly';\n\n\t\tif (isReadOnly) {\n\t\t\twriteLog(\n\t\t\t\t'\uD83D\uDD12 Operating Mode: READ-ONLY. All hardware write operations and optimizations are disabled.',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: false, ack: true });\n\t\t} else if (config.operation_mode === 'modbus') {\n\t\t\twriteLog('\u26A1 Operating Mode: READ/WRITE WITH MODBUS TCP (Hybrid).', 'info');\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\t\t} else {\n\t\t\twriteLog('\u270D\uFE0F Operating Mode: READ/WRITE WITHOUT MODBUS (Native TCP Port 8889).', 'info');\n\t\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv === true, ack: true });\n\t\t}\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\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();\n\n\t\tif (!isReadOnly) {\n\t\t\tawait disableHardwareZipTimer(this);\n\t\t\tsubscribeMotionSensors(this);\n\t\t\tawait initPvManagement(this);\n\t\t}\n\n\t\tthis.subscribeStates('*');\n\n\t\t// --- MODBUS HYBRID INITIALISIERUNG (Vor dem ersten updateData-Aufruf) ---\n\t\tthis.modbusManager = new ModbusManager(this);\n\t\tif (!isReadOnly && config.modbus_active) {\n\t\t\twriteLog('Checking Modbus TCP availability for hybrid operations...', 'info');\n\t\t\tawait this.modbusManager.checkAvailability();\n\t\t}\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\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\tconst dpVirtualZipRemaining = getDpPath('Virtual_ZIP_Remaining_Time');\n\t\tif (dpVirtualZipRemaining) {\n\t\t\tawait this.setState(dpVirtualZipRemaining, { val: 0, 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\tif (config.update_check_active === true) {\n\t\t\tthis.setTimeout(() => {\n\t\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\t}, 15000);\n\n\t\t\tconst cronString = config.update_check_cron || '0 12 * * *';\n\t\t\ttry {\n\t\t\t\tthis.updateCronJob = schedule.scheduleJob(cronString, () => {\n\t\t\t\t\tthis.log.info('F\u00FChre geplante Firmware-Update-Pr\u00FCfung aus (Cron)...');\n\t\t\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\t\t});\n\t\t\t} catch (err: any) {\n\t\t\t\tthis.log.error(`Fehler beim Einrichten des Firmware-Update-Crons (${cronString}): ${err.message}`);\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\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\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 * Automatically routes via Modbus TCP if hybrid mode is enabled for the target datapoint.\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\tconst config = this.config as Record<string, any>;\n\t\tif (config.operation_mode === 'readonly') {\n\t\t\treturn;\n\t\t}\n\t\tif (val === undefined || val === null) {\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\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tlet appliedFactor = definition.factor;\n\t\tif (\n\t\t\tmappingKey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\tmappingKey === 'heating_system_circ_pump_voltage_minimal'\n\t\t) {\n\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t}\n\n\t\tlet valueToWrite: any = val;\n\t\tif (typeof valueToWrite === 'boolean') {\n\t\t\tvalueToWrite = valueToWrite ? 1 : 0;\n\t\t} else if (appliedFactor && typeof val === 'number') {\n\t\t\tvalueToWrite = val * appliedFactor;\n\t\t}\n\n\t\tconst isRawWrite =\n\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !appliedFactor) {\n\t\t\tvalueToWrite = val * 10;\n\t\t}\n\n\t\tconst isModbusEnabled = Boolean(\n\t\t\tthis.modbusManager &&\n\t\t\tthis.modbusManager.isAvailable &&\n\t\t\tconfig.modbus_active &&\n\t\t\tdefinition.modbus &&\n\t\t\tconfig[definition.modbus.configKey] === true,\n\t\t);\n\n\t\tconst writeId = definition.luxWriteId ? parseInt(definition.luxWriteId, 10) : NaN;\n\t\t// FIX: hardwareOutOfSync NUR pr\u00FCfen, wenn der Wert NICHT \u00FCber Modbus (fl\u00FCchtiges RAM) l\u00E4uft!\n\t\tconst hardwareOutOfSync =\n\t\t\t!isModbusEnabled &&\n\t\t\t!definition.isVirtual &&\n\t\t\t!isNaN(writeId) &&\n\t\t\twriteId < 9990 &&\n\t\t\tthis.currentRawParams.length > writeId &&\n\t\t\tthis.currentRawParams[writeId] !== Math.round(Number(valueToWrite));\n\n\t\tif (!state || state.val !== val || hardwareOutOfSync) {\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 || isModbusEnabled) && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\ttry {\n\t\t\t\t\tif (isModbusEnabled && definition.modbus) {\n\t\t\t\t\t\tconst isCoil = definition.modbus.type === 'coil';\n\t\t\t\t\t\tawait this.modbusManager.writeRegister(\n\t\t\t\t\t\t\tdefinition.modbus.register,\n\t\t\t\t\t\t\tNumber(valueToWrite),\n\t\t\t\t\t\t\tisCoil,\n\t\t\t\t\t\t);\n\t\t\t\t\t} else if (!isNaN(writeId) && writeId < 9990) {\n\t\t\t\t\t\tawait queueWrite(this, writeId, valueToWrite);\n\t\t\t\t\t}\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('heating_temperature', config.sync_heating_temperature ?? 0);\n\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\n\t\t\tif (pvIsBoostActive) {\n\t\t\t\tawait evaluatePvBoost(this, true);\n\t\t\t}\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 * @param rawValues - Optional raw telemetry values array from command 3004 as fallback.\n\t * @param rawParams - Optional raw parameters array from command 3003 as fallback.\n\t * @returns A promise that resolves when the execution cycle finishes.\n\t */\n\tprivate async runOptimizationSchedule(rawValues: number[] = [], rawParams: number[] = []): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tif (config.operation_mode === 'readonly') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal =\n\t\t\t\tbzState && bzState.val !== null\n\t\t\t\t\t? String(bzState.val).trim()\n\t\t\t\t\t: rawValues[80] !== undefined\n\t\t\t\t\t\t? String(rawValues[80])\n\t\t\t\t\t\t: '';\n\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\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 (this.lastBzVal === '1' && config.idle_defaults_aktiv === true) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'temperature_hot_water_target',\n\t\t\t\t\t\t\tconfig.sync_warmwater_target_temperature ?? 54,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (pvIsBoostActive) {\n\t\t\t\t\t\t\tawait evaluatePvBoost(this, true);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\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\tconst mode = config.zip_control_mode || 'controller';\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\tconst canRunWearFree =\n\t\t\t\t\t\t\t(mode === 'actor' && validActors.length > 0) ||\n\t\t\t\t\t\t\t(mode === 'modbus' && this.modbusManager?.isAvailable);\n\n\t\t\t\t\t\tif (canRunWearFree) {\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] Wear-free mode (${mode}) active. Starting circulation synchronous to hot water generation.`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 120);\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\twwTargetParamState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\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('temperature_hot_water_target')),\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('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 =\n\t\t\t\ttypeof wwSollState?.val === 'number'\n\t\t\t\t\t? wwSollState.val\n\t\t\t\t\t: typeof wwTargetParamState?.val === 'number'\n\t\t\t\t\t\t? wwTargetParamState.val\n\t\t\t\t\t\t: rawValues[18] !== undefined\n\t\t\t\t\t\t\t? rawValues[18] / 10\n\t\t\t\t\t\t\t: rawParams[105] !== undefined\n\t\t\t\t\t\t\t\t? rawParams[105] / 10\n\t\t\t\t\t\t\t\t: 54;\n\t\t\tconst wwIst =\n\t\t\t\ttypeof wwIstState?.val === 'number'\n\t\t\t\t\t? wwIstState.val\n\t\t\t\t\t: rawValues[17] !== undefined\n\t\t\t\t\t\t? rawValues[17] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst ruecklauf =\n\t\t\t\ttypeof ruecklaufState?.val === 'number'\n\t\t\t\t\t? ruecklaufState.val\n\t\t\t\t\t: rawValues[11] !== undefined\n\t\t\t\t\t\t? rawValues[11] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst ruecklaufSoll =\n\t\t\t\ttypeof ruecklaufSollState?.val === 'number'\n\t\t\t\t\t? ruecklaufSollState.val\n\t\t\t\t\t: rawValues[12] !== undefined\n\t\t\t\t\t\t? rawValues[12] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst spreizung =\n\t\t\t\ttypeof spreizungState?.val === 'number'\n\t\t\t\t\t? spreizungState.val\n\t\t\t\t\t: rawValues[10] !== undefined && rawValues[11] !== undefined\n\t\t\t\t\t\t? (rawValues[10] - rawValues[11]) / 10\n\t\t\t\t\t\t: 0;\n\n\t\t\tconst vd1 =\n\t\t\t\tvd1State?.val !== undefined && vd1State?.val !== null\n\t\t\t\t\t? vd1State.val === 1 || vd1State.val === true || String(vd1State.val).toLowerCase() === 'true'\n\t\t\t\t\t: rawValues[44] === 1;\n\n\t\t\tconst wwHysterese =\n\t\t\t\ttypeof wwHystereseState?.val === 'number'\n\t\t\t\t\t? wwHystereseState.val\n\t\t\t\t\t: rawParams[74] !== undefined\n\t\t\t\t\t\t? rawParams[74] / 10\n\t\t\t\t\t\t: 2.0;\n\t\t\tconst currentHupVolt = (currentHupVoltState?.val as number) ?? 7.0;\n\t\t\tconst heizenHysterese =\n\t\t\t\ttypeof heizenHystereseState?.val === 'number'\n\t\t\t\t\t? heizenHystereseState.val\n\t\t\t\t\t: rawParams[88] !== undefined\n\t\t\t\t\t\t? rawParams[88] / 10\n\t\t\t\t\t\t: 1.5;\n\t\t\tconst mitteltemperatur =\n\t\t\t\ttypeof mitteltempState?.val === 'number'\n\t\t\t\t\t? mitteltempState.val\n\t\t\t\t\t: rawValues[16] !== undefined\n\t\t\t\t\t\t? rawValues[16] / 10\n\t\t\t\t\t\t: 0;\n\t\t\tconst thresholdHeatingLimit =\n\t\t\t\ttypeof thresholdHeatingLimitState?.val === 'number'\n\t\t\t\t\t? thresholdHeatingLimitState.val\n\t\t\t\t\t: rawParams[700] !== undefined\n\t\t\t\t\t\t? rawParams[700] / 10\n\t\t\t\t\t\t: 15;\n\n\t\t\tconst isHeatingLimitEnabled =\n\t\t\t\theatingLimitState?.val !== undefined && heatingLimitState?.val !== null\n\t\t\t\t\t? heatingLimitState.val === 1 ||\n\t\t\t\t\t\theatingLimitState.val === true ||\n\t\t\t\t\t\tString(heatingLimitState.val) === '1' ||\n\t\t\t\t\t\tString(heatingLimitState.val).toLowerCase() === 'true'\n\t\t\t\t\t: rawParams[699] === 1;\n\n\t\t\tconst nachWasser = Boolean(nachWasserState?.val);\n\n\t\t\tif (istHeizen) {\n\t\t\t\tif (aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunktState = await this.getStateAsync(getDpPath('heating_curve_parallel_offset'));\n\t\t\t\t\tconst currentFusspunkt =\n\t\t\t\t\t\ttypeof fusspunktState?.val === 'number'\n\t\t\t\t\t\t\t? fusspunktState.val\n\t\t\t\t\t\t\t: rawParams[13] !== undefined\n\t\t\t\t\t\t\t\t? rawParams[13] / 10\n\t\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tif (currentFusspunkt === 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\tif (aelterAls10 && vd1) {\n\t\t\t\t\tthis.lastPumpOptimization = await handleHupOptimization(\n\t\t\t\t\t\tthis,\n\t\t\t\t\t\tistHeizen,\n\t\t\t\t\t\tspreizung,\n\t\t\t\t\t\tcurrentHupVolt,\n\t\t\t\t\t\tthis.lastPumpOptimization,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (isRegelungAktiv) {\n\t\t\t\t\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\tif (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {\n\t\t\t\t\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t\t\t\t\tif (pvIsBoostActive) {\n\t\t\t\t\t\t\tconst baseWw =\n\t\t\t\t\t\t\t\tparseFloat(String(config.sync_warmwater_target_temperature).replace(',', '.')) || 54;\n\t\t\t\t\t\t\tconst boostWw = parseFloat(String(config.pv_boost_ww).replace(',', '.')) || 0;\n\t\t\t\t\t\t\tconst pvTarget = baseWw + boostWw;\n\t\t\t\t\t\t\tforceSoll = Math.max(forceSoll, pvTarget);\n\t\t\t\t\t\t}\n\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\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\tconst isHeatingAllowedByLimit = !isHeatingLimitEnabled || mitteltemperatur < thresholdHeatingLimit;\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\tif (isRegelungAktiv && isHeatingAllowedByLimit) {\n\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\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 (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll && isHeatingAllowedByLimit) {\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`[CycleOpt] Pre-starting heating before WW (WW: ${wwIst}/${wwSoll}\u00B0C, Hyst: ${wwHysterese}K, RL: ${ruecklauf}/${ruecklaufSoll}\u00B0C). Setting base point to 35\u00B0C.`,\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 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\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\t\t\tlet lastReadError = '';\n\n\t\t\ttry {\n\t\t\t\trawParams = await readAllRaw(this, 3003);\n\t\t\t\tif (rawParams.length > 0) {\n\t\t\t\t\tthis.currentRawParams = rawParams;\n\t\t\t\t}\n\t\t\t} catch (err: unknown) {\n\t\t\t\tlastReadError = err instanceof Error ? err.message : String(err);\n\t\t\t\tthis.log.debug(`Raw parameter acquisition response error (Command 3003): ${lastReadError}`);\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\tlastReadError = err instanceof Error ? err.message : String(err);\n\t\t\t\tthis.log.debug(`Raw telemetry value acquisition response error (Command 3004): ${lastReadError}`);\n\t\t\t}\n\n\t\t\tif (rawParams.length === 0 && rawValues.length === 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`No telemetry or parameter data received from heat pump (${lastReadError || 'empty response'}).`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tconst modbusData =\n\t\t\t\tconfig.modbus_active && this.modbusManager?.isAvailable\n\t\t\t\t\t? await this.modbusManager.readAllRegisters()\n\t\t\t\t\t: null;\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\t\t\tawait this.setState('info.lastUpdate', { val: new Date().toISOString(), ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\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\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) {\n\t\t\t\t\t\t\t\tif (appliedFactor) {\n\t\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t\t} else if (definition.unit === '\u00B0C') {\n\t\t\t\t\t\t\t\t\tvalue /= 10;\n\t\t\t\t\t\t\t\t}\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) {\n\t\t\t\t\t\t\t\tif (appliedFactor) {\n\t\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t\t} else if (definition.unit === '\u00B0C') {\n\t\t\t\t\t\t\t\t\tvalue /= 10;\n\t\t\t\t\t\t\t\t}\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) {\n\t\t\t\t\t\t\tif (appliedFactor) {\n\t\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t\t} else if (definition.unit === '\u00B0C') {\n\t\t\t\t\t\t\t\tvalue /= 10;\n\t\t\t\t\t\t\t}\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\n\t\t\t\t// =========================================================\n\t\t\t\t// MODBUS LIVE-SYNC (Aktualisiert alle aktivierten Modbus-Werte)\n\t\t\t\t// =========================================================\n\t\t\t\tif (\n\t\t\t\t\tmodbusData &&\n\t\t\t\t\tconfig.modbus_active &&\n\t\t\t\t\tdefinition.modbus &&\n\t\t\t\t\tconfig[definition.modbus.configKey] === true\n\t\t\t\t) {\n\t\t\t\t\tconst reg = definition.modbus.register;\n\t\t\t\t\tif (definition.modbus.type === 'holding' && modbusData.holdings[reg] !== undefined) {\n\t\t\t\t\t\tvalue = modbusData.holdings[reg];\n\t\t\t\t\t\tif (appliedFactor) {\n\t\t\t\t\t\t\tvalue /= appliedFactor;\n\t\t\t\t\t\t} else if (definition.unit === '\u00B0C') {\n\t\t\t\t\t\t\tvalue /= 10;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (definition.modbus.type === 'coil' && modbusData.coils[reg] !== undefined) {\n\t\t\t\t\t\tvalue = modbusData.coils[reg] ? 1 : 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// =========================================================\n\n\t\t\t\tif (value !== undefined && typeof value === 'number' && (appliedFactor || definition.unit === '\u00B0C')) {\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\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\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value === 'number' &&\n\t\t\t\t\t\t(key.toLowerCase().includes('energy') ||\n\t\t\t\t\t\t\tkey.toLowerCase().includes('w\u00E4rme') ||\n\t\t\t\t\t\t\tkey.toLowerCase().includes('power'))\n\t\t\t\t\t) {\n\t\t\t\t\t\tstatePromises.push(\n\t\t\t\t\t\t\t(async () => {\n\t\t\t\t\t\t\t\tconst oldState = await this.getStateAsync(stateId);\n\t\t\t\t\t\t\t\tif (oldState && typeof oldState.val === 'number' && value < oldState.val) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tawait this.setState(stateId, { val: value, ack: true });\n\t\t\t\t\t\t\t})(),\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this, rawValues);\n\t\t\tawait calculateTotalEnergy(this, rawValues);\n\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\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\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst currentBzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\twriteLog(`=> Rufe jetzt den COP Manager auf. BZ ist: ${currentBzVal}`, 'debug');\n\t\t\tawait processCopData(this, currentBzVal);\n\n\t\t\tawait this.runOptimizationSchedule(rawValues, rawParams);\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\tthis.clearTimeout(this.zipTimer);\n\t\t\t}\n\t\t\tif (this.zipCountdownInterval) {\n\t\t\t\tthis.clearInterval(this.zipCountdownInterval);\n\t\t\t}\n\n\t\t\tif (this.updateCronJob) {\n\t\t\t\tthis.updateCronJob.cancel();\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\tconst config = this.config as Record<string, any>;\n\t\tconst isReadOnly = config.operation_mode === 'readonly';\n\n\t\tif (!id.startsWith(`${this.namespace}.`)) {\n\t\t\tif (isReadOnly) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandlePvFeedInChange(this, id, state);\n\t\t}\n\n\t\tif (!isReadOnly) {\n\t\t\tconst isMotionSensor = await checkAndHandleMotionSensor(this, id, state);\n\t\t\tif (isMotionSensor) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (!id.startsWith(`${this.namespace}.`)) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\tif (!isReadOnly && id.endsWith('WP_BZ_akt')) {\n\t\t\t\tawait handlePvCycleCheck(this, Number(state.val));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (id.endsWith('check_firmware') && state.val === true) {\n\t\t\tthis.log.info('Manuelle Firmware-Update-Pr\u00FCfung durch Benutzer gestartet...');\n\t\t\tvoid this.setState(id, false, true);\n\t\t\tvoid checkFirmwareUpdate(this);\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\twriteLog(\n\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\tawait dumpAllRawToLog(this);\n\t\t\treturn;\n\t\t}\n\n\t\tif (isReadOnly) {\n\t\t\twriteLog(\n\t\t\t\t`[Read-Only] Write attempt to '${id}' blocked! Change Operating Mode in adapter settings to enable hardware writes.`,\n\t\t\t\t'warn',\n\t\t\t);\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\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\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\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 forceResetPvBoost(this);\n\t\t\t\tawait this.setIdleDefaults();\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\tconst isModbusEnabled = Boolean(\n\t\t\t\tthis.modbusManager &&\n\t\t\t\tthis.modbusManager.isAvailable &&\n\t\t\t\tconfig.modbus_active &&\n\t\t\t\tdefinition.modbus &&\n\t\t\t\tconfig[definition.modbus.configKey] === true,\n\t\t\t);\n\n\t\t\tif (!definition.luxWriteId || (definition.write !== true && !isModbusEnabled)) {\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 appliedFactor = definition.factor;\n\t\t\tif (\n\t\t\t\tmappingKey === 'heating_system_circ_pump_voltage_nominal' ||\n\t\t\t\tmappingKey === 'heating_system_circ_pump_voltage_minimal'\n\t\t\t) {\n\t\t\t\tappliedFactor = config.hup_voltage_factor !== undefined ? Number(config.hup_voltage_factor) : 100;\n\t\t\t}\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (typeof valueToWrite === 'boolean') {\n\t\t\t\tvalueToWrite = valueToWrite ? 1 : 0;\n\t\t\t} else if (\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 (appliedFactor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * appliedFactor;\n\t\t\t}\n\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !appliedFactor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\tif (isModbusEnabled && definition.modbus) {\n\t\t\t\tconst isCoil = definition.modbus.type === 'coil';\n\t\t\t\tconst register = definition.modbus.register;\n\n\t\t\t\tawait this.modbusManager.writeRegister(register, Number(valueToWrite), isCoil);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst targetWriteId = parseInt(definition.luxWriteId, 10);\n\t\t\tif (isNaN(targetWriteId) || targetWriteId >= 9990) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait queueWrite(this, targetWriteId, 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,eAA0B;AAC1B,4BAA2D;AAC3D,2BAA+C;AAC/C,qBAA8D;AAC9D,wBAA+B;AAC/B,wBAAsC;AACtC,oBAAqD;AACrD,2BAA8B;AAC9B,iCAKO;AACP,2BAOO;AACP,uBAOO;AAEP,0BAAwD;AACxD,0BAAyC;AACzC,0BAAqC;AAErC,2BAAoC;AACpC,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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