iobroker.luxtronik2-controller 0.17.2 → 0.18.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 +24 -23
- package/build/copManager.js +28 -6
- package/build/copManager.js.map +2 -2
- package/build/hupManager.js +11 -0
- package/build/hupManager.js.map +2 -2
- package/build/main.js +13 -1
- package/build/main.js.map +2 -2
- package/build/mapping/settings.js +6 -2
- package/build/mapping/settings.js.map +2 -2
- package/build/virtualStates.js +8 -3
- package/build/virtualStates.js.map +2 -2
- package/io-package.json +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Innovations in this version: The luxtronik2-controller natively integrates TCP c
|
|
|
28
28
|
### Features
|
|
29
29
|
|
|
30
30
|
- **Native TCP Communication:** Direct connection to the heat pump without any additional overhead.
|
|
31
|
+
- **COP & JAZ (Efficiency Calculator):** The heat pump's efficiency can now be calculated and tracked directly within the adapter (Today, 7 Days, Month, Year). Live metrics are automatically split into Heating, Hot Water, and Total. You can either use the internal Luxtronik estimates or link high-precision external meters (e.g., Shelly 3EM) via Object IDs.
|
|
31
32
|
- **Compressor Protection (Cycle Optimization):** Intelligent merging of heating and domestic hot water (DHW) cycles to significantly reduce compressor starts.
|
|
32
33
|
- **Dynamic HUP Control:** Automatic voltage adjustment of the heating circulation pump (HUP) based on the flow and return temperature spread for maximum efficiency.
|
|
33
34
|
- **Integrated Actions (Macros):** Pre-defined control logic for forced heating, DHW requests, and the circulation pump (ZIP) – including an automatic fallback to safe default values.
|
|
@@ -85,6 +86,29 @@ Bug reports, compatibility notes for specific firmware versions, or feature requ
|
|
|
85
86
|
## Changelog
|
|
86
87
|
|
|
87
88
|
// ### **WORK IN PROGRESS**
|
|
89
|
+
### 0.18.0 (2026-10-12)
|
|
90
|
+
|
|
91
|
+
**🚀 Features & Enhancements**
|
|
92
|
+
|
|
93
|
+
- **Smart PWM Pump Detection:** The `hupManager` now automatically detects whether the heating circulation pump (HUP) is controlled via a PWM signal (verified by checking if `heating_max_circ_pump_speed > 0%`). If this is the case, the obsolete dynamic 0-10V voltage optimization is automatically bypassed. This saves system resources and prevents unnecessary write commands to the Luxtronik controller.
|
|
94
|
+
|
|
95
|
+
**🐛 Bugfixes**
|
|
96
|
+
|
|
97
|
+
- **HUP Voltage Validation Fixed:** Fixed an issue where ioBroker threw a warning ("nur zwischen 3 und 10 V erlaubt") in the log for HUP voltage values below 3V. The object definitions for minimum and nominal voltage have been explicitly updated to `min: 0` and `max: 10`. This successfully overwrites lingering cache limits in the ioBroker database and allows the pump to transition into 0V standby mode without throwing errors.
|
|
98
|
+
|
|
99
|
+
### 0.17.3 (2026-10-12)
|
|
100
|
+
|
|
101
|
+
**🚀 Features & Enhancements**
|
|
102
|
+
|
|
103
|
+
- **Persistent COP Counters:** Raw energy counters (`last_raw_power`, `last_raw_thermal`) are now safely stored in the ioBroker database (`hidden.cop_buckets`) instead of volatile RAM. Consumption data is no longer lost during adapter instance or ioBroker host restarts, ensuring seamless and continuous delta calculation.
|
|
104
|
+
|
|
105
|
+
**🐛 Bugfixes**
|
|
106
|
+
|
|
107
|
+
- **Anti-Flapping Protection for Energy Counters (Root-Cause Fix):** Fixed a timing bug that caused the internal sum counters for thermal and electrical energy (`thermalenergy_total`, `energy_total`) to temporarily drop to `0 kWh`. The calculation function (`calculateSum`) now blocks physically impossible negative jumps and only writes new sums if they are greater than or equal to the previous peak value.
|
|
108
|
+
- **COP Operating State Recognition:** The COP script no longer ignores energy increments for heating and hot water. The evaluation of the operating state (`WP_BZ_akt`) has been improved to reliably parse text strings with parentheses (e.g., `"Warmwasser(1)"` or `"Heizbetrieb(0)"`), correctly sorting the calculated deltas into their respective buckets (`Heating` / `HotWater`).
|
|
109
|
+
- **CI/CD & Code Quality:** Resolved strict ESLint rule violations (`curly`) in the `copManager` by adding block braces to single-line `if` conditions, allowing the GitHub Actions build pipeline to pass successfully.
|
|
110
|
+
- **Core Anti-Flapping Protection for Energy Counters:** Fixed a critical timing and raw data glitch where the heat pump occasionally transmits `0 kWh` for cumulative energy counters. A strict validation gate was implemented directly into the core polling loop (`main.ts`). All incoming updates for energy, thermal, and power states are now intercepted and discarded if they are lower than the currently persisted ioBroker state. This prevents faulty zero-drops from ever reaching the database and ensures clean, continuously rising graphs in history adapters like InfluxDB.
|
|
111
|
+
|
|
88
112
|
### 0.17.2 (2026-10-11)
|
|
89
113
|
|
|
90
114
|
#### 🛠 Bugfixes & Enhancements
|
|
@@ -117,29 +141,6 @@ Bug reports, compatibility notes for specific firmware versions, or feature requ
|
|
|
117
141
|
- **Config UI Sorting:** Ensured the newly generated configuration tabs maintain a logical and consistent order across rebuilds.
|
|
118
142
|
- **Internal Mapping:** Restructured the `info` folder mapping to cleanly accommodate adapter-level metadata alongside hardware telemetry.
|
|
119
143
|
|
|
120
|
-
### 0.16.1 (2026-10-11)
|
|
121
|
-
|
|
122
|
-
#### 🚀 Features
|
|
123
|
-
|
|
124
|
-
- **Enhanced UI Layout:** Improved the "Datapoints" settings tab layout to display up to 4 items side-by-side on larger screens for a better overview and improved usability.
|
|
125
|
-
|
|
126
|
-
#### 🛠 Bugfixes & Enhancements
|
|
127
|
-
|
|
128
|
-
- **State Cleanup Logic Fixed:** Resolved an issue where unchecked datapoints (e.g., Room Thermostats) were not removed from the ioBroker object tree. The `isStateEnabled` logic now correctly handles `undefined` config states for dynamically generated checkboxes.
|
|
129
|
-
|
|
130
|
-
### 0.16.0 (2026-10-11)
|
|
131
|
-
|
|
132
|
-
#### 🚀 Features
|
|
133
|
-
|
|
134
|
-
- **Dynamic Admin UI Generation:** The "Datapoints / Objects" configuration tab in the adapter settings is now fully auto-generated during the build process (`prebuild`). This ensures the UI is always 100% in sync with the underlying TypeScript state mappings.
|
|
135
|
-
- **Category Master Switches:** Added master toggle switches to the adapter settings. Users can now enable or disable entire hardware categories (e.g., Solar, Cooling, Ventilation) with a single click. This keeps the ioBroker object tree clean and significantly reduces unnecessary polling for unused features.
|
|
136
|
-
- **Dynamic Protection for Critical States:** System-critical datapoints are now protected dynamically via a `required: true` flag in the codebase. They are permanently locked (grayed out) in the UI and cannot be accidentally deleted or disabled by the user or the visibility filter.
|
|
137
|
-
|
|
138
|
-
#### 🛠 Bugfixes & Enhancements
|
|
139
|
-
|
|
140
|
-
- **Cycle Optimization Logic (Hot Water):** Fixed a logic flaw where the adapter erroneously applied an artificial hot water target temperature increase while the heat pump was already actively running a hot water cycle. The trigger is now strictly limited to the end of regular heating cycles.
|
|
141
|
-
- **Build Process Optimized:** Integrated the UI generation script (`generateConfig.ts`) seamlessly into the NPM `prebuild` lifecycle, automatically patching the `jsonConfig.json` before typescript compilation.
|
|
142
|
-
|
|
143
144
|
## License
|
|
144
145
|
|
|
145
146
|
MIT License
|
package/build/copManager.js
CHANGED
|
@@ -23,8 +23,6 @@ __export(copManager_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(copManager_exports);
|
|
24
24
|
var import_logger = require("./logger");
|
|
25
25
|
var import_stateMapping = require("./stateMapping");
|
|
26
|
-
let lastPowerTotal = 0;
|
|
27
|
-
let lastThermalTotal = 0;
|
|
28
26
|
let isInitialized = false;
|
|
29
27
|
async function processCopData(adapter, bzVal) {
|
|
30
28
|
const config = adapter.config;
|
|
@@ -57,17 +55,41 @@ async function processCopData(adapter, bzVal) {
|
|
|
57
55
|
currentThermal = state.val;
|
|
58
56
|
}
|
|
59
57
|
}
|
|
58
|
+
const rawPowerId = "hidden.cop_buckets.last_raw_power";
|
|
59
|
+
const rawThermalId = "hidden.cop_buckets.last_raw_thermal";
|
|
60
60
|
if (!isInitialized) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
await adapter.setObjectNotExistsAsync(rawPowerId, {
|
|
62
|
+
type: "state",
|
|
63
|
+
common: { name: "Last Raw Power", type: "number", role: "value", read: true, write: false },
|
|
64
|
+
native: {}
|
|
65
|
+
});
|
|
66
|
+
await adapter.setObjectNotExistsAsync(rawThermalId, {
|
|
67
|
+
type: "state",
|
|
68
|
+
common: { name: "Last Raw Thermal", type: "number", role: "value", read: true, write: false },
|
|
69
|
+
native: {}
|
|
70
|
+
});
|
|
71
|
+
const lastPowerStateInit = await adapter.getStateAsync(rawPowerId);
|
|
72
|
+
const lastThermalStateInit = await adapter.getStateAsync(rawThermalId);
|
|
73
|
+
if (!lastPowerStateInit || lastPowerStateInit.val === null) {
|
|
74
|
+
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
75
|
+
}
|
|
76
|
+
if (!lastThermalStateInit || lastThermalStateInit.val === null) {
|
|
77
|
+
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
78
|
+
}
|
|
63
79
|
isInitialized = true;
|
|
64
80
|
await handleTimeRollover(adapter);
|
|
65
81
|
return;
|
|
66
82
|
}
|
|
83
|
+
const lastPowerState = await adapter.getStateAsync(rawPowerId);
|
|
84
|
+
const lastThermalState = await adapter.getStateAsync(rawThermalId);
|
|
85
|
+
const lastPowerTotal = lastPowerState && typeof lastPowerState.val === "number" ? lastPowerState.val : currentPower;
|
|
86
|
+
const lastThermalTotal = lastThermalState && typeof lastThermalState.val === "number" ? lastThermalState.val : currentThermal;
|
|
67
87
|
const deltaPower = currentPower - lastPowerTotal;
|
|
68
88
|
const deltaThermal = currentThermal - lastThermalTotal;
|
|
69
|
-
|
|
70
|
-
|
|
89
|
+
if (deltaPower > 0 || deltaThermal > 0) {
|
|
90
|
+
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
91
|
+
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
92
|
+
}
|
|
71
93
|
await handleTimeRollover(adapter);
|
|
72
94
|
if (deltaPower > 0 || deltaThermal > 0) {
|
|
73
95
|
await addDeltaToBucket(adapter, "Total", deltaPower, deltaThermal);
|
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\n// Lokaler Cache f\u00FCr den Z\u00E4hlerstand des letzten Pollings\nlet lastPowerTotal = 0;\nlet lastThermalTotal = 0;\nlet isInitialized = false; // NEU: Sicheres Flag f\u00FCr den Start\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\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// Initialisierung beim ersten Durchlauf\n\t\tif (!isInitialized) {\n\t\t\tlastPowerTotal = currentPower;\n\t\t\tlastThermalTotal = currentThermal;\n\t\t\tisInitialized = true;\n\t\t\t// WICHTIG: Beim ersten Start pr\u00FCfen wir direkt, ob wir Tageswechsel ansto\u00DFen m\u00FCssen\n\t\t\tawait handleTimeRollover(adapter);\n\t\t\treturn;\n\t\t}\n\n\t\t// 3. DELTA BERECHNEN (Zuwachs seit letztem Polling in kWh)\n\t\tconst deltaPower = currentPower - lastPowerTotal;\n\n\t\tconst deltaThermal = currentThermal - lastThermalTotal;\n\n\t\tlastPowerTotal = currentPower;\n\t\tlastThermalTotal = currentThermal;\n\n\t\t// 4. ZEITWECHSEL PR\u00DCFEN (Hat ein neuer Tag/Monat/Jahr begonnen?)\n\t\tawait handleTimeRollover(adapter);\n\n\t\t// Wenn sich die Z\u00E4hler nicht bewegt haben, keine Eimer f\u00FCllen\n\t\tif (deltaPower > 0 || deltaThermal > 0) {\n\t\t\t// 5. WERTE IN DIE ENDLOS-Z\u00C4HLER VERTEILEN\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// 6. LIVE COP BERECHNEN UND SCHREIBEN (Endlosz\u00E4hler minus Snapshot)\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;
|
|
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,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;AAC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AO,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/hupManager.js
CHANGED
|
@@ -22,12 +22,23 @@ __export(hupManager_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(hupManager_exports);
|
|
24
24
|
var import_logger = require("./logger");
|
|
25
|
+
var import_stateMapping = require("./stateMapping");
|
|
25
26
|
async function handleHupOptimization(adapter, istHeizen, spreizung, hupAktiv, lastPumpOptimization) {
|
|
26
27
|
var _a, _b, _c, _d, _e, _f;
|
|
27
28
|
const config = adapter.config;
|
|
28
29
|
if (!istHeizen || config.hup_optimierung_aktiv !== true) {
|
|
29
30
|
return lastPumpOptimization;
|
|
30
31
|
}
|
|
32
|
+
try {
|
|
33
|
+
const maxPwmState = await adapter.getStateAsync((0, import_stateMapping.getDpPath)("heating_max_circ_pump_speed"));
|
|
34
|
+
if (maxPwmState && typeof maxPwmState.val === "number" && maxPwmState.val > 0) {
|
|
35
|
+
if (adapter.isDebugLogActive) {
|
|
36
|
+
(0, import_logger.writeLog)("HUP: PWM-Pumpe erkannt (max_speed > 0). 0-10V Optimierung wird \xFCbersprungen.", "debug");
|
|
37
|
+
}
|
|
38
|
+
return lastPumpOptimization;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
31
42
|
const now = Date.now();
|
|
32
43
|
const checkIntervalMs = ((_a = config.hup_interval_min) != null ? _a : 10) * 6e4;
|
|
33
44
|
if (now - lastPumpOptimization > checkIntervalMs) {
|
package/build/hupManager.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hupManager.ts"],
|
|
4
|
-
"sourcesContent": ["import { writeLog } from './logger';\nimport type { LuxtronikAdapter } from './types';\n\n/**\n * \u00DCbernimmt die dynamische Regelung der Heizungsumw\u00E4lzpumpe (HUP) anhand der Spreizung.\n *\n * @param adapter - Die erweiterte Adapter-Instanz\n * @param istHeizen - Boolean, ob sich die Anlage aktuell im Heizbetrieb befindet\n * @param spreizung - Die aktuell berechnete Temperaturspreizung (Vorlauf - R\u00FCcklauf)\n * @param hupAktiv - Die aktuell anliegende Nominalspannung der HUP\n * @param lastPumpOptimization - Timestamp der letzten Anpassung (f\u00FCr Intervall-Sperre)\n * @returns Den aktualisierten Timestamp der letzten Anpassung\n */\nexport async function handleHupOptimization(\n\tadapter: LuxtronikAdapter,\n\tistHeizen: boolean,\n\tspreizung: number,\n\thupAktiv: number,\n\tlastPumpOptimization: number,\n): Promise<number> {\n\tconst config = adapter.config;\n\n\t// Abbruch, wenn nicht geheizt wird oder das Feature deaktiviert ist\n\tif (!istHeizen || config.hup_optimierung_aktiv !== true) {\n\t\treturn lastPumpOptimization;\n\t}\n\n\tconst now = Date.now();\n\tconst checkIntervalMs = (config.hup_interval_min ?? 10) * 60000;\n\n\t// Pr\u00FCfen, ob das Schutz-Intervall abgelaufen ist\n\tif (now - lastPumpOptimization > checkIntervalMs) {\n\t\tconst minSpreizung = config.hup_spreizung_min ?? 6.5;\n\t\tconst maxSpreizung = config.hup_spreizung_max ?? 7.5;\n\t\tconst step = config.hup_voltage_step ?? 0.25;\n\t\tconst minVolt = config.hup_voltage_limit_min ?? 3.0;\n\t\tconst maxVolt = config.hup_voltage_limit_max ?? 10.0;\n\n\t\tif (spreizung < minSpreizung && hupAktiv > minVolt) {\n\t\t\tconst newVolt = Math.max(minVolt, Math.round((hupAktiv - step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too low (${spreizung}K < ${minSpreizung}K). Scaling nominal voltage down to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t} else if (spreizung > maxSpreizung && hupAktiv < maxVolt) {\n\t\t\tconst newVolt = Math.min(maxVolt, Math.round((hupAktiv + step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too high (${spreizung}K > ${maxSpreizung}K). Scaling nominal voltage up to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t}\n\t}\n\n\treturn lastPumpOptimization;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\n/**\n * \u00DCbernimmt die dynamische Regelung der Heizungsumw\u00E4lzpumpe (HUP) anhand der Spreizung.\n *\n * @param adapter - Die erweiterte Adapter-Instanz\n * @param istHeizen - Boolean, ob sich die Anlage aktuell im Heizbetrieb befindet\n * @param spreizung - Die aktuell berechnete Temperaturspreizung (Vorlauf - R\u00FCcklauf)\n * @param hupAktiv - Die aktuell anliegende Nominalspannung der HUP\n * @param lastPumpOptimization - Timestamp der letzten Anpassung (f\u00FCr Intervall-Sperre)\n * @returns Den aktualisierten Timestamp der letzten Anpassung\n */\nexport async function handleHupOptimization(\n\tadapter: LuxtronikAdapter,\n\tistHeizen: boolean,\n\tspreizung: number,\n\thupAktiv: number,\n\tlastPumpOptimization: number,\n): Promise<number> {\n\tconst config = adapter.config;\n\n\t// Abbruch, wenn nicht geheizt wird oder das Feature deaktiviert ist\n\tif (!istHeizen || config.hup_optimierung_aktiv !== true) {\n\t\treturn lastPumpOptimization;\n\t}\n\n\t// Erkennung einer PWM-Pumpe. Wenn Max-Speed > 0 konfiguriert ist,\n\t// handelt es sich um eine PWM-Pumpe. Die 0-10V Optimierung ist hier nutzlos!\n\ttry {\n\t\tconst maxPwmState = await adapter.getStateAsync(getDpPath('heating_max_circ_pump_speed'));\n\t\tif (maxPwmState && typeof maxPwmState.val === 'number' && maxPwmState.val > 0) {\n\t\t\tif (adapter.isDebugLogActive) {\n\t\t\t\twriteLog('HUP: PWM-Pumpe erkannt (max_speed > 0). 0-10V Optimierung wird \u00FCbersprungen.', 'debug');\n\t\t\t}\n\t\t\treturn lastPumpOptimization; // Abbruch!\n\t\t}\n\t} catch {\n\t\t// Fehler beim Lesen ignorieren und sicherheitshalber weitermachen\n\t}\n\n\tconst now = Date.now();\n\tconst checkIntervalMs = (config.hup_interval_min ?? 10) * 60000;\n\n\t// Pr\u00FCfen, ob das Schutz-Intervall abgelaufen ist\n\tif (now - lastPumpOptimization > checkIntervalMs) {\n\t\tconst minSpreizung = config.hup_spreizung_min ?? 6.5;\n\t\tconst maxSpreizung = config.hup_spreizung_max ?? 7.5;\n\t\tconst step = config.hup_voltage_step ?? 0.25;\n\t\tconst minVolt = config.hup_voltage_limit_min ?? 3.0;\n\t\tconst maxVolt = config.hup_voltage_limit_max ?? 10.0;\n\n\t\tif (spreizung < minSpreizung && hupAktiv > minVolt) {\n\t\t\tconst newVolt = Math.max(minVolt, Math.round((hupAktiv - step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too low (${spreizung}K < ${minSpreizung}K). Scaling nominal voltage down to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t} else if (spreizung > maxSpreizung && hupAktiv < maxVolt) {\n\t\t\tconst newVolt = Math.min(maxVolt, Math.round((hupAktiv + step) * 100) / 100);\n\t\t\tawait adapter.syncConfigValue('heating_system_circ_pump_voltage_nominal', newVolt);\n\t\t\twriteLog(\n\t\t\t\t`HUP: Temperature spread too high (${spreizung}K > ${maxSpreizung}K). Scaling nominal voltage up to ${newVolt}V.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn now;\n\t\t}\n\t}\n\n\treturn lastPumpOptimization;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAa1B,eAAsB,sBACrB,SACA,WACA,WACA,UACA,sBACkB;AApBnB;AAqBC,QAAM,SAAS,QAAQ;AAGvB,MAAI,CAAC,aAAa,OAAO,0BAA0B,MAAM;AACxD,WAAO;AAAA,EACR;AAIA,MAAI;AACH,UAAM,cAAc,MAAM,QAAQ,kBAAc,+BAAU,6BAA6B,CAAC;AACxF,QAAI,eAAe,OAAO,YAAY,QAAQ,YAAY,YAAY,MAAM,GAAG;AAC9E,UAAI,QAAQ,kBAAkB;AAC7B,oCAAS,mFAAgF,OAAO;AAAA,MACjG;AACA,aAAO;AAAA,IACR;AAAA,EACD,QAAQ;AAAA,EAER;AAEA,QAAM,MAAM,KAAK,IAAI;AACrB,QAAM,oBAAmB,YAAO,qBAAP,YAA2B,MAAM;AAG1D,MAAI,MAAM,uBAAuB,iBAAiB;AACjD,UAAM,gBAAe,YAAO,sBAAP,YAA4B;AACjD,UAAM,gBAAe,YAAO,sBAAP,YAA4B;AACjD,UAAM,QAAO,YAAO,qBAAP,YAA2B;AACxC,UAAM,WAAU,YAAO,0BAAP,YAAgC;AAChD,UAAM,WAAU,YAAO,0BAAP,YAAgC;AAEhD,QAAI,YAAY,gBAAgB,WAAW,SAAS;AACnD,YAAM,UAAU,KAAK,IAAI,SAAS,KAAK,OAAO,WAAW,QAAQ,GAAG,IAAI,GAAG;AAC3E,YAAM,QAAQ,gBAAgB,4CAA4C,OAAO;AACjF;AAAA,QACC,oCAAoC,SAAS,OAAO,YAAY,uCAAuC,OAAO;AAAA,QAC9G;AAAA,MACD;AACA,aAAO;AAAA,IACR,WAAW,YAAY,gBAAgB,WAAW,SAAS;AAC1D,YAAM,UAAU,KAAK,IAAI,SAAS,KAAK,OAAO,WAAW,QAAQ,GAAG,IAAI,GAAG;AAC3E,YAAM,QAAQ,gBAAgB,4CAA4C,OAAO;AACjF;AAAA,QACC,qCAAqC,SAAS,OAAO,YAAY,qCAAqC,OAAO;AAAA,QAC7G;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
|
@@ -631,7 +631,19 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
631
631
|
value = Boolean(value);
|
|
632
632
|
}
|
|
633
633
|
const stateId = `${definition.folder}.${key}`;
|
|
634
|
-
|
|
634
|
+
if (typeof value === "number" && (key.toLowerCase().includes("energy") || key.toLowerCase().includes("w\xE4rme") || key.toLowerCase().includes("power"))) {
|
|
635
|
+
statePromises.push(
|
|
636
|
+
(async () => {
|
|
637
|
+
const oldState = await this.getStateAsync(stateId);
|
|
638
|
+
if (oldState && typeof oldState.val === "number" && value < oldState.val) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
await this.setState(stateId, { val: value, ack: true });
|
|
642
|
+
})()
|
|
643
|
+
);
|
|
644
|
+
} else {
|
|
645
|
+
statePromises.push(this.setState(stateId, { val: value, ack: true }));
|
|
646
|
+
}
|
|
635
647
|
}
|
|
636
648
|
}
|
|
637
649
|
await Promise.all(statePromises);
|