iobroker.luxtronik2-controller 0.21.0 → 0.22.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 +13 -22
- package/build/backupManager.js +9 -3
- package/build/backupManager.js.map +2 -2
- package/build/copManager.js +35 -16
- package/build/copManager.js.map +2 -2
- package/build/main.js +6 -10
- package/build/main.js.map +2 -2
- package/build/modbusManager.js +98 -63
- package/build/modbusManager.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/updateManager.js +1 -1
- package/build/updateManager.js.map +2 -2
- package/build/zipManager.js +15 -15
- package/build/zipManager.js.map +2 -2
- package/io-package.json +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,8 +94,20 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
94
94
|
|
|
95
95
|
[Info English](documentation/readme_en.md)
|
|
96
96
|
//### **WORK IN PROGRESS**
|
|
97
|
+
### 0.22.0 (2026-10-26)
|
|
98
|
+
|
|
99
|
+
**🐛 Performance & Tweaks**
|
|
100
|
+
|
|
101
|
+
### 0.21.1 (2026-10-26)
|
|
102
|
+
|
|
103
|
+
**🐛 Bugfixes & Tweaks**
|
|
104
|
+
|
|
105
|
+
- **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.
|
|
106
|
+
- **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`.
|
|
107
|
+
- **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.
|
|
108
|
+
- **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.
|
|
109
|
+
- **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.
|
|
97
110
|
|
|
98
|
-
## Changelog
|
|
99
111
|
### 0.21.0 (2026-10-26)
|
|
100
112
|
|
|
101
113
|
**🚀 New Features**
|
|
@@ -128,27 +140,6 @@ You might see red error messages in the installation log related to `node-gyp`,
|
|
|
128
140
|
|
|
129
141
|
- **Node.js Requirement:** Updated minimum Node.js requirement to `>= 22` in `package.json` and `io-package.json` to meet current adapter standards.
|
|
130
142
|
|
|
131
|
-
### 0.20.2 (2026-10-24)
|
|
132
|
-
|
|
133
|
-
**🔧 Maintenance & Compatibility**
|
|
134
|
-
|
|
135
|
-
- **Repository Checker Fixes:** Addressed multiple warnings from the ioBroker repository checker.
|
|
136
|
-
- **Node.js Requirement:** Updated minimum Node.js requirement to `>= 22` in `package.json` and `io-package.json` to meet current adapter standards.
|
|
137
|
-
- **UI Layout:** Added missing responsive size attributes (`xs`, `sm`, `md`, `lg`, `xl`) to elements in the new updates configuration tab.
|
|
138
|
-
- **Translations:** Added missing i18n translations for all supported languages in the configuration dropdown menus (COP sources and ZIP control mode).
|
|
139
|
-
- **Metadata:** Removed non-existent version entries from the `news` section in `io-package.json`.
|
|
140
|
-
|
|
141
|
-
**✨ Features & Enhancements**
|
|
142
|
-
|
|
143
|
-
- **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
|
-
|
|
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
143
|
## License
|
|
153
144
|
|
|
154
145
|
MIT License
|
package/build/backupManager.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(backupManager_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(backupManager_exports);
|
|
36
36
|
var schedule = __toESM(require("node-schedule"));
|
|
37
37
|
var import_logger = require("./logger");
|
|
38
|
+
const BACKUP_TIMEOUT_MS = 3e4;
|
|
38
39
|
function initAutoBackup(adapter) {
|
|
39
40
|
const config = adapter.config;
|
|
40
41
|
stopAutoBackup(adapter);
|
|
@@ -54,15 +55,20 @@ async function executeDtaBackup(adapter) {
|
|
|
54
55
|
}
|
|
55
56
|
try {
|
|
56
57
|
(0, import_logger.writeLog)("Fetching live DTA file (/NewProc)...", "debug");
|
|
57
|
-
|
|
58
|
+
let isLive = true;
|
|
58
59
|
let arrayBuffer = null;
|
|
59
|
-
let response = await fetch(`http://${ip}/NewProc
|
|
60
|
+
let response = await fetch(`http://${ip}/NewProc`, {
|
|
61
|
+
signal: AbortSignal.timeout(BACKUP_TIMEOUT_MS)
|
|
62
|
+
}).catch(() => null);
|
|
60
63
|
if (response && response.ok) {
|
|
61
64
|
arrayBuffer = await response.arrayBuffer();
|
|
62
65
|
}
|
|
63
66
|
if (!arrayBuffer || arrayBuffer.byteLength < 1e3) {
|
|
64
67
|
(0, import_logger.writeLog)("/NewProc did not return a valid file. Trying /procdta...", "debug");
|
|
65
|
-
|
|
68
|
+
isLive = false;
|
|
69
|
+
response = await fetch(`http://${ip}/procdta`, {
|
|
70
|
+
signal: AbortSignal.timeout(BACKUP_TIMEOUT_MS)
|
|
71
|
+
}).catch(() => null);
|
|
66
72
|
if (response && response.ok) {
|
|
67
73
|
arrayBuffer = await response.arrayBuffer();
|
|
68
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/backupManager.ts"],
|
|
4
|
-
"sourcesContent": ["import * as schedule from 'node-schedule';\nimport { writeLog } from './logger';\nimport type { LuxtronikAdapter } from './types';\n\n/**\n * Initialisiert den automatischen Backup-Zeitplan basierend auf der ioBroker-Konfiguration.\n *\n * @param adapter Die ioBroker Adapter-Instanz\n */\nexport function initAutoBackup(adapter: LuxtronikAdapter): void {\n\tconst config = adapter.config;\n\tstopAutoBackup(adapter)
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAA0B;AAC1B,oBAAyB;
|
|
4
|
+
"sourcesContent": ["import * as schedule from 'node-schedule';\nimport { writeLog } from './logger';\nimport type { LuxtronikAdapter } from './types';\n\nconst BACKUP_TIMEOUT_MS = 30000;\n\n/**\n * Initialisiert den automatischen Backup-Zeitplan basierend auf der ioBroker-Konfiguration.\n *\n * @param adapter Die ioBroker Adapter-Instanz\n */\nexport function initAutoBackup(adapter: LuxtronikAdapter): void {\n\tconst config = adapter.config;\n\tstopAutoBackup(adapter);\n\n\tif (config.autoBackupActive && config.autoBackupCron) {\n\t\twriteLog(`Initializing automated DTA backup with cron schedule: ${config.autoBackupCron}`, 'info');\n\t\tadapter.backupJob = schedule.scheduleJob(config.autoBackupCron, async () => {\n\t\t\tawait executeDtaBackup(adapter);\n\t\t});\n\t}\n}\n\n/**\n * F\u00FChrt den automatischen DTA-Download von der Luxtronik-W\u00E4rmepumpe aus\n * und speichert die Datei sicher im globalen ioBroker-Dateisystem (0_userdata.0).\n * Nutzt prim\u00E4r den direkten Datei-Stream \u00FCber /NewProc ohne k\u00FCnstliche Verz\u00F6gerung.\n *\n * @param adapter Die ioBroker Adapter-Instanz (f\u00FCr Konfiguration, Logs und Dateisystemzugriff)\n * @returns Ein Promise, das nach Abschluss des Downloads aufgel\u00F6st wird\n */\nexport async function executeDtaBackup(adapter: LuxtronikAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tconst ip = config.host;\n\n\tif (!ip) {\n\t\twriteLog('Backup aborted: No IP address configured.', 'warn');\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog('Fetching live DTA file (/NewProc)...', 'debug');\n\n\t\tlet isLive = true;\n\t\tlet arrayBuffer: ArrayBuffer | null = null;\n\n\t\t// 1. NewProc liefert den DTA-Speicher als direkten Datei-Stream (mit 30s Timeout)\n\t\tlet response = await fetch(`http://${ip}/NewProc`, {\n\t\t\tsignal: AbortSignal.timeout(BACKUP_TIMEOUT_MS),\n\t\t}).catch(() => null);\n\n\t\tif (response && response.ok) {\n\t\t\tarrayBuffer = await response.arrayBuffer();\n\t\t}\n\n\t\t// 2. Fallback auf /procdta, falls NewProc leer ist oder fehlt\n\t\tif (!arrayBuffer || arrayBuffer.byteLength < 1000) {\n\t\t\twriteLog('/NewProc did not return a valid file. Trying /procdta...', 'debug');\n\t\t\tisLive = false;\n\t\t\tresponse = await fetch(`http://${ip}/procdta`, {\n\t\t\t\tsignal: AbortSignal.timeout(BACKUP_TIMEOUT_MS),\n\t\t\t}).catch(() => null);\n\n\t\t\tif (response && response.ok) {\n\t\t\t\tarrayBuffer = await response.arrayBuffer();\n\t\t\t}\n\t\t}\n\n\t\tif (!arrayBuffer || arrayBuffer.byteLength < 1000) {\n\t\t\tthrow new Error(`HTTP Error - No valid DTA file found on heat pump webserver.`);\n\t\t}\n\n\t\t// 3. Datei f\u00FCr das Dateisystem vorbereiten\n\t\tconst buffer = Buffer.from(arrayBuffer);\n\t\tconst now = new Date();\n\t\tconst y = now.getFullYear();\n\t\tconst m = String(now.getMonth() + 1).padStart(2, '0');\n\t\tconst d = String(now.getDate()).padStart(2, '0');\n\t\tconst h = String(now.getHours()).padStart(2, '0');\n\t\tconst min = String(now.getMinutes()).padStart(2, '0');\n\t\tconst s = String(now.getSeconds()).padStart(2, '0');\n\t\tconst timestamp = `${y}-${m}-${d}T${h}-${min}-${s}`;\n\t\tconst filePrefix = isLive ? 'dta_live' : 'dta_history';\n\n\t\tconst targetId = '0_userdata.0';\n\t\tconst fileName = `luxtronik_backups/${filePrefix}_${timestamp}.dta`;\n\n\t\t// Speichern im ioBroker-Dateisystem\n\t\tawait adapter.writeFileAsync(targetId, fileName, buffer);\n\n\t\tadapter.log.info(`DTA Backup successfully saved as ${fileName} in folder ${targetId}.`);\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`Failed to execute automated DTA backup: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Stoppt den laufenden Cronjob (wichtig f\u00FCr den Adapter-Neustart).\n *\n * @param adapter Die ioBroker Adapter-Instanz\n */\nexport function stopAutoBackup(adapter: LuxtronikAdapter): void {\n\tif (adapter.backupJob) {\n\t\tadapter.backupJob.cancel();\n\t\tadapter.backupJob = null;\n\t\twriteLog('Automated DTA backup schedule stopped.', 'debug');\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAA0B;AAC1B,oBAAyB;AAGzB,MAAM,oBAAoB;AAOnB,SAAS,eAAe,SAAiC;AAC/D,QAAM,SAAS,QAAQ;AACvB,iBAAe,OAAO;AAEtB,MAAI,OAAO,oBAAoB,OAAO,gBAAgB;AACrD,gCAAS,yDAAyD,OAAO,cAAc,IAAI,MAAM;AACjG,YAAQ,YAAY,SAAS,YAAY,OAAO,gBAAgB,Y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,EAAE,SAAS,GAAG,GAAG;AACpD,UAAM,IAAI,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AAClD,UAAM,YAAY,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjD,UAAM,aAAa,SAAS,aAAa;AAEzC,UAAM,WAAW;AACjB,UAAM,WAAW,qBAAqB,UAAU,IAAI,SAAS;AAG7D,UAAM,QAAQ,eAAe,UAAU,UAAU,MAAM;AAEvD,YAAQ,IAAI,KAAK,oCAAoC,QAAQ,cAAc,QAAQ,GAAG;AAAA,EACvF,SAAS,KAAc;AACtB,UAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,gCAAS,2CAA2C,GAAG,IAAI,OAAO;AAAA,EACnE;AACD;AAOO,SAAS,eAAe,SAAiC;AAC/D,MAAI,QAAQ,WAAW;AACtB,YAAQ,UAAU,OAAO;AACzB,YAAQ,YAAY;AACpB,gCAAS,0CAA0C,OAAO;AAAA,EAC3D;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/copManager.js
CHANGED
|
@@ -24,6 +24,14 @@ module.exports = __toCommonJS(copManager_exports);
|
|
|
24
24
|
var import_logger = require("./logger");
|
|
25
25
|
var import_stateMapping = require("./stateMapping");
|
|
26
26
|
let isInitialized = false;
|
|
27
|
+
const ensuredObjects = /* @__PURE__ */ new Set();
|
|
28
|
+
async function ensureCopObject(adapter, id, obj) {
|
|
29
|
+
if (ensuredObjects.has(id)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
await adapter.setObjectNotExistsAsync(id, obj);
|
|
33
|
+
ensuredObjects.add(id);
|
|
34
|
+
}
|
|
27
35
|
async function processCopData(adapter, bzVal) {
|
|
28
36
|
const config = adapter.config;
|
|
29
37
|
if (!config.cop_calculation_active) {
|
|
@@ -58,12 +66,12 @@ async function processCopData(adapter, bzVal) {
|
|
|
58
66
|
const rawPowerId = "hidden.cop_buckets.last_raw_power";
|
|
59
67
|
const rawThermalId = "hidden.cop_buckets.last_raw_thermal";
|
|
60
68
|
if (!isInitialized) {
|
|
61
|
-
await adapter
|
|
69
|
+
await ensureCopObject(adapter, rawPowerId, {
|
|
62
70
|
type: "state",
|
|
63
71
|
common: { name: "Last Raw Power", type: "number", role: "value", read: true, write: false },
|
|
64
72
|
native: {}
|
|
65
73
|
});
|
|
66
|
-
await adapter
|
|
74
|
+
await ensureCopObject(adapter, rawThermalId, {
|
|
67
75
|
type: "state",
|
|
68
76
|
common: { name: "Last Raw Thermal", type: "number", role: "value", read: true, write: false },
|
|
69
77
|
native: {}
|
|
@@ -84,16 +92,24 @@ async function processCopData(adapter, bzVal) {
|
|
|
84
92
|
const lastThermalState = await adapter.getStateAsync(rawThermalId);
|
|
85
93
|
const lastPowerTotal = lastPowerState && typeof lastPowerState.val === "number" ? lastPowerState.val : currentPower;
|
|
86
94
|
const lastThermalTotal = lastThermalState && typeof lastThermalState.val === "number" ? lastThermalState.val : currentThermal;
|
|
87
|
-
const deltaPower = currentPower - lastPowerTotal;
|
|
88
|
-
const deltaThermal = currentThermal - lastThermalTotal;
|
|
89
|
-
if (
|
|
95
|
+
const deltaPower = Math.max(0, currentPower - lastPowerTotal);
|
|
96
|
+
const deltaThermal = Math.max(0, currentThermal - lastThermalTotal);
|
|
97
|
+
if (currentPower < lastPowerTotal) {
|
|
90
98
|
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
99
|
+
}
|
|
100
|
+
if (currentThermal < lastThermalTotal) {
|
|
101
|
+
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
102
|
+
}
|
|
103
|
+
if (deltaPower > 0) {
|
|
104
|
+
await adapter.setState(rawPowerId, { val: currentPower, ack: true });
|
|
105
|
+
}
|
|
106
|
+
if (deltaThermal > 0) {
|
|
91
107
|
await adapter.setState(rawThermalId, { val: currentThermal, ack: true });
|
|
92
108
|
}
|
|
93
109
|
await handleTimeRollover(adapter);
|
|
94
110
|
if (deltaPower > 0 || deltaThermal > 0) {
|
|
95
111
|
await addDeltaToBucket(adapter, "Total", deltaPower, deltaThermal);
|
|
96
|
-
if (bzVal === "0") {
|
|
112
|
+
if (bzVal === "0" || bzVal === "4") {
|
|
97
113
|
await addDeltaToBucket(adapter, "Heating", deltaPower, deltaThermal);
|
|
98
114
|
} else if (bzVal === "1") {
|
|
99
115
|
await addDeltaToBucket(adapter, "HotWater", deltaPower, deltaThermal);
|
|
@@ -109,17 +125,17 @@ async function processCopData(adapter, bzVal) {
|
|
|
109
125
|
async function handleTimeRollover(adapter) {
|
|
110
126
|
(0, import_logger.writeLog)(`Pr\xFCfe Tageswechsel und lege Ordner an...`, "debug");
|
|
111
127
|
const dateStateId = "hidden.cop_buckets.last_date";
|
|
112
|
-
await adapter
|
|
128
|
+
await ensureCopObject(adapter, "hidden", {
|
|
113
129
|
type: "folder",
|
|
114
130
|
common: { name: "Hidden System Data" },
|
|
115
131
|
native: {}
|
|
116
132
|
});
|
|
117
|
-
await adapter
|
|
133
|
+
await ensureCopObject(adapter, "hidden.cop_buckets", {
|
|
118
134
|
type: "folder",
|
|
119
135
|
common: { name: "COP Data Buckets" },
|
|
120
136
|
native: {}
|
|
121
137
|
});
|
|
122
|
-
await adapter
|
|
138
|
+
await ensureCopObject(adapter, dateStateId, {
|
|
123
139
|
type: "state",
|
|
124
140
|
common: { name: "Last calculation date", type: "string", role: "date", read: true, write: false },
|
|
125
141
|
native: {}
|
|
@@ -127,9 +143,12 @@ async function handleTimeRollover(adapter) {
|
|
|
127
143
|
const state = await adapter.getStateAsync(dateStateId);
|
|
128
144
|
const lastDate = state && typeof state.val === "string" ? state.val : "";
|
|
129
145
|
const now = /* @__PURE__ */ new Date();
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
146
|
+
const y = now.getFullYear();
|
|
147
|
+
const m = String(now.getMonth() + 1).padStart(2, "0");
|
|
148
|
+
const d = String(now.getDate()).padStart(2, "0");
|
|
149
|
+
const currentDate = `${y}-${m}-${d}`;
|
|
150
|
+
const currentMonth = `${y}-${m}`;
|
|
151
|
+
const currentYear = `${y}`;
|
|
133
152
|
if (lastDate !== currentDate) {
|
|
134
153
|
const lastMonth = lastDate ? lastDate.substring(0, 7) : "";
|
|
135
154
|
const lastYear = lastDate ? lastDate.substring(0, 4) : "";
|
|
@@ -152,7 +171,7 @@ async function handleTimeRollover(adapter) {
|
|
|
152
171
|
}
|
|
153
172
|
async function getAbsoluteValue(adapter, category, type) {
|
|
154
173
|
const id = `hidden.cop_buckets.${category}_${type}_absolute`;
|
|
155
|
-
await adapter
|
|
174
|
+
await ensureCopObject(adapter, id, {
|
|
156
175
|
type: "state",
|
|
157
176
|
common: { name: `${category} ${type} Absolute`, type: "number", role: "value", read: true, write: false },
|
|
158
177
|
native: {}
|
|
@@ -163,7 +182,7 @@ async function getAbsoluteValue(adapter, category, type) {
|
|
|
163
182
|
async function setSnapshot(adapter, category, timeframe, power, thermal) {
|
|
164
183
|
const powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;
|
|
165
184
|
const thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;
|
|
166
|
-
await adapter
|
|
185
|
+
await ensureCopObject(adapter, powerId, {
|
|
167
186
|
type: "state",
|
|
168
187
|
common: {
|
|
169
188
|
name: `${category} Power Start ${timeframe}`,
|
|
@@ -174,7 +193,7 @@ async function setSnapshot(adapter, category, timeframe, power, thermal) {
|
|
|
174
193
|
},
|
|
175
194
|
native: {}
|
|
176
195
|
});
|
|
177
|
-
await adapter
|
|
196
|
+
await ensureCopObject(adapter, thermalId, {
|
|
178
197
|
type: "state",
|
|
179
198
|
common: {
|
|
180
199
|
name: `${category} Thermal Start ${timeframe}`,
|
|
@@ -190,7 +209,7 @@ async function setSnapshot(adapter, category, timeframe, power, thermal) {
|
|
|
190
209
|
}
|
|
191
210
|
async function update7DaysHistory(adapter, category, currentPower, currentThermal) {
|
|
192
211
|
const historyId = `hidden.cop_buckets.${category}_history_7d`;
|
|
193
|
-
await adapter
|
|
212
|
+
await ensureCopObject(adapter, historyId, {
|
|
194
213
|
type: "state",
|
|
195
214
|
common: { name: `${category} 7 Days History`, type: "string", role: "json", read: true, write: false },
|
|
196
215
|
native: {}
|
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;
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\nlet isInitialized = false;\n/** Cache f\u00FCr bereits angelegte Datenbank-Objekte zur Vermeidung unn\u00F6tiger DB-Zugriffe */\nconst ensuredObjects = new Set<string>();\n\n/**\n * Stellt einmalig pro Adapter-Laufzeit sicher, dass ein internes COP-Objekt existiert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param id Die Objekt-ID.\n * @param obj Die Objekt-Definition.\n */\nasync function ensureCopObject(adapter: LuxtronikAdapter, id: string, obj: ioBroker.SettableObject): Promise<void> {\n\tif (ensuredObjects.has(id)) {\n\t\treturn;\n\t}\n\tawait adapter.setObjectNotExistsAsync(id, obj);\n\tensuredObjects.add(id);\n}\n\n/**\n * Verarbeitet die COP-Daten und berechnet Live-Werte anhand von absoluten Z\u00E4hlern und Snapshots.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param bzVal Der aktuelle Betriebszustand der W\u00E4rmepumpe als String.\n * @returns Ein Promise, das nach Abschluss der Berechnung aufgel\u00F6st wird.\n */\nexport async function processCopData(adapter: LuxtronikAdapter, bzVal: string): Promise<void> {\n\tconst config = adapter.config as any;\n\tif (!config.cop_calculation_active) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\twriteLog(`COP Manager gestartet. Modus: ${bzVal}`, 'debug');\n\n\t\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// --- 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 ensureCopObject(adapter, 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 ensureCopObject(adapter, 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 (lokale Systemzeit) und erstellt Snapshots der Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n */\nasync function handleTimeRollover(adapter: LuxtronikAdapter): Promise<void> {\n\twriteLog(`Pr\u00FCfe Tageswechsel und lege Ordner an...`, 'debug');\n\tconst dateStateId = 'hidden.cop_buckets.last_date';\n\tawait ensureCopObject(adapter, 'hidden', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'Hidden System Data' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, 'hidden.cop_buckets', {\n\t\ttype: 'folder',\n\t\tcommon: { name: 'COP Data Buckets' },\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, dateStateId, {\n\t\ttype: 'state',\n\t\tcommon: { name: 'Last calculation date', type: 'string', role: 'date', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(dateStateId);\n\tconst lastDate = state && typeof state.val === 'string' ? state.val : '';\n\n\tconst now = new Date();\n\tconst y = now.getFullYear();\n\tconst m = String(now.getMonth() + 1).padStart(2, '0');\n\tconst d = String(now.getDate()).padStart(2, '0');\n\tconst currentDate = `${y}-${m}-${d}`; // Lokales Datum: YYYY-MM-DD\n\tconst currentMonth = `${y}-${m}`; // Lokaler Monat: YYYY-MM\n\tconst currentYear = `${y}`; // Lokales Jahr: YYYY\n\n\tif (lastDate !== currentDate) {\n\t\tconst lastMonth = lastDate ? lastDate.substring(0, 7) : '';\n\t\tconst lastYear = lastDate ? lastDate.substring(0, 4) : '';\n\t\tconst categories = ['Total', 'Heating', 'HotWater'];\n\n\t\tfor (const cat of categories) {\n\t\t\tconst powerAbs = await getAbsoluteValue(adapter, cat, 'power');\n\t\t\tconst thermalAbs = await getAbsoluteValue(adapter, cat, 'thermal');\n\n\t\t\t// IMMER: Tageswechsel Snapshot\n\t\t\tawait setSnapshot(adapter, cat, 'today', powerAbs, thermalAbs);\n\n\t\t\t// Historie f\u00FCr 7-Tage-COP aktualisieren\n\t\t\tawait update7DaysHistory(adapter, cat, powerAbs, thermalAbs);\n\n\t\t\t// Monatswechsel Snapshot\n\t\t\tif (lastMonth !== currentMonth) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'month', powerAbs, thermalAbs);\n\t\t\t}\n\n\t\t\t// Jahreswechsel Snapshot\n\t\t\tif (lastYear !== currentYear) {\n\t\t\t\tawait setSnapshot(adapter, cat, 'year', powerAbs, thermalAbs);\n\t\t\t}\n\t\t}\n\n\t\tawait adapter.setState(dateStateId, { val: currentDate, ack: true });\n\t\twriteLog(`Tageswechsel erkannt. COP-Snapshots f\u00FCr ${currentDate} wurden gesichert.`, 'info');\n\t}\n}\n\n/**\n * Liest den Endlosz\u00E4hler f\u00FCr eine spezifische Kategorie aus.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie (Total, Heating, HotWater).\n * @param type Art der Energie (power oder thermal).\n * @returns Der absolute Wert in kWh.\n */\nasync function getAbsoluteValue(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttype: 'power' | 'thermal',\n): Promise<number> {\n\tconst id = `hidden.cop_buckets.${category}_${type}_absolute`;\n\tawait ensureCopObject(adapter, id, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} ${type} Absolute`, type: 'number', role: 'value', read: true, write: false },\n\t\tnative: {},\n\t});\n\tconst state = await adapter.getStateAsync(id);\n\treturn state && typeof state.val === 'number' ? state.val : 0;\n}\n\n/**\n * Schreibt einen Snapshot-Wert.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param timeframe Der Zeitraum (today, month, year).\n * @param power Der zu sichernde Stromwert.\n * @param thermal Der zu sichernde W\u00E4rmewert.\n */\nasync function setSnapshot(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\ttimeframe: string,\n\tpower: number,\n\tthermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_start_${timeframe}`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_start_${timeframe}`;\n\n\tawait ensureCopObject(adapter, powerId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Power Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\tawait ensureCopObject(adapter, thermalId, {\n\t\ttype: 'state',\n\t\tcommon: {\n\t\t\tname: `${category} Thermal Start ${timeframe}`,\n\t\t\ttype: 'number',\n\t\t\trole: 'value',\n\t\t\tread: true,\n\t\t\twrite: false,\n\t\t},\n\t\tnative: {},\n\t});\n\n\tawait adapter.setState(powerId, { val: power, ack: true });\n\tawait adapter.setState(thermalId, { val: thermal, ack: true });\n}\n\n/**\n * Verwaltet einen rollierenden 7-Tage-Speicher als JSON.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die Kategorie.\n * @param currentPower Der absolute Stromz\u00E4hler.\n * @param currentThermal Der absolute W\u00E4rmez\u00E4hler.\n */\nasync function update7DaysHistory(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tcurrentPower: number,\n\tcurrentThermal: number,\n): Promise<void> {\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tawait ensureCopObject(adapter, historyId, {\n\t\ttype: 'state',\n\t\tcommon: { name: `${category} 7 Days History`, type: 'string', role: 'json', read: true, write: false },\n\t\tnative: {},\n\t});\n\n\tconst state = await adapter.getStateAsync(historyId);\n\tlet history: { power: number; thermal: number }[] = [];\n\n\tif (state && typeof state.val === 'string' && state.val !== '') {\n\t\ttry {\n\t\t\thistory = JSON.parse(state.val);\n\t\t} catch {\n\t\t\t/* ignore */\n\t\t}\n\t}\n\n\thistory.push({ power: currentPower, thermal: currentThermal });\n\tif (history.length > 7) {\n\t\thistory.shift(); // \u00C4ltesten Eintrag entfernen (Ringpuffer)\n\t}\n\n\tawait adapter.setState(historyId, { val: JSON.stringify(history), ack: true });\n}\n\n/**\n * Addiert die neuen kWh-Deltas auf die internen Endlosz\u00E4hler.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die zu aktualisierende Kategorie.\n * @param deltaPower Die verbrauchte elektrische Energie.\n * @param deltaThermal Die erzeugte thermische Energie.\n */\nasync function addDeltaToBucket(\n\tadapter: LuxtronikAdapter,\n\tcategory: string,\n\tdeltaPower: number,\n\tdeltaThermal: number,\n): Promise<void> {\n\tconst powerId = `hidden.cop_buckets.${category}_power_absolute`;\n\tconst thermalId = `hidden.cop_buckets.${category}_thermal_absolute`;\n\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tawait adapter.setState(powerId, { val: currentPower + deltaPower, ack: true });\n\tawait adapter.setState(thermalId, { val: currentThermal + deltaThermal, ack: true });\n}\n\n/**\n * Liest die Endlosz\u00E4hler und Snapshots aus, berechnet die Differenz und schreibt den COP.\n *\n * @param adapter Die Instanz des ioBroker-Adapters.\n * @param category Die auszulesende Kategorie (Total, Heating, HotWater).\n */\nasync function calculateAndWriteCop(adapter: LuxtronikAdapter, category: string): Promise<void> {\n\tconst currentPower = await getAbsoluteValue(adapter, category, 'power');\n\tconst currentThermal = await getAbsoluteValue(adapter, category, 'thermal');\n\n\tconst dpMap: Record<string, Record<string, string>> = {\n\t\tTotal: { today: 'cop_total_today', '7d': 'cop_total_7d', month: 'cop_total_month', year: 'cop_total_year' },\n\t\tHeating: {\n\t\t\ttoday: 'cop_heating_today',\n\t\t\t'7d': 'cop_heating_7d',\n\t\t\tmonth: 'cop_heating_month',\n\t\t\tyear: 'cop_heating_year',\n\t\t},\n\t\tHotWater: { today: 'cop_water_today', '7d': 'cop_water_7d', month: 'cop_water_month', year: 'cop_water_year' },\n\t};\n\n\t// 1. Berechnung f\u00FCr Heute, Monat, Jahr\n\tconst timeframes = ['today', 'month', 'year'];\n\tfor (const tf of timeframes) {\n\t\tconst powerStartId = `hidden.cop_buckets.${category}_power_start_${tf}`;\n\t\tconst thermalStartId = `hidden.cop_buckets.${category}_thermal_start_${tf}`;\n\n\t\tconst pState = await adapter.getStateAsync(powerStartId);\n\t\tconst tState = await adapter.getStateAsync(thermalStartId);\n\n\t\tconst pStart = pState && typeof pState.val === 'number' ? pState.val : currentPower;\n\t\tconst tStart = tState && typeof tState.val === 'number' ? tState.val : currentThermal;\n\n\t\tconst pUsed = currentPower - pStart;\n\t\tconst tGen = currentThermal - tStart;\n\n\t\tif (pUsed > 0) {\n\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\tconst targetId = getDpPath(dpMap[category][tf]);\n\t\t\tif (targetId) {\n\t\t\t\tawait adapter.setState(targetId, { val: cop, ack: true });\n\t\t\t}\n\t\t}\n\t}\n\n\t// 2. Berechnung f\u00FCr rollierende 7 Tage\n\tconst historyId = `hidden.cop_buckets.${category}_history_7d`;\n\tconst hState = await adapter.getStateAsync(historyId);\n\tif (hState && typeof hState.val === 'string' && hState.val !== '') {\n\t\ttry {\n\t\t\tconst history = JSON.parse(hState.val);\n\t\t\tif (history.length > 0) {\n\t\t\t\tconst oldest = history[0];\n\t\t\t\tconst pUsed = currentPower - oldest.power;\n\t\t\t\tconst tGen = currentThermal - oldest.thermal;\n\t\t\t\tif (pUsed > 0) {\n\t\t\t\t\tconst cop = Math.round((tGen / pUsed) * 100) / 100;\n\t\t\t\t\tconst targetId = getDpPath(dpMap[category]['7d']);\n\t\t\t\t\tif (targetId) {\n\t\t\t\t\t\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,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
|
}
|