iobroker.luxtronik2-controller 1.0.2 → 1.0.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 CHANGED
@@ -11,54 +11,64 @@
11
11
 
12
12
  ## luxtronik2-controller adapter for ioBroker
13
13
 
14
- This ioBroker adapter enables the local control, optimization, and monitoring of heat pumps with [Luxtronik 2.x / 3.x controllers](https://www.alpha-innotec.com/en/products/accessories/control/luxtronik) (e.g., Alpha Innotec, Novelan). The adapter is written entirely in TypeScript.
14
+ **100% local monitoring, control, and optimization** for heat pumps with [Luxtronik 2.x / 3.x controllers](https://www.alpha-innotec.com/en/products/accessories/control/luxtronik) (Alpha Innotec, Novelan, Buderus, Siemens, etc.) — completely **cloud-free**.
15
15
 
16
- **If you like this project and want to support its development, feel free to drop a tip here: https://paypal.me/TJahnke**
17
-
18
- ## Acknowledgements & History
19
-
20
- This project builds upon the preliminary work of existing open-source projects. Special thanks go to:
16
+ Communicates directly via **Native TCP (Port 8889)** and optionally combines it with **Modbus TCP (Hybrid Mode)** to write parameters directly into volatile RAM without EEPROM flash wear. Includes built-in **PV surplus automation**, live **COP/JAZ calculation**, intelligent cycle optimization, and smart pump control (HUP & ZIP).
21
17
 
22
- - **[Bouni](https://github.com/bouni/luxtronik-2):** Whose pioneering work and code developments form the essential foundation for communication with Luxtronik controllers.
23
- - **[Coolchip](https://github.com/coolchip/luxtronik2):** For the fundamental reverse engineering of the Luxtronik network protocol.
24
- - **[UncleSamSwiss](https://github.com/UncleSamSwiss/ioBroker.luxtronik2):** For the original ioBroker adapter.
25
- - **[BenPru](https://github.com/BenPru/luxtronik) & rhammen:** A special thanks to BenPru and rhammen for their continuous further development regarding the access and control of the Luxtronik controller. Without their dedication, efforts, and ideas, this adapter would not have reached the advanced state it is in today. _(If you appreciate their work, feel free to buy them a coffee! ☕) [BenPru](https://github.com/sponsors/BenPru) [rhammen](https://github.com/sponsors/rhammen)_
18
+ **Manual:** [English](documentation/readme_en.md) · [Deutsch](documentation/readme_de.md)
26
19
 
27
20
  > **💡 No LAN cable near your heat pump? No problem!**
28
21
  > If your Luxtronik 2.0 controller only has a free USB port instead of a nearby network socket, you can easily connect it via Wi-Fi using the clever **USB 2.0 powered WiFi/Ethernet Bridge** project by _obermolch_. It powers itself directly from the controller's USB port and bridges the connection wirelessly without extra wall power supplies.
29
22
  > Check out the full guide and community discussion here: [ioBroker Forum: USB 2.0 powered WiFi/Ethernet Bridge für Luxtronik 2.0](https://forum.iobroker.net/topic/85773/usb-2-0-powered-wifi-ethernet-bridge-f%C3%BCr-luxtronik-2-0).
30
23
 
31
- **Innovations in this version:**
32
- The `luxtronik2-controller` natively integrates both classic TCP communication (Port `8888` / `8889`) and modern WebSockets (Port `8214` for firmware > V3.81), combined with an optional **Hybrid Modbus TCP** engine (Port `502`) for wear-free RAM writes. Additionally, it features intelligent cycle optimization, dynamic pump control, hardware flash-wear protection, COP/JAZ efficiency tracking, PV-management and automated datapoint management.
24
+ **If you like this project and want to support its development, feel free to drop a tip here: https://paypal.me/TJahnke**
33
25
 
34
26
  ### Features
35
27
 
36
- - **Native TCP & WebSocket Communication:** Direct connection to the heat pump via classic TCP (`8888` / `8889`) or WebSockets (`8214`) without external protocol overhead.
37
- - **Hybrid Modbus TCP Support (0% Flash Wear):** Write volatile parameters (target temperatures, heating curves, operating modes) and coils/switches directly into the controller's RAM via Modbus TCP (Port `502`) without wearing out the internal EEPROM flash memory, while continuing to read full telemetry via the native port. Active Modbus states are automatically tagged with `(Modbus)` in the object tree.
28
+ #### 🔌 Communication & Operating Modes
29
+
30
+ - **3 Flexible Operating Modes:** Switch seamlessly between safe **Read-Only** (monitoring only, all hardware writes blocked), **Native Write** (Port `8889`), and **Modbus Hybrid** mode.
31
+ - **Native TCP & WebSocket Communication:** Direct local connection via classic TCP (`8888` / `8889`) or WebSockets (`8214`) with broad compatibility across V1.x, V2.x, and V3.x firmwares (dynamic scaling factors and adaptive write-queue timing).
32
+ - **Hybrid Modbus TCP Support (0% Flash Wear):** Writes volatile parameters (target temperatures, heating curves, operating modes) and coils directly into controller RAM via Modbus TCP (Port `502`) without wearing out the EEPROM flash memory, while continuing to read full telemetry over the native port. Active Modbus states are automatically tagged with `(Modbus)` in the object tree.
33
+
34
+ #### ☀️ PV Automation & Efficiency
35
+
36
+ - **PV Surplus Management (PV-Ready):** Fully integrated solar surplus automation that uses your live grid feed-in to raise heating and/or hot water setpoints (wear-free via Modbus TCP):
37
+ - **Dynamic Sequence Priority:** Continuously monitors live temperatures and reroutes surplus between hot water and heating once the prioritized target reaches saturation.
38
+ - **Hysteresis & Smart Timers:** Customizable start/stop delays and a dedicated stop threshold (Schmitt trigger logic) prevent self-cancelling feedback loops when the heat pump ramps up.
39
+ - **Battery Prioritization:** Optionally includes home battery charging power in the surplus calculation to prioritize the heat pump as thermal storage.
40
+ - **Hardware Cycle Protection:** Waits for active heating or hot water cycles to finish naturally before reverting setpoints when solar yield drops, protecting the compressor.
41
+ - **COP & JAZ (Efficiency Calculator):** Live efficiency tracking (_Today_, _Last 7 Days_, _Current Month_, _Current Year_), automatically split into _Heating_, _Hot Water_, and _Total_. Supports internal Luxtronik counters or high-precision external meters (e.g., Shelly 3EM, M-Bus heat meters) with persistent storage (`hidden.cop_buckets`) and anti-flapping zero-drop protection.
42
+
43
+ #### 🛡️ Hardware Protection & Smart Optimization
44
+
38
45
  - **Hardware & EEPROM Flash Protection:**
39
- - **Read-Before-Write Cache:** Intercepts and blocks redundant write commands if the controller parameter is already at the target value.
46
+ - **Read-Before-Write Cache:** Intercepts and blocks redundant write commands if the controller already holds the target value.
40
47
  - **Flash Write Counters:** Transparently tracks daily (`write_cycles_today`) and cumulative (`write_cycles_total`) EEPROM write operations.
41
- - **Idle Defaults & Interactive Heat Curve:** Automatically restores safe baseline settings when the heat pump enters standby, featuring a live interactive SVG heat curve preview in the Admin UI.
48
+ - **Idle Defaults & Interactive Heat Curve:** Automatically restores safe baseline settings in standby, featuring a live interactive SVG heat curve preview in the Admin UI.
42
49
  - **Firmware `.90` Crash Shield:** Automatically detects buggy manufacturer firmwares (`V1.90` / `V2.90`) and blocks network writes to prevent hardware crashes.
43
- - **COP & JAZ (Efficiency Calculator):** Calculate and track heat pump efficiency directly within the adapter (_Today_, _Last 7 Days_, _Current Month_, _Current Year_), automatically split into _Heating_, _Hot Water_, and _Total_. Supports internal Luxtronik counters or high-precision external meters (e.g., Shelly 3EM, M-Bus heat meters) with persistent database storage (`hidden.cop_buckets`) and anti-flapping zero-drop protection.
44
- - **Compressor Protection (Cycle Optimization):** Intelligently links heating and domestic hot water (DHW) cycles to prevent unnecessary compressor stops and starts.
45
- - **Dynamic HUP Control (with Auto-PWM Detection):** Automatically scales the 0–10V control voltage of the heating circulation pump (HUP) based on the supply/return temperature spread. PWM-controlled pumps are automatically detected and bypassed.
50
+ - **Compressor Protection (Cycle Optimization):** Intelligently couples heating and domestic hot water (DHW) cycles to prevent unnecessary compressor stops and starts.
51
+ - **Dynamic HUP Control (Auto-PWM Detection):** Automatically scales the 0–10V control voltage of the heating circulation pump (HUP) based on the supply/return temperature spread. PWM-controlled pumps are automatically detected and bypassed.
46
52
  - **Smart 3-Way Circulation Pump (ZIP) Control:**
47
- - Choose intuitively between **Internal Luxtronik Controller**, **External Actor** (e.g., Shelly with 0% flash wear), or **Modbus TCP (Coil 7)**.
53
+ - Choose between **Internal Luxtronik Controller**, **External Actor** (e.g., Shelly with 0% flash wear), or **Modbus TCP (Coil 7)**.
48
54
  - Trigger circulation on-demand via ioBroker motion sensors/buttons (with anti-cycling cooldown) or synchronously during hot water generation.
49
55
  - Includes live virtual status (`Virtual_ZIP_Status`) and a real-time remaining runtime countdown in seconds (`Virtual_ZIP_Remaining_Time`).
50
- - **Integrated Actions (Macros):** Pre-defined triggers for forced heating (`Zwangsheizen`), forced hot water (`Zwangswarmwasser`), circulation (`Activate_Zip`), manual default resets (`Setze_Vorgabewerte`), and full raw data dumps (`Dump_Raw_To_Log`).
51
- - **Smart Object Management & Visibility Filter:** Queries hardware visibility flags (Command `3005`) on startup to automatically hide unsupported system components (e.g., cooling, solar, ventilation, or uninstalled mixing circuits). Deselected categories, datapoints, and empty folders are cleanly removed on restart.
56
+
57
+ #### 📊 Monitoring, Diagnostics & Customization
58
+
59
+ - **Integrated Actions (Macros):** Pre-defined triggers for forced heating (`Zwangsheizen`), forced hot water (`Zwangswarmwasser`), circulation (`Activate_Zip`), manual idle resets (`Setze_Vorgabewerte`), and full raw data dumps (`Dump_Raw_To_Log`).
60
+ - **Smart Object Management & Visibility Filter:** Queries hardware visibility flags (Command `3005`) on startup to hide unsupported components (cooling, solar, ventilation, uninstalled mixing circuits) and cleanly removes deselected datapoints and empty folders on restart.
52
61
  - **Custom Datapoints:** Flexibly add custom telemetry values (Index `3004`) and writable parameters (Index `3003`) via the Admin UI, including custom scaling factors, units, and automatic Unix timestamp formatting.
53
- - **Extended Status Texts & Calculations:** Live calculation of temperature spread, thermal/electrical energy sums, and translated clear-text system states (including heating offsets, frost protection, and cooling status in German or English).
54
- - **Intelligent Notification System:** Dispatches error logs, connectivity alerts, and critical shutdowns (such as water flow rate issues) to **Telegram** and the **ioBroker Notification Center** – including a 60-minute anti-spam cooldown and a live test button.
55
- - **Automated DTA Backup:** Manual one-click links and scheduled Cron downloads of internal `.dta` diagnostic logs directly from the heat pump to `0_userdata.0/luxtronik_backups` for analysis in tools like _OpenDTA_.
56
- - **Broad Compatibility:** Full support for older (V1.x / V2.x) and newer (V3.x) firmware generations using dynamic scaling factors and adaptive write-queue timing.
57
- - **PV Surplus Management (PV-Ready):** Fully integrated, automated solar surplus control. Uses your live grid feed-in to intelligently raise heating and/or hot water setpoints (wear-free via Modbus TCP).
58
- - **Dynamic Sequence Priority:** Continuously monitors live temperatures and intelligently reroutes power between hot water and heating once the prioritized target reaches saturation.
59
- - **Hysteresis & Smart Timers:** Customizable start/stop delays and a dedicated stop threshold (Schmitt trigger logic) prevent self-cancelling feedback loops when the heat pump starts consuming the surplus.
60
- - **Battery Prioritization:** Optionally includes your home battery's charging power in the surplus calculation, treating the heat pump as the primary thermal battery.
61
- - **Hardware Cycle Protection:** Intelligently waits for an active heating or hot water cycle to naturally finish before reverting setpoints after the sun disappears, protecting the compressor.
62
+ - **Extended Status Texts & Calculations:** Live calculation of temperature spread, thermal/electrical energy sums, and translated clear-text system states (German & English).
63
+ - **Intelligent Notifications & Firmware Checks:** Dispatches error logs, connectivity alerts, and critical shutdowns (e.g., flow rate issues) to **Telegram** and the **ioBroker Notification Center** (with 60-minute anti-spam cooldown & live test button). Also supports scheduled (Cron) and manual firmware update checks including changelog retrieval.
64
+ - **Automated DTA Backup:** One-click links and Cron-scheduled downloads of internal `.dta` diagnostic logs directly from the heat pump to `0_userdata.0/luxtronik_backups` for analysis in tools like _OpenDTA_.
65
+
66
+ ## Acknowledgements & History
67
+
68
+ This project builds upon the preliminary work of existing open-source projects. Special thanks go to:
69
+
70
+ - **[Bouni](https://github.com/bouni/luxtronik-2):** Whose pioneering work and code developments form the essential foundation for communication with Luxtronik controllers.
71
+ - **[BenPru](https://github.com/BenPru/luxtronik) & rhammen:** A special thanks to BenPru and rhammen for their continuous further development regarding the access and control of the Luxtronik controller. Without their dedication, efforts, and ideas, this adapter would not have reached the advanced state it is in today. _(If you appreciate their work, feel free to buy them a coffee! ☕) [BenPru](https://github.com/sponsors/BenPru) [rhammen](https://github.com/sponsors/rhammen)_
62
72
 
63
73
  ## ⚠️ Warning
64
74
 
@@ -85,23 +95,25 @@ It is used by manufacturers such as:
85
95
 
86
96
  _This project is not affiliated with Alpha Innotec, Novelan, ait-deutschland GmbH, or any other company. It is a personal project that is maintained in spare time. Use at your own risk._
87
97
 
88
- ## Reporting Bugs & Contributing
98
+ ## Installation
89
99
 
90
- Bug reports, compatibility notes for specific firmware versions, or feature requests can be submitted via the issue tracker in the [GitHub-Repository](https://github.com/TbsJah/ioBroker.luxtronik2-controller/issues).
100
+ > **Note for Raspberry Pi / ARM users:**
101
+ > You might see red error messages in the installation log related to `node-gyp`, `serialport`, or `usocket`. These are optional dependencies and can be completely ignored. The network-based control (TCP) of the Luxtronik will still work without any issues.
91
102
 
92
- ## Installation
103
+ //### **WORK IN PROGRESS**
93
104
 
94
- **Note for Raspberry Pi / ARM users:**
95
- You might see red error messages in the installation log related to `node-gyp`, `serialport`, or `usocket`. These are optional dependencies and can be completely ignored. The network-based control (TCP) of the Luxtronik will still work without any issues.
105
+ ## Changelog
106
+ ### 1.0.4 (2026-11-21)
96
107
 
97
- ## Information
108
+ - Optimized V3.9x SHI Modbus Hybrid mode to achieve zero EEPROM write cycles during cycle optimization, pre-heating, and forced heating (uses volatile SHI offset `+10.0 K` via Holding 23 / `10002` instead of base point parameter `12`)
109
+ - Fixed startup order in `onReady()` so Modbus TCP availability is checked before PV initialization and hardware ZIP timer disable runs after initial raw parameter fetch
110
+ - Improved PV startup recovery to only reset setpoints if a PV boost was actually active before restart, and decoupled PV heating boost from active SHI cycle optimization
111
+ - Released SHI DHW mode (`10005 = 0`) when reverting hot water target to baseline and avoided unnecessary HUP voltage writes in `setIdleDefaults()` when HUP optimization is disabled
98
112
 
99
- [Info Deutsch](documentation/readme_de.md)
113
+ ### 1.0.3 (2026-11-18)
100
114
 
101
- [Info English](documentation/readme_en.md)
102
- //### **WORK IN PROGRESS**
115
+ - Fixed daily COP reset in `copManager.ts` so Heating and Hot Water values reset to `0` after midnight until an active cycle starts
103
116
 
104
- ## Changelog
105
117
  ### 1.0.2 (2026-11-17)
106
118
 
107
119
  - Fixed `node:` protocol imports (`node:fs`, `node:path`) and repository checker lint issues
@@ -116,15 +128,6 @@ You might see red error messages in the installation log related to `node-gyp`,
116
128
 
117
129
  **STABLE**
118
130
 
119
- ### 0.25.2 (2026-11-16)
120
-
121
- - **Fix i18n**
122
-
123
- ### 0.25.1 (2026-11-16)
124
-
125
- - **Removed Dependencies:**
126
- - WS
127
-
128
131
  ## License
129
132
 
130
133
  MIT License
@@ -67,6 +67,7 @@ async function handleZwangswarmwasser(adapter, id) {
67
67
  }
68
68
  }
69
69
  async function handleZwangsheizen(adapter, id) {
70
+ var _a;
70
71
  try {
71
72
  const localId = id.replace(`${adapter.namespace}.`, "");
72
73
  await adapter.setState(localId, { val: false, ack: true });
@@ -91,9 +92,12 @@ async function handleZwangsheizen(adapter, id) {
91
92
  );
92
93
  return;
93
94
  }
94
- await adapter.syncConfigValue("heating_curve_parallel_offset", CONSTANTS.FORCE_HEATING_OFFSET);
95
+ await adapter.activateForcedHeatingBoost("ForcedHeating");
96
+ const isShi = Boolean(
97
+ adapter.config.modbus_active && ((_a = adapter.modbusManager) == null ? void 0 : _a.isAvailable) && adapter.modbusManager.protocolVersion === "shi" && adapter.config.sync_modbus_holding_23 === true
98
+ );
95
99
  (0, import_logger.writeLog)(
96
- `Forced heating: Triggered - Base point temporarily set to ${CONSTANTS.FORCE_HEATING_OFFSET}\xB0C.`,
100
+ isShi ? "Forced heating: Triggered - Volatile SHI heating offset temporarily set to +10.0 K (Modbus RAM)." : `Forced heating: Triggered - Base point temporarily set to ${CONSTANTS.FORCE_HEATING_OFFSET}\xB0C.`,
97
101
  "info"
98
102
  );
99
103
  } catch (err) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/actionHandlers.ts"],
4
- "sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\nimport { getNumber } from './utils';\n\n// =========================================================\n// TYPEN & KONSTANTEN\n// =========================================================\n\nconst CONSTANTS = {\n\t/** Status-Code f\u00FCr den Ruhezustand der Anlage */\n\tSTATE_IDLE: 5,\n\t/** Befehlswert f\u00FCr den Fu\u00DFpunkt beim Zwangsheizen */\n\tFORCE_HEATING_OFFSET: 35,\n};\n\n// =========================================================\n// AKTIONEN\n// =========================================================\n\n/**\n * Erzwingt die Warmwasserbereitung durch tempor\u00E4re Erh\u00F6hung des Sollwerts.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangswarmwasser(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\t// Hysterese zus\u00E4tzlich auslesen, um den perfekten Zielwert zu berechnen\n\t\tconst [wwIstState, wwSollState, wwHystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\tadapter.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst wwIst = getNumber(wwIstState);\n\t\tconst wwSoll = getNumber(wwSollState);\n\t\tconst wwHysterese = getNumber(wwHystereseState, 2); // Fallback auf 2K, falls nicht gefunden\n\n\t\tif (wwIst >= wwSoll - 1) {\n\t\t\twriteLog(\n\t\t\t\t`Forced hot water: Ignored - Actual (${wwIst}\u00B0C) is already sufficient (Target: ${wwSoll}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Neuen Sollwert berechnen: Ist-Wert + aktuelle Hysterese + 1.5K Puffer\n\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t// Sicherheitspr\u00FCfung: Maximaltemperatur kappen, um Regler-Fehler zu vermeiden\n\t\tconst MAX_WW_TEMP = 70;\n\t\tif (forceSoll > MAX_WW_TEMP) {\n\t\t\tforceSoll = MAX_WW_TEMP;\n\t\t}\n\n\t\t// Auf eine Nachkommastelle runden f\u00FCr saubere \u00DCbergabe\n\t\tforceSoll = Math.round(forceSoll * 10) / 10;\n\n\t\t// Statt der Hysterese wird nun der Warmwasser-Sollwert \u00FCberschrieben\n\t\tawait adapter.syncConfigValue('temperature_hot_water_target', forceSoll);\n\n\t\twriteLog(\n\t\t\t`Forced hot water: Triggered - Actual (${wwIst}\u00B0C) < Target-1 (${wwSoll - 1}\u00B0C). Target temperature temporarily set to ${forceSoll}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced hot water: Error during execution - ${msg}`, 'error');\n\t}\n}\n\n/**\n * Erzwingt den Heizbetrieb durch tempor\u00E4re Erh\u00F6hung des Fu\u00DFpunktes.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangsheizen(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\tconst [bzState, ruecklaufState, ruecklaufSollState, hystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('WP_BZ_akt')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_return')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\tadapter.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst bzVal = getNumber(bzState, -1);\n\t\tconst ruecklauf = getNumber(ruecklaufState);\n\t\tconst ruecklaufSoll = getNumber(ruecklaufSollState);\n\t\tconst hysterese = getNumber(hystereseState);\n\n\t\tif (bzVal !== CONSTANTS.STATE_IDLE) {\n\t\t\twriteLog(`Forced heating: Ignored - System is not idle (Status: ${bzVal}).`, 'info');\n\t\t\treturn;\n\t\t}\n\n\t\tif (ruecklauf >= ruecklaufSoll + hysterese) {\n\t\t\twriteLog(\n\t\t\t\t`Forced heating: Ignored - Return temperature high enough (${ruecklauf}\u00B0C >= ${ruecklaufSoll + hysterese}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait adapter.syncConfigValue('heating_curve_parallel_offset', CONSTANTS.FORCE_HEATING_OFFSET);\n\t\twriteLog(\n\t\t\t`Forced heating: Triggered - Base point temporarily set to ${CONSTANTS.FORCE_HEATING_OFFSET}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced heating: Error during execution - ${msg}`, 'error');\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAE1B,mBAA0B;AAM1B,MAAM,YAAY;AAAA;AAAA,EAEjB,YAAY;AAAA;AAAA,EAEZ,sBAAsB;AACvB;AAYA,eAAsB,uBAAuB,SAA2B,IAA2B;AAClG,MAAI;AACH,UAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,SAAS,KAAK,EAAE;AACtD,UAAM,QAAQ,SAAS,SAAS,EAAE,KAAK,OAAO,KAAK,KAAK,CAAC;AAGzD,UAAM,CAAC,YAAY,aAAa,gBAAgB,IAAI,MAAM,QAAQ,IAAI;AAAA,MACrE,QAAQ,kBAAc,+BAAU,yBAAyB,CAAC;AAAA,MAC1D,QAAQ,kBAAc,+BAAU,0BAA0B,CAAC;AAAA,MAC3D,QAAQ,kBAAc,+BAAU,+BAA+B,CAAC;AAAA,IACjE,CAAC;AAED,UAAM,YAAQ,wBAAU,UAAU;AAClC,UAAM,aAAS,wBAAU,WAAW;AACpC,UAAM,kBAAc,wBAAU,kBAAkB,CAAC;AAEjD,QAAI,SAAS,SAAS,GAAG;AACxB;AAAA,QACC,uCAAuC,KAAK,yCAAsC,MAAM;AAAA,QACxF;AAAA,MACD;AACA;AAAA,IACD;AAGA,QAAI,YAAY,QAAQ,cAAc;AAGtC,UAAM,cAAc;AACpB,QAAI,YAAY,aAAa;AAC5B,kBAAY;AAAA,IACb;AAGA,gBAAY,KAAK,MAAM,YAAY,EAAE,IAAI;AAGzC,UAAM,QAAQ,gBAAgB,gCAAgC,SAAS;AAEvE;AAAA,MACC,yCAAyC,K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AG,IAAI,OAAO;AAAA,EACpE;AACD;",
4
+ "sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\nimport { getNumber } from './utils';\n\n// =========================================================\n// TYPEN & KONSTANTEN\n// =========================================================\n\nconst CONSTANTS = {\n\t/** Status-Code f\u00FCr den Ruhezustand der Anlage */\n\tSTATE_IDLE: 5,\n\t/** Befehlswert f\u00FCr den Fu\u00DFpunkt beim Zwangsheizen */\n\tFORCE_HEATING_OFFSET: 35,\n};\n\n// =========================================================\n// AKTIONEN\n// =========================================================\n\n/**\n * Erzwingt die Warmwasserbereitung durch tempor\u00E4re Erh\u00F6hung des Sollwerts.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangswarmwasser(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\t// Hysterese zus\u00E4tzlich auslesen, um den perfekten Zielwert zu berechnen\n\t\tconst [wwIstState, wwSollState, wwHystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Ist')),\n\t\t\tadapter.getStateAsync(getDpPath('Wamwassertemperatur_Soll')),\n\t\t\tadapter.getStateAsync(getDpPath('hotWaterTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst wwIst = getNumber(wwIstState);\n\t\tconst wwSoll = getNumber(wwSollState);\n\t\tconst wwHysterese = getNumber(wwHystereseState, 2); // Fallback auf 2K, falls nicht gefunden\n\n\t\tif (wwIst >= wwSoll - 1) {\n\t\t\twriteLog(\n\t\t\t\t`Forced hot water: Ignored - Actual (${wwIst}\u00B0C) is already sufficient (Target: ${wwSoll}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// Neuen Sollwert berechnen: Ist-Wert + aktuelle Hysterese + 1.5K Puffer\n\t\tlet forceSoll = wwIst + wwHysterese + 1.5;\n\n\t\t// Sicherheitspr\u00FCfung: Maximaltemperatur kappen, um Regler-Fehler zu vermeiden\n\t\tconst MAX_WW_TEMP = 70;\n\t\tif (forceSoll > MAX_WW_TEMP) {\n\t\t\tforceSoll = MAX_WW_TEMP;\n\t\t}\n\n\t\t// Auf eine Nachkommastelle runden f\u00FCr saubere \u00DCbergabe\n\t\tforceSoll = Math.round(forceSoll * 10) / 10;\n\n\t\t// Statt der Hysterese wird nun der Warmwasser-Sollwert \u00FCberschrieben\n\t\tawait adapter.syncConfigValue('temperature_hot_water_target', forceSoll);\n\n\t\twriteLog(\n\t\t\t`Forced hot water: Triggered - Actual (${wwIst}\u00B0C) < Target-1 (${wwSoll - 1}\u00B0C). Target temperature temporarily set to ${forceSoll}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced hot water: Error during execution - ${msg}`, 'error');\n\t}\n}\n\n/**\n * Erzwingt den Heizbetrieb durch tempor\u00E4re Erh\u00F6hung des Fu\u00DFpunktes.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die ID des ausl\u00F6senden Datenpunkts.\n */\nexport async function handleZwangsheizen(adapter: LuxtronikAdapter, id: string): Promise<void> {\n\ttry {\n\t\tconst localId = id.replace(`${adapter.namespace}.`, '');\n\t\tawait adapter.setState(localId, { val: false, ack: true });\n\n\t\tconst [bzState, ruecklaufState, ruecklaufSollState, hystereseState] = await Promise.all([\n\t\t\tadapter.getStateAsync(getDpPath('WP_BZ_akt')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_return')),\n\t\t\tadapter.getStateAsync(getDpPath('temperature_target_return')),\n\t\t\tadapter.getStateAsync(getDpPath('returnTemperatureHysteresis')),\n\t\t]);\n\n\t\tconst bzVal = getNumber(bzState, -1);\n\t\tconst ruecklauf = getNumber(ruecklaufState);\n\t\tconst ruecklaufSoll = getNumber(ruecklaufSollState);\n\t\tconst hysterese = getNumber(hystereseState);\n\n\t\tif (bzVal !== CONSTANTS.STATE_IDLE) {\n\t\t\twriteLog(`Forced heating: Ignored - System is not idle (Status: ${bzVal}).`, 'info');\n\t\t\treturn;\n\t\t}\n\n\t\tif (ruecklauf >= ruecklaufSoll + hysterese) {\n\t\t\twriteLog(\n\t\t\t\t`Forced heating: Ignored - Return temperature high enough (${ruecklauf}\u00B0C >= ${ruecklaufSoll + hysterese}\u00B0C).`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tawait adapter.activateForcedHeatingBoost('ForcedHeating');\n\t\tconst isShi = Boolean(\n\t\t\tadapter.config.modbus_active &&\n\t\t\tadapter.modbusManager?.isAvailable &&\n\t\t\tadapter.modbusManager.protocolVersion === 'shi' &&\n\t\t\tadapter.config.sync_modbus_holding_23 === true,\n\t\t);\n\t\twriteLog(\n\t\t\tisShi\n\t\t\t\t? 'Forced heating: Triggered - Volatile SHI heating offset temporarily set to +10.0 K (Modbus RAM).'\n\t\t\t\t: `Forced heating: Triggered - Base point temporarily set to ${CONSTANTS.FORCE_HEATING_OFFSET}\u00B0C.`,\n\t\t\t'info',\n\t\t);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Forced heating: Error during execution - ${msg}`, 'error');\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAE1B,mBAA0B;AAM1B,MAAM,YAAY;AAAA;AAAA,EAEjB,YAAY;AAAA;AAAA,EAEZ,sBAAsB;AACvB;AAYA,eAAsB,uBAAuB,SAA2B,IAA2B;AAClG,MAAI;AACH,UAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,SAAS,KAAK,EAAE;AACtD,UAAM,QAAQ,SAAS,SAAS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+BAAU,oBAAoB,CAAC;AAAA,MACrD,QAAQ,kBAAc,+BAAU,2BAA2B,CAAC;AAAA,MAC5D,QAAQ,kBAAc,+BAAU,6BAA6B,CAAC;AAAA,IAC/D,CAAC;AAED,UAAM,YAAQ,wBAAU,SAAS,EAAE;AACnC,UAAM,gBAAY,wBAAU,cAAc;AAC1C,UAAM,oBAAgB,wBAAU,kBAAkB;AAClD,UAAM,gBAAY,wBAAU,cAAc;AAE1C,QAAI,UAAU,UAAU,YAAY;AACnC,kCAAS,yDAAyD,KAAK,MAAM,MAAM;AACnF;AAAA,IACD;AAEA,QAAI,aAAa,gBAAgB,WAAW;AAC3C;AAAA,QACC,6DAA6D,SAAS,YAAS,gBAAgB,SAAS;AAAA,QACxG;AAAA,MACD;AACA;AAAA,IACD;AAEA,UAAM,QAAQ,2BAA2B,eAAe;AACxD,UAAM,QAAQ;AAAA,MACb,QAAQ,OAAO,mBACf,aAAQ,kBAAR,mBAAuB,gBACvB,QAAQ,cAAc,oBAAoB,SAC1C,QAAQ,OAAO,2BAA2B;AAAA,IAC3C;AACA;AAAA,MACC,QACG,qGACA,6DAA6D,UAAU,oBAAoB;AAAA,MAC9F;AAAA,IACD;AAAA,EACD,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,4CAA4C,GAAG,IAAI,OAAO;AAAA,EACpE;AACD;",
6
6
  "names": []
7
7
  }
@@ -311,12 +311,13 @@ async function calculateAndWriteCop(adapter, category) {
311
311
  const tStart = tState && typeof tState.val === "number" ? tState.val : currentThermal;
312
312
  const pUsed = currentPower - pStart;
313
313
  const tGen = currentThermal - tStart;
314
+ let cop = 0;
314
315
  if (pUsed > 0) {
315
- const cop = Math.round(tGen / pUsed * 100) / 100;
316
- const targetId = (0, import_stateMapping.getDpPath)(dpMap[category][tf]);
317
- if (targetId) {
318
- await adapter.setState(targetId, { val: cop, ack: true });
319
- }
316
+ cop = Math.round(tGen / pUsed * 100) / 100;
317
+ }
318
+ const targetId = (0, import_stateMapping.getDpPath)(dpMap[category][tf]);
319
+ if (targetId) {
320
+ await adapter.setState(targetId, { val: cop, ack: true });
320
321
  }
321
322
  }
322
323
  const historyId = `hidden.cop_buckets.${category}_history_7d`;
@@ -328,12 +329,13 @@ async function calculateAndWriteCop(adapter, category) {
328
329
  const oldest = history[0];
329
330
  const pUsed = currentPower - oldest.power;
330
331
  const tGen = currentThermal - oldest.thermal;
332
+ let cop = 0;
331
333
  if (pUsed > 0) {
332
- const cop = Math.round(tGen / pUsed * 100) / 100;
333
- const targetId = (0, import_stateMapping.getDpPath)(dpMap[category]["7d"]);
334
- if (targetId) {
335
- await adapter.setState(targetId, { val: cop, ack: true });
336
- }
334
+ cop = Math.round(tGen / pUsed * 100) / 100;
335
+ }
336
+ const targetId = (0, import_stateMapping.getDpPath)(dpMap[category]["7d"]);
337
+ if (targetId) {
338
+ await adapter.setState(targetId, { val: cop, ack: true });
337
339
  }
338
340
  }
339
341
  } catch {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/copManager.ts"],
4
- "sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\nlet isInitialized = false;\n/** Cache f\u00FCr bereits angelegte Datenbank-Objekte zur Vermeidung unn\u00F6tiger DB-Zugriffe */\nconst ensuredObjects = new Set<string>();\n\n/**\n * Stellt einmalig pro Adapter-Laufzeit sicher, dass ein internes COP-Objekt existiert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die Objekt-ID.\n * @param obj Die Objekt-Definition.\n */\nasync function ensureCopObject(adapter: LuxtronikAdapter, id: string, obj: ioBroker.SettableObject): Promise<void> {\n\tif (ensuredObjects.has(id)) {\n\t\treturn;\n\t}\n\tawait adapter.setObjectNotExistsAsync(id, obj);\n\tensuredObjects.add(id);\n}\n\n/**\n * Verarbeitet die COP-Daten und berechnet Live-Werte anhand von absoluten Z\u00E4hlern und Snapshots.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param bzVal Der aktuelle Betriebszustand der W\u00E4rmepumpe als String.\n * @returns Ein Promise, das nach Abschluss der Berechnung aufgel\u00F6st wird.\n */\nexport async function processCopData(adapter: LuxtronikAdapter, bzVal: string): Promise<void> {\n\tconst config = adapter.config as any;\n\tif (!config.cop_calculation_active) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog(`COP Manager gestartet. Modus: ${bzVal}`, 'debug');\n\n\t\tconst isExternalPower = config.cop_source_power === 'external' && Boolean(config.cop_oid_power_total);\n\t\tconst isExternalThermal = config.cop_source_thermal === 'external' && Boolean(config.cop_oid_thermal_total);\n\n\t\t// 1. ALLE STROMZ\u00C4HLER ABRUFEN (Gesamt + Einzelz\u00E4hler)\n\t\tlet currentPowerTotal = 0;\n\t\tlet currentPowerHeating = 0;\n\t\tlet currentPowerWater = 0;\n\n\t\tif (isExternalPower) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_power_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPowerTotal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [sTotal, sHeat, sWater] = await Promise.all([\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_total')),\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_heating')),\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_warmwater')),\n\t\t\t]);\n\t\t\tif (sTotal && typeof sTotal.val === 'number') {\n\t\t\t\tcurrentPowerTotal = sTotal.val;\n\t\t\t}\n\t\t\tif (sHeat && typeof sHeat.val === 'number') {\n\t\t\t\tcurrentPowerHeating = sHeat.val;\n\t\t\t}\n\t\t\tif (sWater && typeof sWater.val === 'number') {\n\t\t\t\tcurrentPowerWater = sWater.val;\n\t\t\t}\n\t\t}\n\n\t\t// 2. ALLE W\u00C4RMEMENGENZ\u00C4HLER ABRUFEN (Gesamt + Einzelz\u00E4hler)\n\t\tlet currentThermalTotal = 0;\n\t\tlet currentThermalHeating = 0;\n\t\tlet currentThermalWater = 0;\n\n\t\tif (isExternalThermal) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_thermal_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermalTotal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [sTotal, sHeat, sWater] = await Promise.all([\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_total')),\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_heating')),\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_warmwater')),\n\t\t\t]);\n\t\t\tif (sTotal && typeof sTotal.val === 'number') {\n\t\t\t\tcurrentThermalTotal = sTotal.val;\n\t\t\t}\n\t\t\tif (sHeat && typeof sHeat.val === 'number') {\n\t\t\t\tcurrentThermalHeating = sHeat.val;\n\t\t\t}\n\t\t\tif (sWater && typeof sWater.val === 'number') {\n\t\t\t\tcurrentThermalWater = sWater.val;\n\t\t\t}\n\t\t}\n\n\t\t// --- SEPARATE REFERENZ-SPEICHER (Verhindert Spr\u00FCnge beim Taktwechsel!) ---\n\t\tconst rawPowerTotalId = 'hidden.cop_buckets.last_raw_power';\n\t\tconst rawPowerHeatId = 'hidden.cop_buckets.last_raw_power_heating';\n\t\tconst rawPowerWaterId = 'hidden.cop_buckets.last_raw_power_water';\n\n\t\tconst rawThermalTotalId = 'hidden.cop_buckets.last_raw_thermal';\n\t\tconst rawThermalHeatId = 'hidden.cop_buckets.last_raw_thermal_heating';\n\t\tconst rawThermalWaterId = 'hidden.cop_buckets.last_raw_thermal_water';\n\n\t\tconst rawTrackers = [\n\t\t\t{ id: rawPowerTotalId, name: 'Last Raw Power Total', current: currentPowerTotal },\n\t\t\t{ id: rawPowerHeatId, name: 'Last Raw Power Heating', current: currentPowerHeating },\n\t\t\t{ id: rawPowerWaterId, name: 'Last Raw Power Water', current: currentPowerWater },\n\t\t\t{ id: rawThermalTotalId, name: 'Last Raw Thermal Total', current: currentThermalTotal },\n\t\t\t{ id: rawThermalHeatId, name: 'Last Raw Thermal Heating', current: currentThermalHeating },\n\t\t\t{ id: rawThermalWaterId, name: 'Last Raw Thermal Water', current: currentThermalWater },\n\t\t];\n\n\t\tif (!isInitialized) {\n\t\t\tfor (const tracker of rawTrackers) {\n\t\t\t\tawait ensureCopObject(adapter, tracker.id, {\n\t\t\t\t\ttype: 'state',\n\t\t\t\t\tcommon: { name: tracker.name, type: 'number', role: 'value', read: true, write: false },\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tconst stateInit = await adapter.getStateAsync(tracker.id);\n\t\t\t\tif (!stateInit || stateInit.val === null) {\n\t\t\t\t\tawait adapter.setState(tracker.id, { val: tracker.current, ack: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tisInitialized = true;\n\t\t\tawait handleTimeRollover(adapter);\n\t\t\treturn;\n\t\t}\n\n\t\t// 3. LETZTE Z\u00C4HLERST\u00C4NDE LADEN & DELTAS ISOLIERT BERECHNEN\n\t\tconst readAndCalcDelta = async (id: string, currentVal: number): Promise<number> => {\n\t\t\tconst lastState = await adapter.getStateAsync(id);\n\t\t\tconst lastVal = lastState && typeof lastState.val === 'number' ? lastState.val : currentVal;\n\t\t\tconst delta = Math.max(0, currentVal - lastVal);\n\n\t\t\t// Referenzwert sofort nachziehen (sowohl bei Zuwachs als auch bei Z\u00E4hler-Reset)\n\t\t\tif (currentVal !== lastVal) {\n\t\t\t\tawait adapter.setState(id, { val: currentVal, ack: true });\n\t\t\t}\n\t\t\treturn delta;\n\t\t};\n\n\t\tconst deltaPowerTotal = await readAndCalcDelta(rawPowerTotalId, currentPowerTotal);\n\t\tconst deltaPowerHeating = await readAndCalcDelta(rawPowerHeatId, currentPowerHeating);\n\t\tconst deltaPowerWater = await readAndCalcDelta(rawPowerWaterId, currentPowerWater);\n\n\t\tconst deltaThermalTotal = await readAndCalcDelta(rawThermalTotalId, currentThermalTotal);\n\t\tconst deltaThermalHeating = await readAndCalcDelta(rawThermalHeatId, currentThermalHeating);\n\t\tconst deltaThermalWater = await readAndCalcDelta(rawThermalWaterId, currentThermalWater);\n\n\t\t// 4. ZEITWECHSEL PR\u00DCFEN\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// 5. INTELLIGENTE ZUORDNUNG MIT AUTOMATISCHEM FALLBACK AUF TOTAL\n\t\tlet modeDeltaPower = 0;\n\t\tlet modeDeltaThermal = 0;\n\n\t\tif (bzVal === '0' || bzVal === '4') {\n\t\t\t// HEIZEN (inkl. Abtauen): Einzelz\u00E4hler nutzen; falls 0 -> Fallback auf Gesamtz\u00E4hler-Delta\n\t\t\tmodeDeltaPower = isExternalPower\n\t\t\t\t? deltaPowerTotal\n\t\t\t\t: deltaPowerHeating > 0\n\t\t\t\t\t? deltaPowerHeating\n\t\t\t\t\t: deltaPowerTotal;\n\t\t\tmodeDeltaThermal = isExternalThermal\n\t\t\t\t? deltaThermalTotal\n\t\t\t\t: deltaThermalHeating > 0\n\t\t\t\t\t? deltaThermalHeating\n\t\t\t\t\t: deltaThermalTotal;\n\n\t\t\tif (modeDeltaPower > 0 || modeDeltaThermal > 0) {\n\t\t\t\tawait addDeltaToBucket(adapter, 'Heating', modeDeltaPower, modeDeltaThermal);\n\t\t\t}\n\t\t} else if (bzVal === '1') {\n\t\t\t// WARMWASSER: Einzelz\u00E4hler nutzen; falls 0 (z.B. Novelan Bug) -> Fallback auf Gesamtz\u00E4hler-Delta\n\t\t\tmodeDeltaPower = isExternalPower\n\t\t\t\t? deltaPowerTotal\n\t\t\t\t: deltaPowerWater > 0\n\t\t\t\t\t? deltaPowerWater\n\t\t\t\t\t: deltaPowerTotal;\n\t\t\tmodeDeltaThermal = isExternalThermal\n\t\t\t\t? deltaThermalTotal\n\t\t\t\t: deltaThermalWater > 0\n\t\t\t\t\t? deltaThermalWater\n\t\t\t\t\t: deltaThermalTotal;\n\n\t\t\tif (!isExternalPower && deltaPowerWater === 0 && deltaPowerTotal > 0) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`[COP] WW-Stromz\u00E4hler meldet 0 Delta. Nutze Delta von energy_total (${deltaPowerTotal} kWh) als Fallback.`,\n\t\t\t\t\t'debug',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!isExternalThermal && deltaThermalWater === 0 && deltaThermalTotal > 0) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`[COP] WW-W\u00E4rmez\u00E4hler meldet 0 Delta. Nutze Delta von thermalenergy_total (${deltaThermalTotal} kWh) als Fallback.`,\n\t\t\t\t\t'debug',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (modeDeltaPower > 0 || modeDeltaThermal > 0) {\n\t\t\t\tawait addDeltaToBucket(adapter, 'HotWater', modeDeltaPower, modeDeltaThermal);\n\t\t\t}\n\t\t}\n\n\t\t// TOTAL-BUCKET: Nimmt das reale Gesamtdelta (oder das Modus-Delta als Fallback)\n\t\tconst totalBucketPower = deltaPowerTotal > 0 ? deltaPowerTotal : modeDeltaPower;\n\t\tconst totalBucketThermal = deltaThermalTotal > 0 ? deltaThermalTotal : modeDeltaThermal;\n\n\t\tif (totalBucketPower > 0 || totalBucketThermal > 0) {\n\t\t\tawait addDeltaToBucket(adapter, 'Total', totalBucketPower, totalBucketThermal);\n\t\t}\n\n\t\t// 6. LIVE COP BERECHNEN UND SCHREIBEN\n\t\tawait calculateAndWriteCop(adapter, 'Total');\n\t\tawait calculateAndWriteCop(adapter, 'Heating');\n\t\tawait calculateAndWriteCop(adapter, 'HotWater');\n\t} catch (err: any) {\n\t\twriteLog(`Fehler bei der COP-Berechnung: ${err.message}`, 'error');\n\t}\n}\n\n/**\n * Pr\u00FCft auf Tages-, Monats- oder Jahreswechsel (lokale Systemzeit) und erstellt Snapshots der Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n */\nasync function handleTimeRollover(adapter: LuxtronikAdapter): Promise<void> {\n\twriteLog(`Pr\u00FCfe Tageswechsel und lege Ordner an...`, 'debug');\n\tconst dateStateId = 'hidden.cop_buckets.last_date';\n\tawait ensureCopObject(adapter, 'hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, 'hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, dateStateId, {\n\t\ttype: 'state',\n\t\tcommon: { name: 'Last calculation date', type: 'string', role: 'date', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(dateStateId);\n\tconst lastDate = state && typeof state.val === 'string' ? state.val : '';\n\n\tconst now = new Date();\n\tconst y = now.getFullYear();\n\tconst m = String(now.getMonth() + 1).padStart(2, '0');\n\tconst d = String(now.getDate()).padStart(2, '0');\n\tconst currentDate = `${y}-${m}-${d}`; // Lokales Datum: YYYY-MM-DD\n\tconst currentMonth = `${y}-${m}`; // Lokaler Monat: YYYY-MM\n\tconst currentYear = `${y}`; // Lokales Jahr: YYYY\n\n\tif (lastDate !== currentDate) {\n\t\tconst lastMonth = lastDate ? lastDate.substring(0, 7) : '';\n\t\tconst lastYear = lastDate ? lastDate.substring(0, 4) : '';\n\t\tconst categories = ['Total', 'Heating', 'HotWater'];\n\n\t\tfor (const cat of categories) {\n\t\t\tconst powerAbs = await getAbsoluteValue(adapter, cat, 'power');\n\t\t\tconst thermalAbs = await getAbsoluteValue(adapter, cat, 'thermal');\n\n\t\t\t// IMMER: Tageswechsel Snapshot\n\t\t\tawait setSnapshot(adapter, cat, 'today', powerAbs, thermalAbs);\n\n\t\t\t// Historie f\u00FCr 7-Tage-COP aktualisieren\n\t\t\tawait update7DaysHistory(adapter, cat, powerAbs, thermalAbs);\n\n\t\t\t// Monatswechsel Snapshot\n\t\t\tif (lastMonth !== currentMonth) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'month', powerAbs, thermalAbs);\n\t\t\t}\n\n\t\t\t// Jahreswechsel Snapshot\n\t\t\tif (lastYear !== currentYear) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'year', powerAbs, thermalAbs);\n\t\t\t}\n\t\t}\n\n\t\tawait adapter.setState(dateStateId, { val: currentDate, ack: true });\n\t\twriteLog(`Tageswechsel erkannt. COP-Snapshots f\u00FCr ${currentDate} wurden gesichert.`, 'info');\n\t}\n}\n\n/**\n * Liest den Endlosz\u00E4hler f\u00FCr eine spezifische Kategorie aus.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie (Total, Heating, HotWater).\n * @param type Art der Energie (power oder thermal).\n * @returns Der absolute Wert in kWh.\n */\nasync function getAbsoluteValue(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttype: 'power' | 'thermal',\n): Promise<number> {\n\tconst id = `hidden.cop_buckets.${category}_${type}_absolute`;\n\tawait ensureCopObject(adapter, id, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} ${type} Absolute`, type: 'number', role: 'value', read: true, write: false },\n\t\tnative: {},\n\t});\n\tconst state = await adapter.getStateAsync(id);\n\treturn state && typeof state.val === 'number' ? state.val : 0;\n}\n\n/**\n * Schreibt einen Snapshot-Wert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param timeframe Der Zeitraum (today, month, year).\n * @param power Der zu sichernde Stromwert.\n * @param thermal Der zu sichernde W\u00E4rmewert.\n */\nasync function setSnapshot(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttimeframe: string,\n\tpower: number,\n\tthermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;\n\n\tawait ensureCopObject(adapter, powerId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Power Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, thermalId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Thermal Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\n\tawait adapter.setState(powerId, { val: power, ack: true });\n\tawait adapter.setState(thermalId, { val: thermal, ack: true });\n}\n\n/**\n * Verwaltet einen rollierenden 7-Tage-Speicher als JSON.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param currentPower Der absolute Stromz\u00E4hler.\n * @param currentThermal Der absolute W\u00E4rmez\u00E4hler.\n */\nasync function update7DaysHistory(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tcurrentPower: number,\n\tcurrentThermal: number,\n): Promise<void> {\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tawait ensureCopObject(adapter, historyId, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} 7 Days History`, type: 'string', role: 'json', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(historyId);\n\tlet history: { power: number; thermal: number }[] = [];\n\n\tif (state && typeof state.val === 'string' && state.val !== '') {\n\t\ttry {\n\t\t\thistory = JSON.parse(state.val);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n\n\thistory.push({ power: currentPower, thermal: currentThermal });\n\tif (history.length > 7) {\n\t\thistory.shift(); // \u00C4ltesten Eintrag entfernen (Ringpuffer)\n\t}\n\n\tawait adapter.setState(historyId, { val: JSON.stringify(history), ack: true });\n}\n\n/**\n * Addiert die neuen kWh-Deltas auf die internen Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die zu aktualisierende Kategorie.\n * @param deltaPower Die verbrauchte elektrische Energie.\n * @param deltaThermal Die erzeugte thermische Energie.\n */\nasync function addDeltaToBucket(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tdeltaPower: number,\n\tdeltaThermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_absolute`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_absolute`;\n\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tawait adapter.setState(powerId, { val: currentPower + deltaPower, ack: true });\n\tawait adapter.setState(thermalId, { val: currentThermal + deltaThermal, ack: true });\n}\n\n/**\n * Liest die Endlosz\u00E4hler und Snapshots aus, berechnet die Differenz und schreibt den COP.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die auszulesende Kategorie (Total, Heating, HotWater).\n */\nasync function calculateAndWriteCop(adapter: LuxtronikAdapter, category: string): Promise<void> {\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tconst dpMap: Record<string, Record<string, string>> = {\n\t\tTotal: { today: 'cop_total_today', '7d': 'cop_total_7d', month: 'cop_total_month', year: 'cop_total_year' },\n\t\tHeating: {\n\t\t\ttoday: 'cop_heating_today',\n\t\t\t'7d': 'cop_heating_7d',\n\t\t\tmonth: 'cop_heating_month',\n\t\t\tyear: 'cop_heating_year',\n\t\t},\n\t\tHotWater: { today: 'cop_water_today', '7d': 'cop_water_7d', month: 'cop_water_month', year: 'cop_water_year' },\n\t};\n\n\t// 1. Berechnung f\u00FCr Heute, Monat, Jahr\n\tconst timeframes = ['today', 'month', 'year'];\n\tfor (const tf of timeframes) {\n\t\tconst powerStartId = `hidden.cop_buckets.${category}_power_start_${tf}`;\n\t\tconst thermalStartId = `hidden.cop_buckets.${category}_thermal_start_${tf}`;\n\n\t\tconst pState = await adapter.getStateAsync(powerStartId);\n\t\tconst tState = await adapter.getStateAsync(thermalStartId);\n\n\t\tconst pStart = pState && typeof pState.val === 'number' ? pState.val : currentPower;\n\t\tconst tStart = tState && typeof tState.val === 'number' ? tState.val : currentThermal;\n\n\t\tconst pUsed = currentPower - pStart;\n\t\tconst tGen = currentThermal - tStart;\n\n\t\tif (pUsed > 0) {\n\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\tconst targetId = getDpPath(dpMap[category][tf]);\n\t\t\tif (targetId) {\n\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Berechnung f\u00FCr rollierende 7 Tage\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tconst hState = await adapter.getStateAsync(historyId);\n\tif (hState && typeof hState.val === 'string' && hState.val !== '') {\n\t\ttry {\n\t\t\tconst history = JSON.parse(hState.val);\n\t\t\tif (history.length > 0) {\n\t\t\t\tconst oldest = history[0];\n\t\t\t\tconst pUsed = currentPower - oldest.power;\n\t\t\t\tconst tGen = currentThermal - oldest.thermal;\n\t\t\t\tif (pUsed > 0) {\n\t\t\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\t\t\tconst targetId = getDpPath(dpMap[category]['7d']);\n\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAG1B,IAAI,gBAAgB;AAEpB,MAAM,iBAAiB,oBAAI,IAAY;AASvC,eAAe,gBAAgB,SAA2B,IAAY,KAA6C;AAClH,MAAI,eAAe,IAAI,EAAE,GAAG;AAC3B;AAAA,EACD;AACA,QAAM,QAAQ,wBAAwB,IAAI,GAAG;AAC7C,iBAAe,IAAI,EAAE;AACtB;AASA,eA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ACd,gBAAM,MAAM,KAAK,MAAO,OAAO,QAAS,GAAG,IAAI;AAC/C,gBAAM,eAAW,+BAAU,MAAM,QAAQ,EAAE,IAAI,CAAC;AAChD,cAAI,UAAU;AACb,kBAAM,QAAQ,SAAS,UAAU,EAAE,KAAK,KAAK,KAAK,KAAK,CAAC;AAAA,UACzD;AAAA,QACD;AAAA,MACD;AAAA,IACD,QAAQ;AAAA,IAER;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\nlet isInitialized = false;\n/** Cache f\u00FCr bereits angelegte Datenbank-Objekte zur Vermeidung unn\u00F6tiger DB-Zugriffe */\nconst ensuredObjects = new Set<string>();\n\n/**\n * Stellt einmalig pro Adapter-Laufzeit sicher, dass ein internes COP-Objekt existiert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die Objekt-ID.\n * @param obj Die Objekt-Definition.\n */\nasync function ensureCopObject(adapter: LuxtronikAdapter, id: string, obj: ioBroker.SettableObject): Promise<void> {\n\tif (ensuredObjects.has(id)) {\n\t\treturn;\n\t}\n\tawait adapter.setObjectNotExistsAsync(id, obj);\n\tensuredObjects.add(id);\n}\n\n/**\n * Verarbeitet die COP-Daten und berechnet Live-Werte anhand von absoluten Z\u00E4hlern und Snapshots.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param bzVal Der aktuelle Betriebszustand der W\u00E4rmepumpe als String.\n * @returns Ein Promise, das nach Abschluss der Berechnung aufgel\u00F6st wird.\n */\nexport async function processCopData(adapter: LuxtronikAdapter, bzVal: string): Promise<void> {\n\tconst config = adapter.config as any;\n\tif (!config.cop_calculation_active) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog(`COP Manager gestartet. Modus: ${bzVal}`, 'debug');\n\n\t\tconst isExternalPower = config.cop_source_power === 'external' && Boolean(config.cop_oid_power_total);\n\t\tconst isExternalThermal = config.cop_source_thermal === 'external' && Boolean(config.cop_oid_thermal_total);\n\n\t\t// 1. ALLE STROMZ\u00C4HLER ABRUFEN (Gesamt + Einzelz\u00E4hler)\n\t\tlet currentPowerTotal = 0;\n\t\tlet currentPowerHeating = 0;\n\t\tlet currentPowerWater = 0;\n\n\t\tif (isExternalPower) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_power_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPowerTotal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [sTotal, sHeat, sWater] = await Promise.all([\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_total')),\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_heating')),\n\t\t\t\tadapter.getStateAsync(getDpPath('energy_warmwater')),\n\t\t\t]);\n\t\t\tif (sTotal && typeof sTotal.val === 'number') {\n\t\t\t\tcurrentPowerTotal = sTotal.val;\n\t\t\t}\n\t\t\tif (sHeat && typeof sHeat.val === 'number') {\n\t\t\t\tcurrentPowerHeating = sHeat.val;\n\t\t\t}\n\t\t\tif (sWater && typeof sWater.val === 'number') {\n\t\t\t\tcurrentPowerWater = sWater.val;\n\t\t\t}\n\t\t}\n\n\t\t// 2. ALLE W\u00C4RMEMENGENZ\u00C4HLER ABRUFEN (Gesamt + Einzelz\u00E4hler)\n\t\tlet currentThermalTotal = 0;\n\t\tlet currentThermalHeating = 0;\n\t\tlet currentThermalWater = 0;\n\n\t\tif (isExternalThermal) {\n\t\t\tconst state = await adapter.getForeignStateAsync(config.cop_oid_thermal_total);\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermalTotal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst [sTotal, sHeat, sWater] = await Promise.all([\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_total')),\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_heating')),\n\t\t\t\tadapter.getStateAsync(getDpPath('thermalenergy_warmwater')),\n\t\t\t]);\n\t\t\tif (sTotal && typeof sTotal.val === 'number') {\n\t\t\t\tcurrentThermalTotal = sTotal.val;\n\t\t\t}\n\t\t\tif (sHeat && typeof sHeat.val === 'number') {\n\t\t\t\tcurrentThermalHeating = sHeat.val;\n\t\t\t}\n\t\t\tif (sWater && typeof sWater.val === 'number') {\n\t\t\t\tcurrentThermalWater = sWater.val;\n\t\t\t}\n\t\t}\n\n\t\t// --- SEPARATE REFERENZ-SPEICHER (Verhindert Spr\u00FCnge beim Taktwechsel!) ---\n\t\tconst rawPowerTotalId = 'hidden.cop_buckets.last_raw_power';\n\t\tconst rawPowerHeatId = 'hidden.cop_buckets.last_raw_power_heating';\n\t\tconst rawPowerWaterId = 'hidden.cop_buckets.last_raw_power_water';\n\n\t\tconst rawThermalTotalId = 'hidden.cop_buckets.last_raw_thermal';\n\t\tconst rawThermalHeatId = 'hidden.cop_buckets.last_raw_thermal_heating';\n\t\tconst rawThermalWaterId = 'hidden.cop_buckets.last_raw_thermal_water';\n\n\t\tconst rawTrackers = [\n\t\t\t{ id: rawPowerTotalId, name: 'Last Raw Power Total', current: currentPowerTotal },\n\t\t\t{ id: rawPowerHeatId, name: 'Last Raw Power Heating', current: currentPowerHeating },\n\t\t\t{ id: rawPowerWaterId, name: 'Last Raw Power Water', current: currentPowerWater },\n\t\t\t{ id: rawThermalTotalId, name: 'Last Raw Thermal Total', current: currentThermalTotal },\n\t\t\t{ id: rawThermalHeatId, name: 'Last Raw Thermal Heating', current: currentThermalHeating },\n\t\t\t{ id: rawThermalWaterId, name: 'Last Raw Thermal Water', current: currentThermalWater },\n\t\t];\n\n\t\tif (!isInitialized) {\n\t\t\tfor (const tracker of rawTrackers) {\n\t\t\t\tawait ensureCopObject(adapter, tracker.id, {\n\t\t\t\t\ttype: 'state',\n\t\t\t\t\tcommon: { name: tracker.name, type: 'number', role: 'value', read: true, write: false },\n\t\t\t\t\tnative: {},\n\t\t\t\t});\n\t\t\t\tconst stateInit = await adapter.getStateAsync(tracker.id);\n\t\t\t\tif (!stateInit || stateInit.val === null) {\n\t\t\t\t\tawait adapter.setState(tracker.id, { val: tracker.current, ack: true });\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tisInitialized = true;\n\t\t\tawait handleTimeRollover(adapter);\n\t\t\treturn;\n\t\t}\n\n\t\t// 3. LETZTE Z\u00C4HLERST\u00C4NDE LADEN & DELTAS ISOLIERT BERECHNEN\n\t\tconst readAndCalcDelta = async (id: string, currentVal: number): Promise<number> => {\n\t\t\tconst lastState = await adapter.getStateAsync(id);\n\t\t\tconst lastVal = lastState && typeof lastState.val === 'number' ? lastState.val : currentVal;\n\t\t\tconst delta = Math.max(0, currentVal - lastVal);\n\n\t\t\t// Referenzwert sofort nachziehen (sowohl bei Zuwachs als auch bei Z\u00E4hler-Reset)\n\t\t\tif (currentVal !== lastVal) {\n\t\t\t\tawait adapter.setState(id, { val: currentVal, ack: true });\n\t\t\t}\n\t\t\treturn delta;\n\t\t};\n\n\t\tconst deltaPowerTotal = await readAndCalcDelta(rawPowerTotalId, currentPowerTotal);\n\t\tconst deltaPowerHeating = await readAndCalcDelta(rawPowerHeatId, currentPowerHeating);\n\t\tconst deltaPowerWater = await readAndCalcDelta(rawPowerWaterId, currentPowerWater);\n\n\t\tconst deltaThermalTotal = await readAndCalcDelta(rawThermalTotalId, currentThermalTotal);\n\t\tconst deltaThermalHeating = await readAndCalcDelta(rawThermalHeatId, currentThermalHeating);\n\t\tconst deltaThermalWater = await readAndCalcDelta(rawThermalWaterId, currentThermalWater);\n\n\t\t// 4. ZEITWECHSEL PR\u00DCFEN\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// 5. INTELLIGENTE ZUORDNUNG MIT AUTOMATISCHEM FALLBACK AUF TOTAL\n\t\tlet modeDeltaPower = 0;\n\t\tlet modeDeltaThermal = 0;\n\n\t\tif (bzVal === '0' || bzVal === '4') {\n\t\t\t// HEIZEN (inkl. Abtauen): Einzelz\u00E4hler nutzen; falls 0 -> Fallback auf Gesamtz\u00E4hler-Delta\n\t\t\tmodeDeltaPower = isExternalPower\n\t\t\t\t? deltaPowerTotal\n\t\t\t\t: deltaPowerHeating > 0\n\t\t\t\t\t? deltaPowerHeating\n\t\t\t\t\t: deltaPowerTotal;\n\t\t\tmodeDeltaThermal = isExternalThermal\n\t\t\t\t? deltaThermalTotal\n\t\t\t\t: deltaThermalHeating > 0\n\t\t\t\t\t? deltaThermalHeating\n\t\t\t\t\t: deltaThermalTotal;\n\n\t\t\tif (modeDeltaPower > 0 || modeDeltaThermal > 0) {\n\t\t\t\tawait addDeltaToBucket(adapter, 'Heating', modeDeltaPower, modeDeltaThermal);\n\t\t\t}\n\t\t} else if (bzVal === '1') {\n\t\t\t// WARMWASSER: Einzelz\u00E4hler nutzen; falls 0 (z.B. Novelan Bug) -> Fallback auf Gesamtz\u00E4hler-Delta\n\t\t\tmodeDeltaPower = isExternalPower\n\t\t\t\t? deltaPowerTotal\n\t\t\t\t: deltaPowerWater > 0\n\t\t\t\t\t? deltaPowerWater\n\t\t\t\t\t: deltaPowerTotal;\n\t\t\tmodeDeltaThermal = isExternalThermal\n\t\t\t\t? deltaThermalTotal\n\t\t\t\t: deltaThermalWater > 0\n\t\t\t\t\t? deltaThermalWater\n\t\t\t\t\t: deltaThermalTotal;\n\n\t\t\tif (!isExternalPower && deltaPowerWater === 0 && deltaPowerTotal > 0) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`[COP] WW-Stromz\u00E4hler meldet 0 Delta. Nutze Delta von energy_total (${deltaPowerTotal} kWh) als Fallback.`,\n\t\t\t\t\t'debug',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!isExternalThermal && deltaThermalWater === 0 && deltaThermalTotal > 0) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`[COP] WW-W\u00E4rmez\u00E4hler meldet 0 Delta. Nutze Delta von thermalenergy_total (${deltaThermalTotal} kWh) als Fallback.`,\n\t\t\t\t\t'debug',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (modeDeltaPower > 0 || modeDeltaThermal > 0) {\n\t\t\t\tawait addDeltaToBucket(adapter, 'HotWater', modeDeltaPower, modeDeltaThermal);\n\t\t\t}\n\t\t}\n\n\t\t// TOTAL-BUCKET: Nimmt das reale Gesamtdelta (oder das Modus-Delta als Fallback)\n\t\tconst totalBucketPower = deltaPowerTotal > 0 ? deltaPowerTotal : modeDeltaPower;\n\t\tconst totalBucketThermal = deltaThermalTotal > 0 ? deltaThermalTotal : modeDeltaThermal;\n\n\t\tif (totalBucketPower > 0 || totalBucketThermal > 0) {\n\t\t\tawait addDeltaToBucket(adapter, 'Total', totalBucketPower, totalBucketThermal);\n\t\t}\n\n\t\t// 6. LIVE COP BERECHNEN UND SCHREIBEN\n\t\tawait calculateAndWriteCop(adapter, 'Total');\n\t\tawait calculateAndWriteCop(adapter, 'Heating');\n\t\tawait calculateAndWriteCop(adapter, 'HotWater');\n\t} catch (err: any) {\n\t\twriteLog(`Fehler bei der COP-Berechnung: ${err.message}`, 'error');\n\t}\n}\n\n/**\n * Pr\u00FCft auf Tages-, Monats- oder Jahreswechsel (lokale Systemzeit) und erstellt Snapshots der Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n */\nasync function handleTimeRollover(adapter: LuxtronikAdapter): Promise<void> {\n\twriteLog(`Pr\u00FCfe Tageswechsel und lege Ordner an...`, 'debug');\n\tconst dateStateId = 'hidden.cop_buckets.last_date';\n\tawait ensureCopObject(adapter, 'hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, 'hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, dateStateId, {\n\t\ttype: 'state',\n\t\tcommon: { name: 'Last calculation date', type: 'string', role: 'date', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(dateStateId);\n\tconst lastDate = state && typeof state.val === 'string' ? state.val : '';\n\n\tconst now = new Date();\n\tconst y = now.getFullYear();\n\tconst m = String(now.getMonth() + 1).padStart(2, '0');\n\tconst d = String(now.getDate()).padStart(2, '0');\n\tconst currentDate = `${y}-${m}-${d}`; // Lokales Datum: YYYY-MM-DD\n\tconst currentMonth = `${y}-${m}`; // Lokaler Monat: YYYY-MM\n\tconst currentYear = `${y}`; // Lokales Jahr: YYYY\n\n\tif (lastDate !== currentDate) {\n\t\tconst lastMonth = lastDate ? lastDate.substring(0, 7) : '';\n\t\tconst lastYear = lastDate ? lastDate.substring(0, 4) : '';\n\t\tconst categories = ['Total', 'Heating', 'HotWater'];\n\n\t\tfor (const cat of categories) {\n\t\t\tconst powerAbs = await getAbsoluteValue(adapter, cat, 'power');\n\t\t\tconst thermalAbs = await getAbsoluteValue(adapter, cat, 'thermal');\n\n\t\t\t// IMMER: Tageswechsel Snapshot\n\t\t\tawait setSnapshot(adapter, cat, 'today', powerAbs, thermalAbs);\n\n\t\t\t// Historie f\u00FCr 7-Tage-COP aktualisieren\n\t\t\tawait update7DaysHistory(adapter, cat, powerAbs, thermalAbs);\n\n\t\t\t// Monatswechsel Snapshot\n\t\t\tif (lastMonth !== currentMonth) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'month', powerAbs, thermalAbs);\n\t\t\t}\n\n\t\t\t// Jahreswechsel Snapshot\n\t\t\tif (lastYear !== currentYear) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'year', powerAbs, thermalAbs);\n\t\t\t}\n\t\t}\n\n\t\tawait adapter.setState(dateStateId, { val: currentDate, ack: true });\n\t\twriteLog(`Tageswechsel erkannt. COP-Snapshots f\u00FCr ${currentDate} wurden gesichert.`, 'info');\n\t}\n}\n\n/**\n * Liest den Endlosz\u00E4hler f\u00FCr eine spezifische Kategorie aus.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie (Total, Heating, HotWater).\n * @param type Art der Energie (power oder thermal).\n * @returns Der absolute Wert in kWh.\n */\nasync function getAbsoluteValue(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttype: 'power' | 'thermal',\n): Promise<number> {\n\tconst id = `hidden.cop_buckets.${category}_${type}_absolute`;\n\tawait ensureCopObject(adapter, id, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} ${type} Absolute`, type: 'number', role: 'value', read: true, write: false },\n\t\tnative: {},\n\t});\n\tconst state = await adapter.getStateAsync(id);\n\treturn state && typeof state.val === 'number' ? state.val : 0;\n}\n\n/**\n * Schreibt einen Snapshot-Wert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param timeframe Der Zeitraum (today, month, year).\n * @param power Der zu sichernde Stromwert.\n * @param thermal Der zu sichernde W\u00E4rmewert.\n */\nasync function setSnapshot(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttimeframe: string,\n\tpower: number,\n\tthermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;\n\n\tawait ensureCopObject(adapter, powerId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Power Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, thermalId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Thermal Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\n\tawait adapter.setState(powerId, { val: power, ack: true });\n\tawait adapter.setState(thermalId, { val: thermal, ack: true });\n}\n\n/**\n * Verwaltet einen rollierenden 7-Tage-Speicher als JSON.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param currentPower Der absolute Stromz\u00E4hler.\n * @param currentThermal Der absolute W\u00E4rmez\u00E4hler.\n */\nasync function update7DaysHistory(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tcurrentPower: number,\n\tcurrentThermal: number,\n): Promise<void> {\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tawait ensureCopObject(adapter, historyId, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} 7 Days History`, type: 'string', role: 'json', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(historyId);\n\tlet history: { power: number; thermal: number }[] = [];\n\n\tif (state && typeof state.val === 'string' && state.val !== '') {\n\t\ttry {\n\t\t\thistory = JSON.parse(state.val);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n\n\thistory.push({ power: currentPower, thermal: currentThermal });\n\tif (history.length > 7) {\n\t\thistory.shift(); // \u00C4ltesten Eintrag entfernen (Ringpuffer)\n\t}\n\n\tawait adapter.setState(historyId, { val: JSON.stringify(history), ack: true });\n}\n\n/**\n * Addiert die neuen kWh-Deltas auf die internen Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die zu aktualisierende Kategorie.\n * @param deltaPower Die verbrauchte elektrische Energie.\n * @param deltaThermal Die erzeugte thermische Energie.\n */\nasync function addDeltaToBucket(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tdeltaPower: number,\n\tdeltaThermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_absolute`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_absolute`;\n\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tawait adapter.setState(powerId, { val: currentPower + deltaPower, ack: true });\n\tawait adapter.setState(thermalId, { val: currentThermal + deltaThermal, ack: true });\n}\n\n/**\n * Liest die Endlosz\u00E4hler und Snapshots aus, berechnet die Differenz und schreibt den COP.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die auszulesende Kategorie (Total, Heating, HotWater).\n */\nasync function calculateAndWriteCop(adapter: LuxtronikAdapter, category: string): Promise<void> {\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tconst dpMap: Record<string, Record<string, string>> = {\n\t\tTotal: { today: 'cop_total_today', '7d': 'cop_total_7d', month: 'cop_total_month', year: 'cop_total_year' },\n\t\tHeating: {\n\t\t\ttoday: 'cop_heating_today',\n\t\t\t'7d': 'cop_heating_7d',\n\t\t\tmonth: 'cop_heating_month',\n\t\t\tyear: 'cop_heating_year',\n\t\t},\n\t\tHotWater: { today: 'cop_water_today', '7d': 'cop_water_7d', month: 'cop_water_month', year: 'cop_water_year' },\n\t};\n\n\t// 1. Berechnung f\u00FCr Heute, Monat, Jahr\n\tconst timeframes = ['today', 'month', 'year'];\n\tfor (const tf of timeframes) {\n\t\tconst powerStartId = `hidden.cop_buckets.${category}_power_start_${tf}`;\n\t\tconst thermalStartId = `hidden.cop_buckets.${category}_thermal_start_${tf}`;\n\n\t\tconst pState = await adapter.getStateAsync(powerStartId);\n\t\tconst tState = await adapter.getStateAsync(thermalStartId);\n\n\t\tconst pStart = pState && typeof pState.val === 'number' ? pState.val : currentPower;\n\t\tconst tStart = tState && typeof tState.val === 'number' ? tState.val : currentThermal;\n\n\t\tconst pUsed = currentPower - pStart;\n\t\tconst tGen = currentThermal - tStart;\n\n\t\tlet cop = 0;\n\t\tif (pUsed > 0) {\n\t\t\tcop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t}\n\n\t\tconst targetId = getDpPath(dpMap[category][tf]);\n\t\tif (targetId) {\n\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t}\n\t}\n\n\t// 2. Berechnung f\u00FCr rollierende 7 Tage\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tconst hState = await adapter.getStateAsync(historyId);\n\tif (hState && typeof hState.val === 'string' && hState.val !== '') {\n\t\ttry {\n\t\t\tconst history = JSON.parse(hState.val);\n\t\t\tif (history.length > 0) {\n\t\t\t\tconst oldest = history[0];\n\t\t\t\tconst pUsed = currentPower - oldest.power;\n\t\t\t\tconst tGen = currentThermal - oldest.thermal;\n\n\t\t\t\tlet cop = 0;\n\t\t\t\tif (pUsed > 0) {\n\t\t\t\t\tcop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\t\t}\n\n\t\t\t\tconst targetId = getDpPath(dpMap[category]['7d']);\n\t\t\t\tif (targetId) {\n\t\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAG1B,IAAI,gBAAgB;AAEpB,MAAM,iBAAiB,oBAAI,IAAY;AASvC,eAAe,gBAAgB,SAA2B,IAAY,KAA6C;AAClH,MAAI,eAAe,IAAI,EAAE,GAAG;AAC3B;AAAA,EACD;AACA,QAAM,QAAQ,wBAAwB,IAAI,GAAG;AAC7C,iBAAe,IAAI,EAAE;AACtB;AASA,eAAsB,eAAe,SAA2B,OAA8B;AAC7F,QAAM,SAAS,QAAQ;AACvB,MAAI,CAAC,OAAO,wBAAwB;AACnC;AAAA,EACD;AAEA,MAAI;AACH,gCAAS,iCAAiC,KAAK,IAAI,OAAO;AAE1D,UAAM,kBAAkB,OAAO,qBAAqB,cAAc,QAAQ,OAAO,mBAAmB;AACpG,UAAM,oBAAoB,OAAO,uBAAuB,cAAc,QAAQ,OAAO,qBAAqB;AAG1G,QAAI,oBAAoB;AACxB,QAAI,sBAAsB;AAC1B,QAAI,oBAAoB;AAExB,QAAI,iBAAiB;AACpB,YAAM,QAAQ,MAAM,QAAQ,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= false;
63
63
  /** Timestamp tracking the last dynamic pump voltage optimization execution */
64
64
  lastPumpOptimization = 0;
65
+ /** Merkt sich, ob Takt-Optimierung oder Zwangsheizen aktuell über den flüchtigen SHI-Modbus-Offset (+10 K) aktiv ist */
66
+ forcedHeatingShiActive = false;
65
67
  /** Internal array storing pending serial hardware write tasks */
66
68
  writeQueue = [];
67
69
  /** Lock flag indicating that the write queue is currently being processed */
@@ -234,19 +236,21 @@ class Luxtronik2Controller extends utils.Adapter {
234
236
  const cycleTotalState = await this.getStateAsync((0, import_stateMapping.getDpPath)("write_cycles_total"));
235
237
  this.writeCyclesTotal = cycleTotalState && typeof cycleTotalState.val === "number" ? cycleTotalState.val : 0;
236
238
  this.scheduleMidnightReset();
237
- if (!isReadOnly) {
238
- await (0, import_zipManager.disableHardwareZipTimer)(this);
239
- (0, import_zipManager.subscribeMotionSensors)(this);
240
- await (0, import_pvManager.initPvManagement)(this);
241
- }
242
- this.subscribeStates("*");
243
239
  this.modbusManager = new import_modbusManager.ModbusManager(this);
244
240
  if (!isReadOnly && config.modbus_active) {
245
241
  (0, import_logger.writeLog)("Checking Modbus TCP availability for hybrid operations...", "info");
246
242
  await this.modbusManager.checkAvailability();
247
243
  }
244
+ if (!isReadOnly) {
245
+ (0, import_zipManager.subscribeMotionSensors)(this);
246
+ await (0, import_pvManager.initPvManagement)(this);
247
+ }
248
+ this.subscribeStates("*");
248
249
  try {
249
250
  await this.updateData();
251
+ if (!isReadOnly) {
252
+ await (0, import_zipManager.disableHardwareZipTimer)(this);
253
+ }
250
254
  } catch (error) {
251
255
  this.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);
252
256
  }
@@ -404,6 +408,82 @@ class Luxtronik2Controller extends utils.Adapter {
404
408
  (0, import_logger.writeLog)(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, "error");
405
409
  }
406
410
  }
411
+ /**
412
+ * Prüft, ob das moderne V3.9x Smart Home Interface (SHI) per Modbus TCP aktiv und erreichbar ist.
413
+ */
414
+ isShiModbusActive() {
415
+ const config = this.config;
416
+ return Boolean(
417
+ config.operation_mode !== "readonly" && config.modbus_active && this.modbusManager && this.modbusManager.isAvailable && this.modbusManager.protocolVersion === "shi" && config.sync_modbus_holding_23 === true
418
+ );
419
+ }
420
+ /**
421
+ * Aktiviert eine temporäre Heizungsanhebung (Takt-Optimierung, Vorheizen oder Zwangsheizen).
422
+ * Nutzt im V3.9x-SHI-Modus flüchtiges Modbus-RAM (+10.0 K über Holding 23 -> SHI 10002),
423
+ * sonst wie bisher den Heizkurven-Fußpunkt (35 °C).
424
+ *
425
+ * @param reason - Optionaler Kontext für das Debug-Log.
426
+ */
427
+ async activateForcedHeatingBoost(reason = "CycleOpt") {
428
+ if (this.isShiModbusActive()) {
429
+ if (!this.forcedHeatingShiActive) {
430
+ await this.modbusManager.writeRegister(23, 100, false);
431
+ this.forcedHeatingShiActive = true;
432
+ const dpHeatingTemp = (0, import_stateMapping.getDpPath)("heating_temperature");
433
+ if (dpHeatingTemp) {
434
+ await this.setOwnStateIfDifferent(dpHeatingTemp, 10, true);
435
+ }
436
+ if (this.isDebugLogActive) {
437
+ (0, import_logger.writeLog)(
438
+ `[${reason}] SHI Modbus active: Setting volatile heating offset to +10.0 K (Holding 23 -> SHI 10002, 0 EEPROM writes).`,
439
+ "info"
440
+ );
441
+ }
442
+ }
443
+ return;
444
+ }
445
+ await this.syncConfigValue("heating_curve_parallel_offset", 35);
446
+ }
447
+ /**
448
+ * Setzt eine aktive temporäre Heizungsanhebung sauber zurück.
449
+ * Im SHI-Modus wird der flüchtige Offset auf den Basiswert zurückgesetzt und ein aktiver PV-Boost optional wiederhergestellt.
450
+ *
451
+ * @param reapplyPv - Stellt bei aktivem PV-Boost dessen Sollwert im Anschluss sofort wieder her.
452
+ */
453
+ async resetForcedHeatingBoost(reapplyPv = true) {
454
+ var _a, _b;
455
+ const config = this.config;
456
+ if (this.isShiModbusActive()) {
457
+ const heatingTempState = await this.getStateAsync((0, import_stateMapping.getDpPath)("heating_temperature"));
458
+ const isShiOffsetStuckHigh = typeof (heatingTempState == null ? void 0 : heatingTempState.val) === "number" && heatingTempState.val >= 10;
459
+ if (!this.forcedHeatingShiActive && !isShiOffsetStuckHigh) {
460
+ return;
461
+ }
462
+ this.forcedHeatingShiActive = false;
463
+ const baseOffset = Number((_a = config.sync_heating_temperature) != null ? _a : 0);
464
+ await this.modbusManager.writeRegister(23, Math.round(baseOffset * 10), false);
465
+ const dpHeatingTemp = (0, import_stateMapping.getDpPath)("heating_temperature");
466
+ if (dpHeatingTemp) {
467
+ await this.setOwnStateIfDifferent(dpHeatingTemp, baseOffset, true);
468
+ }
469
+ if (this.isDebugLogActive) {
470
+ (0, import_logger.writeLog)(
471
+ `[CycleOpt] SHI Modbus active: Resetting volatile heating offset back to ${baseOffset} K (Holding 23 -> SHI 10002).`,
472
+ "info"
473
+ );
474
+ }
475
+ if (reapplyPv && import_pvManager.pvIsBoostActive) {
476
+ await (0, import_pvManager.evaluatePvBoost)(this, true);
477
+ }
478
+ return;
479
+ }
480
+ const fusspunktState = await this.getStateAsync((0, import_stateMapping.getDpPath)("heating_curve_parallel_offset"));
481
+ const currentFusspunkt = typeof (fusspunktState == null ? void 0 : fusspunktState.val) === "number" ? fusspunktState.val : this.currentRawParams[12] !== void 0 ? this.currentRawParams[12] / 10 : 0;
482
+ if (currentFusspunkt === 35) {
483
+ const fallbackFusspunkt = (_b = config.fusspunkt) != null ? _b : 21.7;
484
+ await this.syncConfigValue("heating_curve_parallel_offset", fallbackFusspunkt);
485
+ }
486
+ }
407
487
  /**
408
488
  * Configures fallback factory parameter baselines for the heat pump when in an idle state.
409
489
  *
@@ -413,17 +493,22 @@ class Luxtronik2Controller extends utils.Adapter {
413
493
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
414
494
  try {
415
495
  const config = this.config;
416
- await this.syncConfigValue("heating_curve_end_point", (_a = config.endpunkt) != null ? _a : 23);
417
- await this.syncConfigValue("heating_curve_parallel_offset", (_b = config.fusspunkt) != null ? _b : 21.7);
496
+ await this.resetForcedHeatingBoost(false);
497
+ if (!this.isShiModbusActive()) {
498
+ await this.syncConfigValue("heating_curve_end_point", (_a = config.endpunkt) != null ? _a : 23);
499
+ await this.syncConfigValue("heating_curve_parallel_offset", (_b = config.fusspunkt) != null ? _b : 21.7);
500
+ }
418
501
  await this.syncConfigValue("heating_temperature", (_c = config.sync_heating_temperature) != null ? _c : 0);
419
- await this.syncConfigValue(
420
- "heating_system_circ_pump_voltage_minimal",
421
- (_d = config.sync_heating_system_circ_pump_voltage_minimal_heating) != null ? _d : 3
422
- );
423
- await this.syncConfigValue(
424
- "heating_system_circ_pump_voltage_nominal",
425
- (_e = config.sync_heating_system_circ_pump_voltage_nominal_heating) != null ? _e : 7
426
- );
502
+ if (config.hup_optimierung_aktiv === true) {
503
+ await this.syncConfigValue(
504
+ "heating_system_circ_pump_voltage_minimal",
505
+ (_d = config.sync_heating_system_circ_pump_voltage_minimal_heating) != null ? _d : 3
506
+ );
507
+ await this.syncConfigValue(
508
+ "heating_system_circ_pump_voltage_nominal",
509
+ (_e = config.sync_heating_system_circ_pump_voltage_nominal_heating) != null ? _e : 7
510
+ );
511
+ }
427
512
  await this.syncConfigValue("temperature_hot_water_target", (_f = config.sync_warmwater_target_temperature) != null ? _f : 54);
428
513
  await this.syncConfigValue("returnTemperatureHysteresis", (_g = config.sync_return_temperature_hysteresis) != null ? _g : 1.5);
429
514
  await this.syncConfigValue("zip_aktiv", (_h = config.zip_aktiv) != null ? _h : 0);
@@ -459,7 +544,7 @@ class Luxtronik2Controller extends utils.Adapter {
459
544
  * @returns A promise that resolves when the execution cycle finishes.
460
545
  */
461
546
  async runOptimizationSchedule(rawValues = [], rawParams = []) {
462
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
547
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
463
548
  try {
464
549
  const config = this.config;
465
550
  if (config.operation_mode === "readonly") {
@@ -480,6 +565,8 @@ class Luxtronik2Controller extends utils.Adapter {
480
565
  if (istLeerlauf) {
481
566
  if (config.idle_defaults_aktiv === true) {
482
567
  await this.setIdleDefaults();
568
+ } else if (this.forcedHeatingShiActive) {
569
+ await this.resetForcedHeatingBoost();
483
570
  }
484
571
  } else if (istHeizen) {
485
572
  if (this.lastBzVal === "1" && config.idle_defaults_aktiv === true) {
@@ -586,12 +673,7 @@ class Luxtronik2Controller extends utils.Adapter {
586
673
  const nachWasser = Boolean(nachWasserState == null ? void 0 : nachWasserState.val);
587
674
  if (istHeizen) {
588
675
  if (aelterAls10 && vd1) {
589
- const fusspunktState = await this.getStateAsync((0, import_stateMapping.getDpPath)("heating_curve_parallel_offset"));
590
- const currentFusspunkt = typeof (fusspunktState == null ? void 0 : fusspunktState.val) === "number" ? fusspunktState.val : rawParams[13] !== void 0 ? rawParams[13] / 10 : 0;
591
- if (currentFusspunkt === 35) {
592
- const fallbackFusspunkt = (_k = config.fusspunkt) != null ? _k : 21.7;
593
- await this.syncConfigValue("heating_curve_parallel_offset", fallbackFusspunkt);
594
- }
676
+ await this.resetForcedHeatingBoost();
595
677
  }
596
678
  if (aelterAls10 && vd1) {
597
679
  this.lastPumpOptimization = await (0, import_hupManager.handleHupOptimization)(
@@ -629,7 +711,7 @@ class Luxtronik2Controller extends utils.Adapter {
629
711
  const isHeatingAllowedByLimit = !isHeatingLimitEnabled || mitteltemperatur < thresholdHeatingLimit;
630
712
  if (istWarmwasser && nachWasser) {
631
713
  if (isRegelungAktiv && isHeatingAllowedByLimit) {
632
- await this.syncConfigValue("heating_curve_parallel_offset", 35);
714
+ await this.activateForcedHeatingBoost("CycleOpt-AfterWW");
633
715
  }
634
716
  }
635
717
  if (istLeerlauf) {
@@ -642,11 +724,11 @@ class Luxtronik2Controller extends utils.Adapter {
642
724
  if (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll && isHeatingAllowedByLimit) {
643
725
  if (this.isDebugLogActive) {
644
726
  (0, import_logger.writeLog)(
645
- `[CycleOpt] Pre-starting heating before WW (WW: ${wwIst}/${wwSoll}\xB0C, Hyst: ${wwHysterese}K, RL: ${ruecklauf}/${ruecklaufSoll}\xB0C). Setting base point to 35\xB0C.`,
727
+ `[CycleOpt] Pre-starting heating before WW (WW: ${wwIst}/${wwSoll}\xB0C, Hyst: ${wwHysterese}K, RL: ${ruecklauf}/${ruecklaufSoll}\xB0C).`,
646
728
  "info"
647
729
  );
648
730
  }
649
- await this.syncConfigValue("heating_curve_parallel_offset", 35);
731
+ await this.activateForcedHeatingBoost("CycleOpt-PreHeat");
650
732
  }
651
733
  }
652
734
  }