iobroker.luxtronik2-controller 0.6.2 → 0.6.4
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 +46 -16
- package/admin/jsonConfig.json +333 -102
- package/build/actionHandlers.js +7 -9
- package/build/actionHandlers.js.map +2 -2
- package/build/codes.js +1 -0
- package/build/codes.js.map +2 -2
- package/build/convert.js +49 -0
- package/build/convert.js.map +7 -0
- package/build/main.js +54 -139
- package/build/main.js.map +2 -2
- package/build/objectManager.js +3 -3
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +79 -6
- package/build/rawFunctions.js.map +2 -2
- package/build/stateMapping.js +375 -7
- package/build/stateMapping.js.map +2 -2
- package/build/utils.js +36 -0
- package/build/utils.js.map +7 -0
- package/build/virtualStates.js +53 -34
- package/build/virtualStates.js.map +3 -3
- package/build/zipManager.js +316 -48
- package/build/zipManager.js.map +2 -2
- package/io-package.json +27 -27
- package/package.json +4 -4
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\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;AAC5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.5\n */\nimport * as utils from '@iobroker/adapter-core';\nimport { handleZwangsheizen, handleZwangswarmwasser } from './actionHandlers';\nimport { formatTimerSecondsToTime } from './convert';\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, queueWrite, readAllRaw } 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 {\n\tcheckAndHandleMotionSensor,\n\tdisableHardwareZipTimer,\n\thandleActivateZip,\n\tstopZipAndDeaeration,\n\tsubscribeMotionSensors,\n} from './zipManager';\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// Cache f\u00FCr den globalen Schreibschutz\n\tpublic currentRawParams: number[] = [];\n\t/** ioBroker interval handle for the main data polling loop */\n\tprivate pollingInterval: ioBroker.Interval | undefined;\n\t/** Cache for the last evaluated heat pump operating state code */\n\tprivate lastBzVal: string = '';\n\t/** Lock flag preventing concurrent execution of the polling updates */\n\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\tpublic writeQueue: (() => Promise<void>)[] = [];\n\t/** Lock flag indicating that the write queue is currently being processed */\n\tpublic isWriting: boolean = false;\n\t/** Counter tracking sequential communication timeouts/failures */\n\tprivate errorCount: number = 0;\n\t/** Maximum allowed sequential request failures before connection is flagged as interrupted */\n\tprivate readonly MAX_ERRORS: number = 3;\n\tpublic writeCyclesToday: number = 0;\n\tpublic writeCyclesTotal: number = 0;\n\tprivate midnightTimer?: ioBroker.Timeout;\n\t/**\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\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\t\tawait disableHardwareZipTimer(this);\n\t\t// Schreib-Z\u00E4hler aus ioBroker laden (sichert den Stand bei einem Adapter-Neustart)\n\t\tconst cycleTodayState = await this.getStateAsync(getDpPath('write_cycles_today'));\n\t\tthis.writeCyclesToday = cycleTodayState && typeof cycleTodayState.val === 'number' ? cycleTodayState.val : 0;\n\n\t\tconst cycleTotalState = await this.getStateAsync(getDpPath('write_cycles_total'));\n\t\tthis.writeCyclesTotal = cycleTotalState && typeof cycleTotalState.val === 'number' ? cycleTotalState.val : 0;\n\n\t\tthis.scheduleMidnightReset(); // Startet den 00:00 Uhr Timer (nur f\u00FCr den Tagesz\u00E4hler!)\n\t\tsubscribeMotionSensors(this);\n\n\t\tthis.subscribeStates('*');\n\n\t\ttry {\n\t\t\tawait this.updateData();\n\t\t} catch (error: any) {\n\t\t\tthis.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);\n\t\t}\n\n\t\tlet intervalSeconds = this.config.interval ? Number(this.config.interval) : 45;\n\t\tif (intervalSeconds < 10) {\n\t\t\tintervalSeconds = 10;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval was too short. Forced to minimum threshold of 10 seconds for protection.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\t\tif (intervalSeconds > 3600) {\n\t\t\tintervalSeconds = 3600;\n\t\t\twriteLog(\n\t\t\t\t'Configured polling interval exceeded maximum boundary. Restricted to 3600 seconds to prevent overflow issues.',\n\t\t\t\t'warn',\n\t\t\t);\n\t\t}\n\n\t\tthis.pollingInterval = this.setInterval(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.updateData();\n\t\t\t} catch (error: any) {\n\t\t\t\tthis.log.error(`Error during cyclic data retrieval loop: ${error.message}`);\n\t\t\t}\n\t\t}, intervalSeconds * 1000);\n\n\t\tawait this.setState('info.connection', true, true);\n\t}\n\n\t/**\n\t * Berechnet die Zeit bis Mitternacht und setzt NUR den heutigen Schreibz\u00E4hler auf 0 zur\u00FCck.\n\t */\n\tprivate scheduleMidnightReset(): void {\n\t\tconst now = new Date();\n\t\tconst night = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);\n\t\tconst msToMidnight = night.getTime() - now.getTime();\n\n\t\tthis.midnightTimer = this.setTimeout(() => {\n\t\t\tthis.writeCyclesToday = 0;\n\t\t\tvoid this.setState(getDpPath('write_cycles_today'), { val: 0, ack: true });\n\n\t\t\t// Timer f\u00FCr den n\u00E4chsten Tag neu aufziehen\n\t\t\tthis.scheduleMidnightReset();\n\t\t}, msToMidnight);\n\t}\n\n\t/**\n\t * Synchronizes a single state configuration parameter with the Luxtronik physical controller.\n\t *\n\t * @param mappingKey - The unique key identifier within the STATE_MAPPING structure.\n\t * @param val - The raw or parsed value to apply.\n\t * @returns A promise that resolves when the synchronization task finishes.\n\t */\n\tpublic async syncConfigValue(mappingKey: keyof typeof STATE_MAPPING, val: any): Promise<void> {\n\t\tif (val === undefined || val === null) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = getDpPath(mappingKey);\n\t\tconst state = await this.getStateAsync(id);\n\n\t\tif (!state || state.val !== val) {\n\t\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\t\tif (!definition) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(id, { val: val, ack: true });\n\n\t\t\tif (this.isDebugLogActive) {\n\t\t\t\twriteLog(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, 'info');\n\t\t\t}\n\n\t\t\tif (definition.write === true && !definition.isVirtual && definition.luxWriteId) {\n\t\t\t\tlet valueToWrite: any = val;\n\t\t\t\tif (definition.factor && typeof val === 'number') {\n\t\t\t\t\tvalueToWrite = val * definition.factor;\n\t\t\t\t}\n\n\t\t\t\tconst isRawWrite =\n\t\t\t\t\tdefinition.dataSource === 'raw_parameter' ||\n\t\t\t\t\tdefinition.dataSource === 'raw_value' ||\n\t\t\t\t\t(!definition.dataSource && /^\\d+$/.test(definition.luxWriteId || ''));\n\t\t\t\tif (isRawWrite && definition.unit === '\u00B0C' && typeof val === 'number' && !definition.factor) {\n\t\t\t\t\tvalueToWrite = val * 10;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst targetWriteId = definition.luxWriteId;\n\t\t\t\t\tconst writeId = isRawWrite ? parseInt(targetWriteId, 10) : targetWriteId;\n\t\t\t\t\tawait queueWrite(this, writeId, valueToWrite);\n\t\t\t\t\tawait new Promise(r => global.setTimeout(r, 200));\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\twriteLog(\n\t\t\t\t\t\t`Failed to transmit ${mappingKey} to the heat pump hardware interface: ${err.message}`,\n\t\t\t\t\t\t'error',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Safely updates an internal database state value only if the newly supplied value differs from the existing entry.\n\t *\n\t * @param id - The relative state path ID.\n\t * @param val - The updated value to process.\n\t * @param ack - Explicit acknowledgment flag status to set.\n\t * @returns A promise that resolves when the verification and write operation completes.\n\t */\n\tpublic async setOwnStateIfDifferent(id: string, val: any, ack = false): Promise<void> {\n\t\ttry {\n\t\t\tif (val === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = await this.getStateAsync(id);\n\t\t\tif (!state || state.val !== val) {\n\t\t\t\tawait this.setState(id, { val: val, ack: ack });\n\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\twriteLog(`Applying specific update for local state ${id}: ${val}`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (err: any) {\n\t\t\twriteLog(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, 'error');\n\t\t}\n\t}\n\n\t/**\n\t * Configures fallback factory parameter baselines for the heat pump when in an idle state.\n\t *\n\t * @returns A promise that resolves when all default configuration tasks resolve.\n\t */\n\tprivate async setIdleDefaults(): Promise<void> {\n\t\ttry {\n\t\t\tconst config = this.config as Record<string, any>;\n\t\t\tawait this.syncConfigValue('heating_curve_end_point', config.endpunkt ?? 23);\n\t\t\tawait this.syncConfigValue('heating_curve_parallel_offset', config.fusspunkt ?? 21.7);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_minimal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_minimal_heating ?? 3,\n\t\t\t);\n\t\t\tawait this.syncConfigValue(\n\t\t\t\t'heating_system_circ_pump_voltage_nominal',\n\t\t\t\tconfig.sync_heating_system_circ_pump_voltage_nominal_heating ?? 7,\n\t\t\t);\n\t\t\tawait this.syncConfigValue('warmwater_temperature', config.sync_warmwater_target_temperature ?? 54);\n\t\t\tawait this.syncConfigValue(\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\n\t\t\t\t\t\t// Pr\u00FCfen, ob externe Aktoren konfiguriert sind\n\t\t\t\t\t\tconst actors = config.actors || [];\n\t\t\t\t\t\tconst validActors = actors.filter(\n\t\t\t\t\t\t\t(a: any) => a.zip_external_relay_id && a.zip_external_relay_id.trim() !== '',\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Wenn Aktoren da sind, k\u00F6nnen wir die Zirkulation bedenkenlos starten (0 Flash-Schreibvorg\u00E4nge!)\n\t\t\t\t\t\tif (validActors.length > 0) {\n\t\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\t\tthis.log.debug(\n\t\t\t\t\t\t\t\t\t'[ZIP] Externe Aktoren gefunden. Starte Zirkulation synchron zur Warmwasserbereitung.',\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Dauer aus der Config holen (mit einem sinnvollen Fallback von z.B. 120 Sekunden)\n\t\t\t\t\t\t\tawait this.syncConfigValue('zip_aktiv', config.zip_aktiv_ww ?? 120);\n\t\t\t\t\t\t\t// Makro \u00FCber den Trigger-Datenpunkt ausl\u00F6sen\n\t\t\t\t\t\t\tawait this.setOwnStateIfDifferent(getDpPath('Activate_Zip'), true, false);\n\t\t\t\t\t\t}\n\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// if (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 > 600000) {\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 * 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\tthis.currentRawParams = rawParams; //Cache f\u00FCr Schreibschutz aktuell halten\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait delayHelper(200);\n\n\t\t\ttry {\n\t\t\t\trawValues = await readAllRaw(this, 3004);\n\t\t\t} catch (err: unknown) {\n\t\t\t\tthis.log.debug(\n\t\t\t\t\t`Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.errorCount = 0;\n\t\t\tawait this.setState('info.connection', { val: true, ack: true });\n\n\t\t\tconst statePromises: Promise<any>[] = [];\n\t\t\tconst config = this.config as Record<string, any>;\n\n\t\t\tfor (const [key, definition] of Object.entries(STATE_MAPPING)) {\n\t\t\t\tif (definition.isVirtual) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!isStateEnabled(key, definition, config)) {\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 = formatTimerSecondsToTime(finalSeconds);\n\t\t\t\t\t} else if (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\tconst totalSeconds = typeof value === 'number' ? value : parseInt(value as string, 10);\n\t\t\t\t\t\tif (!isNaN(totalSeconds) && totalSeconds >= 0) {\n\t\t\t\t\t\t\tif (totalSeconds < 86400) {\n\t\t\t\t\t\t\t\tconst h = Math.floor(totalSeconds / 3600)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tconst m = Math.floor((totalSeconds % 3600) / 60)\n\t\t\t\t\t\t\t\t\t.toString()\n\t\t\t\t\t\t\t\t\t.padStart(2, '0');\n\t\t\t\t\t\t\t\tvalue = `${h}:${m}`;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tvalue = new Date(totalSeconds * 1000).toISOString().replace('T', ' ').substring(0, 19);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet targetIoBrokerType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\t\t\ttargetIoBrokerType = 'string';\n\t\t\t\t\t}\n\n\t\t\t\t\tif (targetIoBrokerType === 'string' && typeof value !== 'string') {\n\t\t\t\t\t\tvalue = String(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'number' && typeof value !== 'number') {\n\t\t\t\t\t\tvalue = Number(value);\n\t\t\t\t\t} else if (targetIoBrokerType === 'boolean' && typeof value !== 'boolean') {\n\t\t\t\t\t\tvalue = Boolean(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\t\t\tstatePromises.push(this.setState(stateId, { val: value, ack: true }));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait Promise.all(statePromises);\n\t\t\tawait calculateTotalThermalEnergy(this);\n\t\t\tawait calculateTotalEnergy(this);\n\n\t\t\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\tif (this.midnightTimer) {\n\t\t\t\tthis.clearTimeout(this.midnightTimer);\n\t\t\t}\n\n\t\t\tvoid this.setState('info.connection', { val: false, ack: true });\n\n\t\t\twriteLog(\n\t\t\t\t'Adapter is shutting down. Cleared all active intervals and terminated open socket configurations cleanly.',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tcallback();\n\t\t} catch {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\t/**\n\t * Central observer callback executed whenever a subscribed state receives an update.\n\t *\n\t * @param id - The explicit full namespaced state identifier path.\n\t * @param state - The newly applied state context or null context if dropped.\n\t * @returns A promise that resolves when operations complete.\n\t */\n\tprivate async onStateChange(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n\t\tif (!state) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bewegungsmelder an den Manager auslagern\n\t\tconst isMotionSensor = await checkAndHandleMotionSensor(this, id, state);\n\t\tif (isMotionSensor) {\n\t\t\treturn; // Der zipManager hat das Event verarbeitet, wir sind hier fertig\n\t\t}\n\n\t\tif (state.ack) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (id.startsWith(`${this.namespace}.Custom.`)) {\n\t\t\ttry {\n\t\t\t\tconst obj = await this.getObjectAsync(id);\n\n\t\t\t\tif (obj && obj.native && obj.native.source === 'parameter') {\n\t\t\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\t\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\t\t\tif (obj.native.customType === 'boolean') {\n\t\t\t\t\t\tvalueToWrite = state.val ? 1 : 0;\n\t\t\t\t\t} else if (obj.native.customType === 'number' && typeof state.val === 'number') {\n\t\t\t\t\t\tif (obj.native.factor) {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val / obj.native.factor);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalueToWrite = Math.round(state.val);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst targetWriteId = parseInt(obj.native.luxId, 10);\n\t\t\t\t\tif (!isNaN(targetWriteId)) {\n\t\t\t\t\t\tif (this.isDebugLogActive) {\n\t\t\t\t\t\t\twriteLog(\n\t\t\t\t\t\t\t\t`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,\n\t\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait queueWrite(this, targetWriteId, valueToWrite);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (err: any) {\n\t\t\t\twriteLog(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, 'error');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst mappingKey = id.split('.').pop();\n\t\tif (!mappingKey) {\n\t\t\treturn;\n\t\t}\n\t\tconst definition = STATE_MAPPING[mappingKey];\n\t\tif (!definition) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst relativeId = id.replace(`${this.namespace}.`, '');\n\n\t\t\tif (mappingKey === 'Schreibe_Debug_Log') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\t\tthis.isDebugLogActive = state.val === true;\n\t\t\t\tsetCustomDebug(this.isDebugLogActive);\n\t\t\t\twriteLog(\n\t\t\t\t\t`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? 'enabled' : 'disabled'}.`,\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Regelung_Aktiv' || mappingKey === 'zip_aktiv') {\n\t\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Setze_Vorgabewerte' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait this.setIdleDefaults();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (mappingKey === 'Dump_Raw_To_Log' && state.val === true) {\n\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\tawait dumpAllRawToLog(this);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangswarmwasser') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangswarmwasser(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Zwangsheizen') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tawait handleZwangsheizen(this, id);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mappingKey === 'Activate_Zip') {\n\t\t\t\tif (state.val === true) {\n\t\t\t\t\tconst durationState = await this.getStateAsync(getDpPath('zip_aktiv'));\n\t\t\t\t\tconst durationSeconds =\n\t\t\t\t\t\tdurationState && typeof durationState.val === 'number' ? durationState.val : 120;\n\t\t\t\t\tawait handleActivateZip(this, id, durationSeconds);\n\t\t\t\t} else {\n\t\t\t\t\tawait this.setState(relativeId, { val: false, ack: true });\n\t\t\t\t\tawait stopZipAndDeaeration(this);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!definition.luxWriteId || definition.write !== true) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait this.setState(relativeId, { val: state.val, ack: true });\n\n\t\t\tlet valueToWrite: any = state.val;\n\n\t\t\tif (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 queueWrite(this, parseInt(targetWriteId, 10), valueToWrite);\n\t\t} catch (err: any) {\n\t\t\twriteLog(\n\t\t\t\t`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,\n\t\t\t\t'error',\n\t\t\t);\n\t\t}\n\t}\n}\n\nif (require.main !== module) {\n\tmodule.exports = (options: Partial<utils.AdapterOptions> | undefined) => new Luxtronik2Controller(options);\n} else {\n\t(() => new Luxtronik2Controller())();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAGA,YAAuB;AACvB,4BAA2D;AAC3D,qBAAyC;AACzC,oBAAqD;AACrD,iCAA4F;AAC5F,2BAOO;AACP,0BAAwD;AACxD,0BAAyC;AACzC,2BAUO;AACP,wBAMO;AAIP,MAAM,6BAA6B,MAAM,QAAQ;AAAA;AAAA,EAEzC,gBAA6B,oBAAI,IAAY;AAAA;AAAA,EAE7C;AAAA;AAAA,EAEA,oBAAgD;AAAA;AAAA,EAEhD,0BAAyC;AAAA;AAAA,EAEzC,mBAA4B;AAAA;AAAA,EAE5B,mBAA6B,CAAC;AAAA;AAAA,EAE7B;AAAA;AAAA,EAEA,YAAoB;AAAA;AAAA,EAEpB,gBAAyB;AAAA;AAAA,EAEzB,uBAA+B;AAAA;AAAA,EAGhC,aAAsC,CAAC;AAAA;AAAA,EAEvC,YAAqB;AAAA;AAAA,EAEpB,aAAqB;AAAA;AAAA,EAEZ,aAAqB;AAAA,EAC/B,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,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,cAA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ObjectsExist(adapter) {
|
|
|
272
272
|
} else {
|
|
273
273
|
let needsUpdate = false;
|
|
274
274
|
const existingCommon = existingObj.common;
|
|
275
|
-
if (existingCommon.type !== targetType || existingCommon.role !== definition.role || (existingCommon.unit || "") !== (definition.unit || "") || existingCommon.name !== definition.name || existingCommon.read !== commonDef.read || existingCommon.write !== (definition.write || false) || existingCommon.min !== definition.min || existingCommon.max !== definition.max || JSON.stringify(existingCommon.states) !== JSON.stringify(resolvedStates)) {
|
|
275
|
+
if (existingCommon.type !== targetType || existingCommon.role !== definition.role || (existingCommon.unit || "") !== (definition.unit || "") || JSON.stringify(existingCommon.name) !== JSON.stringify(definition.name) || existingCommon.read !== commonDef.read || existingCommon.write !== (definition.write || false) || existingCommon.min !== definition.min || existingCommon.max !== definition.max || JSON.stringify(existingCommon.states) !== JSON.stringify(resolvedStates)) {
|
|
276
276
|
needsUpdate = true;
|
|
277
277
|
}
|
|
278
278
|
if (needsUpdate) {
|
|
279
|
-
await adapter.
|
|
279
|
+
await adapter.extendObject(stateId, { type: "state", common: commonDef });
|
|
280
280
|
(0, import_logger.writeLog)(`Properties of '${stateId}' synchronized (Repair).`, "debug");
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -350,7 +350,7 @@ async function ensureCustomObjectsExist(adapter) {
|
|
|
350
350
|
await adapter.setObjectNotExistsAsync(stateId, objDef);
|
|
351
351
|
adapter.createdStates.add(stateId);
|
|
352
352
|
}
|
|
353
|
-
await adapter.
|
|
353
|
+
await adapter.extendObject(stateId, { common: objDef.common, native: objDef.native });
|
|
354
354
|
if (isWritable) {
|
|
355
355
|
adapter.subscribeStates(stateId);
|
|
356
356
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/objectManager.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AdapterInstance } from '@iobroker/adapter-core';\nimport { writeLog } from './logger';\nimport { STATE_MAPPING } from './stateMapping';\n\n/**\n * Definition eines Datenpunktes f\u00FCr das dynamische Mapping.\n * Steuert, wie Objekte im ioBroker-Baum angelegt werden.\n */\nexport interface StateDefinition {\n\t/** Der Klartext-Name des Datenpunkts */\n\tname: string;\n\t/** Der ioBroker-Datentyp (z. B. 'number', 'string', 'boolean' oder 'json') */\n\ttype: ioBroker.CommonType | 'json';\n\t/** Die ioBroker-Rolle (z. B. 'value.temperature', 'button', 'text') */\n\trole: string;\n\t/** Optionale physikalische Einheit (z. B. '\u00B0C', 'kWh', 's') */\n\tunit?: string;\n\t/** Gibt an, ob der Datenpunkt vom ioBroker gelesen werden kann */\n\tread?: boolean;\n\t/** Gibt an, ob der Datenpunkt vom ioBroker beschreibbar ist */\n\twrite?: boolean;\n\t/** Optionaler minimal zul\u00E4ssiger Wert */\n\tmin?: number;\n\t/** Optionaler maximal zul\u00E4ssiger Wert */\n\tmax?: number;\n\t/** Optionaler Standardwert bei Neuerstellung des Datenpunkts */\n\tdef?: any;\n\t/** Optionales Werte-Mapping f\u00FCr Status-Texte (unterst\u00FCtzt nun i18n) */\n\tstates?: Record<string, Record<number, string>> | Record<number, string>;\n\t/** Das Verzeichnis/Ordnerstruktur im ioBroker-Objektbaum */\n\tfolder: string;\n\t/** Die ID oder der Index, die zum Schreiben/Lesen an die Luxtronik gesendet wird */\n\tluxWriteId?: string | number;\n\t/** Gibt an, ob dieser Datenpunkt systemrelevant und zwingend erforderlich ist */\n\trequired?: boolean;\n\t/** Steuert die interne Formatierung von rohen Sekunden zu HH:MM:SS */\n\tisDurationFormat?: boolean;\n}\n\n/**\n * Konfiguration eines benutzerdefinierten Datenpunktes aus den Adapter-Einstellungen.\n */\nexport interface CustomStateConfig {\n\t/** Gibt an, ob der benutzerdefinierte Datenpunkt aktiv ist */\n\tactive: boolean;\n\t/** Die Luxtronik-ID des abzufragenden Parameters oder Wertes */\n\tluxId?: number;\n\t/** Der vom Benutzer vergebene Klartext-Name */\n\tname: string;\n\t/** Die Quelle der Daten ('parameter' oder 'value') */\n\tsource: 'parameter' | 'value';\n\t/** Der gew\u00FCnschte Zieldatentyp im ioBroker */\n\ttype: 'number' | 'boolean' | 'datetime' | 'string';\n\t/** Optionaler Multiplikator zur Umrechnung (z. B. 0.1 f\u00FCr Temperaturen) */\n\tfactor?: number | null;\n\t/** Optionale physikalische Einheit */\n\tunit?: string;\n}\n\n/**\n * Erweiterte Adapter-Instanz f\u00FCr Typsicherheit beim Zugriff auf interne Eigenschaften.\n */\nexport interface ExtendedAdapter extends AdapterInstance {\n\t/** Adapter-Konfiguration aus der Benutzeroberfl\u00E4che kombiniert mit dynamischen Werten */\n\tconfig: ioBroker.AdapterConfig & Record<string, any>;\n\t/** Set aller w\u00E4hrend der Laufzeit erstellten oder verifizierten Datenpunkt-IDs */\n\tcreatedStates: Set<string>;\n}\n\n/**\n * Zuweisung von Datenpunkt-Pr\u00E4fixen zu den jeweiligen Konfigurations-Checkboxen.\n */\nconst PREFIX_MAPPING: [string, string][] = [\n\t['HZ_MoSo_', 'sync_heatingOperationTimerTableWeek'],\n\t['HZ_MoFr_', 'sync_heatingOperationTimerTable52MonFri'],\n\t['HZ_SaSo_', 'sync_heatingOperationTimerTable52MonFri'],\n\t['HZ_Montag_', 'sync_heatingOperationTimerTableDayMonday'],\n\t['HZ_Dienstag_', 'sync_heatingOperationTimerTableDayTuesday'],\n\t['HZ_Mittwoch_', 'sync_heatingOperationTimerTableDayWednesday'],\n\t['HZ_Donnerstag_', 'sync_heatingOperationTimerTableDayThursday'],\n\t['HZ_Freitag_', 'sync_heatingOperationTimerTableDayFriday'],\n\t['HZ_Samstag_', 'sync_heatingOperationTimerTableDaySaturday'],\n\t['HZ_Sonntag_', 'sync_heatingOperationTimerTableDaySunday'],\n\t['WW_MoSo_', 'sync_hotWaterTableWeek'],\n\t['WW_MoFr_', 'sync_hotWaterTable52MonFri'],\n\t['WW_SaSo_', 'sync_hotWaterTable52MonFri'],\n\t['WW_Montag_', 'sync_hotWaterTableDayMonday'],\n\t['WW_Dienstag_', 'sync_hotWaterTableDayTuesday'],\n\t['WW_Mittwoch_', 'sync_hotWaterTableDayWednesday'],\n\t['WW_Donnerstag_', 'sync_hotWaterTableDayThursday'],\n\t['WW_Freitag_', 'sync_hotWaterTableDayFriday'],\n\t['WW_Samstag_', 'sync_hotWaterTableDaySaturday'],\n\t['WW_Sonntag_', 'sync_hotWaterTableDaySunday'],\n\t['Zirkulation_MoSo_', 'sync_hotWaterCircPumpTimerTableWeek'],\n\t['Zirkulation_MoFr_', 'sync_hotWaterCircPumpTimerTable52MonFri'],\n\t['Zirkulation_SaSo_', 'sync_hotWaterCircPumpTimerTable52MonFri'],\n\t['Zirkulation_Montag_', 'sync_hotWaterCircPumpTimerTableDayMonday'],\n\t['Zirkulation_Dienstag_', 'sync_hotWaterCircPumpTimerTableDayTuesday'],\n\t['Zirkulation_Mittwoch_', 'sync_hotWaterCircPumpTimerTableDayWednesday'],\n\t['Zirkulation_Donnerstag_', 'sync_hotWaterCircPumpTimerTableDayThursday'],\n\t['Zirkulation_Freitag_', 'sync_hotWaterCircPumpTimerTableDayFriday'],\n\t['Zirkulation_Samstag_', 'sync_hotWaterCircPumpTimerTableDaySaturday'],\n\t['Zirkulation_Sonntag_', 'sync_hotWaterCircPumpTimerTableDaySunday'],\n];\n\n/**\n * Pr\u00FCft anhand der Adapter-Konfiguration, ob ein bestimmter Datenpunkt angelegt werden soll.\n *\n * @param key Der Schl\u00FCssel des Datenpunkts aus dem Mapping.\n * @param definition Die Struktur-Definition des Datenpunkts.\n * @param config Die aktuelle Adapter-Konfiguration.\n * @returns True, wenn der Datenpunkt aktiviert ist und angelegt werden soll.\n */\nexport function isStateEnabled(key: string, definition: StateDefinition, config: Record<string, any>): boolean {\n\tif (definition.required) {\n\t\treturn true;\n\t}\n\n\tconst configKey = `sync_${key}`;\n\tif (config[configKey] === false || String(config[configKey]) === 'false') {\n\t\treturn false;\n\t}\n\n\tfor (const [prefix, mapKey] of PREFIX_MAPPING) {\n\t\tif (key.startsWith(prefix)) {\n\t\t\treturn config[mapKey] !== false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Zeichen-Mapping zum Ersetzen von Umlauten und Sonderzeichen in IDs.\n */\nconst CHAR_MAP: Record<string, string> = {\n\t\u00E4: 'ae',\n\t\u00F6: 'oe',\n\t\u00FC: 'ue',\n\t\u00C4: 'Ae',\n\t\u00D6: 'Oe',\n\t\u00DC: 'Ue',\n\t\u00DF: 'ss',\n};\n\n/**\n * Bereinigt Klartext-Namen so, dass sie als g\u00FCltige ioBroker-IDs verwendet werden k\u00F6nnen.\n *\n * @param name Der zu bereinigende Ursprungsname.\n * @returns Der bereinigte, ID-sichere Name.\n */\nexport function sanitizeName(name: string): string {\n\treturn name\n\t\t.replace(/[\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF]/g, match => CHAR_MAP[match])\n\t\t.replace(/[^a-zA-Z0-9_]/g, '_')\n\t\t.replace(/_+/g, '_')\n\t\t.replace(/^_|_$/g, '');\n}\n\n/**\n * Sucht und l\u00F6scht Datenpunkte aus dem ioBroker-Baum, die in den Adapter-Einstellungen deaktiviert wurden.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupStates(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst activeStateIds = new Set<string>();\n\n\tfor (const [key, def] of Object.entries(STATE_MAPPING)) {\n\t\tconst definition = def as StateDefinition;\n\t\tif (isStateEnabled(key, definition, config)) {\n\t\t\tactiveStateIds.add(`${definition.folder}.${key}`);\n\t\t}\n\t}\n\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const fullId in objects) {\n\t\t\tconst obj = objects[fullId];\n\t\t\tif (obj && obj.type === 'state') {\n\t\t\t\tconst localId = fullId.replace(`${adapter.namespace}.`, '');\n\t\t\t\tif (localId.startsWith('Custom.')) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!activeStateIds.has(localId)) {\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delStateAsync(localId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delObjectAsync(localId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tadapter.createdStates.delete(localId);\n\t\t\t\t\twriteLog(`Datapoint '${localId}' rigorously removed.`, 'debug');\n\t\t\t\t\tdeletedCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} old datapoints cleaned up.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up old datapoints: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Sucht und l\u00F6scht leere Ordner und Kan\u00E4le aus dem ioBroker-Baum, die keine Datenpunkte mehr enthalten.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupEmptyFolders(adapter: ExtendedAdapter): Promise<void> {\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tconst allIds = Object.keys(objects);\n\n\t\tconst folderIds = allIds.filter(id => {\n\t\t\tconst type = objects[id]?.type;\n\t\t\treturn type === 'channel' || type === 'folder' || type === 'device';\n\t\t});\n\n\t\tfolderIds.sort((a, b) => b.length - a.length);\n\n\t\tconst existingParents = new Set<string>();\n\t\tfor (const id of allIds) {\n\t\t\tlet parent = id;\n\t\t\twhile (parent.includes('.')) {\n\t\t\t\tparent = parent.substring(0, parent.lastIndexOf('.'));\n\t\t\t\texistingParents.add(parent);\n\t\t\t}\n\t\t}\n\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const fullId of folderIds) {\n\t\t\tif (fullId === adapter.namespace) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!existingParents.has(fullId)) {\n\t\t\t\tconst localId = fullId.replace(`${adapter.namespace}.`, '');\n\t\t\t\tdeletions.push(\n\t\t\t\t\tadapter.delObjectAsync(localId).catch(() => {\n\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\twriteLog(`Empty folder '${localId}' cleaned up.`, 'debug');\n\t\t\t\tdeletedCount++;\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} empty folders removed from object tree.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up empty folders: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Bereinigt benutzerdefinierte Datenpunkte aus dem Custom-Ordner, die in den Einstellungen entfernt wurden.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupCustomStates(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst customStates = (config.custom_states as CustomStateConfig[]) || [];\n\n\tconst activeIds = new Set(\n\t\tcustomStates\n\t\t\t.filter(c => c.active && c.luxId !== undefined && c.name)\n\t\t\t.map(c => `Custom.${sanitizeName(c.name)}`),\n\t);\n\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const id in objects) {\n\t\t\tif (id.startsWith(`${adapter.namespace}.Custom.`)) {\n\t\t\t\tconst shortId = id.replace(`${adapter.namespace}.`, '');\n\t\t\t\tif (shortId === 'Custom') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!activeIds.has(shortId)) {\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delStateAsync(shortId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delObjectAsync(shortId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tadapter.createdStates.delete(shortId);\n\t\t\t\t\twriteLog(`Custom datapoint '${shortId}' removed.`, 'debug');\n\t\t\t\t\tdeletedCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} custom values cleaned up.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up custom values: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Pr\u00FCft und erzeugt alle im Mapping konfigurierten Standard-Datenpunkte im ioBroker-Baum.\n * Aktualisiert zudem fehlerhafte oder ge\u00E4nderte Eigenschaften existierender Objekte.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Erstellung aufgel\u00F6st wird.\n */\nexport async function ensureAllObjectsExist(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\n\t// Sprachauswahl aus den Settings (Fallback auf 'en')\n\tconst lang = config.language === 'de' ? 'de' : 'en';\n\n\ttry {\n\t\tconst existingObjects = await adapter.getAdapterObjectsAsync();\n\n\t\tfor (const [key, def] of Object.entries(STATE_MAPPING)) {\n\t\t\tconst definition = def as StateDefinition;\n\t\t\tif (!isStateEnabled(key, definition, config)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\tconst fullId = `${adapter.namespace}.${stateId}`;\n\n\t\t\tlet targetType: ioBroker.CommonType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\ttargetType = 'string';\n\t\t\t}\n\n\t\t\t// SPRACHWEICHE F\u00DCR DIE VALUES / DROPDOWNS\n\t\t\tlet resolvedStates: Record<string, string> | undefined = undefined;\n\t\t\tif (definition.states) {\n\t\t\t\tif ('en' in definition.states || 'de' in definition.states) {\n\t\t\t\t\tresolvedStates = (definition.states as any)[lang] || (definition.states as any).en;\n\t\t\t\t} else {\n\t\t\t\t\tresolvedStates = definition.states as Record<string, string>;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst commonDef: ioBroker.StateCommon = {\n\t\t\t\tname: definition.name,\n\t\t\t\ttype: targetType,\n\t\t\t\trole: definition.role,\n\t\t\t\tunit: definition.unit || '',\n\t\t\t\tread: definition.role === 'button' ? false : true,\n\t\t\t\twrite: definition.write || false,\n\t\t\t\tmin: definition.min,\n\t\t\t\tmax: definition.max,\n\t\t\t\tstates: resolvedStates,\n\t\t\t};\n\n\t\t\tconst existingObj = existingObjects[fullId];\n\n\t\t\tif (!existingObj) {\n\t\t\t\tconst folderParts = definition.folder.split('.');\n\t\t\t\tlet currentFolder = '';\n\t\t\t\tfor (const part of folderParts) {\n\t\t\t\t\tcurrentFolder = currentFolder === '' ? part : `${currentFolder}.${part}`;\n\t\t\t\t\tawait adapter.setObjectNotExistsAsync(currentFolder, {\n\t\t\t\t\t\ttype: currentFolder.includes('.') ? 'channel' : 'folder',\n\t\t\t\t\t\tcommon: { name: part },\n\t\t\t\t\t\tnative: {},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tawait adapter.setObjectNotExistsAsync(stateId, { type: 'state', common: commonDef, native: {} });\n\t\t\t} else {\n\t\t\t\tlet needsUpdate = false;\n\t\t\t\tconst existingCommon = existingObj.common as Record<string, any>;\n\n\t\t\t\tif (\n\t\t\t\t\texistingCommon.type !== targetType ||\n\t\t\t\t\texistingCommon.role !== definition.role ||\n\t\t\t\t\t(existingCommon.unit || '') !== (definition.unit || '') ||\n\t\t\t\t\texistingCommon.name !== definition.name ||\n\t\t\t\t\texistingCommon.read !== commonDef.read ||\n\t\t\t\t\texistingCommon.write !== (definition.write || false) ||\n\t\t\t\t\texistingCommon.min !== definition.min ||\n\t\t\t\t\texistingCommon.max !== definition.max ||\n\t\t\t\t\tJSON.stringify(existingCommon.states) !== JSON.stringify(resolvedStates)\n\t\t\t\t) {\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tif (needsUpdate) {\n\t\t\t\t\tawait adapter.extendObjectAsync(stateId, { type: 'state', common: commonDef });\n\t\t\t\t\twriteLog(`Properties of '${stateId}' synchronized (Repair).`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (definition.write) {\n\t\t\t\tadapter.subscribeStates(stateId);\n\t\t\t}\n\n\t\t\tadapter.createdStates.add(stateId);\n\n\t\t\tif (definition.folder === 'Actions') {\n\t\t\t\tconst currentState = await adapter.getStateAsync(stateId);\n\t\t\t\tif (!currentState) {\n\t\t\t\t\tawait adapter.setStateAsync(stateId, {\n\t\t\t\t\t\tval: definition.def !== undefined ? definition.def : false,\n\t\t\t\t\t\tack: true,\n\t\t\t\t\t});\n\t\t\t\t} else if (currentState.ack === false) {\n\t\t\t\t\tconst valToSet = definition.role === 'button' ? false : currentState.val;\n\t\t\t\t\tawait adapter.setStateAsync(stateId, { val: valToSet, ack: true });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error during object validation: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Erzeugt die vom Benutzer in der Konfiguration definierten Custom-Datenpunkte.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Erstellung aufgel\u00F6st wird.\n */\nexport async function ensureCustomObjectsExist(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst customStates = (config.custom_states as CustomStateConfig[]) || [];\n\n\tif (customStates.some(c => c.active)) {\n\t\tawait adapter.setObjectNotExistsAsync('Custom', {\n\t\t\ttype: 'channel',\n\t\t\tcommon: { name: 'Custom values' },\n\t\t\tnative: {},\n\t\t});\n\t}\n\n\tfor (const custom of customStates) {\n\t\tif (!custom.active || custom.luxId === undefined || !custom.name) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst stateId = `Custom.${sanitizeName(custom.name)}`;\n\t\tlet role = 'state';\n\t\tconst targetType: ioBroker.CommonType = custom.type === 'datetime' ? 'string' : custom.type;\n\t\tconst isWritable = custom.source === 'parameter';\n\n\t\tif (custom.type === 'number') {\n\t\t\trole = 'value';\n\t\t} else if (custom.type === 'string') {\n\t\t\trole = 'text';\n\t\t} else if (custom.type === 'boolean') {\n\t\t\trole = isWritable ? 'switch' : 'sensor.switch';\n\t\t} else if (custom.type === 'datetime') {\n\t\t\trole = 'value.time';\n\t\t}\n\n\t\tconst objDef = {\n\t\t\ttype: 'state' as const,\n\t\t\tcommon: {\n\t\t\t\tname: custom.name,\n\t\t\t\ttype: targetType,\n\t\t\t\trole: role,\n\t\t\t\tunit: custom.unit || '',\n\t\t\t\tread: true,\n\t\t\t\twrite: isWritable,\n\t\t\t},\n\t\t\tnative: {\n\t\t\t\tluxId: custom.luxId,\n\t\t\t\tsource: custom.source,\n\t\t\t\tfactor: custom.factor || null,\n\t\t\t\tcustomType: custom.type,\n\t\t\t},\n\t\t};\n\n\t\tif (!adapter.createdStates.has(stateId)) {\n\t\t\tawait adapter.setObjectNotExistsAsync(stateId, objDef);\n\t\t\tadapter.createdStates.add(stateId);\n\t\t}\n\t\tawait adapter.extendObjectAsync(stateId, { common: objDef.common, native: objDef.native });\n\n\t\tif (isWritable) {\n\t\t\tadapter.subscribeStates(stateId);\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAyB;AACzB,0BAA8B;AAsE9B,MAAM,iBAAqC;AAAA,EAC1C,CAAC,YAAY,qCAAqC;AAAA,EAClD,CAAC,YAAY,yCAAyC;AAAA,EACtD,CAAC,YAAY,yCAAyC;AAAA,EACtD,CAAC,cAAc,0CAA0C;AAAA,EACzD,CAAC,gBAAgB,2CAA2C;AAAA,EAC5D,CAAC,gBAAgB,6CAA6C;AAAA,EAC9D,CAAC,kBAAkB,4CAA4C;AAAA,EAC/D,CAAC,eAAe,0CAA0C;AAAA,EAC1D,CAAC,eAAe,4CAA4C;AAAA,EAC5D,CAAC,eAAe,0CAA0C;AAAA,EAC1D,CAAC,YAAY,wBAAwB;AAAA,EACrC,CAAC,YAAY,4BAA4B;AAAA,EACzC,CAAC,YAAY,4BAA4B;AAAA,EACzC,CAAC,cAAc,6BAA6B;AAAA,EAC5C,CAAC,gBAAgB,8BAA8B;AAAA,EAC/C,CAAC,gBAAgB,gCAAgC;AAAA,EACjD,CAAC,kBAAkB,+BAA+B;AAAA,EAClD,CAAC,eAAe,6BAA6B;AAAA,EAC7C,CAAC,eAAe,+BAA+B;AAAA,EAC/C,CAAC,eAAe,6BAA6B;AAAA,EAC7C,CAAC,qBAAqB,qCAAqC;AAAA,EAC3D,CAAC,qBAAqB,yCAAyC;AAAA,EAC/D,CAAC,qBAAqB,yCAAyC;AAAA,EAC/D,CAAC,uBAAuB,0CAA0C;AAAA,EAClE,CAAC,yBAAyB,2CAA2C;AAAA,EACrE,CAAC,yBAAyB,6CAA6C;AAAA,EACvE,C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APPING } from './stateMapping';\n\n/**\n * Definition eines Datenpunktes f\u00FCr das dynamische Mapping.\n * Steuert, wie Objekte im ioBroker-Baum angelegt werden.\n */\nexport interface StateDefinition {\n\t/** Der Klartext-Name des Datenpunkts */\n\tname: string | { en: string; de?: string };\n\t/** Der ioBroker-Datentyp (z. B. 'number', 'string', 'boolean' oder 'json') */\n\ttype: ioBroker.CommonType | 'json';\n\t/** Die ioBroker-Rolle (z. B. 'value.temperature', 'button', 'text') */\n\trole: string;\n\t/** Optionale physikalische Einheit (z. B. '\u00B0C', 'kWh', 's') */\n\tunit?: string;\n\t/** Gibt an, ob der Datenpunkt vom ioBroker gelesen werden kann */\n\tread?: boolean;\n\t/** Gibt an, ob der Datenpunkt vom ioBroker beschreibbar ist */\n\twrite?: boolean;\n\t/** Optionaler minimal zul\u00E4ssiger Wert */\n\tmin?: number;\n\t/** Optionaler maximal zul\u00E4ssiger Wert */\n\tmax?: number;\n\t/** Optionaler Standardwert bei Neuerstellung des Datenpunkts */\n\tdef?: any;\n\t/** Optionales Werte-Mapping f\u00FCr Status-Texte (unterst\u00FCtzt nun i18n) */\n\tstates?: Record<string, Record<number, string>> | Record<number, string>;\n\t/** Das Verzeichnis/Ordnerstruktur im ioBroker-Objektbaum */\n\tfolder: string;\n\t/** Die ID oder der Index, die zum Schreiben/Lesen an die Luxtronik gesendet wird */\n\tluxWriteId?: string | number;\n\t/** Gibt an, ob dieser Datenpunkt systemrelevant und zwingend erforderlich ist */\n\trequired?: boolean;\n\t/** Steuert die interne Formatierung von rohen Sekunden zu HH:MM:SS */\n\tisDurationFormat?: boolean;\n}\n\n/**\n * Konfiguration eines benutzerdefinierten Datenpunktes aus den Adapter-Einstellungen.\n */\nexport interface CustomStateConfig {\n\t/** Gibt an, ob der benutzerdefinierte Datenpunkt aktiv ist */\n\tactive: boolean;\n\t/** Die Luxtronik-ID des abzufragenden Parameters oder Wertes */\n\tluxId?: number;\n\t/** Der vom Benutzer vergebene Klartext-Name */\n\tname: string;\n\t/** Die Quelle der Daten ('parameter' oder 'value') */\n\tsource: 'parameter' | 'value';\n\t/** Der gew\u00FCnschte Zieldatentyp im ioBroker */\n\ttype: 'number' | 'boolean' | 'datetime' | 'string';\n\t/** Optionaler Multiplikator zur Umrechnung (z. B. 0.1 f\u00FCr Temperaturen) */\n\tfactor?: number | null;\n\t/** Optionale physikalische Einheit */\n\tunit?: string;\n}\n\n/**\n * Erweiterte Adapter-Instanz f\u00FCr Typsicherheit beim Zugriff auf interne Eigenschaften.\n */\nexport interface ExtendedAdapter extends AdapterInstance {\n\t/** Adapter-Konfiguration aus der Benutzeroberfl\u00E4che kombiniert mit dynamischen Werten */\n\tconfig: ioBroker.AdapterConfig & Record<string, any>;\n\t/** Set aller w\u00E4hrend der Laufzeit erstellten oder verifizierten Datenpunkt-IDs */\n\tcreatedStates: Set<string>;\n}\n\n/**\n * Zuweisung von Datenpunkt-Pr\u00E4fixen zu den jeweiligen Konfigurations-Checkboxen.\n */\nconst PREFIX_MAPPING: [string, string][] = [\n\t['HZ_MoSo_', 'sync_heatingOperationTimerTableWeek'],\n\t['HZ_MoFr_', 'sync_heatingOperationTimerTable52MonFri'],\n\t['HZ_SaSo_', 'sync_heatingOperationTimerTable52MonFri'],\n\t['HZ_Montag_', 'sync_heatingOperationTimerTableDayMonday'],\n\t['HZ_Dienstag_', 'sync_heatingOperationTimerTableDayTuesday'],\n\t['HZ_Mittwoch_', 'sync_heatingOperationTimerTableDayWednesday'],\n\t['HZ_Donnerstag_', 'sync_heatingOperationTimerTableDayThursday'],\n\t['HZ_Freitag_', 'sync_heatingOperationTimerTableDayFriday'],\n\t['HZ_Samstag_', 'sync_heatingOperationTimerTableDaySaturday'],\n\t['HZ_Sonntag_', 'sync_heatingOperationTimerTableDaySunday'],\n\t['WW_MoSo_', 'sync_hotWaterTableWeek'],\n\t['WW_MoFr_', 'sync_hotWaterTable52MonFri'],\n\t['WW_SaSo_', 'sync_hotWaterTable52MonFri'],\n\t['WW_Montag_', 'sync_hotWaterTableDayMonday'],\n\t['WW_Dienstag_', 'sync_hotWaterTableDayTuesday'],\n\t['WW_Mittwoch_', 'sync_hotWaterTableDayWednesday'],\n\t['WW_Donnerstag_', 'sync_hotWaterTableDayThursday'],\n\t['WW_Freitag_', 'sync_hotWaterTableDayFriday'],\n\t['WW_Samstag_', 'sync_hotWaterTableDaySaturday'],\n\t['WW_Sonntag_', 'sync_hotWaterTableDaySunday'],\n\t['Zirkulation_MoSo_', 'sync_hotWaterCircPumpTimerTableWeek'],\n\t['Zirkulation_MoFr_', 'sync_hotWaterCircPumpTimerTable52MonFri'],\n\t['Zirkulation_SaSo_', 'sync_hotWaterCircPumpTimerTable52MonFri'],\n\t['Zirkulation_Montag_', 'sync_hotWaterCircPumpTimerTableDayMonday'],\n\t['Zirkulation_Dienstag_', 'sync_hotWaterCircPumpTimerTableDayTuesday'],\n\t['Zirkulation_Mittwoch_', 'sync_hotWaterCircPumpTimerTableDayWednesday'],\n\t['Zirkulation_Donnerstag_', 'sync_hotWaterCircPumpTimerTableDayThursday'],\n\t['Zirkulation_Freitag_', 'sync_hotWaterCircPumpTimerTableDayFriday'],\n\t['Zirkulation_Samstag_', 'sync_hotWaterCircPumpTimerTableDaySaturday'],\n\t['Zirkulation_Sonntag_', 'sync_hotWaterCircPumpTimerTableDaySunday'],\n];\n\n/**\n * Pr\u00FCft anhand der Adapter-Konfiguration, ob ein bestimmter Datenpunkt angelegt werden soll.\n *\n * @param key Der Schl\u00FCssel des Datenpunkts aus dem Mapping.\n * @param definition Die Struktur-Definition des Datenpunkts.\n * @param config Die aktuelle Adapter-Konfiguration.\n * @returns True, wenn der Datenpunkt aktiviert ist und angelegt werden soll.\n */\nexport function isStateEnabled(key: string, definition: StateDefinition, config: Record<string, any>): boolean {\n\tif (definition.required) {\n\t\treturn true;\n\t}\n\n\tconst configKey = `sync_${key}`;\n\tif (config[configKey] === false || String(config[configKey]) === 'false') {\n\t\treturn false;\n\t}\n\n\tfor (const [prefix, mapKey] of PREFIX_MAPPING) {\n\t\tif (key.startsWith(prefix)) {\n\t\t\treturn config[mapKey] !== false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Zeichen-Mapping zum Ersetzen von Umlauten und Sonderzeichen in IDs.\n */\nconst CHAR_MAP: Record<string, string> = {\n\t\u00E4: 'ae',\n\t\u00F6: 'oe',\n\t\u00FC: 'ue',\n\t\u00C4: 'Ae',\n\t\u00D6: 'Oe',\n\t\u00DC: 'Ue',\n\t\u00DF: 'ss',\n};\n\n/**\n * Bereinigt Klartext-Namen so, dass sie als g\u00FCltige ioBroker-IDs verwendet werden k\u00F6nnen.\n *\n * @param name Der zu bereinigende Ursprungsname.\n * @returns Der bereinigte, ID-sichere Name.\n */\nexport function sanitizeName(name: string): string {\n\treturn name\n\t\t.replace(/[\u00E4\u00F6\u00FC\u00C4\u00D6\u00DC\u00DF]/g, match => CHAR_MAP[match])\n\t\t.replace(/[^a-zA-Z0-9_]/g, '_')\n\t\t.replace(/_+/g, '_')\n\t\t.replace(/^_|_$/g, '');\n}\n\n/**\n * Sucht und l\u00F6scht Datenpunkte aus dem ioBroker-Baum, die in den Adapter-Einstellungen deaktiviert wurden.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupStates(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst activeStateIds = new Set<string>();\n\n\tfor (const [key, def] of Object.entries(STATE_MAPPING)) {\n\t\tconst definition = def as StateDefinition;\n\t\tif (isStateEnabled(key, definition, config)) {\n\t\t\tactiveStateIds.add(`${definition.folder}.${key}`);\n\t\t}\n\t}\n\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const fullId in objects) {\n\t\t\tconst obj = objects[fullId];\n\t\t\tif (obj && obj.type === 'state') {\n\t\t\t\tconst localId = fullId.replace(`${adapter.namespace}.`, '');\n\t\t\t\tif (localId.startsWith('Custom.')) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!activeStateIds.has(localId)) {\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delStateAsync(localId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delObjectAsync(localId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tadapter.createdStates.delete(localId);\n\t\t\t\t\twriteLog(`Datapoint '${localId}' rigorously removed.`, 'debug');\n\t\t\t\t\tdeletedCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} old datapoints cleaned up.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up old datapoints: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Sucht und l\u00F6scht leere Ordner und Kan\u00E4le aus dem ioBroker-Baum, die keine Datenpunkte mehr enthalten.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupEmptyFolders(adapter: ExtendedAdapter): Promise<void> {\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tconst allIds = Object.keys(objects);\n\n\t\tconst folderIds = allIds.filter(id => {\n\t\t\tconst type = objects[id]?.type;\n\t\t\treturn type === 'channel' || type === 'folder' || type === 'device';\n\t\t});\n\n\t\tfolderIds.sort((a, b) => b.length - a.length);\n\n\t\tconst existingParents = new Set<string>();\n\t\tfor (const id of allIds) {\n\t\t\tlet parent = id;\n\t\t\twhile (parent.includes('.')) {\n\t\t\t\tparent = parent.substring(0, parent.lastIndexOf('.'));\n\t\t\t\texistingParents.add(parent);\n\t\t\t}\n\t\t}\n\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const fullId of folderIds) {\n\t\t\tif (fullId === adapter.namespace) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!existingParents.has(fullId)) {\n\t\t\t\tconst localId = fullId.replace(`${adapter.namespace}.`, '');\n\t\t\t\tdeletions.push(\n\t\t\t\t\tadapter.delObjectAsync(localId).catch(() => {\n\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\twriteLog(`Empty folder '${localId}' cleaned up.`, 'debug');\n\t\t\t\tdeletedCount++;\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} empty folders removed from object tree.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up empty folders: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Bereinigt benutzerdefinierte Datenpunkte aus dem Custom-Ordner, die in den Einstellungen entfernt wurden.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Bereinigung aufgel\u00F6st wird.\n */\nexport async function cleanupCustomStates(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst customStates = (config.custom_states as CustomStateConfig[]) || [];\n\n\tconst activeIds = new Set(\n\t\tcustomStates\n\t\t\t.filter(c => c.active && c.luxId !== undefined && c.name)\n\t\t\t.map(c => `Custom.${sanitizeName(c.name)}`),\n\t);\n\n\ttry {\n\t\tconst objects = await adapter.getAdapterObjectsAsync();\n\t\tlet deletedCount = 0;\n\t\tconst deletions: Promise<void>[] = [];\n\n\t\tfor (const id in objects) {\n\t\t\tif (id.startsWith(`${adapter.namespace}.Custom.`)) {\n\t\t\t\tconst shortId = id.replace(`${adapter.namespace}.`, '');\n\t\t\t\tif (shortId === 'Custom') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (!activeIds.has(shortId)) {\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delStateAsync(shortId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tdeletions.push(\n\t\t\t\t\t\tadapter.delObjectAsync(shortId).catch(() => {\n\t\t\t\t\t\t\tvoid 0;\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\tadapter.createdStates.delete(shortId);\n\t\t\t\t\twriteLog(`Custom datapoint '${shortId}' removed.`, 'debug');\n\t\t\t\t\tdeletedCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (deletions.length > 0) {\n\t\t\tawait Promise.all(deletions);\n\t\t}\n\t\tif (deletedCount > 0) {\n\t\t\twriteLog(`${deletedCount} custom values cleaned up.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error cleaning up custom values: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Pr\u00FCft und erzeugt alle im Mapping konfigurierten Standard-Datenpunkte im ioBroker-Baum.\n * Aktualisiert zudem fehlerhafte oder ge\u00E4nderte Eigenschaften existierender Objekte.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Erstellung aufgel\u00F6st wird.\n */\nexport async function ensureAllObjectsExist(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\n\t// Sprachauswahl aus den Settings (Fallback auf 'en')\n\tconst lang = config.language === 'de' ? 'de' : 'en';\n\n\ttry {\n\t\tconst existingObjects = await adapter.getAdapterObjectsAsync();\n\n\t\tfor (const [key, def] of Object.entries(STATE_MAPPING)) {\n\t\t\tconst definition = def as StateDefinition;\n\t\t\tif (!isStateEnabled(key, definition, config)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst stateId = `${definition.folder}.${key}`;\n\t\t\tconst fullId = `${adapter.namespace}.${stateId}`;\n\n\t\t\tlet targetType: ioBroker.CommonType = definition.type === 'json' ? 'string' : definition.type;\n\n\t\t\tif (definition.role && ['value.datetime', 'value.time', 'date'].includes(definition.role)) {\n\t\t\t\ttargetType = 'string';\n\t\t\t}\n\n\t\t\t// SPRACHWEICHE F\u00DCR DIE VALUES / DROPDOWNS\n\t\t\tlet resolvedStates: Record<string, string> | undefined = undefined;\n\t\t\tif (definition.states) {\n\t\t\t\tif ('en' in definition.states || 'de' in definition.states) {\n\t\t\t\t\tresolvedStates = (definition.states as any)[lang] || (definition.states as any).en;\n\t\t\t\t} else {\n\t\t\t\t\tresolvedStates = definition.states as Record<string, string>;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst commonDef: ioBroker.StateCommon = {\n\t\t\t\tname: definition.name,\n\t\t\t\ttype: targetType,\n\t\t\t\trole: definition.role,\n\t\t\t\tunit: definition.unit || '',\n\t\t\t\tread: definition.role === 'button' ? false : true,\n\t\t\t\twrite: definition.write || false,\n\t\t\t\tmin: definition.min,\n\t\t\t\tmax: definition.max,\n\t\t\t\tstates: resolvedStates,\n\t\t\t};\n\n\t\t\tconst existingObj = existingObjects[fullId];\n\n\t\t\tif (!existingObj) {\n\t\t\t\tconst folderParts = definition.folder.split('.');\n\t\t\t\tlet currentFolder = '';\n\t\t\t\tfor (const part of folderParts) {\n\t\t\t\t\tcurrentFolder = currentFolder === '' ? part : `${currentFolder}.${part}`;\n\t\t\t\t\tawait adapter.setObjectNotExistsAsync(currentFolder, {\n\t\t\t\t\t\ttype: currentFolder.includes('.') ? 'channel' : 'folder',\n\t\t\t\t\t\tcommon: { name: part },\n\t\t\t\t\t\tnative: {},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tawait adapter.setObjectNotExistsAsync(stateId, { type: 'state', common: commonDef, native: {} });\n\t\t\t} else {\n\t\t\t\tlet needsUpdate = false;\n\t\t\t\tconst existingCommon = existingObj.common as Record<string, any>;\n\n\t\t\t\tif (\n\t\t\t\t\texistingCommon.type !== targetType ||\n\t\t\t\t\texistingCommon.role !== definition.role ||\n\t\t\t\t\t(existingCommon.unit || '') !== (definition.unit || '') ||\n\t\t\t\t\tJSON.stringify(existingCommon.name) !== JSON.stringify(definition.name) ||\n\t\t\t\t\texistingCommon.read !== commonDef.read ||\n\t\t\t\t\texistingCommon.write !== (definition.write || false) ||\n\t\t\t\t\texistingCommon.min !== definition.min ||\n\t\t\t\t\texistingCommon.max !== definition.max ||\n\t\t\t\t\tJSON.stringify(existingCommon.states) !== JSON.stringify(resolvedStates)\n\t\t\t\t) {\n\t\t\t\t\tneedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tif (needsUpdate) {\n\t\t\t\t\tawait adapter.extendObject(stateId, { type: 'state', common: commonDef });\n\t\t\t\t\twriteLog(`Properties of '${stateId}' synchronized (Repair).`, 'debug');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (definition.write) {\n\t\t\t\tadapter.subscribeStates(stateId);\n\t\t\t}\n\n\t\t\tadapter.createdStates.add(stateId);\n\n\t\t\tif (definition.folder === 'Actions') {\n\t\t\t\tconst currentState = await adapter.getStateAsync(stateId);\n\t\t\t\tif (!currentState) {\n\t\t\t\t\tawait adapter.setStateAsync(stateId, {\n\t\t\t\t\t\tval: definition.def !== undefined ? definition.def : false,\n\t\t\t\t\t\tack: true,\n\t\t\t\t\t});\n\t\t\t\t} else if (currentState.ack === false) {\n\t\t\t\t\tconst valToSet = definition.role === 'button' ? false : currentState.val;\n\t\t\t\t\tawait adapter.setStateAsync(stateId, { val: valToSet, ack: true });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Error during object validation: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Erzeugt die vom Benutzer in der Konfiguration definierten Custom-Datenpunkte.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @returns Ein Promise, das nach Abschluss der Erstellung aufgel\u00F6st wird.\n */\nexport async function ensureCustomObjectsExist(adapter: ExtendedAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst customStates = (config.custom_states as CustomStateConfig[]) || [];\n\n\tif (customStates.some(c => c.active)) {\n\t\tawait adapter.setObjectNotExistsAsync('Custom', {\n\t\t\ttype: 'channel',\n\t\t\tcommon: { name: 'Custom values' },\n\t\t\tnative: {},\n\t\t});\n\t}\n\n\tfor (const custom of customStates) {\n\t\tif (!custom.active || custom.luxId === undefined || !custom.name) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst stateId = `Custom.${sanitizeName(custom.name)}`;\n\t\tlet role = 'state';\n\t\tconst targetType: ioBroker.CommonType = custom.type === 'datetime' ? 'string' : custom.type;\n\t\tconst isWritable = custom.source === 'parameter';\n\n\t\tif (custom.type === 'number') {\n\t\t\trole = 'value';\n\t\t} else if (custom.type === 'string') {\n\t\t\trole = 'text';\n\t\t} else if (custom.type === 'boolean') {\n\t\t\trole = isWritable ? 'switch' : 'sensor.switch';\n\t\t} else if (custom.type === 'datetime') {\n\t\t\trole = 'value.time';\n\t\t}\n\n\t\tconst objDef = {\n\t\t\ttype: 'state' as const,\n\t\t\tcommon: {\n\t\t\t\tname: custom.name,\n\t\t\t\ttype: targetType,\n\t\t\t\trole: role,\n\t\t\t\tunit: custom.unit || '',\n\t\t\t\tread: true,\n\t\t\t\twrite: isWritable,\n\t\t\t},\n\t\t\tnative: {\n\t\t\t\tluxId: custom.luxId,\n\t\t\t\tsource: custom.source,\n\t\t\t\tfactor: custom.factor || null,\n\t\t\t\tcustomType: custom.type,\n\t\t\t},\n\t\t};\n\n\t\tif (!adapter.createdStates.has(stateId)) {\n\t\t\tawait adapter.setObjectNotExistsAsync(stateId, objDef);\n\t\t\tadapter.createdStates.add(stateId);\n\t\t}\n\t\tawait adapter.extendObject(stateId, { common: objDef.common, native: objDef.native });\n\n\t\tif (isWritable) {\n\t\t\tadapter.subscribeStates(stateId);\n\t\t}\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAyB;AACzB,0BAA8B;AAsE9B,MAAM,iBAAqC;AAAA,EAC1C,CAAC,YAAY,qCAAqC;AAAA,EAClD,CAAC,YAAY,yCAAyC;AAAA,EACtD,CAAC,YAAY,yCAAyC;AAAA,EACtD,CAAC,cAAc,0CAA0C;AAAA,EACzD,CAAC,gBAAgB,2CAA2C;AAAA,EAC5D,CAAC,gBAAgB,6CAA6C;AAAA,EAC9D,CAAC,kBAAkB,4CAA4C;AAAA,EAC/D,CAAC,eAAe,0CAA0C;AAAA,EAC1D,CAAC,eAAe,4CAA4C;AAAA,EAC5D,CAAC,eAAe,0CAA0C;AAAA,EAC1D,CAAC,YAAY,wBAAwB;AAAA,EACrC,CAAC,YAAY,4BAA4B;AAAA,EACzC,CAAC,YAAY,4BAA4B;AAAA,EACzC,CAAC,cAAc,6BAA6B;AAAA,EAC5C,CAAC,gBAAgB,8BAA8B;AAAA,EAC/C,CAAC,gBAAgB,gCAAgC;AAAA,EACjD,CAAC,kBAAkB,+BAA+B;AAAA,EAClD,CAAC,eAAe,6BAA6B;AAAA,EAC7C,CAAC,eAAe,+BAA+B;AAAA,EAC/C,CAAC,eAAe,6BAA6B;AAAA,EAC7C,CAAC,qBAAqB,qCAAqC;AAAA,EAC3D,CAAC,qBAAqB,yCAAyC;AAAA,EAC/D,CAAC,qBAAqB,yCAAyC;AAAA,EAC/D,CAAC,uBAAuB,0CAA0C;AAAA,EAClE,CAAC,yBAAyB,2CAA2C;AAAA,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
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var rawFunctions_exports = {};
|
|
30
30
|
__export(rawFunctions_exports, {
|
|
31
|
-
delay: () => delay,
|
|
32
31
|
dumpAllRawToLog: () => dumpAllRawToLog,
|
|
32
|
+
queueWrite: () => queueWrite,
|
|
33
33
|
readAllRaw: () => readAllRaw,
|
|
34
|
+
writePumpSafe: () => writePumpSafe,
|
|
34
35
|
writeRawParameter: () => writeRawParameter
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(rawFunctions_exports);
|
|
37
38
|
var net = __toESM(require("node:net"));
|
|
38
39
|
var import_ws = require("ws");
|
|
39
40
|
var import_logger = require("./logger");
|
|
41
|
+
var import_stateMapping = require("./stateMapping");
|
|
42
|
+
var import_utils = require("./utils");
|
|
40
43
|
const CONSTANTS = {
|
|
41
44
|
/** Schreib-Befehl für einen Parameter */
|
|
42
45
|
CMD_WRITE: 3002,
|
|
@@ -56,8 +59,40 @@ const CONSTANTS = {
|
|
|
56
59
|
DELAY_RECONNECT: 1e3
|
|
57
60
|
};
|
|
58
61
|
const TCP_PORTS = /* @__PURE__ */ new Set([8888, 8889]);
|
|
59
|
-
function
|
|
60
|
-
|
|
62
|
+
async function writePumpSafe(adapter, cmd, val) {
|
|
63
|
+
const paramId = typeof cmd === "string" ? parseInt(cmd, 10) : cmd;
|
|
64
|
+
let value = typeof val === "string" ? parseInt(val, 10) : val;
|
|
65
|
+
if (typeof value === "boolean") {
|
|
66
|
+
value = value ? 1 : 0;
|
|
67
|
+
}
|
|
68
|
+
if (adapter.currentRawParams && adapter.currentRawParams[paramId] === value) {
|
|
69
|
+
if (adapter.isDebugLogActive) {
|
|
70
|
+
(0, import_logger.writeLog)(
|
|
71
|
+
`[Global SafeWrite] Register ${paramId} steht bereits auf ${value}. Netzwerk-Schreibbefehl blockiert!`,
|
|
72
|
+
"debug"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (adapter.isDebugLogActive) {
|
|
78
|
+
(0, import_logger.writeLog)(`writePumpSafe: Sende an Luxtronik -> Register ${paramId}, Wert: ${value}`, "debug");
|
|
79
|
+
}
|
|
80
|
+
await writeRawParameter(adapter, paramId, value);
|
|
81
|
+
if (adapter.currentRawParams) {
|
|
82
|
+
adapter.currentRawParams[paramId] = value;
|
|
83
|
+
}
|
|
84
|
+
if (typeof adapter.writeCyclesToday === "number") {
|
|
85
|
+
adapter.writeCyclesToday++;
|
|
86
|
+
adapter.writeCyclesTotal++;
|
|
87
|
+
const dpToday = (0, import_stateMapping.getDpPath)("write_cycles_today");
|
|
88
|
+
const dpTotal = (0, import_stateMapping.getDpPath)("write_cycles_total");
|
|
89
|
+
if (dpToday) {
|
|
90
|
+
void adapter.setState(dpToday, { val: adapter.writeCyclesToday, ack: true });
|
|
91
|
+
}
|
|
92
|
+
if (dpTotal) {
|
|
93
|
+
void adapter.setState(dpTotal, { val: adapter.writeCyclesTotal, ack: true });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
61
96
|
}
|
|
62
97
|
function shouldUseWs(adapter) {
|
|
63
98
|
const port = adapter.config.port ? Number(adapter.config.port) : CONSTANTS.PORT_TCP;
|
|
@@ -259,7 +294,7 @@ async function dumpAllRawToLog(adapter) {
|
|
|
259
294
|
const useWs = shouldUseWs(adapter);
|
|
260
295
|
try {
|
|
261
296
|
const dumpList = async (command, title) => {
|
|
262
|
-
await delay(adapter, CONSTANTS.DELAY_RECONNECT);
|
|
297
|
+
await (0, import_utils.delay)(adapter, CONSTANTS.DELAY_RECONNECT);
|
|
263
298
|
(0, import_logger.writeLog)("=======================================================", "info");
|
|
264
299
|
(0, import_logger.writeLog)(`START COMPACT RAW DUMP: LIST ${command} (${title}) via ${useWs ? "WebSocket" : "TCP"}`, "info");
|
|
265
300
|
(0, import_logger.writeLog)("=======================================================", "info");
|
|
@@ -270,7 +305,7 @@ async function dumpAllRawToLog(adapter) {
|
|
|
270
305
|
(0, import_logger.writeLog)(`--- END OF LIST ${command} (Total ${data.length} indices logged) ---`, "info");
|
|
271
306
|
(0, import_logger.writeLog)("=======================================================", "info");
|
|
272
307
|
};
|
|
273
|
-
await delay(adapter, CONSTANTS.DELAY_RECONNECT);
|
|
308
|
+
await (0, import_utils.delay)(adapter, CONSTANTS.DELAY_RECONNECT);
|
|
274
309
|
await dumpList(CONSTANTS.CMD_READ_PARAM, "PARAMETERS");
|
|
275
310
|
await dumpList(CONSTANTS.CMD_READ_VALUE, "VALUES");
|
|
276
311
|
} catch (err) {
|
|
@@ -278,11 +313,49 @@ async function dumpAllRawToLog(adapter) {
|
|
|
278
313
|
(0, import_logger.writeLog)(`Error executing raw dump: ${msg}`, "error");
|
|
279
314
|
}
|
|
280
315
|
}
|
|
316
|
+
async function queueWrite(adapter, cmd, val) {
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
adapter.writeQueue.push(async () => {
|
|
319
|
+
try {
|
|
320
|
+
await writePumpSafe(adapter, cmd, val);
|
|
321
|
+
resolve();
|
|
322
|
+
} catch (err) {
|
|
323
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
void processQueue(adapter);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
async function processQueue(adapter) {
|
|
330
|
+
if (adapter.isWriting || adapter.writeQueue.length === 0) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
adapter.isWriting = true;
|
|
334
|
+
try {
|
|
335
|
+
while (adapter.writeQueue.length > 0) {
|
|
336
|
+
const task = adapter.writeQueue.shift();
|
|
337
|
+
if (task) {
|
|
338
|
+
try {
|
|
339
|
+
await task();
|
|
340
|
+
await new Promise((resolve) => adapter.setTimeout(resolve, 300));
|
|
341
|
+
} catch (taskError) {
|
|
342
|
+
(0, import_logger.writeLog)(
|
|
343
|
+
`Error processing specific serial write task sequence in queue: ${taskError.message}`,
|
|
344
|
+
"error"
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
} finally {
|
|
350
|
+
adapter.isWriting = false;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
281
353
|
// Annotate the CommonJS export names for ESM import in node:
|
|
282
354
|
0 && (module.exports = {
|
|
283
|
-
delay,
|
|
284
355
|
dumpAllRawToLog,
|
|
356
|
+
queueWrite,
|
|
285
357
|
readAllRaw,
|
|
358
|
+
writePumpSafe,
|
|
286
359
|
writeRawParameter
|
|
287
360
|
});
|
|
288
361
|
//# sourceMappingURL=rawFunctions.js.map
|