iobroker.luxtronik2-controller 0.21.0 → 0.21.1
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 +10 -7
- package/build/copManager.js +18 -7
- package/build/copManager.js.map +2 -2
- package/build/main.js +6 -10
- package/build/main.js.map +2 -2
- package/build/objectManager.js +3 -3
- package/build/objectManager.js.map +1 -1
- package/build/pvManager.js +59 -57
- package/build/pvManager.js.map +2 -2
- package/build/zipManager.js +15 -15
- package/build/zipManager.js.map +2 -2
- package/io-package.json +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,16 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
96
96
|
//### **WORK IN PROGRESS**
|
|
97
97
|
|
|
98
98
|
## Changelog
|
|
99
|
+
### 0.21.1 (2026-10-26)
|
|
100
|
+
|
|
101
|
+
**🐛 Bugfixes & Tweaks**
|
|
102
|
+
|
|
103
|
+
- **PV Manager Target & Offset Fixes:** Fixed remaining references to the read-only `Wamwassertemperatur_Soll` datapoint in `activateBoost` and `deactivateBoost` (now consistently targeting `temperature_hot_water_target`). Resolved a baseline mix-up where `fusspunkt` was mistakenly applied to the parallel offset (`heating_temperature`), and fixed the heating saturation check (`isHzFull`) to compare actual return temperature against target return + hysteresis without prematurely revoking active boosts.
|
|
104
|
+
- **Cycle Optimization & Heating Limit:** Replaced the language-dependent `'Heating limit'` string check during idle with a reliable numerical evaluation of the heating limit parameters. Added a `!pvIsBoostActive` guard to prevent forced hot water triggers from overwriting active solar boosts, and included a baseline reset (`0 K`) for `heating_temperature` in `setIdleDefaults`.
|
|
105
|
+
- **ZIP Controller Timer Fix:** Fixed a bug in `zipManager` (internal controller mode) where hot water timer slots (`WW_MoSo_...`) were backed up and overwritten instead of the circulation pump timer slots (`Zirkulation_MoSo_...`), and improved time string restoration.
|
|
106
|
+
- **COP Calculation Accuracy:** Fixed a UTC timezone offset in the daily rollover check so COP snapshots occur accurately at local midnight (00:00). Included defrosting cycles (`WP_BZ_akt = 4`) in the heating COP bucket and added clamping against negative deltas if external energy meters are reset.
|
|
107
|
+
- **Object Management & Virtual States:** Removed a redundant loop in `onReady` that recreated disabled virtual datapoints on startup, and fixed `PREFIX_MAPPING` for weekend timer tables (`SaSo`) to properly reference the `52SatSun` configuration flags.
|
|
108
|
+
|
|
99
109
|
### 0.21.0 (2026-10-26)
|
|
100
110
|
|
|
101
111
|
**🚀 New Features**
|
|
@@ -142,13 +152,6 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
142
152
|
|
|
143
153
|
- **Notification Center:** Introduced a dedicated notification category (`lwpSystem`) for firmware updates and system info to cleanly separate them from critical heat pump errors in the ioBroker UI.
|
|
144
154
|
|
|
145
|
-
### 0.20.1 (2026-10-22)
|
|
146
|
-
|
|
147
|
-
**🐛 Bugfixes & Tweaks**
|
|
148
|
-
|
|
149
|
-
- **Modbus Factor Correction:** Explicitly set the scaling factor for the heating target temperature offset (Luxtronik ID 1 / Holding 23) to `10` to correctly handle and display Modbus TCP values in tenths of a degree (e.g., 5.0 °C instead of 50).
|
|
150
|
-
- **Configuration UI:** Clarified the English and German labels for heating parameters (such as base point and parallel offset) in the adapter settings to prevent mapping confusion.
|
|
151
|
-
|
|
152
155
|
## License
|
|
153
156
|
|
|
154
157
|
MIT License
|
package/build/copManager.js
CHANGED
|
@@ -84,16 +84,24 @@ async function processCopData(adapter, bzVal) {
|
|
|
84
84
|
const lastThermalState = await adapter.getStateAsync(rawThermalId);
|
|
85
85
|
const lastPowerTotal = lastPowerState && typeof lastPowerState.val === "number" ? lastPowerState.val : currentPower;
|
|
86
86
|
const lastThermalTotal = lastThermalState && typeof lastThermalState.val === "number" ? lastThermalState.val : currentThermal;
|
|
87
|
-
const deltaPower = currentPower - lastPowerTotal;
|
|
88
|
-
const deltaThermal = currentThermal - lastThermalTotal;
|
|
89
|
-
if (
|
|
87
|
+
const deltaPower = Math.max(0, currentPower - lastPowerTotal);
|
|
88
|
+
const deltaThermal = Math.max(0, currentThermal - lastThermalTotal);
|
|
89
|
+
if (currentPower < lastPowerTotal) {
|
|
90
|
+
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
91
|
+
}
|
|
92
|
+
if (currentThermal < lastThermalTotal) {
|
|
93
|
+
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
94
|
+
}
|
|
95
|
+
if (deltaPower > 0) {
|
|
90
96
|
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
97
|
+
}
|
|
98
|
+
if (deltaThermal > 0) {
|
|
91
99
|
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
92
100
|
}
|
|
93
101
|
await handleTimeRollover(adapter);
|
|
94
102
|
if (deltaPower > 0 || deltaThermal > 0) {
|
|
95
103
|
await addDeltaToBucket(adapter, "Total", deltaPower, deltaThermal);
|
|
96
|
-
if (bzVal === "0") {
|
|
104
|
+
if (bzVal === "0" || bzVal === "4") {
|
|
97
105
|
await addDeltaToBucket(adapter, "Heating", deltaPower, deltaThermal);
|
|
98
106
|
} else if (bzVal === "1") {
|
|
99
107
|
await addDeltaToBucket(adapter, "HotWater", deltaPower, deltaThermal);
|
|
@@ -127,9 +135,12 @@ async function handleTimeRollover(adapter) {
|
|
|
127
135
|
const state = await adapter.getStateAsync(dateStateId);
|
|
128
136
|
const lastDate = state && typeof state.val === "string" ? state.val : "";
|
|
129
137
|
const now = /* @__PURE__ */ new Date();
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
138
|
+
const y = now.getFullYear();
|
|
139
|
+
const m = String(now.getMonth() + 1).padStart(2, "0");
|
|
140
|
+
const d = String(now.getDate()).padStart(2, "0");
|
|
141
|
+
const currentDate = `${y}-${m}-${d}`;
|
|
142
|
+
const currentMonth = `${y}-${m}`;
|
|
143
|
+
const currentYear = `${y}`;
|
|
133
144
|
if (lastDate !== currentDate) {
|
|
134
145
|
const lastMonth = lastDate ? lastDate.substring(0, 7) : "";
|
|
135
146
|
const lastYear = lastDate ? lastDate.substring(0, 4) : "";
|
package/build/copManager.js.map
CHANGED
|
@@ -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\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\t// 1. STROMVERBRAUCH ABRUFEN\n\t\tlet currentPower = 0;\n\t\tif (config.cop_source_power === 'external' && config.cop_oid_power_total) {\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\tcurrentPower = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('energy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPower = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// 2. W\u00C4RMEMENGE ABRUFEN\n\t\tlet currentThermal = 0;\n\t\tif (config.cop_source_thermal === 'external' && config.cop_oid_thermal_total) {\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\tcurrentThermal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('thermalenergy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermal = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// --- NEU: ABSOLUT SICHERE INITIALISIERUNG AUS DER DATENBANK ---\n\t\tconst rawPowerId = 'hidden.cop_buckets.last_raw_power';\n\t\tconst rawThermalId = 'hidden.cop_buckets.last_raw_thermal';\n\n\t\tif (!isInitialized) {\n\t\t\tawait adapter.setObjectNotExistsAsync(rawPowerId, {\n\t\t\t\ttype: 'state',\n\t\t\t\tcommon: { name: 'Last Raw Power', type: 'number', role: 'value', read: true, write: false },\n\t\t\t\tnative: {},\n\t\t\t});\n\t\t\tawait adapter.setObjectNotExistsAsync(rawThermalId, {\n\t\t\t\ttype: 'state',\n\t\t\t\tcommon: { name: 'Last Raw Thermal', type: 'number', role: 'value', read: true, write: false },\n\t\t\t\tnative: {},\n\t\t\t});\n\n\t\t\tconst lastPowerStateInit = await adapter.getStateAsync(rawPowerId);\n\t\t\tconst lastThermalStateInit = await adapter.getStateAsync(rawThermalId);\n\n\t\t\t// Wenn noch nie was gespeichert wurde, nimm den aktuellen Wert\n\t\t\tif (!lastPowerStateInit || lastPowerStateInit.val === null) {\n\t\t\t\tawait adapter.setState(rawPowerId, { val: currentPower, ack: true });\n\t\t\t}\n\t\t\tif (!lastThermalStateInit || lastThermalStateInit.val === null) {\n\t\t\t\tawait adapter.setState(rawThermalId, { val: currentThermal, ack: true });\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 AUS DER DATENBANK LADEN (\u00DCberlebt jeden Neustart!)\n\t\tconst lastPowerState = await adapter.getStateAsync(rawPowerId);\n\t\tconst lastThermalState = await adapter.getStateAsync(rawThermalId);\n\n\t\tconst lastPowerTotal =\n\t\t\tlastPowerState && typeof lastPowerState.val === 'number' ? lastPowerState.val : currentPower;\n\t\tconst lastThermalTotal =\n\t\t\tlastThermalState && typeof lastThermalState.val === 'number' ? lastThermalState.val : currentThermal;\n\n\t\t// 4. DELTA BERECHNEN\n\t\tconst deltaPower = currentPower - lastPowerTotal;\n\t\tconst deltaThermal = currentThermal - lastThermalTotal;\n\n\t\t// 5. NEUE Z\u00C4HLERST\u00C4NDE SOFORT F\u00DCR DEN N\u00C4CHSTEN DURCHLAUF IN DB SPEICHERN\n\t\tif (deltaPower > 0 || deltaThermal > 0) {\n\t\t\tawait adapter.setState(rawPowerId, { val: currentPower, ack: true });\n\t\t\tawait adapter.setState(rawThermalId, { val: currentThermal, ack: true });\n\t\t}\n\n\t\t// 6. ZEITWECHSEL PR\u00DCFEN (Hat ein neuer Tag/Monat/Jahr begonnen?)\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// 7. WERTE IN DIE ENDLOS-Z\u00C4HLER VERTEILEN\n\t\tif (deltaPower > 0 || deltaThermal > 0) {\n\t\t\tawait addDeltaToBucket(adapter, 'Total', deltaPower, deltaThermal);\n\n\t\t\tif (bzVal === '0') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'Heating', deltaPower, deltaThermal);\n\t\t\t} else if (bzVal === '1') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'HotWater', deltaPower, deltaThermal);\n\t\t\t}\n\t\t}\n\n\t\t// 8. 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 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 adapter.setObjectNotExistsAsync('hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync('hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync(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 currentDate = now.toISOString().split('T')[0]; // Format: YYYY-MM-DD\n\tconst currentMonth = currentDate.substring(0, 7); // Format: YYYY-MM\n\tconst currentYear = currentDate.substring(0, 4); // Format: 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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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\t// Mapping der Ziel-Datenpunkte\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]; // Das ist der Stand vor bis zu 7 Tagen\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;AASpB,eAAsB,eAAe,SAA2B,OAA8B;AAC7F,QAAM,SAAS,QAAQ;AACvB,MAAI,CAAC,OAAO,wBAAwB;AACnC;AAAA,EACD;AAEA,MAAI;AACH,gCAAS,iCAAiC,KAAK,IAAI,OAAO;AAG1D,QAAI,eAAe;AACnB,QAAI,OAAO,qBAAqB,cAAc,OAAO,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AAC3D,cAAM,QAAQ,SAAS,YAAY,EAAE,KAAK,cAAc,KAAK,KAAK,CAAC;AAAA,MACpE;AACA,UAAI,CAAC,wBAAwB,qBAAqB,QAAQ,MAAM;AAC/D,cAAM,QAAQ,SAAS,cAAc,EAAE,KAAK,gBAAgB,KAAK,KAAK,CAAC;AAAA,MACxE;AAEA,sBAAgB;AAChB,YAAM,mBAAmB,OAAO;AAChC;AAAA,IACD;AAGA,UAAM,iBAAiB,MAAM,QAAQ,cAAc,UAAU;AAC7D,UAAM,mBAAmB,MAAM,QAAQ,cAAc,YAAY;AAEjE,UAAM,iBACL,kBAAkB,OAAO,eAAe,QAAQ,WAAW,eAAe,MAAM;AACjF,UAAM,mBACL,oBAAoB,OAAO,iBAAiB,QAAQ,WAAW,iBAAiB,MAAM;AAGvF,UAAM,aAAa,eAAe;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\nlet isInitialized = false;\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\t// 1. STROMVERBRAUCH ABRUFEN\n\t\tlet currentPower = 0;\n\t\tif (config.cop_source_power === 'external' && config.cop_oid_power_total) {\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\tcurrentPower = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('energy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentPower = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// 2. W\u00C4RMEMENGE ABRUFEN\n\t\tlet currentThermal = 0;\n\t\tif (config.cop_source_thermal === 'external' && config.cop_oid_thermal_total) {\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\tcurrentThermal = state.val;\n\t\t\t}\n\t\t} else {\n\t\t\tconst state = await adapter.getStateAsync(getDpPath('thermalenergy_total'));\n\t\t\tif (state && typeof state.val === 'number') {\n\t\t\t\tcurrentThermal = state.val;\n\t\t\t}\n\t\t}\n\n\t\t// --- NEU: ABSOLUT SICHERE INITIALISIERUNG AUS DER DATENBANK ---\n\t\tconst rawPowerId = 'hidden.cop_buckets.last_raw_power';\n\t\tconst rawThermalId = 'hidden.cop_buckets.last_raw_thermal';\n\n\t\tif (!isInitialized) {\n\t\t\tawait adapter.setObjectNotExistsAsync(rawPowerId, {\n\t\t\t\ttype: 'state',\n\t\t\t\tcommon: { name: 'Last Raw Power', type: 'number', role: 'value', read: true, write: false },\n\t\t\t\tnative: {},\n\t\t\t});\n\t\t\tawait adapter.setObjectNotExistsAsync(rawThermalId, {\n\t\t\t\ttype: 'state',\n\t\t\t\tcommon: { name: 'Last Raw Thermal', type: 'number', role: 'value', read: true, write: false },\n\t\t\t\tnative: {},\n\t\t\t});\n\n\t\t\tconst lastPowerStateInit = await adapter.getStateAsync(rawPowerId);\n\t\t\tconst lastThermalStateInit = await adapter.getStateAsync(rawThermalId);\n\n\t\t\t// Wenn noch nie was gespeichert wurde, nimm den aktuellen Wert\n\t\t\tif (!lastPowerStateInit || lastPowerStateInit.val === null) {\n\t\t\t\tawait adapter.setState(rawPowerId, { val: currentPower, ack: true });\n\t\t\t}\n\t\t\tif (!lastThermalStateInit || lastThermalStateInit.val === null) {\n\t\t\t\tawait adapter.setState(rawThermalId, { val: currentThermal, ack: true });\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 AUS DER DATENBANK LADEN (\u00DCberlebt jeden Neustart!)\n\t\tconst lastPowerState = await adapter.getStateAsync(rawPowerId);\n\t\tconst lastThermalState = await adapter.getStateAsync(rawThermalId);\n\n\t\tconst lastPowerTotal =\n\t\t\tlastPowerState && typeof lastPowerState.val === 'number' ? lastPowerState.val : currentPower;\n\t\tconst lastThermalTotal =\n\t\t\tlastThermalState && typeof lastThermalState.val === 'number' ? lastThermalState.val : currentThermal;\n\n\t\t// 4. DELTA BERECHNEN (Gegen negative Werte absichern)\n\t\tconst deltaPower = Math.max(0, currentPower - lastPowerTotal);\n\t\tconst deltaThermal = Math.max(0, currentThermal - lastThermalTotal);\n\n\t\t// Falls ein externer Z\u00E4hler genullt wurde (Reset), Referenzwert nachziehen\n\t\tif (currentPower < lastPowerTotal) {\n\t\t\tawait adapter.setState(rawPowerId, { val: currentPower, ack: true });\n\t\t}\n\t\tif (currentThermal < lastThermalTotal) {\n\t\t\tawait adapter.setState(rawThermalId, { val: currentThermal, ack: true });\n\t\t}\n\n\t\t// 5. NEUE Z\u00C4HLERST\u00C4NDE SOFORT F\u00DCR DEN N\u00C4CHSTEN DURCHLAUF IN DB SPEICHERN\n\t\tif (deltaPower > 0) {\n\t\t\tawait adapter.setState(rawPowerId, { val: currentPower, ack: true });\n\t\t}\n\t\tif (deltaThermal > 0) {\n\t\t\tawait adapter.setState(rawThermalId, { val: currentThermal, ack: true });\n\t\t}\n\n\t\t// 6. ZEITWECHSEL PR\u00DCFEN (Hat ein neuer Tag/Monat/Jahr begonnen?)\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// 7. WERTE IN DIE ENDLOS-Z\u00C4HLER VERTEILEN (inkl. Abtauen = '4' f\u00FCr Heizung)\n\t\tif (deltaPower > 0 || deltaThermal > 0) {\n\t\t\tawait addDeltaToBucket(adapter, 'Total', deltaPower, deltaThermal);\n\n\t\t\tif (bzVal === '0' || bzVal === '4') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'Heating', deltaPower, deltaThermal);\n\t\t\t} else if (bzVal === '1') {\n\t\t\t\tawait addDeltaToBucket(adapter, 'HotWater', deltaPower, deltaThermal);\n\t\t\t}\n\t\t}\n\n\t\t// 8. 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 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 adapter.setObjectNotExistsAsync('hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync('hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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 adapter.setObjectNotExistsAsync(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\t// Mapping der Ziel-Datenpunkte\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]; // Das ist der Stand vor bis zu 7 Tagen\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;AASpB,eAAsB,eAAe,SAA2B,OAA8B;AAC7F,QAAM,SAAS,QAAQ;AACvB,MAAI,CAAC,OAAO,wBAAwB;AACnC;AAAA,EACD;AAEA,MAAI;AACH,gCAAS,iCAAiC,KAAK,IAAI,OAAO;AAG1D,QAAI,eAAe;AACnB,QAAI,OAAO,qBAAqB,cAAc,OAAO,qBAAqB;AACzE,YAAM,QAAQ,MAAM,QAAQ,qBAAqB,OAAO,mBAAmB;AAC3E,UAAI,SAAS,OAAO,MAAM,QAAQ,UAAU;AAC3C,uBAAe,MAAM;AAAA,MACtB;AAAA,IACD,OAAO;AACN,YAAM,QAAQ,MAAM,QAAQ,kBAAc,+BAAU,cAAc,CAAC;AACnE,UAAI,SAAS,OAAO,MAAM,QAAQ,UAAU;AAC3C,uBAAe,MAAM;AAAA,MACtB;AAAA,IACD;AAGA,QAAI,iBAAiB;AACrB,QAAI,OAAO,uBAAuB,cAAc,OAAO,uBAAuB;AAC7E,YAAM,QAAQ,MAAM,QAAQ,qBAAqB,OAAO,qBAAqB;AAC7E,UAAI,SAAS,OAAO,MAAM,QAAQ,UA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OAAO,QAAQ,IAAI;AAClE,QAAI;AACH,YAAM,UAAU,KAAK,MAAM,OAAO,GAAG;AACrC,UAAI,QAAQ,SAAS,GAAG;AACvB,cAAM,SAAS,QAAQ,CAAC;AACxB,cAAM,QAAQ,eAAe,OAAO;AACpC,cAAM,OAAO,iBAAiB,OAAO;AACrC,YAAI,QAAQ,GAAG;AACd,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;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
|
@@ -512,7 +512,6 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
512
512
|
wwIstState,
|
|
513
513
|
ruecklaufState,
|
|
514
514
|
spreizungState,
|
|
515
|
-
heatingStateStrState,
|
|
516
515
|
vd1State,
|
|
517
516
|
wwHystereseState,
|
|
518
517
|
ruecklaufSollState,
|
|
@@ -528,7 +527,6 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
528
527
|
this.getStateAsync((0, import_stateMapping.getDpPath)("Wamwassertemperatur_Ist")),
|
|
529
528
|
this.getStateAsync((0, import_stateMapping.getDpPath)("temperature_return")),
|
|
530
529
|
this.getStateAsync((0, import_stateMapping.getDpPath)("spreizung_vorlauf_ruecklauf")),
|
|
531
|
-
this.getStateAsync((0, import_stateMapping.getDpPath)("opStateHeatingString")),
|
|
532
530
|
this.getStateAsync((0, import_stateMapping.getDpPath)("VD1out")),
|
|
533
531
|
this.getStateAsync((0, import_stateMapping.getDpPath)("hotWaterTemperatureHysteresis")),
|
|
534
532
|
this.getStateAsync((0, import_stateMapping.getDpPath)("temperature_target_return")),
|
|
@@ -544,7 +542,6 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
544
542
|
const wwIst = (_k = wwIstState == null ? void 0 : wwIstState.val) != null ? _k : 0;
|
|
545
543
|
const ruecklauf = (_l = ruecklaufState == null ? void 0 : ruecklaufState.val) != null ? _l : 0;
|
|
546
544
|
const spreizung = (_m = spreizungState == null ? void 0 : spreizungState.val) != null ? _m : 0;
|
|
547
|
-
const heatingStateStr = String((heatingStateStrState == null ? void 0 : heatingStateStrState.val) || "").trim();
|
|
548
545
|
const vd1 = (vd1State == null ? void 0 : vd1State.val) === 1;
|
|
549
546
|
const wwHysterese = (_n = wwHystereseState == null ? void 0 : wwHystereseState.val) != null ? _n : 0;
|
|
550
547
|
const ruecklaufSoll = (_o = ruecklaufSollState == null ? void 0 : ruecklaufSollState.val) != null ? _o : 0;
|
|
@@ -579,7 +576,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
579
576
|
} else if (!nachWasser && config.Heating_after_warmwater === true) {
|
|
580
577
|
await this.syncConfigValue("Heizen_nach_Wasser", true);
|
|
581
578
|
}
|
|
582
|
-
if (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {
|
|
579
|
+
if (!import_pvManager.pvIsBoostActive && wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {
|
|
583
580
|
let forceSoll = wwIst + wwHysterese + 1.5;
|
|
584
581
|
if (forceSoll > 70) {
|
|
585
582
|
forceSoll = 70;
|
|
@@ -589,11 +586,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
589
586
|
}
|
|
590
587
|
}
|
|
591
588
|
}
|
|
589
|
+
const isHeatingAllowedByLimit = heatingLimit === 1 && mitteltemperatur < thresholdHeatingLimit || heatingLimit === 0;
|
|
592
590
|
if (istWarmwasser && nachWasser) {
|
|
593
|
-
if (isRegelungAktiv) {
|
|
594
|
-
|
|
595
|
-
await this.syncConfigValue("heating_curve_parallel_offset", 35);
|
|
596
|
-
}
|
|
591
|
+
if (isRegelungAktiv && isHeatingAllowedByLimit) {
|
|
592
|
+
await this.syncConfigValue("heating_curve_parallel_offset", 35);
|
|
597
593
|
}
|
|
598
594
|
}
|
|
599
595
|
if (istLeerlauf) {
|
|
@@ -602,8 +598,8 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
602
598
|
await (0, import_zipManager.stopZipAndDeaeration)(this);
|
|
603
599
|
}
|
|
604
600
|
}
|
|
605
|
-
if (isRegelungAktiv) {
|
|
606
|
-
if (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll &&
|
|
601
|
+
if (isRegelungAktiv && !import_pvManager.pvIsBoostActive) {
|
|
602
|
+
if (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll && isHeatingAllowedByLimit) {
|
|
607
603
|
await this.syncConfigValue("heating_curve_parallel_offset", 35);
|
|
608
604
|
}
|
|
609
605
|
}
|