iobroker.luxtronik2-controller 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/build/actionHandlers.js +11 -9
- package/build/actionHandlers.js.map +2 -2
- package/build/codes.js +121 -121
- package/build/codes.js.map +2 -2
- package/build/main.js +195 -61
- package/build/main.js.map +2 -2
- package/build/notificationManager.js +23 -24
- package/build/notificationManager.js.map +2 -2
- package/build/objectManager.js +44 -37
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +11 -11
- package/build/rawFunctions.js.map +2 -2
- package/build/stateMapping.js +1284 -1286
- package/build/stateMapping.js.map +2 -2
- package/build/virtualStates.js +74 -70
- package/build/virtualStates.js.map +2 -2
- package/build/zipManager.js +39 -16
- package/build/zipManager.js.map +2 -2
- package/io-package.json +30 -30
- package/package.json +1 -1
package/build/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
|
-
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v3.1.5\n */\nimport * as utils from '@iobroker/adapter-core';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport { checkAndSendErrorNotifications, handleTestMessage, sendTelegramNotification } from './notificationManager';\nimport {\n\tcleanupCustomStates,\n\tcleanupEmptyFolders,\n\tcleanupStates,\n\tensureAllObjectsExist,\n\tensureCustomObjectsExist,\n\tisStateEnabled,\n} from './objectManager';\nimport { dumpAllRawToLog, readAllRaw, writeRawParameter } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport {\n\tcalculateTemperatureSpread,\n\tcalculateTotalEnergy,\n\tcalculateTotalThermalEnergy,\n\tupdateCustomStates,\n\tupdateErrorHistory,\n\tupdateOutageHistory,\n\tupdateStatusStrings,\n\tupdateSystemInfos,\n\tupdateTimerTables,\n} from './virtualStates';\nimport { handleActivateZip, stopZipAndDeaeration } from './zipManager';\n\nclass Luxtronik2Controller extends utils.Adapter {\n\tpublic createdStates = new Set<string>();\n\tpublic zipTimer?: ioBroker.Timeout;\n\tpublic originalZipConfig: Record<string, any> | null = null;\n\tpublic lastKnownErrorTimestamp: number | null = null;\n\tpublic isDebugLogActive = false;\n\tprivate pollingInterval: ioBroker.Interval | undefined;\n\tprivate lastBzVal = '';\n\tprivate updateRunning = false;\n\tprivate lastPumpOptimization: number = 0;\n\n\tprivate writeQueue: (() => Promise<void>)[] = [];\n\tprivate isWriting = false;\n\tprivate errorCount = 0;\n\tprivate readonly MAX_ERRORS = 3;\n\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}\n\t}\n\n\tprivate async onReady(): Promise<void> {\n\t\tconst config = this.config as Record<string, any>;\n\t\tconst ip = config.host;\n\t\tconst port = config.port || 8889;\n\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\twriteLog(`Verbinde mit W\u00E4rmepumpe auf ${ip}:${port}...`, 'info');\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\t// Synchronisiere das virtuelle Objekt mit der neuen Konfigurations-Checkbox\n\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv !== false, ack: true });\n\n\t\tconst debugState = await this.getStateAsync(getDpPath('Schreibe_Debug_Log'));\n\t\tthis.isDebugLogActive = debugState?.val === true;\n\t\tsetCustomDebug(this.isDebugLogActive);\n\n\t\tif (this.isDebugLogActive) {\n\t\t\twriteLog('Synchronisiere Konfigurationswerte mit der W\u00E4rmepumpe...', 'info');\n\t\t}\n\t\tawait this.setIdleDefaults();\n\n\t\tif (config.motion_sensors_aktiv && Array.isArray(config.motionSensors)) {\n\t\t\tfor (const sensor of config.motionSensors) {\n\t\t\t\tif (sensor.oid && typeof sensor.oid === 'string' && sensor.oid.trim() !== '') {\n\t\t\t\t\tthis.subscribeForeignStates(sensor.oid.trim());\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(`Bewegungssensor abonniert: ${sensor.name} (${sensor.oid})`, 'info');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.subscribeStates('*');\n\n\t\ttry {\n\t\t\t// Wir versuchen die Anlage einmalig beim Start auszulesen\n\t\t\tawait this.updateData();\n\t\t} catch (error: any) {\n\t\t\t// Wenn die Pumpe beim Start offline ist, st\u00FCrzt der Adapter nicht mehr ab!\n\t\t\tthis.log.error(`Fehler bei der initialen Datenabfrage (Pumpe offline?): ${error.message}`);\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('Eingestelltes Intervall war zu kurz. Wurde zum Schutz auf 10 Sekunden korrigiert.', 'warn');\n\t\t}\n\n\t\tthis.pollingInterval = this.setInterval(async () => {\n\t\t\t// Auch im Intervall selbst fangen wir Fehler ab, damit ein Timeout den ioBroker nicht crasht\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(`Fehler w\u00E4hrend des zyklischen Datenabrufs: ${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\tpublic async syncConfigValue(mappingKey: keyof typeof STATE_MAPPING, val: any): Promise<void> {\n\t\tif (val === undefined || val === null) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tif (!state || state.val !== val) {\n\t\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\t\tif (!definition) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(id, { val: val, ack: true });\n\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\twriteLog(`Schreibe Wert direkt in W\u00E4rmepumpe: ${mappingKey} = ${val}`, 'info');\n\t\t\t}\n\n\t\t\tif (definition.write === true && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\tlet valueToWrite: any = val;\n\t\t\t\tif (definition.factor && typeof val === 'number') {\n\t\t\t\t\tvalueToWrite = val * definition.factor;\n\t\t\t\t}\n\n\t\t\t\tconst isRawWrite =\n\t\t\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\t\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !definition.factor) {\n\t\t\t\t\tvalueToWrite = val * 10;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\t\t\tconst writeId = isRawWrite ? parseInt(targetWriteId, 10) : targetWriteId;\n\t\t\t\t\tawait this.queueWrite(writeId, valueToWrite);\n\t\t\t\t\tawait new Promise(r => global.setTimeout(r, 200));\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\twriteLog(`Fehler beim Schreiben von ${mappingKey} an die Pumpe: ${err.message}`, 'error');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\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(`Setze Werte f\u00FCr ${id}: ${val}`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Fehler in setOwnStateIfDifferent f\u00FCr ${id}: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\tprivate async setIdleDefaults(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\t// \u00DCberall mit ?? (Nullish Coalescing) den sicheren Werks-Standard hinterlegen!\n\t\t\tawait this.syncConfigValue('heating_curve_end_point', config.endpunkt ?? 23);\n\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', config.fusspunkt ?? 21.7);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('warmwater_temperature', config.sync_warmwater_target_temperature ?? 54);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'hotWaterTemperatureHysteresis',\n\t\t\t\tconfig.sync_hotwater_temperature_hysteresis ?? 10,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('returnTemperatureHysteresis', config.sync_return_temperature_hysteresis ?? 1.5);\n\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Fehler beim Setzen der Leerlauf-Vorgabewerte: ${err.message}`, 'error');\n\t\t}\n\t}\n\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\tprivate async runOptimizationSchedule(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\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\t// Wenn kein relevanter Status aktiv ist, abbrechen\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. DYNAMISCHE PARAMETER-ANPASSUNG BEI STATUSWECHSEL\n\t\t\t// =========================================================\n\t\t\tif (bzVal !== this.lastBzVal) {\n\t\t\t\tif (istLeerlauf) {\n\t\t\t\t\t// Checkbox: Standardwerte im Leerlauf erzwingen\n\t\t\t\t\tif (config.idle_defaults_aktiv !== false) {\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\t// Checkbox: ZIP- & HUP-Spannungsoptimierung\n\t\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\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\t// Checkbox: Takt-Optimierung (Heizen nach Wasser zur\u00FCcksetzen)\n\t\t\t\t\tif (config.regelung_aktiv !== false) {\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\t// Checkbox: ZIP- & HUP-Spannungsoptimierung\n\t\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'hotWaterTemperatureHysteresis',\n\t\t\t\t\t\t\tconfig.sync_hotwater_temperature_hysteresis ?? 2,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 0);\n\t\t\t\t\t\tawait this.setOwnStateIfDifferent(getDpPath('Activate_Zip'), true, false);\n\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} else if (istAbtauen) {\n\t\t\t\t\t// Checkbox: ZIP- & HUP-Spannungsoptimierung\n\t\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', 10);\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\t// Paralleler Abruf aller Telemetriedaten f\u00FCr die laufende Zyklus-\u00DCberwachung\n\t\t\tconst [\n\t\t\t\twwSollState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\n\t\t\t\theatingStateStrState,\n\t\t\t\tvd1State,\n\t\t\t\twwHystereseState,\n\t\t\t\truecklaufSollState,\n\t\t\t\thupAktivState,\n\t\t\t\theizenHystereseState,\n\t\t\t\tnachWasserState,\n\t\t\t\taelterAls10,\n\t\t\t] = await Promise.all([\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('spreizung_vorlauf_ruecklauf')),\n\t\t\t\tthis.getStateAsync(getDpPath('opStateHeatingString')),\n\t\t\t\tthis.getStateAsync(getDpPath('VD1out')),\n\t\t\t\tthis.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('HUPout')),\n\t\t\t\tthis.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('Heizen_nach_Wasser')),\n\t\t\t\tthis.istBetriebszustandAelterAls10Min(),\n\t\t\t]);\n\n\t\t\tconst wwSoll = (wwSollState?.val as number) ?? 0;\n\t\t\tconst wwIst = (wwIstState?.val as number) ?? 0;\n\t\t\tconst ruecklauf = (ruecklaufState?.val as number) ?? 0;\n\t\t\tconst spreizung = (spreizungState?.val as number) ?? 0;\n\t\t\tconst heatingStateStr = String(heatingStateStrState?.val || '').trim();\n\t\t\tconst vd1 = vd1State?.val === 1;\n\t\t\tconst wwHysterese = (wwHystereseState?.val as number) ?? 0;\n\t\t\tconst ruecklaufSoll = (ruecklaufSollState?.val as number) ?? 0;\n\t\t\tconst hupAktiv = (hupAktivState?.val as number) ?? 0;\n\t\t\tconst heizenHysterese = (heizenHystereseState?.val as number) ?? 0;\n\t\t\tconst nachWasser = nachWasserState?.val;\n\t\t\tconst betriebsart = (bzState?.val as number) ?? 0;\n\n\t\t\t// =========================================================\n\t\t\t// 2. KONTINUIERLICHE \u00DCBERWACHUNG W\u00C4HREND DES BETRIEBS\n\t\t\t// =========================================================\n\t\t\tif (istHeizen) {\n\t\t\t\t// Takt-Optimierung: Anhebung des Fu\u00DFpunkts nach 10 min stabilisieren\n\t\t\t\tif (config.regelung_aktiv !== false && aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunkt = (await this.getStateAsync(getDpPath('heating_curve_parallel_offset')))?.val;\n\t\t\t\t\tif (fusspunkt === 35) {\n\t\t\t\t\t\tconst fallbackFusspunkt = config.fusspunkt ?? 21.7;\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', fallbackFusspunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// ZIP- & HUP-Spannungsoptimierung: Dynamische Spreizungsregelung der HUP\n\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\tconst now = Date.now();\n\t\t\t\t\tif (now - this.lastPumpOptimization > 300000) {\n\t\t\t\t\t\tif (spreizung < 6.5 && hupAktiv > 5.5) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', hupAktiv - 0.25);\n\t\t\t\t\t\t\tthis.lastPumpOptimization = now;\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Spreizung zu gering (${spreizung}K). HUP-Spannung auf ${hupAktiv - 0.25}V gesenkt.`,\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} else if (spreizung > 7.5 && hupAktiv < 10) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', hupAktiv + 0.25);\n\t\t\t\t\t\t\tthis.lastPumpOptimization = now;\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Spreizung zu hoch (${spreizung}K). HUP-Spannung auf ${hupAktiv + 0.25}V erh\u00F6ht.`,\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}\n\t\t\t\t}\n\n\t\t\t\t// Takt-Optimierung: \"Heizen nach Wasser\" und Hysteresen-Management\n\t\t\t\tif (config.regelung_aktiv !== false) {\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\tconst fallbackHyst = config.sync_hotwater_temperature_hysteresis ?? 2;\n\t\t\t\t\t\tawait this.syncConfigValue('hotWaterTemperatureHysteresis', fallbackHyst);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\t// Takt-Optimierung: Fu\u00DFpunkt anheben bei Heizen nach Wasser\n\t\t\t\tif (config.regelung_aktiv !== false) {\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\t// ZIP- & HUP-Spannungsoptimierung: ZIP bei erreichten Sollwerten beenden\n\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\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\t// Takt-Optimierung: Heiztakt vor einer nahenden Warmwasserladung vorziehen\n\t\t\t\tif (config.regelung_aktiv !== false) {\n\t\t\t\t\tif (\n\t\t\t\t\t\twwSoll - wwIst >= wwHysterese - 1.5 &&\n\t\t\t\t\t\truecklauf <= ruecklaufSoll &&\n\t\t\t\t\t\tbetriebsart !== 4 &&\n\t\t\t\t\t\theatingStateStr !== 'Heizgrenze'\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Fehler im runOptimizationSchedule-Ablauf: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\tprivate async writePumpAsync(cmd: string | number, val: any): Promise<void> {\n\t\tif (this.isDebugLogActive) {\n\t\t\twriteLog(`writePumpAsync Raw-Befehl: ID ${cmd}, val: ${val}`, 'debug');\n\t\t}\n\t\tconst paramId = typeof cmd === 'string' ? parseInt(cmd, 10) : cmd;\n\t\tlet value = typeof val === 'string' ? parseInt(val, 10) : val;\n\n\t\t// Boolean-Werte in 1/0 umwandeln\n\t\tif (typeof value === 'boolean') {\n\t\t\tvalue = value ? 1 : 0;\n\t\t}\n\n\t\tawait writeRawParameter(this, paramId, value);\n\t}\n\n\tpublic async queueWrite(cmd: string | number, val: any): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.writeQueue.push(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.writePumpAsync(cmd, val);\n\t\t\t\t\tresolve();\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t}\n\t\t\t});\n\t\t\tvoid this.processQueue();\n\t\t});\n\t}\n\n\tprivate async processQueue(): Promise<void> {\n\t\t// Wenn die Queue bereits abgearbeitet wird oder leer ist, brechen wir ab\n\t\tif (this.isWriting || this.writeQueue.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Warteschlange wird jetzt blockiert, damit keine parallelen Schreibzugriffe stattfinden\n\t\tthis.isWriting = true;\n\n\t\ttry {\n\t\t\t// Solange noch Auftr\u00E4ge in der Liste sind, arbeiten wir sie der Reihe nach ab\n\t\t\twhile (this.writeQueue.length > 0) {\n\t\t\t\tconst task = this.writeQueue.shift(); // Nimmt den \u00E4ltesten Auftrag aus der Liste\n\n\t\t\t\tif (task) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\t// Versuche, den Schreibbefehl an die Luxtronik zu senden\n\t\t\t\t\t\tawait task();\n\n\t\t\t\t\t\t// Hardware-Schutz: Zwingende Pause (z.B. 300ms) nach jedem Schreibbefehl,\n\t\t\t\t\t\t// damit sich der Controller der W\u00E4rmepumpe nicht verschluckt.\n\t\t\t\t\t\tawait new Promise(resolve => global.setTimeout(resolve, 300));\n\t\t\t\t\t} catch (taskError: any) {\n\t\t\t\t\t\t// Wenn ein einzelner Schreibbefehl fehlschl\u00E4gt, fangen wir das HIER ab.\n\t\t\t\t\t\t// Dadurch st\u00FCrzt die Schleife nicht ab, sondern macht einfach mit dem\n\t\t\t\t\t\t// n\u00E4chsten Befehl in der Warteschlange weiter!\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Fehler beim Ausf\u00FChren eines Schreibbefehls in der Queue: ${taskError.message}`,\n\t\t\t\t\t\t\t'error',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\t// oder mit einem schweren Fehler (Exception) abgebrochen ist.\n\t\t\t// So ist garantiert, dass die Warteschlange immer wieder f\u00FCr neue Befehle freigegeben wird!\n\t\t\tthis.isWriting = false;\n\t\t}\n\t}\n\n\tprivate formatSecondsToHMS(totalSeconds: number): string {\n\t\tif (totalSeconds < 0 || isNaN(totalSeconds)) {\n\t\t\treturn '00:00:00';\n\t\t}\n\t\tconst hours = Math.floor(totalSeconds / 3600);\n\t\tconst minutes = Math.floor((totalSeconds % 3600) / 60);\n\t\tconst seconds = Math.floor(totalSeconds % 60);\n\t\treturn `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;\n\t}\n\n\tprivate async updateData(): Promise<void> {\n\t\tif (this.updateRunning) {\n\t\t\treturn;\n\t\t}\n\t\tthis.updateRunning = true;\n\t\ttry {\n\t\t\tconst delay = (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\t// 1. Parameter (3003) auslesen\n\t\t\ttry {\n\t\t\t\trawParams = await readAllRaw(this, 3003);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(`Raw 3003 Fehler: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t}\n\n\t\t\t// Kurze Atempause f\u00FCr die CPU der W\u00E4rmepumpe (statt 3,5 Sekunden!)\n\t\t\tawait delay(200);\n\n\t\t\t// 2. Messwerte (3004) auslesen\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(`Raw 3004 Fehler: ${err instanceof Error ? err.message : String(err)}`);\n\t\t\t}\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tfor (const [key, definition] of Object.entries(STATE_MAPPING)) {\n\t\t\t\tif (definition.isVirtual) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!isStateEnabled(key, definition, config)) {\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\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 && definition.factor) {\n\t\t\t\t\t\t\t\tvalue /= definition.factor;\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 && definition.factor) {\n\t\t\t\t\t\t\t\tvalue /= definition.factor;\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\t// Die alte coolchip-Bibliothek ist entfernt.\n\t\t\t\t\t\t\t// Diese alten Text-Werte (z. B. Firmware) werden ignoriert.\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\t// Logik: Einstellungen sind meist Parameter (3003), Infos sind Messwerte (3004)\n\t\t\t\t\t\tvalue = definition.folder.startsWith('Einstellungen') ? rawParams?.[idx] : rawValues?.[idx];\n\t\t\t\t\t\tif (value !== undefined && definition.factor) {\n\t\t\t\t\t\t\tvalue /= definition.factor;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback f\u00FCr alte Text-IDs (z.B. \"firmware\" statt einer Nummer)\n\t\t\t\t\t\tvalue = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\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\tif (definition.unit === 's' && typeof value === 'number') {\n\t\t\t\t\t\tvalue = this.formatSecondsToHMS(value);\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\t// NEU: Zwingt die Anzeige \u00FCberall auf zweistellige Werte mit f\u00FChrender Null\n\t\t\t\t\t\t\t\tvalue = new Date(totalSeconds * 1000).toLocaleString('de-DE', {\n\t\t\t\t\t\t\t\t\tday: '2-digit',\n\t\t\t\t\t\t\t\t\tmonth: '2-digit',\n\t\t\t\t\t\t\t\t\tyear: 'numeric',\n\t\t\t\t\t\t\t\t\thour: '2-digit',\n\t\t\t\t\t\t\t\t\tminute: '2-digit',\n\t\t\t\t\t\t\t\t\tsecond: '2-digit',\n\t\t\t\t\t\t\t\t\thour12: false,\n\t\t\t\t\t\t\t\t});\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\t// Wir ermitteln, welchen Typ das ioBroker-Objekt zwingend erwartet\n\t\t\t\t\tlet targetIoBrokerType = definition.type === 'json' ? 'string' : definition.type;\n\t\t\t\t\tif (definition.unit === 's' && definition.type === 'number') {\n\t\t\t\t\t\ttargetIoBrokerType = 'string';\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auch hier: Alle Zeitrollen als String absichern\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\t// Und zwingen den Rohwert gnadenlos in diesen Typ!\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\t\t\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this);\n\t\t\tawait calculateTotalEnergy(this);\n\n\t\t\tconst fehlerDp = getDpPath('Fehlerspeicher');\n\t\t\tconst oldFehlerState = await this.getStateAsync(fehlerDp);\n\t\t\tconst oldFehlerVal = oldFehlerState?.val as string | undefined;\n\n\t\t\tawait updateErrorHistory(this, rawValues);\n\n\t\t\tconst newFehlerState = await this.getStateAsync(fehlerDp);\n\t\t\tconst newFehlerVal = newFehlerState?.val as string | undefined;\n\n\t\t\t// ---> NEUER AUFRUF DES EXTERNEN MANAGERS <---\n\t\t\tawait checkAndSendErrorNotifications(this, oldFehlerVal, newFehlerVal);\n\n\t\t\tawait updateOutageHistory(this, rawValues);\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\t\t\tawait this.runOptimizationSchedule();\n\t\t} catch (err: any) {\n\t\t\tthis.errorCount++;\n\t\t\twriteLog(`Abfragefehler (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`, 'error');\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('W\u00E4rmepumpe nicht erreichbar. Verbindung wurde als unterbrochen markiert.', 'warn');\n\t\t\t\tsendTelegramNotification(\n\t\t\t\t\tthis,\n\t\t\t\t\t'W\u00E4rmepumpe nicht erreichbar. Verbindung wurde als unterbrochen markiert.',\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\tprivate onUnload(callback: () => void): void {\n\t\ttry {\n\t\t\tif (this.pollingInterval) {\n\t\t\t\tclearInterval(this.pollingInterval);\n\t\t\t}\n\t\t\tif (this.zipTimer) {\n\t\t\t\tclearTimeout(this.zipTimer);\n\t\t\t}\n\n\t\t\tvoid this.setState('info.connection', { val: false, ack: true });\n\n\t\t\twriteLog('Adapter wird beendet. Alle Timer und Verbindungen sauber gestoppt.', 'info');\n\t\t\tcallback();\n\t\t} catch {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\tprivate async onStateChange(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\t// 1. Bewegungssensoren Logik\n\t\tconst config = this.config as Record<string, any>;\n\t\tif (config.motion_sensors_aktiv && config.motionSensors && Array.isArray(config.motionSensors)) {\n\t\t\tconst matchedSensor = config.motionSensors.find((s: any) => s.oid && s.oid.trim() === id);\n\n\t\t\tif (matchedSensor && state.val === true) {\n\t\t\t\t// Wenn die Zirkulationspumpe physisch bereits l\u00E4uft, tun wir gar nichts.\n\t\t\t\tconst zipOutState = await this.getStateAsync(getDpPath('ZIPout'));\n\t\t\t\tif (zipOutState && zipOutState.val === 1) {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(`Bewegung an '${matchedSensor.name}' ignoriert, da ZIP bereits l\u00E4uft.`, 'debug');\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst lastZipChange = zipOutState?.lc || 0;\n\n\t\t\t\tif (now - lastZipChange > (config.zip_last_run_min || 600) * 1000) {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(`Bewegung an '${matchedSensor.name || id}' erkannt. Triggere ZIP Makro.`, 'debug');\n\t\t\t\t\t}\n\t\t\t\t\t// FIX: Volle ID mit Namespace und setForeignStateAsync f\u00FCr den internen Trigger nutzen\n\t\t\t\t\tawait this.setForeignStateAsync(`${this.namespace}.${getDpPath('Activate_Zip')}`, {\n\t\t\t\t\t\tval: true,\n\t\t\t\t\t\tack: false,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Bewegung an '${matchedSensor.name || id}' erkannt, aber ZIP hat k\u00FCrzlich gearbeitet.`,\n\t\t\t\t\t\t\t'debug',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// 2. Eigene Datenpunkte\n\t\tif (state.ack) {\n\t\t\treturn;\n\t\t}\n\n\t\t// =================================================================\n\t\t// BENUTZERDEFINIERTE WERTE SCHREIBEN\n\t\t// =================================================================\n\t\tif (id.startsWith(`${this.namespace}.Benutzer.`)) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getObjectAsync(id);\n\n\t\t\t\t// Nur weitermachen, wenn es wirklich ein Parameter ist\n\t\t\t\tif (obj && obj.native && obj.native.source === 'parameter') {\n\t\t\t\t\t// FIX: setForeignStateAsync f\u00FCr die volle ID nutzen\n\t\t\t\t\tawait this.setForeignStateAsync(id, { val: state.val, ack: true });\n\n\t\t\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\t\t\t// Konvertierung r\u00FCckg\u00E4ngig machen (ioBroker -> Luxtronik)\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`Schreibe benutzerdefinierten Parameter ${targetWriteId} mit Wert ${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\t// Ab in die sichere Warteschlange zur W\u00E4rmepumpe!\n\t\t\t\t\t\tawait this.queueWrite(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(`Fehler beim Schreiben eines eigenen Parameters: ${err.message}`, 'error');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// =================================================================\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tif (!mappingKey) {\n\t\t\treturn;\n\t\t}\n\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\tif (!definition) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\t\t// FIX: setForeignStateAsync nutzen\n\t\t\t\tawait this.setForeignStateAsync(id, { val: state.val, ack: true });\n\n\t\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\t\twriteLog(`Erweitertes Logging ist nun ${this.isDebugLogActive ? 'aktiviert' : 'deaktiviert'}`, 'info');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Regelung_Aktiv' || mappingKey === 'zip_aktiv') {\n\t\t\t\t// FIX: setForeignStateAsync nutzen\n\t\t\t\tawait this.setForeignStateAsync(id, { 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\t// FIX: setForeignStateAsync nutzen\n\t\t\t\tawait this.setForeignStateAsync(id, { val: false, ack: true });\n\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\t\t// FIX: setForeignStateAsync nutzen\n\t\t\t\tawait this.setForeignStateAsync(id, { val: false, ack: true });\n\t\t\t\tawait dumpAllRawToLog(this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// ==========================================\n\t\t\t// Zwangswarmwasser\n\t\t\t// ==========================================\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\t// ==========================================\n\t\t\t// Zwangsheizen\n\t\t\t// ==========================================\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\t// ==========================================\n\t\t\t// Activate_Zip\n\t\t\t// ==========================================\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.setForeignStateAsync(id, { val: false, ack: true });\n\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!definition.luxWriteId || definition.write !== true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// FIX: setForeignStateAsync f\u00FCr alle normalen Parameter am Ende nutzen\n\t\t\tawait this.setForeignStateAsync(id, { val: state.val, ack: true });\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (definition.role === 'value.datetime') {\n\t\t\t\tconst valStr = String(state.val).trim();\n\t\t\t\tconst timeMatch = valStr.match(/^(\\d{1,2}):(\\d{1,2})/);\n\t\t\t\tif (timeMatch) {\n\t\t\t\t\tvalueToWrite = parseInt(timeMatch[1], 10) * 3600 + parseInt(timeMatch[2], 10) * 60;\n\t\t\t\t}\n\t\t\t} else if (definition.factor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * definition.factor;\n\t\t\t}\n\n\t\t\t// Temperaturwerte f\u00FCr die Roh-Schnittstelle aufbereiten (z.B. 21.5 \u00B0C -> 215)\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !definition.factor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\tawait this.queueWrite(parseInt(targetWriteId, 10), valueToWrite);\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Fehler bei Befehlsausf\u00FChrung: ${err.message}`, 'error');\n\t\t}\n\t}\n}\n\nif (require.main !== module) {\n\tmodule.exports = (options: Partial<utils.AdapterOptions> | undefined) => new Luxtronik2Controller(options);\n} else {\n\t(() => new Luxtronik2Controller())();\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAuB;AACvB,4BAA2D;AAC3D,oBAAqD;AACrD,iCAA4F;AAC5F,2BAOO;AACP,0BAA+D;AAC/D,0BAAyC;AACzC,2BAUO;AACP,wBAAwD;AAExD,MAAM,6BAA6B,MAAM,QAAQ;AAAA,EACzC,gBAAgB,oBAAI,IAAY;AAAA,EAChC;AAAA,EACA,oBAAgD;AAAA,EAChD,0BAAyC;AAAA,EACzC,mBAAmB;AAAA,EAClB;AAAA,EACA,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,uBAA+B;AAAA,EAE/B,aAAsC,CAAC;AAAA,EACvC,YAAY;AAAA,EACZ,aAAa;AAAA,EACJ,aAAa;AAAA,EAEvB,YAAY,UAAyC,CAAC,GAAG;AAC/D,UAAM;AAAA,MACL,GAAG;AAAA,MACH,MAAM;AAAA,IACP,CAAC;AACD,kCAAW,IAAI;AAEf,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AACpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAC1C,SAAK,GAAG,WAAW,KAAK,U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AAqB,IAAI;AAAA,QAChC;AACA;AAAA,MACD;AAEA,UAAI,CAAC,WAAW,cAAc,WAAW,UAAU,MAAM;AACxD;AAAA,MACD;AAGA,YAAM,KAAK,qBAAqB,IAAI,EAAE,KAAK,MAAM,KAAK,KAAK,KAAK,CAAC;AAEjE,UAAI,eAAoB,MAAM;AAE9B,UAAI,WAAW,SAAS,kBAAkB;AACzC,cAAM,SAAS,OAAO,MAAM,GAAG,EAAE,KAAK;AACtC,cAAM,YAAY,OAAO,MAAM,sBAAsB;AACrD,YAAI,WAAW;AACd,yBAAe,SAAS,UAAU,CAAC,GAAG,EAAE,IAAI,OAAO,SAAS,UAAU,CAAC,GAAG,EAAE,IAAI;AAAA,QACjF;AAAA,MACD,WAAW,WAAW,UAAU,OAAO,MAAM,QAAQ,UAAU;AAC9D,uBAAe,MAAM,MAAM,WAAW;AAAA,MACvC;AAGA,UAAI,WAAW,SAAS,WAAQ,OAAO,MAAM,QAAQ,YAAY,CAAC,WAAW,QAAQ;AACpF,uBAAe,MAAM,MAAM;AAAA,MAC5B;AAEA,YAAM,gBAAgB,WAAW;AACjC,YAAM,KAAK,WAAW,SAAS,eAAe,EAAE,GAAG,YAAY;AAAA,IAChE,SAAS,KAAU;AAClB,kCAAS,oCAAiC,IAAI,OAAO,IAAI,OAAO;AAAA,IACjE;AAAA,EACD;AACD;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,SAAO,UAAU,CAAC,YAAuD,IAAI,qBAAqB,OAAO;AAC1G,OAAO;AACN,GAAC,MAAM,IAAI,qBAAqB,GAAG;AACpC;",
|
|
4
|
+
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v3.1.5\n */\nimport * as utils from '@iobroker/adapter-core';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { initLogger, setCustomDebug, writeLog } from './logger';\nimport { checkAndSendErrorNotifications, handleTestMessage, sendTelegramNotification } from './notificationManager';\nimport {\n\tcleanupCustomStates,\n\tcleanupEmptyFolders,\n\tcleanupStates,\n\tensureAllObjectsExist,\n\tensureCustomObjectsExist,\n\tisStateEnabled,\n} from './objectManager';\nimport { dumpAllRawToLog, readAllRaw, writeRawParameter } from './rawFunctions';\nimport { STATE_MAPPING, getDpPath } from './stateMapping';\nimport {\n\tcalculateTemperatureSpread,\n\tcalculateTotalEnergy,\n\tcalculateTotalThermalEnergy,\n\tupdateCustomStates,\n\tupdateErrorHistory,\n\tupdateOutageHistory,\n\tupdateStatusStrings,\n\tupdateSystemInfos,\n\tupdateTimerTables,\n} from './virtualStates';\nimport { handleActivateZip, stopZipAndDeaeration } from './zipManager';\n\n/**\n * Main class for the Luxtronik2 Controller ioBroker Adapter.\n */\nclass Luxtronik2Controller extends utils.Adapter {\n\t/** Set of all active namespaced state IDs created or managed by the adapter */\n\tpublic createdStates: Set<string> = new Set<string>();\n\t/** ioBroker timeout handle for the hot water circulation pump macro */\n\tpublic zipTimer?: ioBroker.Timeout;\n\t/** Cached copy of the original circulation pump settings before macro activation */\n\tpublic originalZipConfig: Record<string, any> | null = null;\n\t/** Unix timestamp of the last error dispatched to prevent duplicate notification triggers */\n\tpublic lastKnownErrorTimestamp: number | null = null;\n\t/** Determines whether verbose debugging output is enabled */\n\tpublic isDebugLogActive: boolean = false;\n\t/** 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\tprivate 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\tprivate writeQueue: (() => Promise<void>)[] = [];\n\t/** Lock flag indicating that the write queue is currently being processed */\n\tprivate 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\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\t/**\n\t * Processes incoming inter-adapter messages or commands dispatched from the Admin UI.\n\t *\n\t * @param obj - The standardized ioBroker message structure containing parameters and optional callbacks.\n\t * @returns A promise that resolves once the message has been processed.\n\t */\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}\n\t}\n\n\t/**\n\t * Callback executed once the ioBroker host framework completely initializes the adapter subsystem.\n\t * Sets up database objects, applies configurations, subscribes to states, and triggers the polling loop.\n\t *\n\t * @returns A promise that resolves when initialization completes.\n\t */\n\tprivate async onReady(): Promise<void> {\n\t\tconst config = this.config as Record<string, any>;\n\t\tconst ip = config.host;\n\t\tconst port = config.port || 8889;\n\n\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\twriteLog(`Connecting to heat pump at ${ip}:${port}...`, 'info');\n\n\t\tawait cleanupStates(this);\n\t\tawait cleanupCustomStates(this);\n\t\tawait cleanupEmptyFolders(this);\n\t\tawait ensureAllObjectsExist(this);\n\t\tawait ensureCustomObjectsExist(this);\n\n\t\tawait this.setState(getDpPath('Regelung_Aktiv'), { val: config.regelung_aktiv !== false, ack: true });\n\n\t\tconst debugState = await this.getStateAsync(getDpPath('Schreibe_Debug_Log'));\n\t\tthis.isDebugLogActive = debugState?.val === true;\n\t\tsetCustomDebug(this.isDebugLogActive);\n\n\t\tif (this.isDebugLogActive) {\n\t\t\twriteLog('Synchronizing configuration values with the heat pump...', 'info');\n\t\t}\n\t\tawait this.setIdleDefaults();\n\n\t\tif (config.motion_sensors_aktiv && Array.isArray(config.motionSensors)) {\n\t\t\tfor (const sensor of config.motionSensors) {\n\t\t\t\tif (sensor.oid && typeof sensor.oid === 'string' && sensor.oid.trim() !== '') {\n\t\t\t\t\tthis.subscribeForeignStates(sensor.oid.trim());\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(`Motion sensor subscribed: ${sensor.name} (${sensor.oid})`, 'info');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.subscribeStates('*');\n\n\t\ttry {\n\t\t\tawait this.updateData();\n\t\t} catch (error: any) {\n\t\t\tthis.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);\n\t\t}\n\n\t\tlet intervalSeconds = this.config.interval ? Number(this.config.interval) : 45;\n\t\tif (intervalSeconds < 10) {\n\t\t\tintervalSeconds = 10;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval was too short. Forced to minimum threshold of 10 seconds for protection.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\t\tif (intervalSeconds > 3600) {\n\t\t\tintervalSeconds = 3600;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval exceeded maximum boundary. Restricted to 3600 seconds to prevent overflow issues.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\n\t\tthis.pollingInterval = this.setInterval(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.updateData();\n\t\t\t} catch (error: any) {\n\t\t\t\tthis.log.error(`Error during cyclic data retrieval loop: ${error.message}`);\n\t\t\t}\n\t\t}, intervalSeconds * 1000);\n\n\t\tawait this.setState('info.connection', true, true);\n\t}\n\n\t/**\n\t * Synchronizes a single state configuration parameter with the Luxtronik physical controller.\n\t *\n\t * @param mappingKey - The unique key identifier within the STATE_MAPPING structure.\n\t * @param val - The raw or parsed value to apply.\n\t * @returns A promise that resolves when the synchronization task finishes.\n\t */\n\tpublic async syncConfigValue(mappingKey: keyof typeof STATE_MAPPING, val: any): Promise<void> {\n\t\tif (val === undefined || val === null) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tif (!state || state.val !== val) {\n\t\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\t\tif (!definition) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(id, { val: val, ack: true });\n\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\twriteLog(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, 'info');\n\t\t\t}\n\n\t\t\tif (definition.write === true && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\tlet valueToWrite: any = val;\n\t\t\t\tif (definition.factor && typeof val === 'number') {\n\t\t\t\t\tvalueToWrite = val * definition.factor;\n\t\t\t\t}\n\n\t\t\t\tconst isRawWrite =\n\t\t\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\t\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !definition.factor) {\n\t\t\t\t\tvalueToWrite = val * 10;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\t\t\tconst writeId = isRawWrite ? parseInt(targetWriteId, 10) : targetWriteId;\n\t\t\t\t\tawait this.queueWrite(writeId, valueToWrite);\n\t\t\t\t\tawait new Promise(r => global.setTimeout(r, 200));\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Failed to transmit ${mappingKey} to the heat pump hardware interface: ${err.message}`,\n\t\t\t\t\t\t'error',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Safely updates an internal database state value only if the newly supplied value differs from the existing entry.\n\t *\n\t * @param id - The relative state path ID.\n\t * @param val - The updated value to process.\n\t * @param ack - Explicit acknowledgment flag status to set.\n\t * @returns A promise that resolves when the verification and write operation completes.\n\t */\n\tpublic async setOwnStateIfDifferent(id: string, val: any, ack = false): Promise<void> {\n\t\ttry {\n\t\t\tif (val === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = await this.getStateAsync(id);\n\t\t\tif (!state || state.val !== val) {\n\t\t\t\tawait this.setState(id, { val: val, ack: ack });\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(`Applying specific update for local state ${id}: ${val}`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Configures fallback factory parameter baselines for the heat pump when in an idle state.\n\t *\n\t * @returns A promise that resolves when all default configuration tasks resolve.\n\t */\n\tprivate async setIdleDefaults(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tawait this.syncConfigValue('heating_curve_end_point', config.endpunkt ?? 23);\n\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', config.fusspunkt ?? 21.7);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('warmwater_temperature', config.sync_warmwater_target_temperature ?? 54);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'hotWaterTemperatureHysteresis',\n\t\t\t\tconfig.sync_hotwater_temperature_hysteresis ?? 10,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('returnTemperatureHysteresis', config.sync_return_temperature_hysteresis ?? 1.5);\n\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\n\t\t\tawait this.syncConfigValue('Heizen_nach_Wasser', config.Heating_after_warmwater ?? false);\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Failed to apply the baseline idle configuration defaults: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Evaluates whether the current active operating state timestamp is older than ten minutes.\n\t *\n\t * @returns A promise that resolves to true if the state has remained unaltered for at least 10 minutes.\n\t */\n\tprivate async istBetriebszustandAelterAls10Min(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst state = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst lastChange = state?.lc ?? 0;\n\t\t\treturn (Date.now() - lastChange) / 60000 >= 10;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Primary intelligent engine analyzing live telemetry values to execute continuous performance optimizations.\n\t * Manages dynamic heating curves, anti-cycling protective delays, and voltage scaling algorithms.\n\t *\n\t * @returns A promise that resolves when the execution cycle finishes.\n\t */\n\tprivate async runOptimizationSchedule(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tconst bzState = await this.getStateAsync(getDpPath('WP_BZ_akt'));\n\t\t\tconst bzVal = bzState && bzState.val !== null ? String(bzState.val).trim() : '';\n\n\t\t\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 !== false) {\n\t\t\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\t\t}\n\t\t\t\t} else if (istHeizen) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv ?? 0);\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 (config.regelung_aktiv !== false) {\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 !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue(\n\t\t\t\t\t\t\t'hotWaterTemperatureHysteresis',\n\t\t\t\t\t\t\tconfig.sync_hotwater_temperature_hysteresis ?? 2,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 0);\n\t\t\t\t\t\tawait this.setOwnStateIfDifferent(getDpPath('Activate_Zip'), true, false);\n\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} else if (istAbtauen) {\n\t\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', 10);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.lastBzVal = bzVal;\n\t\t\t}\n\n\t\t\tconst [\n\t\t\t\twwSollState,\n\t\t\t\twwIstState,\n\t\t\t\truecklaufState,\n\t\t\t\tspreizungState,\n\t\t\t\theatingStateStrState,\n\t\t\t\tvd1State,\n\t\t\t\twwHystereseState,\n\t\t\t\truecklaufSollState,\n\t\t\t\thupAktivState,\n\t\t\t\theizenHystereseState,\n\t\t\t\tnachWasserState,\n\t\t\t\taelterAls10,\n\t\t\t] = await Promise.all([\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\t\tthis.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('spreizung_vorlauf_ruecklauf')),\n\t\t\t\tthis.getStateAsync(getDpPath('opStateHeatingString')),\n\t\t\t\tthis.getStateAsync(getDpPath('VD1out')),\n\t\t\t\tthis.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\t\tthis.getStateAsync(getDpPath('HUPout')),\n\t\t\t\tthis.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t\t\tthis.getStateAsync(getDpPath('Heizen_nach_Wasser')),\n\t\t\t\tthis.istBetriebszustandAelterAls10Min(),\n\t\t\t]);\n\n\t\t\tconst wwSoll = (wwSollState?.val as number) ?? 0;\n\t\t\tconst wwIst = (wwIstState?.val as number) ?? 0;\n\t\t\tconst ruecklauf = (ruecklaufState?.val as number) ?? 0;\n\t\t\tconst spreizung = (spreizungState?.val as number) ?? 0;\n\t\t\tconst heatingStateStr = String(heatingStateStrState?.val || '').trim();\n\t\t\tconst vd1 = vd1State?.val === 1;\n\t\t\tconst wwHysterese = (wwHystereseState?.val as number) ?? 0;\n\t\t\tconst ruecklaufSoll = (ruecklaufSollState?.val as number) ?? 0;\n\t\t\tconst hupAktiv = (hupAktivState?.val as number) ?? 0;\n\t\t\tconst heizenHysterese = (heizenHystereseState?.val as number) ?? 0;\n\t\t\tconst nachWasser = nachWasserState?.val;\n\n\t\t\t// =========================================================\n\t\t\t// 2. CONTINUOUS IN-SERVICE TELEMETRY EVALUATION\n\t\t\t// =========================================================\n\t\t\tif (istHeizen) {\n\t\t\t\tif (config.regelung_aktiv !== false && aelterAls10 && vd1) {\n\t\t\t\t\tconst fusspunkt = (await this.getStateAsync(getDpPath('heating_curve_parallel_offset')))?.val;\n\t\t\t\t\tif (fusspunkt === 35) {\n\t\t\t\t\t\tconst fallbackFusspunkt = config.fusspunkt ?? 21.7;\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', fallbackFusspunkt);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (config.zip_optimierung_aktiv !== false) {\n\t\t\t\t\tconst now = Date.now();\n\t\t\t\t\tif (now - this.lastPumpOptimization > 300000) {\n\t\t\t\t\t\tif (spreizung < 6.5 && hupAktiv > 5.5) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', hupAktiv - 0.25);\n\t\t\t\t\t\t\tthis.lastPumpOptimization = now;\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Temperature spread too low (${spreizung}K). Scaling down HUP nominal target to ${hupAktiv - 0.25}V.`,\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} else if (spreizung > 7.5 && hupAktiv < 10) {\n\t\t\t\t\t\t\tawait this.syncConfigValue('heating_system_circ_pump_voltage_nominal', hupAktiv + 0.25);\n\t\t\t\t\t\t\tthis.lastPumpOptimization = now;\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Temperature spread too high (${spreizung}K). Scaling up HUP nominal target to ${hupAktiv + 0.25}V.`,\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}\n\t\t\t\t}\n\n\t\t\t\tif (config.regelung_aktiv !== false) {\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\tconst fallbackHyst = config.sync_hotwater_temperature_hysteresis ?? 2;\n\t\t\t\t\t\tawait this.syncConfigValue('hotWaterTemperatureHysteresis', fallbackHyst);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (istWarmwasser && nachWasser) {\n\t\t\t\tif (config.regelung_aktiv !== false) {\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 !== false) {\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 (config.regelung_aktiv !== false) {\n\t\t\t\t\tif (\n\t\t\t\t\t\twwSoll - wwIst >= wwHysterese - 1.5 &&\n\t\t\t\t\t\truecklauf <= ruecklaufSoll &&\n\t\t\t\t\t\theatingStateStr !== 'Heating limit'\n\t\t\t\t\t) {\n\t\t\t\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', 35);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during runOptimizationSchedule loop execution: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Directly transmits a raw command block buffer over the chosen communications channel.\n\t *\n\t * @param cmd - The parameter numeric index code.\n\t * @param val - The compiled target payload value.\n\t * @returns A promise that resolves when the transmission finishes.\n\t */\n\tprivate async writePumpAsync(cmd: string | number, val: any): Promise<void> {\n\t\tif (this.isDebugLogActive) {\n\t\t\twriteLog(`writePumpAsync direct interface command triggered: Register ${cmd}, value: ${val}`, 'debug');\n\t\t}\n\t\tconst paramId = typeof cmd === 'string' ? parseInt(cmd, 10) : cmd;\n\t\tlet value = typeof val === 'string' ? parseInt(val, 10) : val;\n\n\t\tif (typeof value === 'boolean') {\n\t\t\tvalue = value ? 1 : 0;\n\t\t}\n\n\t\tawait writeRawParameter(this, paramId, value);\n\t}\n\n\t/**\n\t * Pushes a hardware write task into a single-threaded execution queue to guarantee transmission safety.\n\t *\n\t * @param cmd - Target parameter register ID.\n\t * @param val - The value payload to map.\n\t * @returns A promise that completes once the queue executes this task.\n\t */\n\tpublic async queueWrite(cmd: string | number, val: any): Promise<void> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.writeQueue.push(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.writePumpAsync(cmd, val);\n\t\t\t\t\tresolve();\n\t\t\t\t} catch (err) {\n\t\t\t\t\treject(err instanceof Error ? err : new Error(String(err)));\n\t\t\t\t}\n\t\t\t});\n\t\t\tvoid this.processQueue();\n\t\t});\n\t}\n\n\t/**\n\t * Iteratively processes sequential write tasks inside the internal queue buffer.\n\t * Enforces defensive execution delay separation spacing to secure hardware stability.\n\t *\n\t * @returns A promise that resolves when processing cycles resolve.\n\t */\n\tprivate async processQueue(): Promise<void> {\n\t\tif (this.isWriting || this.writeQueue.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isWriting = true;\n\n\t\ttry {\n\t\t\twhile (this.writeQueue.length > 0) {\n\t\t\t\tconst task = this.writeQueue.shift();\n\n\t\t\t\tif (task) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait task();\n\t\t\t\t\t\tawait new Promise(resolve => global.setTimeout(resolve, 300));\n\t\t\t\t\t} catch (taskError: any) {\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Error processing specific serial write task sequence in queue: ${taskError.message}`,\n\t\t\t\t\t\t\t'error',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.isWriting = false;\n\t\t}\n\t}\n\n\t/**\n\t * Standardizes raw seconds telemetry counters into readable zero-padded \"HH:MM:SS\" time blocks.\n\t *\n\t * @param totalSeconds - Total input seconds configuration value.\n\t * @returns Legible time block string.\n\t */\n\tprivate formatSecondsToHMS(totalSeconds: number): string {\n\t\tif (totalSeconds < 0 || isNaN(totalSeconds)) {\n\t\t\treturn '00:00:00';\n\t\t}\n\t\tconst hours = Math.floor(totalSeconds / 3600);\n\t\tconst minutes = Math.floor((totalSeconds % 3600) / 60);\n\t\tconst seconds = Math.floor(totalSeconds % 60);\n\t\treturn `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;\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\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} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait delayHelper(200);\n\n\t\t\ttry {\n\t\t\t\trawValues = await readAllRaw(this, 3004);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tfor (const [key, definition] of Object.entries(STATE_MAPPING)) {\n\t\t\t\tif (definition.isVirtual) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!isStateEnabled(key, definition, config)) {\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\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 && definition.factor) {\n\t\t\t\t\t\t\t\tvalue /= definition.factor;\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 && definition.factor) {\n\t\t\t\t\t\t\t\tvalue /= definition.factor;\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 && definition.factor) {\n\t\t\t\t\t\t\tvalue /= definition.factor;\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\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 = this.formatSecondsToHMS(finalSeconds);\n\t\t\t\t\t} else if (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\tconst totalSeconds = typeof value === 'number' ? value : parseInt(value as string, 10);\n\t\t\t\t\t\tif (!isNaN(totalSeconds) && totalSeconds >= 0) {\n\t\t\t\t\t\t\tif (totalSeconds < 86400) {\n\t\t\t\t\t\t\t\tconst h = Math.floor(totalSeconds / 3600)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tconst m = Math.floor((totalSeconds % 3600) / 60)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tvalue = `${h}:${m}`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = new Date(totalSeconds * 1000).toISOString().replace('T', ' ').substring(0, 19);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet targetIoBrokerType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\ttargetIoBrokerType = 'string';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (targetIoBrokerType === 'string' && typeof value !== 'string') {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'number' && typeof value !== 'number') {\n\t\t\t\t\t\tvalue = Number(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'boolean' && typeof value !== 'boolean') {\n\t\t\t\t\t\tvalue = Boolean(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this);\n\t\t\tawait calculateTotalEnergy(this);\n\n\t\t\tconst fehlerDp = getDpPath('Fehlerspeicher');\n\t\t\tconst oldFehlerState = await this.getStateAsync(fehlerDp);\n\t\t\tconst oldFehlerVal = oldFehlerState?.val as string | undefined;\n\n\t\t\tawait updateErrorHistory(this, rawValues);\n\n\t\t\tconst newFehlerState = await this.getStateAsync(fehlerDp);\n\t\t\tconst newFehlerVal = newFehlerState?.val as string | undefined;\n\n\t\t\tawait checkAndSendErrorNotifications(this, oldFehlerVal, newFehlerVal);\n\n\t\t\tawait updateOutageHistory(this, rawValues);\n\t\t\tawait calculateTemperatureSpread(this);\n\t\t\tawait updateStatusStrings(this, rawValues, rawParams);\n\t\t\tawait updateCustomStates(this, rawValues, rawParams);\n\t\t\tawait updateTimerTables(this);\n\t\t\tawait updateSystemInfos(this, rawValues);\n\t\t\tawait this.runOptimizationSchedule();\n\t\t} catch (err: any) {\n\t\t\tthis.errorCount++;\n\t\t\twriteLog(\n\t\t\t\t`Communication error encountered (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\n\t\t\tif (this.errorCount >= this.MAX_ERRORS) {\n\t\t\t\tawait this.setState('info.connection', { val: false, ack: true });\n\t\t\t\twriteLog('Heat pump controller unreachable. Flagging connection status as disconnected.', 'warn');\n\t\t\t\tsendTelegramNotification(\n\t\t\t\t\tthis,\n\t\t\t\t\t'Heat pump controller unreachable. Flagging connection status as disconnected.',\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.updateRunning = false;\n\t\t}\n\t}\n\n\t/**\n\t * Callback issued by the ioBroker framework during adapter shutdown sequences.\n\t *\n\t * @param callback - Termination completion trigger function.\n\t */\n\tprivate onUnload(callback: () => void): void {\n\t\ttry {\n\t\t\tif (this.pollingInterval) {\n\t\t\t\tclearInterval(this.pollingInterval);\n\t\t\t}\n\t\t\tif (this.zipTimer) {\n\t\t\t\tclearTimeout(this.zipTimer);\n\t\t\t}\n\n\t\t\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\tif (config.motion_sensors_aktiv && config.motionSensors && Array.isArray(config.motionSensors)) {\n\t\t\tconst matchedSensor = config.motionSensors.find((s: any) => s.oid && s.oid.trim() === id);\n\n\t\t\tif (matchedSensor && state.val === true) {\n\t\t\t\tconst zipOutState = await this.getStateAsync(getDpPath('ZIPout'));\n\t\t\t\tif (zipOutState && zipOutState.val === 1) {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Motion registered at sensor '${matchedSensor.name}' but circulation pump ZIP is already running. Action ignored.`,\n\t\t\t\t\t\t\t'debug',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst lastZipChange = zipOutState?.lc || 0;\n\n\t\t\t\tif (now - lastZipChange > (config.zip_last_run_min || 600) * 1000) {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Motion registered at sensor '${matchedSensor.name || id}'. Launching circulation pump ZIP macro sequence.`,\n\t\t\t\t\t\t\t'debug',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait this.setState(getDpPath('Activate_Zip'), {\n\t\t\t\t\t\tval: true,\n\t\t\t\t\t\tack: false,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t`Motion registered at sensor '${matchedSensor.name || id}' but circulation pump execution suppressed due to anti-cycling protective interval timer.`,\n\t\t\t\t\t\t\t'debug',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (id.startsWith(`${this.namespace}.Custom.`)) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getObjectAsync(id);\n\n\t\t\t\tif (obj && obj.native && obj.native.source === 'parameter') {\n\t\t\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\t\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\t\t\tif (obj.native.customType === 'boolean') {\n\t\t\t\t\t\tvalueToWrite = state.val ? 1 : 0;\n\t\t\t\t\t} else if (obj.native.customType === 'number' && typeof state.val === 'number') {\n\t\t\t\t\t\tif (obj.native.factor) {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val / obj.native.factor);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst targetWriteId = parseInt(obj.native.luxId, 10);\n\t\t\t\t\tif (!isNaN(targetWriteId)) {\n\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,\n\t\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait this.queueWrite(targetWriteId, valueToWrite);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, 'error');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tif (!mappingKey) {\n\t\t\treturn;\n\t\t}\n\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\tif (!definition) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\t\twriteLog(\n\t\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Regelung_Aktiv' || mappingKey === 'zip_aktiv') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Setze_Vorgabewerte' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait dumpAllRawToLog(this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangswarmwasser') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangswarmwasser(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangsheizen') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangsheizen(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Activate_Zip') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tconst durationState = await this.getStateAsync(getDpPath('zip_aktiv'));\n\t\t\t\t\tconst durationSeconds =\n\t\t\t\t\t\tdurationState && typeof durationState.val === 'number' ? durationState.val : 120;\n\t\t\t\t\tawait handleActivateZip(this, id, durationSeconds);\n\t\t\t\t} else {\n\t\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!definition.luxWriteId || definition.write !== true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (definition.role === 'value.datetime') {\n\t\t\t\tconst valStr = String(state.val).trim();\n\t\t\t\tconst timeMatch = valStr.match(/^(\\d{1,2}):(\\d{1,2})/);\n\t\t\t\tif (timeMatch) {\n\t\t\t\t\tvalueToWrite = parseInt(timeMatch[1], 10) * 3600 + parseInt(timeMatch[2], 10) * 60;\n\t\t\t\t}\n\t\t\t} else if (definition.factor && typeof state.val === 'number') {\n\t\t\t\tvalueToWrite = state.val * definition.factor;\n\t\t\t}\n\n\t\t\tif (definition.unit === '\u00B0C' && typeof state.val === 'number' && !definition.factor) {\n\t\t\t\tvalueToWrite = state.val * 10;\n\t\t\t}\n\n\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\tawait this.queueWrite(parseInt(targetWriteId, 10), valueToWrite);\n\t\t} catch (err: any) {\n\t\t\twriteLog(\n\t\t\t\t`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\t\t}\n\t}\n}\n\nif (require.main !== module) {\n\tmodule.exports = (options: Partial<utils.AdapterOptions> | undefined) => new Luxtronik2Controller(options);\n} else {\n\t(() => new Luxtronik2Controller())();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAuB;AACvB,4BAA2D;AAC3D,oBAAqD;AACrD,iCAA4F;AAC5F,2BAOO;AACP,0BAA+D;AAC/D,0BAAyC;AACzC,2BAUO;AACP,wBAAwD;AAKxD,MAAM,6BAA6B,MAAM,QAAQ;AAAA;AAAA,EAEzC,gBAA6B,oBAAI,IAAY;AAAA;AAAA,EAE7C;AAAA;AAAA,EAEA,oBAAgD;AAAA;AAAA,EAEhD,0BAAyC;AAAA;AAAA,EAEzC,mBAA4B;AAAA;AAAA,EAE3B;AAAA;AAAA,EAEA,YAAoB;AAAA;AAAA,EAEpB,gBAAyB;AAAA;AAAA,EAEzB,uBAA+B;AAAA;AAAA,EAG/B,aAAsC,CAAC;AAAA;AAAA,EAEvC,YAAqB;AAAA;AAAA,EAErB,aAAqB;AAAA;AAAA,EAEZ,aAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO/B,YAAY,UAAyC,CAAC,GAAG;AAC/D,UAAM;AAAA,MACL,GAAG;AAAA,MACH,MAAM;AAAA,IACP,CAAC;AACD,kCAAW,IAAI;AAEf,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC;AACpD,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAC1C,SAAK,GAAG,WAAW,KAAK,UAAU,KAAK,IAAI,CAAC;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAc,UAAU,KAAsC;AAC7D,QAAI,IAAI,YAAY,gBAAgB;AACnC,gBAAM,8CAAkB,MAAM,GAAG;AAA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,IAAI,OAAO;AAAA,QAChG;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAC5B,SAAO,UAAU,CAAC,YAAuD,IAAI,qBAAqB,OAAO;AAC1G,OAAO;AACN,GAAC,MAAM,IAAI,qBAAqB,GAAG;AACpC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -39,15 +39,14 @@ async function sendNotification(adapter, message) {
|
|
|
39
39
|
if (config.notification_bell === true) {
|
|
40
40
|
if (typeof adapter.registerNotification === "function") {
|
|
41
41
|
await adapter.registerNotification("luxtronik2-controller", "lwpError", message);
|
|
42
|
-
(0, import_logger.writeLog)("
|
|
43
|
-
successMessages.push("
|
|
42
|
+
(0, import_logger.writeLog)("Notification sent to ioBroker notification center.", "info");
|
|
43
|
+
successMessages.push("Notification Center");
|
|
44
44
|
} else {
|
|
45
|
-
(0, import_logger.writeLog)(`\u{1F6A8} ioBroker
|
|
45
|
+
(0, import_logger.writeLog)(`\u{1F6A8} ioBroker notification center unavailable. Message: ${message}`, "warn");
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
const telegramInstance = config.telegram_instance;
|
|
49
|
-
const isTelegramActive = config.telegram_enabled === true && typeof telegramInstance === "string" &&
|
|
50
|
-
telegramInstance !== "none";
|
|
49
|
+
const isTelegramActive = config.telegram_enabled === true && typeof telegramInstance === "string" && telegramInstance !== "none";
|
|
51
50
|
if (isTelegramActive) {
|
|
52
51
|
const sendObj = { text: message };
|
|
53
52
|
const receiver = (_a = config.telegram_receiver) == null ? void 0 : _a.trim();
|
|
@@ -59,7 +58,7 @@ async function sendNotification(adapter, message) {
|
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
adapter.sendTo(telegramInstance, "send", sendObj);
|
|
62
|
-
(0, import_logger.writeLog)(`Telegram
|
|
61
|
+
(0, import_logger.writeLog)(`Telegram message sent to ${telegramInstance}`, "info");
|
|
63
62
|
successMessages.push("Telegram");
|
|
64
63
|
}
|
|
65
64
|
return successMessages;
|
|
@@ -69,7 +68,7 @@ function sendTelegramNotification(adapter, message) {
|
|
|
69
68
|
}
|
|
70
69
|
async function handleTestMessage(adapter, obj) {
|
|
71
70
|
try {
|
|
72
|
-
(0, import_logger.writeLog)("Test
|
|
71
|
+
(0, import_logger.writeLog)("Test button triggered!", "info");
|
|
73
72
|
const config = adapter.config;
|
|
74
73
|
const isTelegramActive = config.telegram_enabled === true && config.telegram_instance && config.telegram_instance !== "none";
|
|
75
74
|
const isIoBrokerNotifyActive = config.notification_bell === true;
|
|
@@ -79,7 +78,7 @@ async function handleTestMessage(adapter, obj) {
|
|
|
79
78
|
obj.from,
|
|
80
79
|
obj.command,
|
|
81
80
|
{
|
|
82
|
-
error: "
|
|
81
|
+
error: "Error: Neither Telegram nor Notification Center are active! Please save settings first."
|
|
83
82
|
},
|
|
84
83
|
obj.callback
|
|
85
84
|
);
|
|
@@ -93,40 +92,40 @@ async function handleTestMessage(adapter, obj) {
|
|
|
93
92
|
const errorList = safeParse(lastErrorState.val);
|
|
94
93
|
if (errorList && errorList.length > 0) {
|
|
95
94
|
const newestError = errorList[0];
|
|
96
|
-
msg = `\u{1F6A8} *Test
|
|
95
|
+
msg = `\u{1F6A8} *Test Alarm: Error Log*
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
Most recent error:
|
|
99
98
|
Code: ${newestError.code}
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
Error: ${newestError.beschreibung}
|
|
100
|
+
Date: ${newestError.datum}
|
|
102
101
|
|
|
103
102
|
`;
|
|
104
103
|
if (errorList.length > 1) {
|
|
105
|
-
const history = errorList.slice(1).map((e) => `
|
|
104
|
+
const history = errorList.slice(1).map((e) => `Date: ${e.datum}
|
|
106
105
|
Code: ${e.code}
|
|
107
|
-
|
|
108
|
-
msg += `
|
|
106
|
+
Error: ${e.beschreibung}`).join("\n\n");
|
|
107
|
+
msg += `History:
|
|
109
108
|
${history}`;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
if (msg === "") {
|
|
114
|
-
msg = "\u2705 *
|
|
113
|
+
msg = "\u2705 *Successful Test*\n\nThis is a generated test message. Communication via Telegram and ioBroker works perfectly! (There are currently no real heat pump errors).";
|
|
115
114
|
}
|
|
116
115
|
const successMessages = await sendNotification(adapter, msg);
|
|
117
116
|
if (obj.callback) {
|
|
118
117
|
adapter.sendTo(
|
|
119
118
|
obj.from,
|
|
120
119
|
obj.command,
|
|
121
|
-
{ result: `
|
|
120
|
+
{ result: `Successfully triggered: ${successMessages.join(" & ")}` },
|
|
122
121
|
obj.callback
|
|
123
122
|
);
|
|
124
123
|
}
|
|
125
124
|
} catch (err) {
|
|
126
125
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
127
|
-
(0, import_logger.writeLog)(`
|
|
126
|
+
(0, import_logger.writeLog)(`Error processing test button: ${errorMessage}`, "error");
|
|
128
127
|
if (obj.callback) {
|
|
129
|
-
adapter.sendTo(obj.from, obj.command, { error: `
|
|
128
|
+
adapter.sendTo(obj.from, obj.command, { error: `Script error: ${errorMessage}` }, obj.callback);
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
}
|
|
@@ -146,19 +145,19 @@ async function checkAndSendErrorNotifications(adapter, oldFehlerVal, newFehlerVa
|
|
|
146
145
|
}
|
|
147
146
|
if (adapter.lastKnownErrorTimestamp === void 0 || adapter.lastKnownErrorTimestamp === null) {
|
|
148
147
|
adapter.lastKnownErrorTimestamp = currentErrorTimestamp;
|
|
149
|
-
(0, import_logger.writeLog)("
|
|
148
|
+
(0, import_logger.writeLog)("Error monitoring initialized. Last known error timestamp set silently.", "debug");
|
|
150
149
|
return;
|
|
151
150
|
}
|
|
152
151
|
if (currentErrorTimestamp <= adapter.lastKnownErrorTimestamp) {
|
|
153
152
|
return;
|
|
154
153
|
}
|
|
155
154
|
adapter.lastKnownErrorTimestamp = currentErrorTimestamp;
|
|
156
|
-
const msg = `\u{1F6A8} *
|
|
157
|
-
|
|
155
|
+
const msg = `\u{1F6A8} *Heat Pump Malfunction!*
|
|
156
|
+
An error was registered on the heat pump:
|
|
158
157
|
|
|
159
158
|
*Code:* ${currentErrorCode}
|
|
160
|
-
*
|
|
161
|
-
*
|
|
159
|
+
*Error:* ${newestError.beschreibung}
|
|
160
|
+
*Date:* ${newestError.datum}`;
|
|
162
161
|
await sendNotification(adapter, msg);
|
|
163
162
|
}
|
|
164
163
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/notificationManager.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\n\n// =========================================================\n//
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAyB;AACzB,0BAA0B;AAwC1B,SAAS,UAAa,OAAyB;AAC9C,MAAI;AACH,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB,QAAQ;
|
|
4
|
+
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\n\n// =========================================================\n// TYPES & INTERFACES\n// =========================================================\n\n/**\n * Structure of an entry in the error or outage history.\n */\nexport interface ErrorHistoryEntry {\n\t/** The code of the registered error or outage */\n\tcode: number;\n\t/** The clear text description of the code */\n\tbeschreibung: string;\n\t/** The formatted date of occurrence */\n\tdatum: string;\n\t/** The raw Unix timestamp */\n\ttimestamp?: number;\n}\n\n/**\n * Extended adapter interface to provide type safety for dynamic properties and methods.\n */\nexport interface ExtendedAdapter extends AdapterInstance {\n\t/** The adapter configuration from io-package.json combined with dynamic values */\n\tconfig: ioBroker.AdapterConfig & Record<string, any>;\n\t/** Stores the timestamp of the last reported error to prevent duplicate alerts */\n\tlastKnownErrorTimestamp?: number | null;\n}\n\n// =========================================================\n// HELPER FUNCTIONS\n// =========================================================\n\n/**\n * Parses a JSON string in a type-safe manner and silently handles parsing errors.\n *\n * @param value - The JSON string to parse.\n * @returns The parsed object of type T, or null if parsing fails.\n */\nfunction safeParse<T>(value: string): T | null {\n\ttry {\n\t\treturn JSON.parse(value) as T;\n\t} catch {\n\t\tvoid 0;\n\t\treturn null;\n\t}\n}\n\n/**\n * Sends a notification message via the configured channels (ioBroker Notification Center & Telegram).\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n * @returns A promise resolving to an array of successful delivery channel names.\n */\nasync function sendNotification(adapter: ExtendedAdapter, message: string): Promise<string[]> {\n\tconst config = adapter.config;\n\tconst successMessages: string[] = [];\n\n\tif (config.notification_bell === true) {\n\t\tif (typeof adapter.registerNotification === 'function') {\n\t\t\tawait adapter.registerNotification('luxtronik2-controller', 'lwpError', message);\n\t\t\twriteLog('Notification sent to ioBroker notification center.', 'info');\n\t\t\tsuccessMessages.push('Notification Center');\n\t\t} else {\n\t\t\twriteLog(`\uD83D\uDEA8 ioBroker notification center unavailable. Message: ${message}`, 'warn');\n\t\t}\n\t}\n\n\tconst telegramInstance = config.telegram_instance;\n\tconst isTelegramActive =\n\t\tconfig.telegram_enabled === true && typeof telegramInstance === 'string' && telegramInstance !== 'none';\n\n\tif (isTelegramActive) {\n\t\tconst sendObj: Record<string, any> = { text: message };\n\t\tconst receiver = config.telegram_receiver?.trim();\n\n\t\tif (receiver) {\n\t\t\tif (/^-?\\d+$/.test(receiver)) {\n\t\t\t\tsendObj.chatId = Number(receiver);\n\t\t\t} else {\n\t\t\t\tsendObj.user = receiver;\n\t\t\t}\n\t\t}\n\n\t\tadapter.sendTo(telegramInstance, 'send', sendObj);\n\t\twriteLog(`Telegram message sent to ${telegramInstance}`, 'info');\n\t\tsuccessMessages.push('Telegram');\n\t}\n\n\treturn successMessages;\n}\n\n// =========================================================\n// MAIN EXPORTS\n// =========================================================\n\n/**\n * Backwards-compatible wrapper to send Telegram notifications explicitly.\n * Forwards the request to the universal notification function.\n *\n * @param adapter - The extended adapter instance.\n * @param message - The message text to send.\n */\nexport function sendTelegramNotification(adapter: ExtendedAdapter, message: string): void {\n\tvoid sendNotification(adapter, message);\n}\n\n/**\n * Handles the 'testTelegram' message from the ioBroker Admin UI.\n *\n * @param adapter - The extended adapter instance.\n * @param obj - The standardized ioBroker message structure.\n * @returns A promise resolving when the test message has been processed.\n */\nexport async function handleTestMessage(adapter: ExtendedAdapter, obj: ioBroker.Message): Promise<void> {\n\ttry {\n\t\twriteLog('Test button triggered!', 'info');\n\t\tconst config = adapter.config;\n\n\t\tconst isTelegramActive =\n\t\t\tconfig.telegram_enabled === true && config.telegram_instance && config.telegram_instance !== 'none';\n\t\tconst isIoBrokerNotifyActive = config.notification_bell === true;\n\n\t\tif (!isTelegramActive && !isIoBrokerNotifyActive) {\n\t\t\tif (obj.callback) {\n\t\t\t\tadapter.sendTo(\n\t\t\t\t\tobj.from,\n\t\t\t\t\tobj.command,\n\t\t\t\t\t{\n\t\t\t\t\t\terror: 'Error: Neither Telegram nor Notification Center are active! Please save settings first.',\n\t\t\t\t\t},\n\t\t\t\t\tobj.callback,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst errorPath = getDpPath('Fehlerspeicher');\n\t\tconst lastErrorState = errorPath ? await adapter.getStateAsync(errorPath) : null;\n\t\tlet msg = '';\n\n\t\tif (lastErrorState && typeof lastErrorState.val === 'string') {\n\t\t\tconst errorList = safeParse<ErrorHistoryEntry[]>(lastErrorState.val);\n\n\t\t\tif (errorList && errorList.length > 0) {\n\t\t\t\tconst newestError = errorList[0];\n\t\t\t\tmsg = `\uD83D\uDEA8 *Test Alarm: Error Log*\\n\\nMost recent error:\\nCode: ${newestError.code}\\nError: ${newestError.beschreibung}\\nDate: ${newestError.datum}\\n\\n`;\n\n\t\t\t\tif (errorList.length > 1) {\n\t\t\t\t\tconst history = errorList\n\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t.map(e => `Date: ${e.datum}\\nCode: ${e.code}\\nError: ${e.beschreibung}`)\n\t\t\t\t\t\t.join('\\n\\n');\n\t\t\t\t\tmsg += `History:\\n${history}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (msg === '') {\n\t\t\tmsg =\n\t\t\t\t'\u2705 *Successful Test*\\n\\nThis is a generated test message. Communication via Telegram and ioBroker works perfectly! (There are currently no real heat pump errors).';\n\t\t}\n\n\t\tconst successMessages = await sendNotification(adapter, msg);\n\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(\n\t\t\t\tobj.from,\n\t\t\t\tobj.command,\n\t\t\t\t{ result: `Successfully triggered: ${successMessages.join(' & ')}` },\n\t\t\t\tobj.callback,\n\t\t\t);\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst errorMessage = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error processing test button: ${errorMessage}`, 'error');\n\t\tif (obj.callback) {\n\t\t\tadapter.sendTo(obj.from, obj.command, { error: `Script error: ${errorMessage}` }, obj.callback);\n\t\t}\n\t}\n}\n\n/**\n * Checks for changes in the error log, filters out known errors,\n * and triggers an alarm for new, genuine heat pump errors.\n *\n * @param adapter - The extended adapter instance.\n * @param oldFehlerVal - The previous state of the error memory as a JSON string.\n * @param newFehlerVal - The new state of the error memory as a JSON string.\n * @returns A promise resolving when the check finishes.\n */\nexport async function checkAndSendErrorNotifications(\n\tadapter: ExtendedAdapter,\n\toldFehlerVal: string | undefined,\n\tnewFehlerVal: string | undefined,\n): Promise<void> {\n\tif (!newFehlerVal || newFehlerVal === oldFehlerVal) {\n\t\treturn;\n\t}\n\n\tconst newList = safeParse<ErrorHistoryEntry[]>(newFehlerVal);\n\tif (!newList || newList.length === 0) {\n\t\treturn;\n\t}\n\n\tconst newestError = newList[0];\n\tconst currentErrorTimestamp = newestError.timestamp;\n\tconst currentErrorCode = newestError.code;\n\n\tif (currentErrorTimestamp === undefined || currentErrorCode === 0) {\n\t\treturn;\n\t}\n\n\tif (adapter.lastKnownErrorTimestamp === undefined || adapter.lastKnownErrorTimestamp === null) {\n\t\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\t\twriteLog('Error monitoring initialized. Last known error timestamp set silently.', 'debug');\n\t\treturn;\n\t}\n\n\tif (currentErrorTimestamp <= adapter.lastKnownErrorTimestamp) {\n\t\treturn;\n\t}\n\n\tadapter.lastKnownErrorTimestamp = currentErrorTimestamp;\n\n\tconst msg = `\uD83D\uDEA8 *Heat Pump Malfunction!*\\nAn error was registered on the heat pump:\\n\\n*Code:* ${currentErrorCode}\\n*Error:* ${newestError.beschreibung}\\n*Date:* ${newestError.datum}`;\n\n\tawait sendNotification(adapter, msg);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAyB;AACzB,0BAA0B;AAwC1B,SAAS,UAAa,OAAyB;AAC9C,MAAI;AACH,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB,QAAQ;AAEP,WAAO;AAAA,EACR;AACD;AASA,eAAe,iBAAiB,SAA0B,SAAoC;AA1D9F;AA2DC,QAAM,SAAS,QAAQ;AACvB,QAAM,kBAA4B,CAAC;AAEnC,MAAI,OAAO,sBAAsB,MAAM;AACtC,QAAI,OAAO,QAAQ,yBAAyB,YAAY;AACvD,YAAM,QAAQ,qBAAqB,yBAAyB,YAAY,OAAO;AAC/E,kCAAS,sDAAsD,MAAM;AACrE,sBAAgB,KAAK,qBAAqB;AAAA,IAC3C,OAAO;AACN,kCAAS,gEAAyD,OAAO,IAAI,MAAM;AAAA,IACpF;AAAA,EACD;AAEA,QAAM,mBAAmB,OAAO;AAChC,QAAM,mBACL,OAAO,qBAAqB,QAAQ,OAAO,qBAAqB,YAAY,qBAAqB;AAElG,MAAI,kBAAkB;AACrB,UAAM,UAA+B,EAAE,MAAM,QAAQ;AACrD,UAA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