iobroker.luxtronik2-controller 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -17
- package/admin/jsonConfig.json +146 -0
- package/build/copManager.js +107 -55
- package/build/copManager.js.map +2 -2
- package/build/main.js +80 -29
- package/build/main.js.map +2 -2
- package/io-package.json +29 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
|
|
14
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.
|
|
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
|
+
|
|
16
18
|
## Acknowledgements & History
|
|
17
19
|
|
|
18
20
|
This project builds upon the preliminary work of existing open-source projects. Special thanks go to:
|
|
@@ -22,6 +24,10 @@ This project builds upon the preliminary work of existing open-source projects.
|
|
|
22
24
|
- **[UncleSamSwiss](https://github.com/UncleSamSwiss/ioBroker.luxtronik2):** For the original ioBroker adapter.
|
|
23
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)_
|
|
24
26
|
|
|
27
|
+
> **💡 No LAN cable near your heat pump? No problem!**
|
|
28
|
+
> 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
|
+
> 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
|
+
|
|
25
31
|
**Innovations in this version:**
|
|
26
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.
|
|
27
33
|
|
|
@@ -96,6 +102,22 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
96
102
|
//### **WORK IN PROGRESS**
|
|
97
103
|
|
|
98
104
|
## Changelog
|
|
105
|
+
### 0.24.0 (2026-11-09)
|
|
106
|
+
|
|
107
|
+
**🐛 Bugfixes & Tweaks**
|
|
108
|
+
|
|
109
|
+
- **Operating Mode & Write Protection (`jsonConfig.json`, `main.ts`):**
|
|
110
|
+
- **Explicit Operating Mode Selection:** Added a central "Operating Mode" selector in the Connection tab with color-coded status banners to clearly distinguish between **Read-Only (Monitoring)**, **Read & Write without Modbus (Native via Port 8889)**, and **Read & Write with Modbus TCP (Hybrid RAM access)**.
|
|
111
|
+
- **Dynamic UI Locking:** When "Read-Only" is selected, all write-related configuration tabs (Modbus, Idle Defaults, Cycle Optimization, HUP, ZIP, and PV Surplus) and their inputs are automatically grayed out and disabled. Selecting native write mode unlocks the optimization tabs while keeping the Modbus tab disabled.
|
|
112
|
+
- **Strict Backend Write Lock:** Enforced a global hardware write lock in Read-Only mode across `onReady`, `syncConfigValue`, `runOptimizationSchedule`, and `onStateChange` (while keeping diagnostic functions like debug logging, raw dumps, and firmware checks active).
|
|
113
|
+
- **Automatic Config Migration:** Existing installations are seamlessly migrated on startup to the matching operating mode based on their previously active Modbus and optimization settings.
|
|
114
|
+
|
|
115
|
+
### 0.23.2 (2026-11-07)
|
|
116
|
+
|
|
117
|
+
- **COP & Efficiency Calculation (`copManager.ts`):**
|
|
118
|
+
- **Isolated Counter Tracking:** Introduced dedicated reference states for Total, Heating, and Hot Water counters (`last_raw_power_*` and `last_raw_thermal_*`). Each counter is now compared strictly against its own previous value, completely preventing cross-mode "ghost deltas" and astronomical COP spikes during cycle transitions.
|
|
119
|
+
- **Automatic Total-Delta Fallback:** Added seamless fallback detection for controllers with firmware bugs (e.g., Novelan LAV) where mode-specific counters like `energy_warmwater` remain permanently at `0`. If a specific counter reports a delta of `0` during an active cycle, the adapter automatically uses the live delta of the corresponding total counter (`energy_total` / `thermalenergy_total`) without requiring manual configuration workarounds.
|
|
120
|
+
|
|
99
121
|
### 0.23.1 (2026-11-07)
|
|
100
122
|
|
|
101
123
|
- **COP & Efficiency Calculation Fix (`copManager.ts`):**
|
|
@@ -120,23 +142,6 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
120
142
|
- **Smart Delta Routing:** When the heat pump is actively generating hot water (`WP_BZ_akt === 1`), the COP manager now checks if the internal DHW power meter is stuck at zero. If so, it automatically intercepts the delta from the total energy meter (`energy_total`) over the last polling interval and securely routes it into the Hot Water COP bucket.
|
|
121
143
|
- **Continuous Standby Sync:** Enhanced the database tracking to ensure the total energy fallback counter is continuously synced even during standby or heating modes. This prevents idle power consumption from accumulating in the background and falsely distorting the next hot water efficiency calculation.
|
|
122
144
|
|
|
123
|
-
### 0.22.7 (2026-11-07)
|
|
124
|
-
|
|
125
|
-
**🐛 Bugfixes**
|
|
126
|
-
|
|
127
|
-
- **PV Surplus Management & Cycle Optimization:**
|
|
128
|
-
- **Zero-Drift Baseline Calculation:** Rewrote the PV boost baseline logic in `pvManager.ts`. The adapter no longer reads live datapoint states to calculate the boost, but strictly enforces the configured baseline values (`sync_warmwater_target_temperature` and `0K` for heating). This permanently resolves the "snowball effect" where the hot water target could incrementally drift up to the 70 °C safety limit.
|
|
129
|
-
- **Cycle Coupling Handshake:** Enhanced the intelligent cycle optimization (`main.ts`) during active PV surplus. At the end of a heating cycle, the adapter now seamlessly couples a hot water cycle and intelligently enforces the PV boost target (e.g., 60 °C) to maximize solar self-consumption, without interfering with the strict baseline logic.
|
|
130
|
-
|
|
131
|
-
### 0.22.6 (2026-11-05)
|
|
132
|
-
|
|
133
|
-
**🐛 Bugfixes**
|
|
134
|
-
|
|
135
|
-
- **Cycle Optimization & Hardware Sync (`main.ts`):**
|
|
136
|
-
- **Pre-Heating & Heating Limit Type Fix:** Fixed strict type comparison bugs (`boolean` vs. `number`) when evaluating `heatingLimit` and `VD1out` (`vd1`). Previously, boolean state values caused `isHeatingAllowedByLimit` and `vd1` to evaluate to `false`, which blocked pre-heating before hot water generation (raising `heating_curve_parallel_offset` to 35 °C), prevented the 10-minute base point reset, and skipped HUP voltage optimization.
|
|
137
|
-
- **Raw Data Fallbacks (`rawValues` / `rawParams`):** Added direct fallbacks to raw heat pump telemetry and parameter arrays in `runOptimizationSchedule` so cycle optimization, HUP control, and heating limit checks remain fully functional even if individual datapoints (`thresholdHeatingLimit`, `Mitteltemperatur`, `heatingLimit`, `VD1out`, etc.) are disabled in the ioBroker object tree.
|
|
138
|
-
- **Hardware Out-of-Sync Verification:** Enhanced `syncConfigValue` to verify target values against the live hardware parameter cache (`currentRawParams`), ensuring parameters are reliably written to the controller even if the local ioBroker state is disabled or out of sync with the heat pump.
|
|
139
|
-
|
|
140
145
|
## License
|
|
141
146
|
|
|
142
147
|
MIT License
|
package/admin/jsonConfig.json
CHANGED
|
@@ -88,6 +88,137 @@
|
|
|
88
88
|
"lg": 12,
|
|
89
89
|
"xl": 12
|
|
90
90
|
},
|
|
91
|
+
"divider_operation_mode": {
|
|
92
|
+
"type": "divider",
|
|
93
|
+
"color": "primary",
|
|
94
|
+
"style": {
|
|
95
|
+
"marginBottom": "15px",
|
|
96
|
+
"marginTop": "15px"
|
|
97
|
+
},
|
|
98
|
+
"xs": 12,
|
|
99
|
+
"sm": 12,
|
|
100
|
+
"md": 12,
|
|
101
|
+
"lg": 12,
|
|
102
|
+
"xl": 12
|
|
103
|
+
},
|
|
104
|
+
"headerOperationMode": {
|
|
105
|
+
"type": "header",
|
|
106
|
+
"text": {
|
|
107
|
+
"en": "Operating Mode & Hardware Write Access",
|
|
108
|
+
"de": "Betriebsmodus & Hardware-Schreibzugriff"
|
|
109
|
+
},
|
|
110
|
+
"size": 4,
|
|
111
|
+
"xs": 12,
|
|
112
|
+
"sm": 12,
|
|
113
|
+
"md": 12,
|
|
114
|
+
"lg": 12,
|
|
115
|
+
"xl": 12
|
|
116
|
+
},
|
|
117
|
+
"operation_mode": {
|
|
118
|
+
"type": "select",
|
|
119
|
+
"label": {
|
|
120
|
+
"en": "Select Operating Mode",
|
|
121
|
+
"de": "Betriebsmodus auswählen"
|
|
122
|
+
},
|
|
123
|
+
"options": [
|
|
124
|
+
{
|
|
125
|
+
"label": {
|
|
126
|
+
"en": "🔒 Read-Only (Monitoring only – 0% flash wear, all optimizations disabled)",
|
|
127
|
+
"de": "🔒 Nur Lesend (Reines Monitoring – 0% Flash-Verschleiß, alle Optimierungen deaktiviert)"
|
|
128
|
+
},
|
|
129
|
+
"value": "readonly"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"label": {
|
|
133
|
+
"en": "✍️ Read & Write: Without Modbus (Native via Port 8889 – writes to EEPROM)",
|
|
134
|
+
"de": "✍️ Schreibend: Ohne Modbus (Nativ über Port 8889 – schreibt in EEPROM)"
|
|
135
|
+
},
|
|
136
|
+
"value": "native"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"label": {
|
|
140
|
+
"en": "⚡ Read & Write: With Modbus TCP (Hybrid – wear-free RAM access)",
|
|
141
|
+
"de": "⚡ Schreibend: Mit Modbus TCP (Hybrid – verschleißfreier RAM-Zugriff)"
|
|
142
|
+
},
|
|
143
|
+
"value": "modbus"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"default": "readonly",
|
|
147
|
+
"xs": 12,
|
|
148
|
+
"sm": 12,
|
|
149
|
+
"md": 12,
|
|
150
|
+
"lg": 12,
|
|
151
|
+
"xl": 12
|
|
152
|
+
},
|
|
153
|
+
"infoModeReadonly": {
|
|
154
|
+
"type": "staticText",
|
|
155
|
+
"text": {
|
|
156
|
+
"en": "🔒 <b>Read-Only Mode active:</b> The adapter only reads telemetry and parameters. All write-related tabs (Modbus, Idle Defaults, Cycle Optimization, HUP, ZIP, PV Surplus) are disabled and grayed out. Manual changes in the object tree are blocked.",
|
|
157
|
+
"de": "🔒 <b>Nur-Lesen-Modus aktiv:</b> Der Adapter liest ausschließlich Messwerte und Parameter aus (z.B. für Visualisierungen und COP-Berechnung). Alle schreibenden Reiter (Modbus, Vorgaben, Takt-Optimierung, HUP, ZIP, PV-Überschuss) sind komplett deaktiviert und ausgegraut. Es finden garantiert keine Schreibzugriffe auf die Wärmepumpe statt."
|
|
158
|
+
},
|
|
159
|
+
"hidden": "data.operation_mode !== 'readonly'",
|
|
160
|
+
"style": {
|
|
161
|
+
"marginTop": "10px",
|
|
162
|
+
"marginBottom": "15px",
|
|
163
|
+
"fontSize": "13px",
|
|
164
|
+
"backgroundColor": "#e3f2fd",
|
|
165
|
+
"color": "#0d47a1",
|
|
166
|
+
"padding": "12px",
|
|
167
|
+
"borderRadius": "5px",
|
|
168
|
+
"borderLeft": "5px solid #1976d2"
|
|
169
|
+
},
|
|
170
|
+
"xs": 12,
|
|
171
|
+
"sm": 12,
|
|
172
|
+
"md": 12,
|
|
173
|
+
"lg": 12,
|
|
174
|
+
"xl": 12
|
|
175
|
+
},
|
|
176
|
+
"infoModeNative": {
|
|
177
|
+
"type": "staticText",
|
|
178
|
+
"text": {
|
|
179
|
+
"en": "✍️ <b>Write Mode (Without Modbus / Native Port 8889):</b> Active optimizations and parameter changes are written directly to the Luxtronik EEPROM via port 8889. Please enable 'Idle Defaults' when using optimizations and monitor daily flash write cycles.",
|
|
180
|
+
"de": "✍️ <b>Schreibmodus (Ohne Modbus / Nativ über Port 8889):</b> Aktive Optimierungen (Takt, HUP, ZIP, PV) und Parameter-Änderungen werden direkt über Port 8889 in den EEPROM-Speicher der Luxtronik geschrieben. Der Reiter 'Modbus (Hybrid)' ist deaktiviert."
|
|
181
|
+
},
|
|
182
|
+
"hidden": "data.operation_mode !== 'native'",
|
|
183
|
+
"style": {
|
|
184
|
+
"marginTop": "10px",
|
|
185
|
+
"marginBottom": "15px",
|
|
186
|
+
"fontSize": "13px",
|
|
187
|
+
"backgroundColor": "#fff3e0",
|
|
188
|
+
"color": "#e65100",
|
|
189
|
+
"padding": "12px",
|
|
190
|
+
"borderRadius": "5px",
|
|
191
|
+
"borderLeft": "5px solid #ff9800"
|
|
192
|
+
},
|
|
193
|
+
"xs": 12,
|
|
194
|
+
"sm": 12,
|
|
195
|
+
"md": 12,
|
|
196
|
+
"lg": 12,
|
|
197
|
+
"xl": 12
|
|
198
|
+
},
|
|
199
|
+
"infoModeModbus": {
|
|
200
|
+
"type": "staticText",
|
|
201
|
+
"text": {
|
|
202
|
+
"en": "⚡ <b>Hybrid Mode (Write with Modbus TCP):</b> Volatile parameters (setpoints, offsets, coils) are written directly into the controller's RAM via Modbus TCP without causing EEPROM flash wear. Please select your active registers in the 'Modbus (Hybrid)' tab.",
|
|
203
|
+
"de": "⚡ <b>Hybrid-Modus (Schreibend mit Modbus TCP):</b> Flüchtige Parameter (Sollwerte, Parallelverschiebung, Coils) werden ohne EEPROM-Verschleiß direkt über Modbus TCP in den Arbeitsspeicher (RAM) geschrieben. Bitte wähle im Reiter 'Modbus (Hybrid)' die gewünschten Register aus."
|
|
204
|
+
},
|
|
205
|
+
"hidden": "data.operation_mode !== 'modbus'",
|
|
206
|
+
"style": {
|
|
207
|
+
"marginTop": "10px",
|
|
208
|
+
"marginBottom": "15px",
|
|
209
|
+
"fontSize": "13px",
|
|
210
|
+
"backgroundColor": "#e8f5e9",
|
|
211
|
+
"color": "#1b5e20",
|
|
212
|
+
"padding": "12px",
|
|
213
|
+
"borderRadius": "5px",
|
|
214
|
+
"borderLeft": "5px solid #4caf50"
|
|
215
|
+
},
|
|
216
|
+
"xs": 12,
|
|
217
|
+
"sm": 12,
|
|
218
|
+
"md": 12,
|
|
219
|
+
"lg": 12,
|
|
220
|
+
"xl": 12
|
|
221
|
+
},
|
|
91
222
|
"headerOption": {
|
|
92
223
|
"type": "header",
|
|
93
224
|
"text": {
|
|
@@ -584,6 +715,7 @@
|
|
|
584
715
|
},
|
|
585
716
|
"idleTab": {
|
|
586
717
|
"type": "panel",
|
|
718
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
587
719
|
"label": {
|
|
588
720
|
"en": "Idle Defaults",
|
|
589
721
|
"de": "Vorgaben"
|
|
@@ -632,6 +764,7 @@
|
|
|
632
764
|
"de": "Standardwerte im Leerlauf erzwingen"
|
|
633
765
|
},
|
|
634
766
|
"default": false,
|
|
767
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
635
768
|
"confirm": {
|
|
636
769
|
"condition": "data.idle_defaults_aktiv === true",
|
|
637
770
|
"text": {
|
|
@@ -1011,6 +1144,7 @@
|
|
|
1011
1144
|
},
|
|
1012
1145
|
"cycleOptimizationTab": {
|
|
1013
1146
|
"type": "panel",
|
|
1147
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1014
1148
|
"label": {
|
|
1015
1149
|
"en": "Cycle Optimization",
|
|
1016
1150
|
"de": "Takt-Optimierung"
|
|
@@ -1039,6 +1173,7 @@
|
|
|
1039
1173
|
"en": "Enable intelligent cycle optimization",
|
|
1040
1174
|
"de": "Intelligente Takt-Optimierung aktivieren"
|
|
1041
1175
|
},
|
|
1176
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1042
1177
|
"default": false,
|
|
1043
1178
|
"confirm": {
|
|
1044
1179
|
"condition": "data.regelung_aktiv === true && data.idle_defaults_aktiv !== true",
|
|
@@ -1059,6 +1194,7 @@
|
|
|
1059
1194
|
},
|
|
1060
1195
|
"Heating_after_warmwater": {
|
|
1061
1196
|
"type": "checkbox",
|
|
1197
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1062
1198
|
"label": {
|
|
1063
1199
|
"en": "Heating after hot water",
|
|
1064
1200
|
"de": "Heizen nach Warmwasser erzwingen"
|
|
@@ -1093,6 +1229,7 @@
|
|
|
1093
1229
|
},
|
|
1094
1230
|
"hupTab": {
|
|
1095
1231
|
"type": "panel",
|
|
1232
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1096
1233
|
"label": {
|
|
1097
1234
|
"en": "HUP control",
|
|
1098
1235
|
"de": "HUP Steuerung"
|
|
@@ -1117,6 +1254,7 @@
|
|
|
1117
1254
|
},
|
|
1118
1255
|
"hup_voltage_factor": {
|
|
1119
1256
|
"type": "select",
|
|
1257
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1120
1258
|
"label": {
|
|
1121
1259
|
"en": "Hardware voltage scale",
|
|
1122
1260
|
"de": "Hardware Spannungs-Faktor"
|
|
@@ -1144,6 +1282,7 @@
|
|
|
1144
1282
|
},
|
|
1145
1283
|
"hup_optimierung_aktiv": {
|
|
1146
1284
|
"type": "checkbox",
|
|
1285
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1147
1286
|
"label": {
|
|
1148
1287
|
"en": "Enable dynamic HUP spread control",
|
|
1149
1288
|
"de": "Dynamische HUP-Spreizungsregelung aktivieren"
|
|
@@ -1315,6 +1454,7 @@
|
|
|
1315
1454
|
},
|
|
1316
1455
|
"zipTab": {
|
|
1317
1456
|
"type": "panel",
|
|
1457
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1318
1458
|
"label": {
|
|
1319
1459
|
"en": "Circulation pump",
|
|
1320
1460
|
"de": "ZIP Steuerung"
|
|
@@ -1323,6 +1463,7 @@
|
|
|
1323
1463
|
"items": {
|
|
1324
1464
|
"zip_control_mode": {
|
|
1325
1465
|
"type": "select",
|
|
1466
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1326
1467
|
"label": {
|
|
1327
1468
|
"en": "How is your circulation pump (ZIP) controlled?",
|
|
1328
1469
|
"de": "Wie wird deine Zirkulationspumpe (ZIP) gesteuert?"
|
|
@@ -1440,6 +1581,7 @@
|
|
|
1440
1581
|
},
|
|
1441
1582
|
"zip_lWP_aktiv": {
|
|
1442
1583
|
"type": "checkbox",
|
|
1584
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1443
1585
|
"label": {
|
|
1444
1586
|
"en": "Disable base ZIP values (Set Luxtronik timers to 0)",
|
|
1445
1587
|
"de": "Deaktiviere reguläre ZIP Werte (Luxtronik-Timer auf 0)"
|
|
@@ -1454,6 +1596,7 @@
|
|
|
1454
1596
|
},
|
|
1455
1597
|
"zip_optimierung_aktiv": {
|
|
1456
1598
|
"type": "checkbox",
|
|
1599
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1457
1600
|
"label": {
|
|
1458
1601
|
"en": "Allow ZIP optimization",
|
|
1459
1602
|
"de": "ZIP-Optimierung zulassen"
|
|
@@ -1538,6 +1681,7 @@
|
|
|
1538
1681
|
},
|
|
1539
1682
|
"motion_sensors_aktiv": {
|
|
1540
1683
|
"type": "checkbox",
|
|
1684
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1541
1685
|
"label": {
|
|
1542
1686
|
"en": "Actively use motion sensors",
|
|
1543
1687
|
"de": "Bewegungssensoren aktiv nutzen"
|
|
@@ -1652,6 +1796,7 @@
|
|
|
1652
1796
|
},
|
|
1653
1797
|
"pvTab": {
|
|
1654
1798
|
"type": "panel",
|
|
1799
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1655
1800
|
"label": {
|
|
1656
1801
|
"en": "PV / Surplus",
|
|
1657
1802
|
"de": "PV-Überschuss"
|
|
@@ -1660,6 +1805,7 @@
|
|
|
1660
1805
|
"items": {
|
|
1661
1806
|
"pv_active": {
|
|
1662
1807
|
"type": "checkbox",
|
|
1808
|
+
"disabled": "data.operation_mode === 'readonly'",
|
|
1663
1809
|
"label": {
|
|
1664
1810
|
"en": "Enable PV surplus management",
|
|
1665
1811
|
"de": "PV-Überschusssteuerung aktivieren"
|
package/build/copManager.js
CHANGED
|
@@ -39,81 +39,133 @@ async function processCopData(adapter, bzVal) {
|
|
|
39
39
|
}
|
|
40
40
|
try {
|
|
41
41
|
(0, import_logger.writeLog)(`COP Manager gestartet. Modus: ${bzVal}`, "debug");
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const isExternalPower = config.cop_source_power === "external" && Boolean(config.cop_oid_power_total);
|
|
43
|
+
const isExternalThermal = config.cop_source_thermal === "external" && Boolean(config.cop_oid_thermal_total);
|
|
44
|
+
let currentPowerTotal = 0;
|
|
45
|
+
let currentPowerHeating = 0;
|
|
46
|
+
let currentPowerWater = 0;
|
|
47
|
+
if (isExternalPower) {
|
|
44
48
|
const state = await adapter.getForeignStateAsync(config.cop_oid_power_total);
|
|
45
49
|
if (state && typeof state.val === "number") {
|
|
46
|
-
|
|
50
|
+
currentPowerTotal = state.val;
|
|
47
51
|
}
|
|
48
52
|
} else {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
const [sTotal, sHeat, sWater] = await Promise.all([
|
|
54
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("energy_total")),
|
|
55
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("energy_heating")),
|
|
56
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("energy_warmwater"))
|
|
57
|
+
]);
|
|
58
|
+
if (sTotal && typeof sTotal.val === "number") {
|
|
59
|
+
currentPowerTotal = sTotal.val;
|
|
60
|
+
}
|
|
61
|
+
if (sHeat && typeof sHeat.val === "number") {
|
|
62
|
+
currentPowerHeating = sHeat.val;
|
|
63
|
+
}
|
|
64
|
+
if (sWater && typeof sWater.val === "number") {
|
|
65
|
+
currentPowerWater = sWater.val;
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
|
-
let
|
|
55
|
-
|
|
68
|
+
let currentThermalTotal = 0;
|
|
69
|
+
let currentThermalHeating = 0;
|
|
70
|
+
let currentThermalWater = 0;
|
|
71
|
+
if (isExternalThermal) {
|
|
56
72
|
const state = await adapter.getForeignStateAsync(config.cop_oid_thermal_total);
|
|
57
73
|
if (state && typeof state.val === "number") {
|
|
58
|
-
|
|
74
|
+
currentThermalTotal = state.val;
|
|
59
75
|
}
|
|
60
76
|
} else {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
const [sTotal, sHeat, sWater] = await Promise.all([
|
|
78
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("thermalenergy_total")),
|
|
79
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("thermalenergy_heating")),
|
|
80
|
+
adapter.getStateAsync((0, import_stateMapping.getDpPath)("thermalenergy_warmwater"))
|
|
81
|
+
]);
|
|
82
|
+
if (sTotal && typeof sTotal.val === "number") {
|
|
83
|
+
currentThermalTotal = sTotal.val;
|
|
84
|
+
}
|
|
85
|
+
if (sHeat && typeof sHeat.val === "number") {
|
|
86
|
+
currentThermalHeating = sHeat.val;
|
|
87
|
+
}
|
|
88
|
+
if (sWater && typeof sWater.val === "number") {
|
|
89
|
+
currentThermalWater = sWater.val;
|
|
64
90
|
}
|
|
65
91
|
}
|
|
66
|
-
const
|
|
67
|
-
const
|
|
92
|
+
const rawPowerTotalId = "hidden.cop_buckets.last_raw_power";
|
|
93
|
+
const rawPowerHeatId = "hidden.cop_buckets.last_raw_power_heating";
|
|
94
|
+
const rawPowerWaterId = "hidden.cop_buckets.last_raw_power_water";
|
|
95
|
+
const rawThermalTotalId = "hidden.cop_buckets.last_raw_thermal";
|
|
96
|
+
const rawThermalHeatId = "hidden.cop_buckets.last_raw_thermal_heating";
|
|
97
|
+
const rawThermalWaterId = "hidden.cop_buckets.last_raw_thermal_water";
|
|
98
|
+
const rawTrackers = [
|
|
99
|
+
{ id: rawPowerTotalId, name: "Last Raw Power Total", current: currentPowerTotal },
|
|
100
|
+
{ id: rawPowerHeatId, name: "Last Raw Power Heating", current: currentPowerHeating },
|
|
101
|
+
{ id: rawPowerWaterId, name: "Last Raw Power Water", current: currentPowerWater },
|
|
102
|
+
{ id: rawThermalTotalId, name: "Last Raw Thermal Total", current: currentThermalTotal },
|
|
103
|
+
{ id: rawThermalHeatId, name: "Last Raw Thermal Heating", current: currentThermalHeating },
|
|
104
|
+
{ id: rawThermalWaterId, name: "Last Raw Thermal Water", current: currentThermalWater }
|
|
105
|
+
];
|
|
68
106
|
if (!isInitialized) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const lastPowerStateInit = await adapter.getStateAsync(rawPowerId);
|
|
80
|
-
const lastThermalStateInit = await adapter.getStateAsync(rawThermalId);
|
|
81
|
-
if (!lastPowerStateInit || lastPowerStateInit.val === null) {
|
|
82
|
-
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
83
|
-
}
|
|
84
|
-
if (!lastThermalStateInit || lastThermalStateInit.val === null) {
|
|
85
|
-
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
107
|
+
for (const tracker of rawTrackers) {
|
|
108
|
+
await ensureCopObject(adapter, tracker.id, {
|
|
109
|
+
type: "state",
|
|
110
|
+
common: { name: tracker.name, type: "number", role: "value", read: true, write: false },
|
|
111
|
+
native: {}
|
|
112
|
+
});
|
|
113
|
+
const stateInit = await adapter.getStateAsync(tracker.id);
|
|
114
|
+
if (!stateInit || stateInit.val === null) {
|
|
115
|
+
await adapter.setState(tracker.id, { val: tracker.current, ack: true });
|
|
116
|
+
}
|
|
86
117
|
}
|
|
87
118
|
isInitialized = true;
|
|
88
119
|
await handleTimeRollover(adapter);
|
|
89
120
|
return;
|
|
90
121
|
}
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (deltaThermal > 0) {
|
|
107
|
-
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
108
|
-
}
|
|
122
|
+
const readAndCalcDelta = async (id, currentVal) => {
|
|
123
|
+
const lastState = await adapter.getStateAsync(id);
|
|
124
|
+
const lastVal = lastState && typeof lastState.val === "number" ? lastState.val : currentVal;
|
|
125
|
+
const delta = Math.max(0, currentVal - lastVal);
|
|
126
|
+
if (currentVal !== lastVal) {
|
|
127
|
+
await adapter.setState(id, { val: currentVal, ack: true });
|
|
128
|
+
}
|
|
129
|
+
return delta;
|
|
130
|
+
};
|
|
131
|
+
const deltaPowerTotal = await readAndCalcDelta(rawPowerTotalId, currentPowerTotal);
|
|
132
|
+
const deltaPowerHeating = await readAndCalcDelta(rawPowerHeatId, currentPowerHeating);
|
|
133
|
+
const deltaPowerWater = await readAndCalcDelta(rawPowerWaterId, currentPowerWater);
|
|
134
|
+
const deltaThermalTotal = await readAndCalcDelta(rawThermalTotalId, currentThermalTotal);
|
|
135
|
+
const deltaThermalHeating = await readAndCalcDelta(rawThermalHeatId, currentThermalHeating);
|
|
136
|
+
const deltaThermalWater = await readAndCalcDelta(rawThermalWaterId, currentThermalWater);
|
|
109
137
|
await handleTimeRollover(adapter);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
let modeDeltaPower = 0;
|
|
139
|
+
let modeDeltaThermal = 0;
|
|
140
|
+
if (bzVal === "0" || bzVal === "4") {
|
|
141
|
+
modeDeltaPower = isExternalPower ? deltaPowerTotal : deltaPowerHeating > 0 ? deltaPowerHeating : deltaPowerTotal;
|
|
142
|
+
modeDeltaThermal = isExternalThermal ? deltaThermalTotal : deltaThermalHeating > 0 ? deltaThermalHeating : deltaThermalTotal;
|
|
143
|
+
if (modeDeltaPower > 0 || modeDeltaThermal > 0) {
|
|
144
|
+
await addDeltaToBucket(adapter, "Heating", modeDeltaPower, modeDeltaThermal);
|
|
116
145
|
}
|
|
146
|
+
} else if (bzVal === "1") {
|
|
147
|
+
modeDeltaPower = isExternalPower ? deltaPowerTotal : deltaPowerWater > 0 ? deltaPowerWater : deltaPowerTotal;
|
|
148
|
+
modeDeltaThermal = isExternalThermal ? deltaThermalTotal : deltaThermalWater > 0 ? deltaThermalWater : deltaThermalTotal;
|
|
149
|
+
if (!isExternalPower && deltaPowerWater === 0 && deltaPowerTotal > 0) {
|
|
150
|
+
(0, import_logger.writeLog)(
|
|
151
|
+
`[COP] WW-Stromz\xE4hler meldet 0 Delta. Nutze Delta von energy_total (${deltaPowerTotal} kWh) als Fallback.`,
|
|
152
|
+
"debug"
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (!isExternalThermal && deltaThermalWater === 0 && deltaThermalTotal > 0) {
|
|
156
|
+
(0, import_logger.writeLog)(
|
|
157
|
+
`[COP] WW-W\xE4rmez\xE4hler meldet 0 Delta. Nutze Delta von thermalenergy_total (${deltaThermalTotal} kWh) als Fallback.`,
|
|
158
|
+
"debug"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
if (modeDeltaPower > 0 || modeDeltaThermal > 0) {
|
|
162
|
+
await addDeltaToBucket(adapter, "HotWater", modeDeltaPower, modeDeltaThermal);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const totalBucketPower = deltaPowerTotal > 0 ? deltaPowerTotal : modeDeltaPower;
|
|
166
|
+
const totalBucketThermal = deltaThermalTotal > 0 ? deltaThermalTotal : modeDeltaThermal;
|
|
167
|
+
if (totalBucketPower > 0 || totalBucketThermal > 0) {
|
|
168
|
+
await addDeltaToBucket(adapter, "Total", totalBucketPower, totalBucketThermal);
|
|
117
169
|
}
|
|
118
170
|
await calculateAndWriteCop(adapter, "Total");
|
|
119
171
|
await calculateAndWriteCop(adapter, "Heating");
|