iobroker.luxtronik2-controller 0.5.0 → 0.5.2
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 +11 -12
- package/build/actionHandlers.js +11 -12
- package/build/actionHandlers.js.map +2 -2
- package/build/codes.js +121 -121
- package/build/codes.js.map +2 -2
- package/build/main.js +190 -57
- package/build/main.js.map +2 -2
- package/build/notificationManager.js +26 -27
- package/build/notificationManager.js.map +2 -2
- package/build/objectManager.js +47 -40
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +11 -11
- package/build/rawFunctions.js.map +2 -2
- package/build/stateMapping.js +1268 -1269
- package/build/stateMapping.js.map +2 -2
- package/build/virtualStates.js +43 -65
- package/build/virtualStates.js.map +2 -2
- package/build/zipManager.js +35 -12
- package/build/zipManager.js.map +2 -2
- package/io-package.json +28 -28
- package/package.json +1 -1
package/build/main.js
CHANGED
|
@@ -31,19 +31,37 @@ var import_stateMapping = require("./stateMapping");
|
|
|
31
31
|
var import_virtualStates = require("./virtualStates");
|
|
32
32
|
var import_zipManager = require("./zipManager");
|
|
33
33
|
class Luxtronik2Controller extends utils.Adapter {
|
|
34
|
+
/** Set of all active namespaced state IDs created or managed by the adapter */
|
|
34
35
|
createdStates = /* @__PURE__ */ new Set();
|
|
36
|
+
/** ioBroker timeout handle for the hot water circulation pump macro */
|
|
35
37
|
zipTimer;
|
|
38
|
+
/** Cached copy of the original circulation pump settings before macro activation */
|
|
36
39
|
originalZipConfig = null;
|
|
40
|
+
/** Unix timestamp of the last error dispatched to prevent duplicate notification triggers */
|
|
37
41
|
lastKnownErrorTimestamp = null;
|
|
42
|
+
/** Determines whether verbose debugging output is enabled */
|
|
38
43
|
isDebugLogActive = false;
|
|
44
|
+
/** ioBroker interval handle for the main data polling loop */
|
|
39
45
|
pollingInterval;
|
|
46
|
+
/** Cache for the last evaluated heat pump operating state code */
|
|
40
47
|
lastBzVal = "";
|
|
48
|
+
/** Lock flag preventing concurrent execution of the polling updates */
|
|
41
49
|
updateRunning = false;
|
|
50
|
+
/** Timestamp tracking the last dynamic pump voltage optimization execution */
|
|
42
51
|
lastPumpOptimization = 0;
|
|
52
|
+
/** Internal array storing pending serial hardware write tasks */
|
|
43
53
|
writeQueue = [];
|
|
54
|
+
/** Lock flag indicating that the write queue is currently being processed */
|
|
44
55
|
isWriting = false;
|
|
56
|
+
/** Counter tracking sequential communication timeouts/failures */
|
|
45
57
|
errorCount = 0;
|
|
58
|
+
/** Maximum allowed sequential request failures before connection is flagged as interrupted */
|
|
46
59
|
MAX_ERRORS = 3;
|
|
60
|
+
/**
|
|
61
|
+
* Initializes a new instance of the Luxtronik2Controller class.
|
|
62
|
+
*
|
|
63
|
+
* @param options - Optional core configuration overrides passed by the ioBroker host.
|
|
64
|
+
*/
|
|
47
65
|
constructor(options = {}) {
|
|
48
66
|
super({
|
|
49
67
|
...options,
|
|
@@ -55,17 +73,29 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
55
73
|
this.on("unload", this.onUnload.bind(this));
|
|
56
74
|
this.on("message", this.onMessage.bind(this));
|
|
57
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Processes incoming inter-adapter messages or commands dispatched from the Admin UI.
|
|
78
|
+
*
|
|
79
|
+
* @param obj - The standardized ioBroker message structure containing parameters and optional callbacks.
|
|
80
|
+
* @returns A promise that resolves once the message has been processed.
|
|
81
|
+
*/
|
|
58
82
|
async onMessage(obj) {
|
|
59
83
|
if (obj.command === "testTelegram") {
|
|
60
84
|
await (0, import_notificationManager.handleTestMessage)(this, obj);
|
|
61
85
|
}
|
|
62
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Callback executed once the ioBroker host framework completely initializes the adapter subsystem.
|
|
89
|
+
* Sets up database objects, applies configurations, subscribes to states, and triggers the polling loop.
|
|
90
|
+
*
|
|
91
|
+
* @returns A promise that resolves when initialization completes.
|
|
92
|
+
*/
|
|
63
93
|
async onReady() {
|
|
64
94
|
const config = this.config;
|
|
65
95
|
const ip = config.host;
|
|
66
96
|
const port = config.port || 8889;
|
|
67
97
|
await this.setState("info.connection", { val: false, ack: true });
|
|
68
|
-
(0, import_logger.writeLog)(`
|
|
98
|
+
(0, import_logger.writeLog)(`Connecting to heat pump at ${ip}:${port}...`, "info");
|
|
69
99
|
await (0, import_objectManager.cleanupStates)(this);
|
|
70
100
|
await (0, import_objectManager.cleanupCustomStates)(this);
|
|
71
101
|
await (0, import_objectManager.cleanupEmptyFolders)(this);
|
|
@@ -76,7 +106,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
76
106
|
this.isDebugLogActive = (debugState == null ? void 0 : debugState.val) === true;
|
|
77
107
|
(0, import_logger.setCustomDebug)(this.isDebugLogActive);
|
|
78
108
|
if (this.isDebugLogActive) {
|
|
79
|
-
(0, import_logger.writeLog)("
|
|
109
|
+
(0, import_logger.writeLog)("Synchronizing configuration values with the heat pump...", "info");
|
|
80
110
|
}
|
|
81
111
|
await this.setIdleDefaults();
|
|
82
112
|
if (config.motion_sensors_aktiv && Array.isArray(config.motionSensors)) {
|
|
@@ -84,7 +114,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
84
114
|
if (sensor.oid && typeof sensor.oid === "string" && sensor.oid.trim() !== "") {
|
|
85
115
|
this.subscribeForeignStates(sensor.oid.trim());
|
|
86
116
|
if (this.isDebugLogActive) {
|
|
87
|
-
(0, import_logger.writeLog)(`
|
|
117
|
+
(0, import_logger.writeLog)(`Motion sensor subscribed: ${sensor.name} (${sensor.oid})`, "info");
|
|
88
118
|
}
|
|
89
119
|
}
|
|
90
120
|
}
|
|
@@ -93,22 +123,39 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
93
123
|
try {
|
|
94
124
|
await this.updateData();
|
|
95
125
|
} catch (error) {
|
|
96
|
-
this.log.error(`
|
|
126
|
+
this.log.error(`Initial data retrieval failed (device offline?): ${error.message}`);
|
|
97
127
|
}
|
|
98
128
|
let intervalSeconds = this.config.interval ? Number(this.config.interval) : 45;
|
|
99
129
|
if (intervalSeconds < 10) {
|
|
100
130
|
intervalSeconds = 10;
|
|
101
|
-
(0, import_logger.writeLog)(
|
|
131
|
+
(0, import_logger.writeLog)(
|
|
132
|
+
"Configured polling interval was too short. Forced to minimum threshold of 10 seconds for protection.",
|
|
133
|
+
"warn"
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (intervalSeconds > 3600) {
|
|
137
|
+
intervalSeconds = 3600;
|
|
138
|
+
(0, import_logger.writeLog)(
|
|
139
|
+
"Configured polling interval exceeded maximum boundary. Restricted to 3600 seconds to prevent overflow issues.",
|
|
140
|
+
"warn"
|
|
141
|
+
);
|
|
102
142
|
}
|
|
103
143
|
this.pollingInterval = this.setInterval(async () => {
|
|
104
144
|
try {
|
|
105
145
|
await this.updateData();
|
|
106
146
|
} catch (error) {
|
|
107
|
-
this.log.error(`
|
|
147
|
+
this.log.error(`Error during cyclic data retrieval loop: ${error.message}`);
|
|
108
148
|
}
|
|
109
149
|
}, intervalSeconds * 1e3);
|
|
110
150
|
await this.setState("info.connection", true, true);
|
|
111
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Synchronizes a single state configuration parameter with the Luxtronik physical controller.
|
|
154
|
+
*
|
|
155
|
+
* @param mappingKey - The unique key identifier within the STATE_MAPPING structure.
|
|
156
|
+
* @param val - The raw or parsed value to apply.
|
|
157
|
+
* @returns A promise that resolves when the synchronization task finishes.
|
|
158
|
+
*/
|
|
112
159
|
async syncConfigValue(mappingKey, val) {
|
|
113
160
|
if (val === void 0 || val === null) {
|
|
114
161
|
return;
|
|
@@ -122,7 +169,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
122
169
|
}
|
|
123
170
|
await this.setState(id, { val, ack: true });
|
|
124
171
|
if (this.isDebugLogActive) {
|
|
125
|
-
(0, import_logger.writeLog)(`
|
|
172
|
+
(0, import_logger.writeLog)(`Writing value directly into heat pump controller: ${mappingKey} = ${val}`, "info");
|
|
126
173
|
}
|
|
127
174
|
if (definition.write === true && !definition.isVirtual && definition.luxWriteId) {
|
|
128
175
|
let valueToWrite = val;
|
|
@@ -139,11 +186,22 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
139
186
|
await this.queueWrite(writeId, valueToWrite);
|
|
140
187
|
await new Promise((r) => global.setTimeout(r, 200));
|
|
141
188
|
} catch (err) {
|
|
142
|
-
(0, import_logger.writeLog)(
|
|
189
|
+
(0, import_logger.writeLog)(
|
|
190
|
+
`Failed to transmit ${mappingKey} to the heat pump hardware interface: ${err.message}`,
|
|
191
|
+
"error"
|
|
192
|
+
);
|
|
143
193
|
}
|
|
144
194
|
}
|
|
145
195
|
}
|
|
146
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Safely updates an internal database state value only if the newly supplied value differs from the existing entry.
|
|
199
|
+
*
|
|
200
|
+
* @param id - The relative state path ID.
|
|
201
|
+
* @param val - The updated value to process.
|
|
202
|
+
* @param ack - Explicit acknowledgment flag status to set.
|
|
203
|
+
* @returns A promise that resolves when the verification and write operation completes.
|
|
204
|
+
*/
|
|
147
205
|
async setOwnStateIfDifferent(id, val, ack = false) {
|
|
148
206
|
try {
|
|
149
207
|
if (val === void 0) {
|
|
@@ -153,13 +211,18 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
153
211
|
if (!state || state.val !== val) {
|
|
154
212
|
await this.setState(id, { val, ack });
|
|
155
213
|
if (this.isDebugLogActive) {
|
|
156
|
-
(0, import_logger.writeLog)(`
|
|
214
|
+
(0, import_logger.writeLog)(`Applying specific update for local state ${id}: ${val}`, "debug");
|
|
157
215
|
}
|
|
158
216
|
}
|
|
159
217
|
} catch (err) {
|
|
160
|
-
(0, import_logger.writeLog)(`
|
|
218
|
+
(0, import_logger.writeLog)(`Error occurred during setOwnStateIfDifferent operation for state ${id}: ${err.message}`, "error");
|
|
161
219
|
}
|
|
162
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Configures fallback factory parameter baselines for the heat pump when in an idle state.
|
|
223
|
+
*
|
|
224
|
+
* @returns A promise that resolves when all default configuration tasks resolve.
|
|
225
|
+
*/
|
|
163
226
|
async setIdleDefaults() {
|
|
164
227
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
165
228
|
try {
|
|
@@ -183,9 +246,14 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
183
246
|
await this.syncConfigValue("zip_aktiv", (_h = config.zip_aktiv) != null ? _h : 0);
|
|
184
247
|
await this.syncConfigValue("Heizen_nach_Wasser", (_i = config.Heating_after_warmwater) != null ? _i : false);
|
|
185
248
|
} catch (err) {
|
|
186
|
-
(0, import_logger.writeLog)(`
|
|
249
|
+
(0, import_logger.writeLog)(`Failed to apply the baseline idle configuration defaults: ${err.message}`, "error");
|
|
187
250
|
}
|
|
188
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Evaluates whether the current active operating state timestamp is older than ten minutes.
|
|
254
|
+
*
|
|
255
|
+
* @returns A promise that resolves to true if the state has remained unaltered for at least 10 minutes.
|
|
256
|
+
*/
|
|
189
257
|
async istBetriebszustandAelterAls10Min() {
|
|
190
258
|
var _a;
|
|
191
259
|
try {
|
|
@@ -196,8 +264,14 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
196
264
|
return false;
|
|
197
265
|
}
|
|
198
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Primary intelligent engine analyzing live telemetry values to execute continuous performance optimizations.
|
|
269
|
+
* Manages dynamic heating curves, anti-cycling protective delays, and voltage scaling algorithms.
|
|
270
|
+
*
|
|
271
|
+
* @returns A promise that resolves when the execution cycle finishes.
|
|
272
|
+
*/
|
|
199
273
|
async runOptimizationSchedule() {
|
|
200
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s
|
|
274
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
201
275
|
try {
|
|
202
276
|
const config = this.config;
|
|
203
277
|
const bzState = await this.getStateAsync((0, import_stateMapping.getDpPath)("WP_BZ_akt"));
|
|
@@ -291,12 +365,11 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
291
365
|
const hupAktiv = (_o = hupAktivState == null ? void 0 : hupAktivState.val) != null ? _o : 0;
|
|
292
366
|
const heizenHysterese = (_p = heizenHystereseState == null ? void 0 : heizenHystereseState.val) != null ? _p : 0;
|
|
293
367
|
const nachWasser = nachWasserState == null ? void 0 : nachWasserState.val;
|
|
294
|
-
const betriebsart = (_q = bzState == null ? void 0 : bzState.val) != null ? _q : 0;
|
|
295
368
|
if (istHeizen) {
|
|
296
369
|
if (config.regelung_aktiv !== false && aelterAls10 && vd1) {
|
|
297
|
-
const fusspunkt = (
|
|
370
|
+
const fusspunkt = (_q = await this.getStateAsync((0, import_stateMapping.getDpPath)("heating_curve_parallel_offset"))) == null ? void 0 : _q.val;
|
|
298
371
|
if (fusspunkt === 35) {
|
|
299
|
-
const fallbackFusspunkt = (
|
|
372
|
+
const fallbackFusspunkt = (_r = config.fusspunkt) != null ? _r : 21.7;
|
|
300
373
|
await this.syncConfigValue("heating_curve_parallel_offset", fallbackFusspunkt);
|
|
301
374
|
}
|
|
302
375
|
}
|
|
@@ -307,14 +380,14 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
307
380
|
await this.syncConfigValue("heating_system_circ_pump_voltage_nominal", hupAktiv - 0.25);
|
|
308
381
|
this.lastPumpOptimization = now;
|
|
309
382
|
(0, import_logger.writeLog)(
|
|
310
|
-
`
|
|
383
|
+
`Temperature spread too low (${spreizung}K). Scaling down HUP nominal target to ${hupAktiv - 0.25}V.`,
|
|
311
384
|
"info"
|
|
312
385
|
);
|
|
313
386
|
} else if (spreizung > 7.5 && hupAktiv < 10) {
|
|
314
387
|
await this.syncConfigValue("heating_system_circ_pump_voltage_nominal", hupAktiv + 0.25);
|
|
315
388
|
this.lastPumpOptimization = now;
|
|
316
389
|
(0, import_logger.writeLog)(
|
|
317
|
-
`
|
|
390
|
+
`Temperature spread too high (${spreizung}K). Scaling up HUP nominal target to ${hupAktiv + 0.25}V.`,
|
|
318
391
|
"info"
|
|
319
392
|
);
|
|
320
393
|
}
|
|
@@ -329,7 +402,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
329
402
|
await this.syncConfigValue("Heizen_nach_Wasser", true);
|
|
330
403
|
}
|
|
331
404
|
if (wwSoll - wwIst > 2 && ruecklauf >= ruecklaufSoll + heizenHysterese - 0.1) {
|
|
332
|
-
const fallbackHyst = (
|
|
405
|
+
const fallbackHyst = (_s = config.sync_hotwater_temperature_hysteresis) != null ? _s : 2;
|
|
333
406
|
await this.syncConfigValue("hotWaterTemperatureHysteresis", fallbackHyst);
|
|
334
407
|
}
|
|
335
408
|
}
|
|
@@ -346,18 +419,25 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
346
419
|
}
|
|
347
420
|
}
|
|
348
421
|
if (config.regelung_aktiv !== false) {
|
|
349
|
-
if (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll &&
|
|
422
|
+
if (wwSoll - wwIst >= wwHysterese - 1.5 && ruecklauf <= ruecklaufSoll && heatingStateStr !== "Heating limit") {
|
|
350
423
|
await this.syncConfigValue("heating_curve_parallel_offset", 35);
|
|
351
424
|
}
|
|
352
425
|
}
|
|
353
426
|
}
|
|
354
427
|
} catch (err) {
|
|
355
|
-
(0, import_logger.writeLog)(`
|
|
428
|
+
(0, import_logger.writeLog)(`Error occurred during runOptimizationSchedule loop execution: ${err.message}`, "error");
|
|
356
429
|
}
|
|
357
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Directly transmits a raw command block buffer over the chosen communications channel.
|
|
433
|
+
*
|
|
434
|
+
* @param cmd - The parameter numeric index code.
|
|
435
|
+
* @param val - The compiled target payload value.
|
|
436
|
+
* @returns A promise that resolves when the transmission finishes.
|
|
437
|
+
*/
|
|
358
438
|
async writePumpAsync(cmd, val) {
|
|
359
439
|
if (this.isDebugLogActive) {
|
|
360
|
-
(0, import_logger.writeLog)(`writePumpAsync
|
|
440
|
+
(0, import_logger.writeLog)(`writePumpAsync direct interface command triggered: Register ${cmd}, value: ${val}`, "debug");
|
|
361
441
|
}
|
|
362
442
|
const paramId = typeof cmd === "string" ? parseInt(cmd, 10) : cmd;
|
|
363
443
|
let value = typeof val === "string" ? parseInt(val, 10) : val;
|
|
@@ -366,6 +446,13 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
366
446
|
}
|
|
367
447
|
await (0, import_rawFunctions.writeRawParameter)(this, paramId, value);
|
|
368
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Pushes a hardware write task into a single-threaded execution queue to guarantee transmission safety.
|
|
451
|
+
*
|
|
452
|
+
* @param cmd - Target parameter register ID.
|
|
453
|
+
* @param val - The value payload to map.
|
|
454
|
+
* @returns A promise that completes once the queue executes this task.
|
|
455
|
+
*/
|
|
369
456
|
async queueWrite(cmd, val) {
|
|
370
457
|
return new Promise((resolve, reject) => {
|
|
371
458
|
this.writeQueue.push(async () => {
|
|
@@ -379,6 +466,12 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
379
466
|
void this.processQueue();
|
|
380
467
|
});
|
|
381
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Iteratively processes sequential write tasks inside the internal queue buffer.
|
|
471
|
+
* Enforces defensive execution delay separation spacing to secure hardware stability.
|
|
472
|
+
*
|
|
473
|
+
* @returns A promise that resolves when processing cycles resolve.
|
|
474
|
+
*/
|
|
382
475
|
async processQueue() {
|
|
383
476
|
if (this.isWriting || this.writeQueue.length === 0) {
|
|
384
477
|
return;
|
|
@@ -393,7 +486,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
393
486
|
await new Promise((resolve) => global.setTimeout(resolve, 300));
|
|
394
487
|
} catch (taskError) {
|
|
395
488
|
(0, import_logger.writeLog)(
|
|
396
|
-
`
|
|
489
|
+
`Error processing specific serial write task sequence in queue: ${taskError.message}`,
|
|
397
490
|
"error"
|
|
398
491
|
);
|
|
399
492
|
}
|
|
@@ -403,6 +496,12 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
403
496
|
this.isWriting = false;
|
|
404
497
|
}
|
|
405
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* Standardizes raw seconds telemetry counters into readable zero-padded "HH:MM:SS" time blocks.
|
|
501
|
+
*
|
|
502
|
+
* @param totalSeconds - Total input seconds configuration value.
|
|
503
|
+
* @returns Legible time block string.
|
|
504
|
+
*/
|
|
406
505
|
formatSecondsToHMS(totalSeconds) {
|
|
407
506
|
if (totalSeconds < 0 || isNaN(totalSeconds)) {
|
|
408
507
|
return "00:00:00";
|
|
@@ -412,25 +511,35 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
412
511
|
const seconds = Math.floor(totalSeconds % 60);
|
|
413
512
|
return `${hours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
414
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* Fetches, parses, converts types, and populates live data registries over the configured TCP socket.
|
|
516
|
+
* Dispatches calculation and history logging subroutines accordingly.
|
|
517
|
+
*
|
|
518
|
+
* @returns A promise that resolves when the internal update registers conclude.
|
|
519
|
+
*/
|
|
415
520
|
async updateData() {
|
|
416
521
|
if (this.updateRunning) {
|
|
417
522
|
return;
|
|
418
523
|
}
|
|
419
524
|
this.updateRunning = true;
|
|
420
525
|
try {
|
|
421
|
-
const
|
|
526
|
+
const delayHelper = (ms) => new Promise((resolve) => this.setTimeout(resolve, ms));
|
|
422
527
|
let rawParams = [];
|
|
423
528
|
let rawValues = [];
|
|
424
529
|
try {
|
|
425
530
|
rawParams = await (0, import_rawFunctions.readAllRaw)(this, 3003);
|
|
426
531
|
} catch (err) {
|
|
427
|
-
this.log.debug(
|
|
532
|
+
this.log.debug(
|
|
533
|
+
`Raw parameter acquisition response error (Command 3003): ${err instanceof Error ? err.message : String(err)}`
|
|
534
|
+
);
|
|
428
535
|
}
|
|
429
|
-
await
|
|
536
|
+
await delayHelper(200);
|
|
430
537
|
try {
|
|
431
538
|
rawValues = await (0, import_rawFunctions.readAllRaw)(this, 3004);
|
|
432
539
|
} catch (err) {
|
|
433
|
-
this.log.debug(
|
|
540
|
+
this.log.debug(
|
|
541
|
+
`Raw telemetry value acquisition response error (Command 3004): ${err instanceof Error ? err.message : String(err)}`
|
|
542
|
+
);
|
|
434
543
|
}
|
|
435
544
|
this.errorCount = 0;
|
|
436
545
|
await this.setState("info.connection", { val: true, ack: true });
|
|
@@ -468,7 +577,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
468
577
|
} else {
|
|
469
578
|
if (/^\d+$/.test(luxId)) {
|
|
470
579
|
const idx = parseInt(luxId, 10);
|
|
471
|
-
value = definition.folder.startsWith("
|
|
580
|
+
value = definition.folder.startsWith("Settings") ? rawParams == null ? void 0 : rawParams[idx] : rawValues == null ? void 0 : rawValues[idx];
|
|
472
581
|
if (value !== void 0 && definition.factor) {
|
|
473
582
|
value /= definition.factor;
|
|
474
583
|
}
|
|
@@ -484,7 +593,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
484
593
|
} else if (definition.type === "json" && typeof value === "object") {
|
|
485
594
|
value = JSON.stringify(value);
|
|
486
595
|
}
|
|
487
|
-
if (definition.unit === "s" &&
|
|
596
|
+
if (definition.unit === "s" && definition.type === "number") {
|
|
488
597
|
value = this.formatSecondsToHMS(value);
|
|
489
598
|
} else if (definition.role && ["value.datetime", "value.time", "date"].includes(definition.role)) {
|
|
490
599
|
const totalSeconds = typeof value === "number" ? value : parseInt(value, 10);
|
|
@@ -494,15 +603,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
494
603
|
const m = Math.floor(totalSeconds % 3600 / 60).toString().padStart(2, "0");
|
|
495
604
|
value = `${h}:${m}`;
|
|
496
605
|
} else {
|
|
497
|
-
value = new Date(totalSeconds * 1e3).
|
|
498
|
-
day: "2-digit",
|
|
499
|
-
month: "2-digit",
|
|
500
|
-
year: "numeric",
|
|
501
|
-
hour: "2-digit",
|
|
502
|
-
minute: "2-digit",
|
|
503
|
-
second: "2-digit",
|
|
504
|
-
hour12: false
|
|
505
|
-
});
|
|
606
|
+
value = new Date(totalSeconds * 1e3).toISOString().replace("T", " ").substring(0, 19);
|
|
506
607
|
}
|
|
507
608
|
}
|
|
508
609
|
}
|
|
@@ -543,19 +644,27 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
543
644
|
await this.runOptimizationSchedule();
|
|
544
645
|
} catch (err) {
|
|
545
646
|
this.errorCount++;
|
|
546
|
-
(0, import_logger.writeLog)(
|
|
647
|
+
(0, import_logger.writeLog)(
|
|
648
|
+
`Communication error encountered (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`,
|
|
649
|
+
"error"
|
|
650
|
+
);
|
|
547
651
|
if (this.errorCount >= this.MAX_ERRORS) {
|
|
548
652
|
await this.setState("info.connection", { val: false, ack: true });
|
|
549
|
-
(0, import_logger.writeLog)("
|
|
653
|
+
(0, import_logger.writeLog)("Heat pump controller unreachable. Flagging connection status as disconnected.", "warn");
|
|
550
654
|
(0, import_notificationManager.sendTelegramNotification)(
|
|
551
655
|
this,
|
|
552
|
-
"
|
|
656
|
+
"Heat pump controller unreachable. Flagging connection status as disconnected."
|
|
553
657
|
);
|
|
554
658
|
}
|
|
555
659
|
} finally {
|
|
556
660
|
this.updateRunning = false;
|
|
557
661
|
}
|
|
558
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Callback issued by the ioBroker framework during adapter shutdown sequences.
|
|
665
|
+
*
|
|
666
|
+
* @param callback - Termination completion trigger function.
|
|
667
|
+
*/
|
|
559
668
|
onUnload(callback) {
|
|
560
669
|
try {
|
|
561
670
|
if (this.pollingInterval) {
|
|
@@ -565,12 +674,22 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
565
674
|
clearTimeout(this.zipTimer);
|
|
566
675
|
}
|
|
567
676
|
void this.setState("info.connection", { val: false, ack: true });
|
|
568
|
-
(0, import_logger.writeLog)(
|
|
677
|
+
(0, import_logger.writeLog)(
|
|
678
|
+
"Adapter is shutting down. Cleared all active intervals and terminated open socket configurations cleanly.",
|
|
679
|
+
"info"
|
|
680
|
+
);
|
|
569
681
|
callback();
|
|
570
682
|
} catch {
|
|
571
683
|
callback();
|
|
572
684
|
}
|
|
573
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* Central observer callback executed whenever a subscribed state receives an update.
|
|
688
|
+
*
|
|
689
|
+
* @param id - The explicit full namespaced state identifier path.
|
|
690
|
+
* @param state - The newly applied state context or null context if dropped.
|
|
691
|
+
* @returns A promise that resolves when operations complete.
|
|
692
|
+
*/
|
|
574
693
|
async onStateChange(id, state) {
|
|
575
694
|
if (!state) {
|
|
576
695
|
return;
|
|
@@ -582,7 +701,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
582
701
|
const zipOutState = await this.getStateAsync((0, import_stateMapping.getDpPath)("ZIPout"));
|
|
583
702
|
if (zipOutState && zipOutState.val === 1) {
|
|
584
703
|
if (this.isDebugLogActive) {
|
|
585
|
-
(0, import_logger.writeLog)(
|
|
704
|
+
(0, import_logger.writeLog)(
|
|
705
|
+
`Motion registered at sensor '${matchedSensor.name}' but circulation pump ZIP is already running. Action ignored.`,
|
|
706
|
+
"debug"
|
|
707
|
+
);
|
|
586
708
|
}
|
|
587
709
|
return;
|
|
588
710
|
}
|
|
@@ -590,16 +712,19 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
590
712
|
const lastZipChange = (zipOutState == null ? void 0 : zipOutState.lc) || 0;
|
|
591
713
|
if (now - lastZipChange > (config.zip_last_run_min || 600) * 1e3) {
|
|
592
714
|
if (this.isDebugLogActive) {
|
|
593
|
-
(0, import_logger.writeLog)(
|
|
715
|
+
(0, import_logger.writeLog)(
|
|
716
|
+
`Motion registered at sensor '${matchedSensor.name || id}'. Launching circulation pump ZIP macro sequence.`,
|
|
717
|
+
"debug"
|
|
718
|
+
);
|
|
594
719
|
}
|
|
595
|
-
await this.
|
|
720
|
+
await this.setState((0, import_stateMapping.getDpPath)("Activate_Zip"), {
|
|
596
721
|
val: true,
|
|
597
722
|
ack: false
|
|
598
723
|
});
|
|
599
724
|
} else {
|
|
600
725
|
if (this.isDebugLogActive) {
|
|
601
726
|
(0, import_logger.writeLog)(
|
|
602
|
-
`
|
|
727
|
+
`Motion registered at sensor '${matchedSensor.name || id}' but circulation pump execution suppressed due to anti-cycling protective interval timer.`,
|
|
603
728
|
"debug"
|
|
604
729
|
);
|
|
605
730
|
}
|
|
@@ -610,11 +735,12 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
610
735
|
if (state.ack) {
|
|
611
736
|
return;
|
|
612
737
|
}
|
|
613
|
-
if (id.startsWith(`${this.namespace}.
|
|
738
|
+
if (id.startsWith(`${this.namespace}.Custom.`)) {
|
|
614
739
|
try {
|
|
615
740
|
const obj = await this.getObjectAsync(id);
|
|
616
741
|
if (obj && obj.native && obj.native.source === "parameter") {
|
|
617
|
-
|
|
742
|
+
const relativeId = id.replace(`${this.namespace}.`, "");
|
|
743
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
618
744
|
let valueToWrite = state.val;
|
|
619
745
|
if (obj.native.customType === "boolean") {
|
|
620
746
|
valueToWrite = state.val ? 1 : 0;
|
|
@@ -629,7 +755,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
629
755
|
if (!isNaN(targetWriteId)) {
|
|
630
756
|
if (this.isDebugLogActive) {
|
|
631
757
|
(0, import_logger.writeLog)(
|
|
632
|
-
`
|
|
758
|
+
`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,
|
|
633
759
|
"info"
|
|
634
760
|
);
|
|
635
761
|
}
|
|
@@ -637,7 +763,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
637
763
|
}
|
|
638
764
|
}
|
|
639
765
|
} catch (err) {
|
|
640
|
-
(0, import_logger.writeLog)(`
|
|
766
|
+
(0, import_logger.writeLog)(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, "error");
|
|
641
767
|
}
|
|
642
768
|
return;
|
|
643
769
|
}
|
|
@@ -650,24 +776,28 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
650
776
|
return;
|
|
651
777
|
}
|
|
652
778
|
try {
|
|
779
|
+
const relativeId = id.replace(`${this.namespace}.`, "");
|
|
653
780
|
if (mappingKey === "Schreibe_Debug_Log") {
|
|
654
|
-
await this.
|
|
781
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
655
782
|
this.isDebugLogActive = state.val === true;
|
|
656
783
|
(0, import_logger.setCustomDebug)(this.isDebugLogActive);
|
|
657
|
-
(0, import_logger.writeLog)(
|
|
784
|
+
(0, import_logger.writeLog)(
|
|
785
|
+
`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? "enabled" : "disabled"}.`,
|
|
786
|
+
"info"
|
|
787
|
+
);
|
|
658
788
|
return;
|
|
659
789
|
}
|
|
660
790
|
if (mappingKey === "Regelung_Aktiv" || mappingKey === "zip_aktiv") {
|
|
661
|
-
await this.
|
|
791
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
662
792
|
return;
|
|
663
793
|
}
|
|
664
794
|
if (mappingKey === "Setze_Vorgabewerte" && state.val === true) {
|
|
665
|
-
await this.
|
|
795
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
666
796
|
await this.setIdleDefaults();
|
|
667
797
|
return;
|
|
668
798
|
}
|
|
669
799
|
if (mappingKey === "Dump_Raw_To_Log" && state.val === true) {
|
|
670
|
-
await this.
|
|
800
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
671
801
|
await (0, import_rawFunctions.dumpAllRawToLog)(this);
|
|
672
802
|
return;
|
|
673
803
|
}
|
|
@@ -689,7 +819,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
689
819
|
const durationSeconds = durationState && typeof durationState.val === "number" ? durationState.val : 120;
|
|
690
820
|
await (0, import_zipManager.handleActivateZip)(this, id, durationSeconds);
|
|
691
821
|
} else {
|
|
692
|
-
await this.
|
|
822
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
693
823
|
await (0, import_zipManager.stopZipAndDeaeration)(this);
|
|
694
824
|
}
|
|
695
825
|
return;
|
|
@@ -697,7 +827,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
697
827
|
if (!definition.luxWriteId || definition.write !== true) {
|
|
698
828
|
return;
|
|
699
829
|
}
|
|
700
|
-
await this.
|
|
830
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
701
831
|
let valueToWrite = state.val;
|
|
702
832
|
if (definition.role === "value.datetime") {
|
|
703
833
|
const valStr = String(state.val).trim();
|
|
@@ -714,7 +844,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
714
844
|
const targetWriteId = definition.luxWriteId;
|
|
715
845
|
await this.queueWrite(parseInt(targetWriteId, 10), valueToWrite);
|
|
716
846
|
} catch (err) {
|
|
717
|
-
(0, import_logger.writeLog)(
|
|
847
|
+
(0, import_logger.writeLog)(
|
|
848
|
+
`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,
|
|
849
|
+
"error"
|
|
850
|
+
);
|
|
718
851
|
}
|
|
719
852
|
}
|
|
720
853
|
}
|