iobroker.luxtronik2-controller 0.5.1 → 0.5.3
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 +12 -10
- package/build/actionHandlers.js +11 -9
- package/build/actionHandlers.js.map +2 -2
- package/build/codes.js +121 -121
- package/build/codes.js.map +2 -2
- package/build/main.js +195 -61
- package/build/main.js.map +2 -2
- package/build/notificationManager.js +23 -24
- package/build/notificationManager.js.map +2 -2
- package/build/objectManager.js +44 -37
- package/build/objectManager.js.map +2 -2
- package/build/rawFunctions.js +11 -11
- package/build/rawFunctions.js.map +2 -2
- package/build/stateMapping.js +1284 -1286
- package/build/stateMapping.js.map +2 -2
- package/build/virtualStates.js +74 -70
- package/build/virtualStates.js.map +2 -2
- package/build/zipManager.js +39 -16
- package/build/zipManager.js.map +2 -2
- package/io-package.json +30 -30
- 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,8 +593,12 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
484
593
|
} else if (definition.type === "json" && typeof value === "object") {
|
|
485
594
|
value = JSON.stringify(value);
|
|
486
595
|
}
|
|
487
|
-
|
|
488
|
-
|
|
596
|
+
let finalSeconds = Number(value);
|
|
597
|
+
if (definition.isDurationFormat && key === "Time_WPein_akt" && finalSeconds === 1) {
|
|
598
|
+
finalSeconds = 0;
|
|
599
|
+
}
|
|
600
|
+
if (definition.isDurationFormat) {
|
|
601
|
+
value = this.formatSecondsToHMS(finalSeconds);
|
|
489
602
|
} else if (definition.role && ["value.datetime", "value.time", "date"].includes(definition.role)) {
|
|
490
603
|
const totalSeconds = typeof value === "number" ? value : parseInt(value, 10);
|
|
491
604
|
if (!isNaN(totalSeconds) && totalSeconds >= 0) {
|
|
@@ -494,22 +607,11 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
494
607
|
const m = Math.floor(totalSeconds % 3600 / 60).toString().padStart(2, "0");
|
|
495
608
|
value = `${h}:${m}`;
|
|
496
609
|
} 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
|
-
});
|
|
610
|
+
value = new Date(totalSeconds * 1e3).toISOString().replace("T", " ").substring(0, 19);
|
|
506
611
|
}
|
|
507
612
|
}
|
|
508
613
|
}
|
|
509
614
|
let targetIoBrokerType = definition.type === "json" ? "string" : definition.type;
|
|
510
|
-
if (definition.unit === "s" && definition.type === "number") {
|
|
511
|
-
targetIoBrokerType = "string";
|
|
512
|
-
}
|
|
513
615
|
if (definition.role && ["value.datetime", "value.time", "date"].includes(definition.role)) {
|
|
514
616
|
targetIoBrokerType = "string";
|
|
515
617
|
}
|
|
@@ -543,19 +645,27 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
543
645
|
await this.runOptimizationSchedule();
|
|
544
646
|
} catch (err) {
|
|
545
647
|
this.errorCount++;
|
|
546
|
-
(0, import_logger.writeLog)(
|
|
648
|
+
(0, import_logger.writeLog)(
|
|
649
|
+
`Communication error encountered (${this.errorCount}/${this.MAX_ERRORS}): ${err.message}`,
|
|
650
|
+
"error"
|
|
651
|
+
);
|
|
547
652
|
if (this.errorCount >= this.MAX_ERRORS) {
|
|
548
653
|
await this.setState("info.connection", { val: false, ack: true });
|
|
549
|
-
(0, import_logger.writeLog)("
|
|
654
|
+
(0, import_logger.writeLog)("Heat pump controller unreachable. Flagging connection status as disconnected.", "warn");
|
|
550
655
|
(0, import_notificationManager.sendTelegramNotification)(
|
|
551
656
|
this,
|
|
552
|
-
"
|
|
657
|
+
"Heat pump controller unreachable. Flagging connection status as disconnected."
|
|
553
658
|
);
|
|
554
659
|
}
|
|
555
660
|
} finally {
|
|
556
661
|
this.updateRunning = false;
|
|
557
662
|
}
|
|
558
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Callback issued by the ioBroker framework during adapter shutdown sequences.
|
|
666
|
+
*
|
|
667
|
+
* @param callback - Termination completion trigger function.
|
|
668
|
+
*/
|
|
559
669
|
onUnload(callback) {
|
|
560
670
|
try {
|
|
561
671
|
if (this.pollingInterval) {
|
|
@@ -565,12 +675,22 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
565
675
|
clearTimeout(this.zipTimer);
|
|
566
676
|
}
|
|
567
677
|
void this.setState("info.connection", { val: false, ack: true });
|
|
568
|
-
(0, import_logger.writeLog)(
|
|
678
|
+
(0, import_logger.writeLog)(
|
|
679
|
+
"Adapter is shutting down. Cleared all active intervals and terminated open socket configurations cleanly.",
|
|
680
|
+
"info"
|
|
681
|
+
);
|
|
569
682
|
callback();
|
|
570
683
|
} catch {
|
|
571
684
|
callback();
|
|
572
685
|
}
|
|
573
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Central observer callback executed whenever a subscribed state receives an update.
|
|
689
|
+
*
|
|
690
|
+
* @param id - The explicit full namespaced state identifier path.
|
|
691
|
+
* @param state - The newly applied state context or null context if dropped.
|
|
692
|
+
* @returns A promise that resolves when operations complete.
|
|
693
|
+
*/
|
|
574
694
|
async onStateChange(id, state) {
|
|
575
695
|
if (!state) {
|
|
576
696
|
return;
|
|
@@ -582,7 +702,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
582
702
|
const zipOutState = await this.getStateAsync((0, import_stateMapping.getDpPath)("ZIPout"));
|
|
583
703
|
if (zipOutState && zipOutState.val === 1) {
|
|
584
704
|
if (this.isDebugLogActive) {
|
|
585
|
-
(0, import_logger.writeLog)(
|
|
705
|
+
(0, import_logger.writeLog)(
|
|
706
|
+
`Motion registered at sensor '${matchedSensor.name}' but circulation pump ZIP is already running. Action ignored.`,
|
|
707
|
+
"debug"
|
|
708
|
+
);
|
|
586
709
|
}
|
|
587
710
|
return;
|
|
588
711
|
}
|
|
@@ -590,16 +713,19 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
590
713
|
const lastZipChange = (zipOutState == null ? void 0 : zipOutState.lc) || 0;
|
|
591
714
|
if (now - lastZipChange > (config.zip_last_run_min || 600) * 1e3) {
|
|
592
715
|
if (this.isDebugLogActive) {
|
|
593
|
-
(0, import_logger.writeLog)(
|
|
716
|
+
(0, import_logger.writeLog)(
|
|
717
|
+
`Motion registered at sensor '${matchedSensor.name || id}'. Launching circulation pump ZIP macro sequence.`,
|
|
718
|
+
"debug"
|
|
719
|
+
);
|
|
594
720
|
}
|
|
595
|
-
await this.
|
|
721
|
+
await this.setState((0, import_stateMapping.getDpPath)("Activate_Zip"), {
|
|
596
722
|
val: true,
|
|
597
723
|
ack: false
|
|
598
724
|
});
|
|
599
725
|
} else {
|
|
600
726
|
if (this.isDebugLogActive) {
|
|
601
727
|
(0, import_logger.writeLog)(
|
|
602
|
-
`
|
|
728
|
+
`Motion registered at sensor '${matchedSensor.name || id}' but circulation pump execution suppressed due to anti-cycling protective interval timer.`,
|
|
603
729
|
"debug"
|
|
604
730
|
);
|
|
605
731
|
}
|
|
@@ -610,11 +736,12 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
610
736
|
if (state.ack) {
|
|
611
737
|
return;
|
|
612
738
|
}
|
|
613
|
-
if (id.startsWith(`${this.namespace}.
|
|
739
|
+
if (id.startsWith(`${this.namespace}.Custom.`)) {
|
|
614
740
|
try {
|
|
615
741
|
const obj = await this.getObjectAsync(id);
|
|
616
742
|
if (obj && obj.native && obj.native.source === "parameter") {
|
|
617
|
-
|
|
743
|
+
const relativeId = id.replace(`${this.namespace}.`, "");
|
|
744
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
618
745
|
let valueToWrite = state.val;
|
|
619
746
|
if (obj.native.customType === "boolean") {
|
|
620
747
|
valueToWrite = state.val ? 1 : 0;
|
|
@@ -629,7 +756,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
629
756
|
if (!isNaN(targetWriteId)) {
|
|
630
757
|
if (this.isDebugLogActive) {
|
|
631
758
|
(0, import_logger.writeLog)(
|
|
632
|
-
`
|
|
759
|
+
`Transmitting modified custom configuration parameter ${targetWriteId} to hardware layer with payload value ${valueToWrite}`,
|
|
633
760
|
"info"
|
|
634
761
|
);
|
|
635
762
|
}
|
|
@@ -637,7 +764,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
637
764
|
}
|
|
638
765
|
}
|
|
639
766
|
} catch (err) {
|
|
640
|
-
(0, import_logger.writeLog)(`
|
|
767
|
+
(0, import_logger.writeLog)(`Failed to compile custom value parameter adjustment payload write: ${err.message}`, "error");
|
|
641
768
|
}
|
|
642
769
|
return;
|
|
643
770
|
}
|
|
@@ -650,24 +777,28 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
650
777
|
return;
|
|
651
778
|
}
|
|
652
779
|
try {
|
|
780
|
+
const relativeId = id.replace(`${this.namespace}.`, "");
|
|
653
781
|
if (mappingKey === "Schreibe_Debug_Log") {
|
|
654
|
-
await this.
|
|
782
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
655
783
|
this.isDebugLogActive = state.val === true;
|
|
656
784
|
(0, import_logger.setCustomDebug)(this.isDebugLogActive);
|
|
657
|
-
(0, import_logger.writeLog)(
|
|
785
|
+
(0, import_logger.writeLog)(
|
|
786
|
+
`Extended debugging telemetry logging mode has been ${this.isDebugLogActive ? "enabled" : "disabled"}.`,
|
|
787
|
+
"info"
|
|
788
|
+
);
|
|
658
789
|
return;
|
|
659
790
|
}
|
|
660
791
|
if (mappingKey === "Regelung_Aktiv" || mappingKey === "zip_aktiv") {
|
|
661
|
-
await this.
|
|
792
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
662
793
|
return;
|
|
663
794
|
}
|
|
664
795
|
if (mappingKey === "Setze_Vorgabewerte" && state.val === true) {
|
|
665
|
-
await this.
|
|
796
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
666
797
|
await this.setIdleDefaults();
|
|
667
798
|
return;
|
|
668
799
|
}
|
|
669
800
|
if (mappingKey === "Dump_Raw_To_Log" && state.val === true) {
|
|
670
|
-
await this.
|
|
801
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
671
802
|
await (0, import_rawFunctions.dumpAllRawToLog)(this);
|
|
672
803
|
return;
|
|
673
804
|
}
|
|
@@ -689,7 +820,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
689
820
|
const durationSeconds = durationState && typeof durationState.val === "number" ? durationState.val : 120;
|
|
690
821
|
await (0, import_zipManager.handleActivateZip)(this, id, durationSeconds);
|
|
691
822
|
} else {
|
|
692
|
-
await this.
|
|
823
|
+
await this.setState(relativeId, { val: false, ack: true });
|
|
693
824
|
await (0, import_zipManager.stopZipAndDeaeration)(this);
|
|
694
825
|
}
|
|
695
826
|
return;
|
|
@@ -697,7 +828,7 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
697
828
|
if (!definition.luxWriteId || definition.write !== true) {
|
|
698
829
|
return;
|
|
699
830
|
}
|
|
700
|
-
await this.
|
|
831
|
+
await this.setState(relativeId, { val: state.val, ack: true });
|
|
701
832
|
let valueToWrite = state.val;
|
|
702
833
|
if (definition.role === "value.datetime") {
|
|
703
834
|
const valStr = String(state.val).trim();
|
|
@@ -714,7 +845,10 @@ class Luxtronik2Controller extends utils.Adapter {
|
|
|
714
845
|
const targetWriteId = definition.luxWriteId;
|
|
715
846
|
await this.queueWrite(parseInt(targetWriteId, 10), valueToWrite);
|
|
716
847
|
} catch (err) {
|
|
717
|
-
(0, import_logger.writeLog)(
|
|
848
|
+
(0, import_logger.writeLog)(
|
|
849
|
+
`Failed to finalize downstream state change command event pipeline execution loop: ${err.message}`,
|
|
850
|
+
"error"
|
|
851
|
+
);
|
|
718
852
|
}
|
|
719
853
|
}
|
|
720
854
|
}
|