iobroker.luxtronik2-controller 0.20.4 → 0.21.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 +28 -10
- package/admin/img/PV.png +0 -0
- package/admin/jsonConfig.json +478 -3
- package/build/main.js +42 -24
- package/build/main.js.map +2 -2
- package/build/mapping/info.js +37 -0
- package/build/mapping/info.js.map +2 -2
- package/build/modbusManager.js +23 -22
- package/build/modbusManager.js.map +2 -2
- package/build/pvManager.js +367 -0
- package/build/pvManager.js.map +7 -0
- package/build/virtualStates.js +6 -6
- package/build/virtualStates.js.map +2 -2
- package/io-package.json +14 -14
- package/package.json +2 -2
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pvManager_exports = {};
|
|
20
|
+
__export(pvManager_exports, {
|
|
21
|
+
forceResetPvBoost: () => forceResetPvBoost,
|
|
22
|
+
handlePvCycleCheck: () => handlePvCycleCheck,
|
|
23
|
+
handlePvFeedInChange: () => handlePvFeedInChange,
|
|
24
|
+
initPvManagement: () => initPvManagement,
|
|
25
|
+
pvIsBoostActive: () => pvIsBoostActive,
|
|
26
|
+
pvWaitingForCycleEnd: () => pvWaitingForCycleEnd
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(pvManager_exports);
|
|
29
|
+
var import_logger = require("./logger");
|
|
30
|
+
var import_stateMapping = require("./stateMapping");
|
|
31
|
+
let pvStartTimer;
|
|
32
|
+
let pvStopTimer;
|
|
33
|
+
let pvIsBoostActive = false;
|
|
34
|
+
let pvWaitingForCycleEnd = false;
|
|
35
|
+
let activeBoostWwApplied = false;
|
|
36
|
+
let activeBoostHzApplied = false;
|
|
37
|
+
let currentGridSurplusW = 0;
|
|
38
|
+
let currentBatteryChargeW = 0;
|
|
39
|
+
let originalWw = null;
|
|
40
|
+
let originalHz = null;
|
|
41
|
+
async function initPvManagement(adapter) {
|
|
42
|
+
const config = adapter.config;
|
|
43
|
+
if (!config.pv_active || !config.pv_feed_in_dp || config.pv_feed_in_dp.trim() === "") {
|
|
44
|
+
(0, import_logger.writeLog)("[PV] PV surplus management is disabled or no valid datapoint provided.", "debug");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
currentGridSurplusW = 0;
|
|
49
|
+
currentBatteryChargeW = 0;
|
|
50
|
+
pvIsBoostActive = false;
|
|
51
|
+
pvWaitingForCycleEnd = false;
|
|
52
|
+
activeBoostWwApplied = false;
|
|
53
|
+
activeBoostHzApplied = false;
|
|
54
|
+
const gridDp = config.pv_feed_in_dp.trim();
|
|
55
|
+
await adapter.subscribeForeignStatesAsync(gridDp);
|
|
56
|
+
(0, import_logger.writeLog)(`[PV] Initialized PV management. Subscribed to grid feed-in: ${gridDp}`, "info");
|
|
57
|
+
try {
|
|
58
|
+
const initialGridState = await adapter.getForeignStateAsync(gridDp);
|
|
59
|
+
if (initialGridState) {
|
|
60
|
+
handlePvFeedInChange(adapter, gridDp, initialGridState);
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
if (config.pv_battery_active && config.pv_battery_dp && config.pv_battery_dp.trim() !== "") {
|
|
65
|
+
const batDp = config.pv_battery_dp.trim();
|
|
66
|
+
await adapter.subscribeForeignStatesAsync(batDp);
|
|
67
|
+
(0, import_logger.writeLog)(`[PV] Battery prioritization active. Subscribed to battery datapoint: ${batDp}`, "info");
|
|
68
|
+
try {
|
|
69
|
+
const initialBatState = await adapter.getForeignStateAsync(batDp);
|
|
70
|
+
if (initialBatState) {
|
|
71
|
+
handlePvFeedInChange(adapter, batDp, initialBatState);
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const dpActive = (0, import_stateMapping.getDpPath)("pv_boost_active");
|
|
77
|
+
const dpSince = (0, import_stateMapping.getDpPath)("pv_boost_active_since");
|
|
78
|
+
if (dpActive) {
|
|
79
|
+
await adapter.setState(dpActive, { val: false, ack: true });
|
|
80
|
+
}
|
|
81
|
+
if (dpSince) {
|
|
82
|
+
await adapter.setState(dpSince, { val: "", ack: true });
|
|
83
|
+
}
|
|
84
|
+
} catch (err) {
|
|
85
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
86
|
+
(0, import_logger.writeLog)(`[PV] Error initializing PV management: ${msg}`, "error");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function handlePvFeedInChange(adapter, id, state) {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const config = adapter.config;
|
|
92
|
+
if (!config.pv_active || !state || typeof state.val !== "number") {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const isGridDp = id === ((_a = config.pv_feed_in_dp) == null ? void 0 : _a.trim());
|
|
96
|
+
const isBatteryDp = config.pv_battery_active && id === ((_b = config.pv_battery_dp) == null ? void 0 : _b.trim());
|
|
97
|
+
if (!isGridDp && !isBatteryDp) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
let rawValue = state.val;
|
|
101
|
+
if (isGridDp) {
|
|
102
|
+
if (config.pv_feed_in_unit === "kW") {
|
|
103
|
+
rawValue *= 1e3;
|
|
104
|
+
}
|
|
105
|
+
if (config.pv_feed_in_sign === "negative") {
|
|
106
|
+
currentGridSurplusW = rawValue < 0 ? Math.abs(rawValue) : 0;
|
|
107
|
+
} else {
|
|
108
|
+
currentGridSurplusW = rawValue > 0 ? rawValue : 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (isBatteryDp) {
|
|
112
|
+
if (config.pv_battery_unit === "kW") {
|
|
113
|
+
rawValue *= 1e3;
|
|
114
|
+
}
|
|
115
|
+
if (config.pv_battery_sign === "negative") {
|
|
116
|
+
currentBatteryChargeW = rawValue < 0 ? Math.abs(rawValue) : 0;
|
|
117
|
+
} else {
|
|
118
|
+
currentBatteryChargeW = rawValue > 0 ? rawValue : 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const totalSurplus = currentGridSurplusW + currentBatteryChargeW;
|
|
122
|
+
const thresholdStart = config.pv_threshold_start || 2e3;
|
|
123
|
+
const thresholdStop = config.pv_threshold_stop !== void 0 ? Number(config.pv_threshold_stop) : 0;
|
|
124
|
+
const delayStartMs = (config.pv_delay_start || 5) * 6e4;
|
|
125
|
+
const delayStopMs = (config.pv_delay_stop || 10) * 6e4;
|
|
126
|
+
if (totalSurplus >= thresholdStart) {
|
|
127
|
+
if (pvStopTimer) {
|
|
128
|
+
adapter.clearTimeout(pvStopTimer);
|
|
129
|
+
pvStopTimer = void 0;
|
|
130
|
+
(0, import_logger.writeLog)(
|
|
131
|
+
`[PV] Surplus restored (${totalSurplus} W >= ${thresholdStart} W). Stop timer cancelled.`,
|
|
132
|
+
"debug"
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
if (!pvIsBoostActive && !pvStartTimer) {
|
|
136
|
+
(0, import_logger.writeLog)(
|
|
137
|
+
`[PV] Surplus of ${totalSurplus} W exceeds start threshold (${thresholdStart} W). Starting ${config.pv_delay_start} min activation timer.`,
|
|
138
|
+
"info"
|
|
139
|
+
);
|
|
140
|
+
pvStartTimer = adapter.setTimeout(() => activateBoost(adapter), delayStartMs);
|
|
141
|
+
} else if (pvIsBoostActive) {
|
|
142
|
+
void evaluatePvBoost(adapter);
|
|
143
|
+
}
|
|
144
|
+
} else if (totalSurplus <= thresholdStop) {
|
|
145
|
+
if (pvStartTimer) {
|
|
146
|
+
adapter.clearTimeout(pvStartTimer);
|
|
147
|
+
pvStartTimer = void 0;
|
|
148
|
+
(0, import_logger.writeLog)(
|
|
149
|
+
`[PV] Surplus dropped to ${totalSurplus} W (<= ${thresholdStop} W). Start timer cancelled.`,
|
|
150
|
+
"debug"
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (pvIsBoostActive && !pvStopTimer && !pvWaitingForCycleEnd) {
|
|
154
|
+
(0, import_logger.writeLog)(
|
|
155
|
+
`[PV] Surplus dropped to ${totalSurplus} W (<= stop threshold ${thresholdStop} W). Starting ${config.pv_delay_stop} min deactivation timer.`,
|
|
156
|
+
"info"
|
|
157
|
+
);
|
|
158
|
+
pvStopTimer = adapter.setTimeout(() => initiateDeactivation(adapter), delayStopMs);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
if (pvStartTimer) {
|
|
162
|
+
adapter.clearTimeout(pvStartTimer);
|
|
163
|
+
pvStartTimer = void 0;
|
|
164
|
+
(0, import_logger.writeLog)(`[PV] Surplus ${totalSurplus} W is below start threshold. Start timer cancelled.`, "debug");
|
|
165
|
+
}
|
|
166
|
+
if (pvStopTimer) {
|
|
167
|
+
adapter.clearTimeout(pvStopTimer);
|
|
168
|
+
pvStopTimer = void 0;
|
|
169
|
+
(0, import_logger.writeLog)(`[PV] Surplus ${totalSurplus} W is above stop threshold. Stop timer cancelled.`, "debug");
|
|
170
|
+
}
|
|
171
|
+
if (pvIsBoostActive) {
|
|
172
|
+
void evaluatePvBoost(adapter);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function activateBoost(adapter) {
|
|
177
|
+
pvStartTimer = void 0;
|
|
178
|
+
if (pvIsBoostActive) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const config = adapter.config;
|
|
182
|
+
try {
|
|
183
|
+
const wwPath = (0, import_stateMapping.getDpPath)("Wamwassertemperatur_Soll");
|
|
184
|
+
const hzPath = (0, import_stateMapping.getDpPath)("heating_temperature");
|
|
185
|
+
const currentWwState = wwPath ? await adapter.getStateAsync(wwPath) : null;
|
|
186
|
+
const currentHzState = hzPath ? await adapter.getStateAsync(hzPath) : null;
|
|
187
|
+
let baseWw = currentWwState && typeof currentWwState.val === "number" ? currentWwState.val : null;
|
|
188
|
+
let baseHz = currentHzState && typeof currentHzState.val === "number" ? currentHzState.val : null;
|
|
189
|
+
if (config.idle_defaults_aktiv) {
|
|
190
|
+
if (config.sync_warmwater_target_temperature) {
|
|
191
|
+
baseWw = Number(config.sync_warmwater_target_temperature);
|
|
192
|
+
}
|
|
193
|
+
if (config.fusspunkt) {
|
|
194
|
+
baseHz = Number(config.fusspunkt);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
originalWw = baseWw;
|
|
198
|
+
originalHz = baseHz;
|
|
199
|
+
pvIsBoostActive = true;
|
|
200
|
+
pvWaitingForCycleEnd = false;
|
|
201
|
+
activeBoostWwApplied = false;
|
|
202
|
+
activeBoostHzApplied = false;
|
|
203
|
+
(0, import_logger.writeLog)("[PV] Timer finished. Activating boost logic...", "info");
|
|
204
|
+
await evaluatePvBoost(adapter);
|
|
205
|
+
const nowStr = (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").substring(0, 19);
|
|
206
|
+
const dpActive = (0, import_stateMapping.getDpPath)("pv_boost_active");
|
|
207
|
+
const dpSince = (0, import_stateMapping.getDpPath)("pv_boost_active_since");
|
|
208
|
+
const dpLast = (0, import_stateMapping.getDpPath)("pv_boost_last_activation");
|
|
209
|
+
if (dpActive) {
|
|
210
|
+
await adapter.setState(dpActive, { val: true, ack: true });
|
|
211
|
+
}
|
|
212
|
+
if (dpSince) {
|
|
213
|
+
await adapter.setState(dpSince, { val: nowStr, ack: true });
|
|
214
|
+
}
|
|
215
|
+
if (dpLast) {
|
|
216
|
+
await adapter.setState(dpLast, { val: nowStr, ack: true });
|
|
217
|
+
}
|
|
218
|
+
} catch (err) {
|
|
219
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
220
|
+
(0, import_logger.writeLog)(`[PV] Error activating boost: ${msg}`, "error");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async function evaluatePvBoost(adapter) {
|
|
224
|
+
if (!pvIsBoostActive) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
const config = adapter.config;
|
|
229
|
+
const priority = config.pv_priority || "both";
|
|
230
|
+
const boostWwAmount = Number(config.pv_boost_ww) || 0;
|
|
231
|
+
const boostHzAmount = Number(config.pv_boost_hz) || 0;
|
|
232
|
+
const wwPath = (0, import_stateMapping.getDpPath)("temperature_hot_water_target");
|
|
233
|
+
const hzPath = (0, import_stateMapping.getDpPath)("heating_temperature");
|
|
234
|
+
const wwIstState = await adapter.getStateAsync((0, import_stateMapping.getDpPath)("Wamwassertemperatur_Ist"));
|
|
235
|
+
const hzIstState = await adapter.getStateAsync((0, import_stateMapping.getDpPath)("temperature_return"));
|
|
236
|
+
const wwIst = wwIstState && typeof wwIstState.val === "number" ? wwIstState.val : 0;
|
|
237
|
+
const hzIst = hzIstState && typeof hzIstState.val === "number" ? hzIstState.val : 0;
|
|
238
|
+
const isWwFull = originalWw !== null && wwIst >= originalWw + boostWwAmount - 0.5;
|
|
239
|
+
const isHzFull = originalHz !== null && hzIst >= originalHz + boostHzAmount - 0.5;
|
|
240
|
+
let shouldBoostWw = false;
|
|
241
|
+
let shouldBoostHz = false;
|
|
242
|
+
if (priority === "ww") {
|
|
243
|
+
if (!isWwFull) {
|
|
244
|
+
shouldBoostWw = true;
|
|
245
|
+
} else {
|
|
246
|
+
shouldBoostHz = true;
|
|
247
|
+
}
|
|
248
|
+
} else if (priority === "hz") {
|
|
249
|
+
if (!isHzFull) {
|
|
250
|
+
shouldBoostHz = true;
|
|
251
|
+
} else {
|
|
252
|
+
shouldBoostWw = true;
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
shouldBoostWw = !isWwFull;
|
|
256
|
+
shouldBoostHz = !isHzFull;
|
|
257
|
+
}
|
|
258
|
+
if (shouldBoostWw && !activeBoostWwApplied && originalWw !== null && boostWwAmount > 0 && wwPath) {
|
|
259
|
+
await adapter.setState(wwPath, { val: originalWw + boostWwAmount, ack: false });
|
|
260
|
+
activeBoostWwApplied = true;
|
|
261
|
+
(0, import_logger.writeLog)(`[PV] Priority logic: Applying Hot Water boost (+${boostWwAmount}K).`, "info");
|
|
262
|
+
} else if (!shouldBoostWw && activeBoostWwApplied && originalWw !== null && wwPath) {
|
|
263
|
+
await adapter.setState(wwPath, { val: originalWw, ack: false });
|
|
264
|
+
activeBoostWwApplied = false;
|
|
265
|
+
(0, import_logger.writeLog)(`[PV] Priority logic: Target reached. Revoking Hot Water boost.`, "info");
|
|
266
|
+
}
|
|
267
|
+
if (shouldBoostHz && !activeBoostHzApplied && originalHz !== null && boostHzAmount > 0 && hzPath) {
|
|
268
|
+
await adapter.setState(hzPath, { val: originalHz + boostHzAmount, ack: false });
|
|
269
|
+
activeBoostHzApplied = true;
|
|
270
|
+
(0, import_logger.writeLog)(`[PV] Priority logic: Applying Heating boost (+${boostHzAmount}K).`, "info");
|
|
271
|
+
} else if (!shouldBoostHz && activeBoostHzApplied && originalHz !== null && hzPath) {
|
|
272
|
+
await adapter.setState(hzPath, { val: originalHz, ack: false });
|
|
273
|
+
activeBoostHzApplied = false;
|
|
274
|
+
(0, import_logger.writeLog)(`[PV] Priority logic: Target reached. Revoking Heating boost.`, "info");
|
|
275
|
+
}
|
|
276
|
+
} catch (err) {
|
|
277
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
278
|
+
(0, import_logger.writeLog)(`[PV] Error evaluating boost priority: ${msg}`, "error");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function initiateDeactivation(adapter) {
|
|
282
|
+
pvStopTimer = void 0;
|
|
283
|
+
if (!pvIsBoostActive) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const config = adapter.config;
|
|
287
|
+
(0, import_logger.writeLog)("[PV] Deactivation timer finished.", "info");
|
|
288
|
+
if (config.pv_finish_cycle) {
|
|
289
|
+
try {
|
|
290
|
+
const bzPath = (0, import_stateMapping.getDpPath)("WP_BZ_akt");
|
|
291
|
+
const bzState = bzPath ? await adapter.getStateAsync(bzPath) : null;
|
|
292
|
+
const bzVal = bzState ? Number(bzState.val) : 5;
|
|
293
|
+
if (bzVal !== 5) {
|
|
294
|
+
(0, import_logger.writeLog)(
|
|
295
|
+
`[PV] Compressor is active (Status: ${bzVal}). Waiting for cycle to finish before resetting values.`,
|
|
296
|
+
"info"
|
|
297
|
+
);
|
|
298
|
+
pvWaitingForCycleEnd = true;
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
303
|
+
(0, import_logger.writeLog)(`[PV] Error checking compressor status: ${msg}`, "error");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
await deactivateBoost(adapter);
|
|
307
|
+
}
|
|
308
|
+
async function deactivateBoost(adapter) {
|
|
309
|
+
try {
|
|
310
|
+
(0, import_logger.writeLog)("[PV] Reverting values to original base targets.", "info");
|
|
311
|
+
const wwPath = (0, import_stateMapping.getDpPath)("Wamwassertemperatur_Soll");
|
|
312
|
+
const hzPath = (0, import_stateMapping.getDpPath)("heating_temperature");
|
|
313
|
+
if (originalWw !== null && wwPath) {
|
|
314
|
+
await adapter.setState(wwPath, { val: originalWw, ack: false });
|
|
315
|
+
}
|
|
316
|
+
if (originalHz !== null && hzPath) {
|
|
317
|
+
await adapter.setState(hzPath, { val: originalHz, ack: false });
|
|
318
|
+
}
|
|
319
|
+
pvIsBoostActive = false;
|
|
320
|
+
pvWaitingForCycleEnd = false;
|
|
321
|
+
activeBoostWwApplied = false;
|
|
322
|
+
activeBoostHzApplied = false;
|
|
323
|
+
originalWw = null;
|
|
324
|
+
originalHz = null;
|
|
325
|
+
const dpActive = (0, import_stateMapping.getDpPath)("pv_boost_active");
|
|
326
|
+
const dpSince = (0, import_stateMapping.getDpPath)("pv_boost_active_since");
|
|
327
|
+
if (dpActive) {
|
|
328
|
+
await adapter.setState(dpActive, { val: false, ack: true });
|
|
329
|
+
}
|
|
330
|
+
if (dpSince) {
|
|
331
|
+
await adapter.setState(dpSince, { val: "", ack: true });
|
|
332
|
+
}
|
|
333
|
+
} catch (err) {
|
|
334
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
335
|
+
(0, import_logger.writeLog)(`[PV] Error deactivating boost: ${msg}`, "error");
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
async function handlePvCycleCheck(adapter, newBzVal) {
|
|
339
|
+
if (pvWaitingForCycleEnd && newBzVal === 5) {
|
|
340
|
+
(0, import_logger.writeLog)("[PV] Compressor finished cycle (Status: 5). Resetting PV boost targets now.", "info");
|
|
341
|
+
await deactivateBoost(adapter);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async function forceResetPvBoost(adapter) {
|
|
345
|
+
if (pvIsBoostActive) {
|
|
346
|
+
(0, import_logger.writeLog)("[PV] Manual override triggered. Cancelling active PV boost...", "info");
|
|
347
|
+
if (pvStartTimer) {
|
|
348
|
+
adapter.clearTimeout(pvStartTimer);
|
|
349
|
+
pvStartTimer = void 0;
|
|
350
|
+
}
|
|
351
|
+
if (pvStopTimer) {
|
|
352
|
+
adapter.clearTimeout(pvStopTimer);
|
|
353
|
+
pvStopTimer = void 0;
|
|
354
|
+
}
|
|
355
|
+
await deactivateBoost(adapter);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
359
|
+
0 && (module.exports = {
|
|
360
|
+
forceResetPvBoost,
|
|
361
|
+
handlePvCycleCheck,
|
|
362
|
+
handlePvFeedInChange,
|
|
363
|
+
initPvManagement,
|
|
364
|
+
pvIsBoostActive,
|
|
365
|
+
pvWaitingForCycleEnd
|
|
366
|
+
});
|
|
367
|
+
//# sourceMappingURL=pvManager.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/pvManager.ts"],
|
|
4
|
+
"sourcesContent": ["import { writeLog } from './logger';\nimport { getDpPath } from './stateMapping';\nimport type { LuxtronikAdapter } from './types';\n\n// =========================================================\n// STATE VARIABLES\n// =========================================================\n\nlet pvStartTimer: ioBroker.Timeout | undefined;\nlet pvStopTimer: ioBroker.Timeout | undefined;\nexport let pvIsBoostActive = false;\nexport let pvWaitingForCycleEnd = false;\n\n// Flags f\u00FCr die dynamische Priorit\u00E4tssteuerung\nlet activeBoostWwApplied = false;\nlet activeBoostHzApplied = false;\n\n// Live-Werte f\u00FCr die Berechnung des Gesamt-\u00DCberschusses\nlet currentGridSurplusW = 0;\nlet currentBatteryChargeW = 0;\n\n// Cache f\u00FCr die urspr\u00FCnglichen Werte vor dem Boost\nlet originalWw: number | null = null;\nlet originalHz: number | null = null;\n\n// =========================================================\n// MAIN LOGIC\n// =========================================================\n\n/**\n * Initialisiert die PV-\u00DCberwachung, abonniert Fremd-Datenpunkte und l\u00E4dt Initialwerte.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nexport async function initPvManagement(adapter: LuxtronikAdapter): Promise<void> {\n\tconst config = adapter.config;\n\tif (!config.pv_active || !config.pv_feed_in_dp || config.pv_feed_in_dp.trim() === '') {\n\t\twriteLog('[PV] PV surplus management is disabled or no valid datapoint provided.', 'debug');\n\t\treturn;\n\t}\n\n\ttry {\n\t\tcurrentGridSurplusW = 0;\n\t\tcurrentBatteryChargeW = 0;\n\t\tpvIsBoostActive = false;\n\t\tpvWaitingForCycleEnd = false;\n\t\tactiveBoostWwApplied = false;\n\t\tactiveBoostHzApplied = false;\n\n\t\t// 1. Netz-Datenpunkt abonnieren & Initialwert holen\n\t\tconst gridDp = config.pv_feed_in_dp.trim();\n\t\tawait adapter.subscribeForeignStatesAsync(gridDp);\n\t\twriteLog(`[PV] Initialized PV management. Subscribed to grid feed-in: ${gridDp}`, 'info');\n\n\t\ttry {\n\t\t\tconst initialGridState = await adapter.getForeignStateAsync(gridDp);\n\t\t\tif (initialGridState) {\n\t\t\t\thandlePvFeedInChange(adapter, gridDp, initialGridState);\n\t\t\t}\n\t\t} catch {\n\t\t\t/* ignore initial fetch error */\n\t\t}\n\n\t\t// 2. Batterie-Datenpunkt abonnieren & Initialwert holen (falls aktiv)\n\t\tif (config.pv_battery_active && config.pv_battery_dp && config.pv_battery_dp.trim() !== '') {\n\t\t\tconst batDp = config.pv_battery_dp.trim();\n\t\t\tawait adapter.subscribeForeignStatesAsync(batDp);\n\t\t\twriteLog(`[PV] Battery prioritization active. Subscribed to battery datapoint: ${batDp}`, 'info');\n\n\t\t\ttry {\n\t\t\t\tconst initialBatState = await adapter.getForeignStateAsync(batDp);\n\t\t\t\tif (initialBatState) {\n\t\t\t\t\thandlePvFeedInChange(adapter, batDp, initialBatState);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t/* ignore initial fetch error */\n\t\t\t}\n\t\t}\n\n\t\tconst dpActive = getDpPath('pv_boost_active');\n\t\tconst dpSince = getDpPath('pv_boost_active_since');\n\n\t\tif (dpActive) {\n\t\t\tawait adapter.setState(dpActive, { val: false, ack: true });\n\t\t}\n\t\tif (dpSince) {\n\t\t\tawait adapter.setState(dpSince, { val: '', ack: true });\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`[PV] Error initializing PV management: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Wird bei jeder \u00C4nderung eines Foreign-States aufgerufen. Berechnet die Summe aus Netz + Batterie.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n * @param id Die ID (OID) des ge\u00E4nderten Datenpunkts.\n * @param state Das neue ioBroker State-Objekt.\n */\nexport function handlePvFeedInChange(adapter: LuxtronikAdapter, id: string, state: ioBroker.State): void {\n\tconst config = adapter.config;\n\tif (!config.pv_active || !state || typeof state.val !== 'number') {\n\t\treturn;\n\t}\n\n\tconst isGridDp = id === config.pv_feed_in_dp?.trim();\n\tconst isBatteryDp = config.pv_battery_active && id === config.pv_battery_dp?.trim();\n\n\t// Abbrechen, wenn das Event von einem anderen (irrelevanten) Fremd-Datenpunkt kommt\n\tif (!isGridDp && !isBatteryDp) {\n\t\treturn;\n\t}\n\n\tlet rawValue = state.val;\n\n\t// Update Netz-\u00DCberschuss\n\tif (isGridDp) {\n\t\tif (config.pv_feed_in_unit === 'kW') {\n\t\t\trawValue *= 1000;\n\t\t}\n\t\tif (config.pv_feed_in_sign === 'negative') {\n\t\t\tcurrentGridSurplusW = rawValue < 0 ? Math.abs(rawValue) : 0;\n\t\t} else {\n\t\t\tcurrentGridSurplusW = rawValue > 0 ? rawValue : 0;\n\t\t}\n\t}\n\n\t// Update Batterie-Ladeleistung\n\tif (isBatteryDp) {\n\t\tif (config.pv_battery_unit === 'kW') {\n\t\t\trawValue *= 1000;\n\t\t}\n\t\tif (config.pv_battery_sign === 'negative') {\n\t\t\tcurrentBatteryChargeW = rawValue < 0 ? Math.abs(rawValue) : 0;\n\t\t} else {\n\t\t\tcurrentBatteryChargeW = rawValue > 0 ? rawValue : 0;\n\t\t}\n\t}\n\n\t// Effektiver Gesamt\u00FCberschuss = Reale Einspeisung + Strom, der aktuell in die Batterie flie\u00DFt\n\tconst totalSurplus = currentGridSurplusW + currentBatteryChargeW;\n\n\tconst thresholdStart = config.pv_threshold_start || 2000;\n\tconst thresholdStop = config.pv_threshold_stop !== undefined ? Number(config.pv_threshold_stop) : 0;\n\tconst delayStartMs = (config.pv_delay_start || 5) * 60000;\n\tconst delayStopMs = (config.pv_delay_stop || 10) * 60000;\n\n\tif (totalSurplus >= thresholdStart) {\n\t\tif (pvStopTimer) {\n\t\t\tadapter.clearTimeout(pvStopTimer);\n\t\t\tpvStopTimer = undefined;\n\t\t\twriteLog(\n\t\t\t\t`[PV] Surplus restored (${totalSurplus} W >= ${thresholdStart} W). Stop timer cancelled.`,\n\t\t\t\t'debug',\n\t\t\t);\n\t\t}\n\n\t\tif (!pvIsBoostActive && !pvStartTimer) {\n\t\t\twriteLog(\n\t\t\t\t`[PV] Surplus of ${totalSurplus} W exceeds start threshold (${thresholdStart} W). Starting ${config.pv_delay_start} min activation timer.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tpvStartTimer = adapter.setTimeout(() => activateBoost(adapter), delayStartMs);\n\t\t} else if (pvIsBoostActive) {\n\t\t\tvoid evaluatePvBoost(adapter);\n\t\t}\n\t} else if (totalSurplus <= thresholdStop) {\n\t\tif (pvStartTimer) {\n\t\t\tadapter.clearTimeout(pvStartTimer);\n\t\t\tpvStartTimer = undefined;\n\t\t\twriteLog(\n\t\t\t\t`[PV] Surplus dropped to ${totalSurplus} W (<= ${thresholdStop} W). Start timer cancelled.`,\n\t\t\t\t'debug',\n\t\t\t);\n\t\t}\n\n\t\tif (pvIsBoostActive && !pvStopTimer && !pvWaitingForCycleEnd) {\n\t\t\twriteLog(\n\t\t\t\t`[PV] Surplus dropped to ${totalSurplus} W (<= stop threshold ${thresholdStop} W). Starting ${config.pv_delay_stop} min deactivation timer.`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tpvStopTimer = adapter.setTimeout(() => initiateDeactivation(adapter), delayStopMs);\n\t\t}\n\t} else {\n\t\t// Grauzone (Hysterese)\n\t\tif (pvStartTimer) {\n\t\t\tadapter.clearTimeout(pvStartTimer);\n\t\t\tpvStartTimer = undefined;\n\t\t\twriteLog(`[PV] Surplus ${totalSurplus} W is below start threshold. Start timer cancelled.`, 'debug');\n\t\t}\n\t\tif (pvStopTimer) {\n\t\t\tadapter.clearTimeout(pvStopTimer);\n\t\t\tpvStopTimer = undefined;\n\t\t\twriteLog(`[PV] Surplus ${totalSurplus} W is above stop threshold. Stop timer cancelled.`, 'debug');\n\t\t}\n\t\tif (pvIsBoostActive) {\n\t\t\tvoid evaluatePvBoost(adapter);\n\t\t}\n\t}\n}\n\n/**\n * Legt die Originalwerte ab und startet den dynamischen Boost.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nasync function activateBoost(adapter: LuxtronikAdapter): Promise<void> {\n\tpvStartTimer = undefined;\n\tif (pvIsBoostActive) {\n\t\treturn;\n\t}\n\n\tconst config = adapter.config;\n\ttry {\n\t\tconst wwPath = getDpPath('Wamwassertemperatur_Soll');\n\t\tconst hzPath = getDpPath('heating_temperature');\n\n\t\tconst currentWwState = wwPath ? await adapter.getStateAsync(wwPath) : null;\n\t\tconst currentHzState = hzPath ? await adapter.getStateAsync(hzPath) : null;\n\n\t\tlet baseWw = currentWwState && typeof currentWwState.val === 'number' ? currentWwState.val : null;\n\t\tlet baseHz = currentHzState && typeof currentHzState.val === 'number' ? currentHzState.val : null;\n\n\t\tif (config.idle_defaults_aktiv) {\n\t\t\tif (config.sync_warmwater_target_temperature) {\n\t\t\t\tbaseWw = Number(config.sync_warmwater_target_temperature);\n\t\t\t}\n\t\t\tif (config.fusspunkt) {\n\t\t\t\tbaseHz = Number(config.fusspunkt);\n\t\t\t}\n\t\t}\n\n\t\toriginalWw = baseWw;\n\t\toriginalHz = baseHz;\n\t\tpvIsBoostActive = true;\n\t\tpvWaitingForCycleEnd = false;\n\t\tactiveBoostWwApplied = false;\n\t\tactiveBoostHzApplied = false;\n\n\t\twriteLog('[PV] Timer finished. Activating boost logic...', 'info');\n\t\tawait evaluatePvBoost(adapter);\n\n\t\tconst nowStr = new Date().toISOString().replace('T', ' ').substring(0, 19);\n\t\tconst dpActive = getDpPath('pv_boost_active');\n\t\tconst dpSince = getDpPath('pv_boost_active_since');\n\t\tconst dpLast = getDpPath('pv_boost_last_activation');\n\n\t\tif (dpActive) {\n\t\t\tawait adapter.setState(dpActive, { val: true, ack: true });\n\t\t}\n\t\tif (dpSince) {\n\t\t\tawait adapter.setState(dpSince, { val: nowStr, ack: true });\n\t\t}\n\t\tif (dpLast) {\n\t\t\tawait adapter.setState(dpLast, { val: nowStr, ack: true });\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`[PV] Error activating boost: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Evaluiert fortlaufend die Priorit\u00E4ten und schreibt die Sollwerte dynamisch in die Anlage.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nasync function evaluatePvBoost(adapter: LuxtronikAdapter): Promise<void> {\n\tif (!pvIsBoostActive) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst config = adapter.config;\n\t\tconst priority = config.pv_priority || 'both';\n\n\t\tconst boostWwAmount = Number(config.pv_boost_ww) || 0;\n\t\tconst boostHzAmount = Number(config.pv_boost_hz) || 0;\n\n\t\tconst wwPath = getDpPath('temperature_hot_water_target');\n\t\tconst hzPath = getDpPath('heating_temperature');\n\n\t\tconst wwIstState = await adapter.getStateAsync(getDpPath('Wamwassertemperatur_Ist'));\n\t\tconst hzIstState = await adapter.getStateAsync(getDpPath('temperature_return'));\n\n\t\tconst wwIst = wwIstState && typeof wwIstState.val === 'number' ? wwIstState.val : 0;\n\t\tconst hzIst = hzIstState && typeof hzIstState.val === 'number' ? hzIstState.val : 0;\n\n\t\tconst isWwFull = originalWw !== null && wwIst >= originalWw + boostWwAmount - 0.5;\n\t\tconst isHzFull = originalHz !== null && hzIst >= originalHz + boostHzAmount - 0.5;\n\n\t\tlet shouldBoostWw = false;\n\t\tlet shouldBoostHz = false;\n\n\t\tif (priority === 'ww') {\n\t\t\tif (!isWwFull) {\n\t\t\t\tshouldBoostWw = true;\n\t\t\t} else {\n\t\t\t\tshouldBoostHz = true;\n\t\t\t}\n\t\t} else if (priority === 'hz') {\n\t\t\tif (!isHzFull) {\n\t\t\t\tshouldBoostHz = true;\n\t\t\t} else {\n\t\t\t\tshouldBoostWw = true;\n\t\t\t}\n\t\t} else {\n\t\t\tshouldBoostWw = !isWwFull;\n\t\t\tshouldBoostHz = !isHzFull;\n\t\t}\n\n\t\tif (shouldBoostWw && !activeBoostWwApplied && originalWw !== null && boostWwAmount > 0 && wwPath) {\n\t\t\tawait adapter.setState(wwPath, { val: originalWw + boostWwAmount, ack: false });\n\t\t\tactiveBoostWwApplied = true;\n\t\t\twriteLog(`[PV] Priority logic: Applying Hot Water boost (+${boostWwAmount}K).`, 'info');\n\t\t} else if (!shouldBoostWw && activeBoostWwApplied && originalWw !== null && wwPath) {\n\t\t\tawait adapter.setState(wwPath, { val: originalWw, ack: false });\n\t\t\tactiveBoostWwApplied = false;\n\t\t\twriteLog(`[PV] Priority logic: Target reached. Revoking Hot Water boost.`, 'info');\n\t\t}\n\n\t\tif (shouldBoostHz && !activeBoostHzApplied && originalHz !== null && boostHzAmount > 0 && hzPath) {\n\t\t\tawait adapter.setState(hzPath, { val: originalHz + boostHzAmount, ack: false });\n\t\t\tactiveBoostHzApplied = true;\n\t\t\twriteLog(`[PV] Priority logic: Applying Heating boost (+${boostHzAmount}K).`, 'info');\n\t\t} else if (!shouldBoostHz && activeBoostHzApplied && originalHz !== null && hzPath) {\n\t\t\tawait adapter.setState(hzPath, { val: originalHz, ack: false });\n\t\t\tactiveBoostHzApplied = false;\n\t\t\twriteLog(`[PV] Priority logic: Target reached. Revoking Heating boost.`, 'info');\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`[PV] Error evaluating boost priority: ${msg}`, 'error');\n\t}\n}\n\n/**\n * Startet den Abbruch. Pr\u00FCft, ob der Verdichter-Takt noch beendet werden soll.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nasync function initiateDeactivation(adapter: LuxtronikAdapter): Promise<void> {\n\tpvStopTimer = undefined;\n\tif (!pvIsBoostActive) {\n\t\treturn;\n\t}\n\n\tconst config = adapter.config;\n\twriteLog('[PV] Deactivation timer finished.', 'info');\n\n\tif (config.pv_finish_cycle) {\n\t\ttry {\n\t\t\tconst bzPath = getDpPath('WP_BZ_akt');\n\t\t\tconst bzState = bzPath ? await adapter.getStateAsync(bzPath) : null;\n\t\t\tconst bzVal = bzState ? Number(bzState.val) : 5;\n\n\t\t\tif (bzVal !== 5) {\n\t\t\t\twriteLog(\n\t\t\t\t\t`[PV] Compressor is active (Status: ${bzVal}). Waiting for cycle to finish before resetting values.`,\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\tpvWaitingForCycleEnd = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch (err: unknown) {\n\t\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\t\twriteLog(`[PV] Error checking compressor status: ${msg}`, 'error');\n\t\t}\n\t}\n\n\tawait deactivateBoost(adapter);\n}\n\n/**\n * Setzt die Werte hart auf den Ursprung zur\u00FCck.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nasync function deactivateBoost(adapter: LuxtronikAdapter): Promise<void> {\n\ttry {\n\t\twriteLog('[PV] Reverting values to original base targets.', 'info');\n\t\tconst wwPath = getDpPath('Wamwassertemperatur_Soll');\n\t\tconst hzPath = getDpPath('heating_temperature');\n\n\t\tif (originalWw !== null && wwPath) {\n\t\t\tawait adapter.setState(wwPath, { val: originalWw, ack: false });\n\t\t}\n\t\tif (originalHz !== null && hzPath) {\n\t\t\tawait adapter.setState(hzPath, { val: originalHz, ack: false });\n\t\t}\n\n\t\tpvIsBoostActive = false;\n\t\tpvWaitingForCycleEnd = false;\n\t\tactiveBoostWwApplied = false;\n\t\tactiveBoostHzApplied = false;\n\t\toriginalWw = null;\n\t\toriginalHz = null;\n\n\t\tconst dpActive = getDpPath('pv_boost_active');\n\t\tconst dpSince = getDpPath('pv_boost_active_since');\n\n\t\tif (dpActive) {\n\t\t\tawait adapter.setState(dpActive, { val: false, ack: true });\n\t\t}\n\t\tif (dpSince) {\n\t\t\tawait adapter.setState(dpSince, { val: '', ack: true });\n\t\t}\n\t} catch (err: unknown) {\n\t\tconst msg = err instanceof Error ? err.message : String(err);\n\t\twriteLog(`[PV] Error deactivating boost: ${msg}`, 'error');\n\t}\n}\n\n/**\n * \u00DCberwacht den Betriebszustand (WP_BZ_akt). Wird aus der main.ts aufgerufen.\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n * @param newBzVal Der neue Wert von WP_BZ_akt.\n */\nexport async function handlePvCycleCheck(adapter: LuxtronikAdapter, newBzVal: number): Promise<void> {\n\tif (pvWaitingForCycleEnd && newBzVal === 5) {\n\t\twriteLog('[PV] Compressor finished cycle (Status: 5). Resetting PV boost targets now.', 'info');\n\t\tawait deactivateBoost(adapter);\n\t}\n}\n\n/**\n * Bricht den PV-Boost manuell ab (z.B. wenn der Benutzer den Reset-Button dr\u00FCckt).\n *\n * @param adapter Die aktuelle Adapter-Instanz.\n */\nexport async function forceResetPvBoost(adapter: LuxtronikAdapter): Promise<void> {\n\tif (pvIsBoostActive) {\n\t\twriteLog('[PV] Manual override triggered. Cancelling active PV boost...', 'info');\n\n\t\t// Laufende Timer sofort aufr\u00E4umen\n\t\tif (pvStartTimer) {\n\t\t\tadapter.clearTimeout(pvStartTimer);\n\t\t\tpvStartTimer = undefined;\n\t\t}\n\t\tif (pvStopTimer) {\n\t\t\tadapter.clearTimeout(pvStopTimer);\n\t\t\tpvStopTimer = undefined;\n\t\t}\n\n\t\tawait deactivateBoost(adapter);\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyB;AACzB,0BAA0B;AAO1B,IAAI;AACJ,IAAI;AAC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ACf;AAEA,UAAM,gBAAgB,OAAO;AAAA,EAC9B;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/virtualStates.js
CHANGED
|
@@ -226,7 +226,7 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
const dpHeating = (0, import_stateMapping.getDpPath)("opStateHeatingString");
|
|
229
|
-
if (dpHeating) {
|
|
229
|
+
if (dpHeating && adapter.createdStates.has(dpHeating)) {
|
|
230
230
|
await adapter.setStateChangedAsync(dpHeating, heatingStr, true);
|
|
231
231
|
}
|
|
232
232
|
let stateStr = "Unknown";
|
|
@@ -267,16 +267,16 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
267
267
|
const line2Text = line2Map[0] || "since";
|
|
268
268
|
extStateStr = `${line1Text} ${line2Text} ${zeitStringText}`;
|
|
269
269
|
const dpDuration = (0, import_stateMapping.getDpPath)("heatpump_duration");
|
|
270
|
-
if (dpDuration) {
|
|
270
|
+
if (dpDuration && adapter.createdStates.has(dpDuration)) {
|
|
271
271
|
await adapter.setStateChangedAsync(dpDuration, zeitStringDuration, true);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
const dpExtState = (0, import_stateMapping.getDpPath)("heatpump_extendet_state_string");
|
|
275
|
-
if (dpExtState) {
|
|
275
|
+
if (dpExtState && adapter.createdStates.has(dpExtState)) {
|
|
276
276
|
await adapter.setStateChangedAsync(dpExtState, stateStr, true);
|
|
277
277
|
}
|
|
278
278
|
const dpState = (0, import_stateMapping.getDpPath)("heatpump_state_string");
|
|
279
|
-
if (dpState) {
|
|
279
|
+
if (dpState && adapter.createdStates.has(dpState)) {
|
|
280
280
|
await adapter.setStateChangedAsync(dpState, extStateStr, true);
|
|
281
281
|
}
|
|
282
282
|
const hotWaterBoilerValve = rawValues[(0, import_stateMapping.getLuxIdByKey)("hotWaterBoilerValve")] || 0;
|
|
@@ -294,7 +294,7 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
294
294
|
hotWaterStr = `Unknown [${opStateHotWaterOriginal}/${hotWaterBoilerValve}]`;
|
|
295
295
|
}
|
|
296
296
|
const dpHotWater = (0, import_stateMapping.getDpPath)("opStateHotWaterString");
|
|
297
|
-
if (dpHotWater) {
|
|
297
|
+
if (dpHotWater && adapter.createdStates.has(dpHotWater)) {
|
|
298
298
|
await adapter.setStateChangedAsync(dpHotWater, hotWaterStr, true);
|
|
299
299
|
}
|
|
300
300
|
const coolingOpMode = rawParams[(0, import_stateMapping.getLuxIdByKey)("cooling_operation_mode")];
|
|
@@ -318,7 +318,7 @@ async function updateStatusStrings(adapter, rawValues, rawParams) {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
const dpCooling = (0, import_stateMapping.getDpPath)("opStateCoolingString");
|
|
321
|
-
if (dpCooling) {
|
|
321
|
+
if (dpCooling && adapter.createdStates.has(dpCooling)) {
|
|
322
322
|
await adapter.setStateChangedAsync(dpCooling, coolingStr, true);
|
|
323
323
|
}
|
|
324
324
|
} catch (err) {
|