node-red-contrib-ccu 4.16.0 → 4.17.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,42 @@ Notable changes to node-red-contrib-ccu. Format follows
5
5
  user-visible symptom and the cause, not the commit list (the release notes
6
6
  append commits automatically).
7
7
 
8
+ ## 4.17.1 (2026-11-29)
9
+
10
+ ### Fixed
11
+
12
+ - **A taken callback port crashed Node-RED.** When the BINRPC listening port
13
+ of a ccu-connection node was already in use - by a second connection node
14
+ with the same port, as a flow imported with a copy of the connection node
15
+ brings it, or by another process - Node-RED ended with
16
+ `listen EADDRINUSE` at every start (on RedMatic: only the safe mode was
17
+ left). Since 4.1.0 the error of the BINRPC callback server went unheard.
18
+ Now only that connection fails: its nodes show `port <n> in use`, the log
19
+ names the port and the connection node holding it, and the rest of the
20
+ runtime keeps running. The editor marks a connection node whose listening
21
+ port another connection node uses. Reported by HA_Beginner
22
+ (homematic-forum).
23
+
24
+ ## 4.17.0 (2026-11-28)
25
+
26
+ ### Changed
27
+
28
+ - **sysvar and program: new default topics** `hm/status/sysvar/${Name}` and
29
+ `hm/status/program/${Name}` (both were `ReGaHSS/${Name}`). They apply to
30
+ newly placed nodes; nodes already in a flow keep the topic they were saved
31
+ with.
32
+
33
+ ### Fixed
34
+
35
+ - **openccu-lite: a system variable or program made in the Logic addon while
36
+ Node-RED runs was missing** from the sysvar and program nodes' lists, and
37
+ their nodes did not find it, until its value was first written (a computed
38
+ value: until its inputs changed) or Node-RED was restarted. The connection
39
+ took a Logic object only from a value event, and Logic announces a new one
40
+ without. Now its values are read as soon as Logic announces it, so it is
41
+ listed at once - first under its key if the name is not there yet, then
42
+ under its name, and after a rename under the new one.
43
+
8
44
  ## 4.16.0 (2026-11-28)
9
45
 
10
46
  ### Added
package/README.md CHANGED
@@ -72,20 +72,22 @@ CCU-Jack keep their own connections.
72
72
 
73
73
  Every node that emits messages builds `msg.topic` from the same template, configurable per node, with these defaults:
74
74
 
75
- | Node | Default topic |
76
- | --------------- | ------------------------------------------------- |
77
- | rpc-event | `${CCU}/${Interface}/${channelName}/${datapoint}` |
78
- | value | `${CCU}/${Interface}/${channel}/${datapoint}` |
79
- | get value | _(empty: `msg.topic` stays as it came in)_ |
80
- | sysvar, program | `ReGaHSS/${Name}` |
81
- | rpc | `${CCU}/${Interface}/${Method}` |
82
- | script | `${CCU}/${Interface}` |
75
+ | Node | Default topic |
76
+ | --------- | ------------------------------------------------- |
77
+ | rpc-event | `${CCU}/${Interface}/${channelName}/${datapoint}` |
78
+ | value | `${CCU}/${Interface}/${channel}/${datapoint}` |
79
+ | get value | _(empty: `msg.topic` stays as it came in)_ |
80
+ | sysvar | `hm/status/sysvar/${Name}` |
81
+ | program | `hm/status/program/${Name}` |
82
+ | rpc | `${CCU}/${Interface}/${Method}` |
83
+ | script | `${CCU}/${Interface}` |
83
84
 
84
85
  Placeholders are the message's properties, matched case-insensitively: `${CCU}`, `${Interface}`, `${device}`,
85
86
  `${deviceName}`, `${deviceType}`, `${channel}`, `${channelName}`, `${channelType}`, `${channelIndex}`, `${datapoint}`,
86
87
  `${datapointName}`; `${Name}` for a variable or program, `${Method}` for an RPC call. To get one scheme everywhere -
87
- `hm/<interface>/<channel>/<datapoint>`, say - enter `hm/${Interface}/${channel}/${datapoint}` in each node; the defaults
88
- stay as they are so existing flows and subscriptions keep working. The value node's input accepts a datapoint address in
88
+ `hm/<interface>/<channel>/<datapoint>`, say - enter `hm/${Interface}/${channel}/${datapoint}` in each node. A default
89
+ applies to newly placed nodes only: existing nodes keep the topic they were saved with (the default of the sysvar
90
+ and program nodes was `ReGaHSS/${Name}` until 4.16.0), so existing flows and subscriptions keep working. The value node's input accepts a datapoint address in
89
91
  `msg.topic` either as `iface.channel.datapoint` or in the emitted shape (`ccu3/BidCos-RF/OEQ1868878:1/STATE`,
90
92
  `hm/BidCos-RF/OEQ1868878:1/STATE`: the last three segments count), so an event's topic can be fed straight back. The
91
93
  `ccu-mqtt` node has its own templates for its MQTT topics.
@@ -14,6 +14,23 @@
14
14
  ccuActivePairing = null;
15
15
  };
16
16
 
17
+ // a callback port another connection node listens on, too: only one of the two can open it
18
+ // (a flow imported with a copy of the connection node brings the same ports)
19
+ const ccuUniquePort = function (value) {
20
+ if (!value) {
21
+ return false;
22
+ }
23
+
24
+ let taken = false;
25
+ RED.nodes.eachConfig(node => {
26
+ if (node.type === 'ccu-connection' && node.id !== this.id && !node.d &&
27
+ (String(node.rpcBinPort) === String(value) || String(node.rpcXmlPort) === String(value))) {
28
+ taken = true;
29
+ }
30
+ });
31
+ return !taken || 'port ' + value + ' is used by another ccu-connection node';
32
+ };
33
+
17
34
  RED.nodes.registerType('ccu-connection', {
18
35
  category: 'config',
19
36
  defaults: {
@@ -45,8 +62,8 @@
45
62
  rpcPingTimeout: {value: 60},
46
63
  rpcInitAddress: {value: ''},
47
64
  rpcServerHost: {value: '', required: true},
48
- rpcBinPort: {value: '', required: true},
49
- rpcXmlPort: {value: '', required: true},
65
+ rpcBinPort: {value: '', required: true, validate: ccuUniquePort},
66
+ rpcXmlPort: {value: '', required: true, validate: ccuUniquePort},
50
67
 
51
68
  tls: {value: false},
52
69
  inSecure: {value: false},
@@ -107,6 +107,11 @@ module.exports = function (RED) {
107
107
 
108
108
  const ccu = {network: {listen: [], ports: []}};
109
109
 
110
+ // the callback ports the connection nodes of this runtime listen on, port -> {node, protocol}:
111
+ // a port that is taken names the config node holding it (two connection nodes with the same
112
+ // port, e.g. after importing a flow that carried a copy of one)
113
+ const callbackPorts = new Map();
114
+
110
115
  /**
111
116
  *
112
117
  * @param start
@@ -792,6 +797,8 @@ module.exports = function (RED) {
792
797
  this.liteListed = false;
793
798
  this.logicObjects = {};
794
799
  this.logicWaiters = [];
800
+ // B-52: the state store's picture was taken - Logic objects announced after it are read
801
+ this.litePictured = false;
795
802
  this.metaMode = false;
796
803
  this.meta = null;
797
804
  // #167: minutes between re-reads of channel names, rooms and
@@ -1125,7 +1132,7 @@ module.exports = function (RED) {
1125
1132
  }
1126
1133
 
1127
1134
  waiting = Boolean(waiting) && !connected;
1128
- if (connected && this.ifaceError[iface]) {
1135
+ if (connected && this.ifaceError[iface] && !this.serverError[iface]) {
1129
1136
  delete this.ifaceError[iface];
1130
1137
  this.ifaceStatus[iface] = null; // the nodes drop the error text
1131
1138
  }
@@ -3126,6 +3133,7 @@ module.exports = function (RED) {
3126
3133
  }
3127
3134
  });
3128
3135
  this.logicPictureDone();
3136
+ this.litePictured = true;
3129
3137
  this.logger.debug('lite-rpc: ' + count + ' values from the state store');
3130
3138
  this.cachedValuesReceived = true;
3131
3139
  this.saveValues();
@@ -3413,6 +3421,56 @@ module.exports = function (RED) {
3413
3421
  }
3414
3422
  }
3415
3423
 
3424
+ /**
3425
+ * B-52: Logic announced variables or programs (newDevices): one made after the start has no
3426
+ * value event until it is written, so it would be missing from the editor's lists and from
3427
+ * its nodes until then. Its datapoints are read once, as the start's picture would have
3428
+ * given them. The objects of the connect itself come with the picture and are skipped.
3429
+ * @param {Array<object>} devices the descriptions of the newDevices call
3430
+ */
3431
+ logicAnnounced(devices) {
3432
+ if (!this.litePictured || !this.logicIface || !Array.isArray(devices)) {
3433
+ return;
3434
+ }
3435
+
3436
+ const iface = this.logicIface;
3437
+ devices.forEach((device) => {
3438
+ const ref = logic.parseAddress(device && device.ADDRESS);
3439
+ if (!ref || this.logicObjects[ref.channel]) {
3440
+ return;
3441
+ }
3442
+
3443
+ this.methodCall(iface, 'getParamset', [ref.channel, 'VALUES'], {quiet: true})
3444
+ .then((values) => {
3445
+ if (iface !== this.logicIface || this.logicObjects[ref.channel]) {
3446
+ // an event came first, or the addon went
3447
+ return;
3448
+ }
3449
+
3450
+ const paramset = values && typeof values === 'object' ? values : {};
3451
+ const ts = now();
3452
+ if (ref.kind === 'variable') {
3453
+ this.logicValue(iface, ref.channel, 'VALUE', paramset.VALUE, {ts, picture: true});
3454
+ } else {
3455
+ this.updateLogicProgram(ref, {active: Boolean(paramset.ACTIVE)}, ts, true);
3456
+ this.logicPictureDone();
3457
+ }
3458
+
3459
+ this.logger.debug(
3460
+ 'Logic',
3461
+ ref.channel,
3462
+ 'announced:',
3463
+ JSON.stringify(this.logicObjects[ref.channel] && this.logicObjects[ref.channel].name),
3464
+ );
3465
+ })
3466
+ .catch((error) => {
3467
+ this.logger.warn(
3468
+ 'Logic: ' + ref.channel + ' announced but not readable: ' + (error.message || error),
3469
+ );
3470
+ });
3471
+ });
3472
+ }
3473
+
3416
3474
  /**
3417
3475
  * task 32: the entry of a Logic object under its current name in `table` (this.sysvar or
3418
3476
  * this.program): a rename moves it, a name another object holds is not taken over.
@@ -4213,6 +4271,12 @@ module.exports = function (RED) {
4213
4271
  }
4214
4272
  });
4215
4273
 
4274
+ callbackPorts.forEach((holder, port) => {
4275
+ if (holder.node === this) {
4276
+ callbackPorts.delete(port);
4277
+ }
4278
+ });
4279
+
4216
4280
  this.logger.debug('queue binrpc server closing');
4217
4281
  calls.push(() => {
4218
4282
  return new Promise((resolve) => {
@@ -4283,6 +4347,54 @@ module.exports = function (RED) {
4283
4347
  return protocol + '://' + (this.rpcInitAddress || this.rpcServerHost) + ':' + port;
4284
4348
  }
4285
4349
 
4350
+ /**
4351
+ * The callback server of a protocol could not listen (the port is taken, the address is
4352
+ * gone): the interfaces that use it show why, the log names the port and who holds it, and
4353
+ * the rest of the runtime keeps running.
4354
+ * @param {string} protocol binrpc, http or https
4355
+ * @param {number} port the callback port
4356
+ * @param {Error} err the socket's error
4357
+ */
4358
+ callbackServerError(protocol, port, err) {
4359
+ const kind = protocol === 'binrpc' ? 'BINRPC' : 'XMLRPC';
4360
+ let text;
4361
+ if (err && err.code === 'EADDRINUSE') {
4362
+ const holder = callbackPorts.get(port);
4363
+ const other = holder && holder.node !== this ? holder.node : null;
4364
+ const name = other ? '"' + (other.name || other.id) + '" (' + other.id + ')' : '';
4365
+ this.logger.error(
4366
+ kind +
4367
+ ' listening port ' +
4368
+ port +
4369
+ ' is already in use' +
4370
+ (other
4371
+ ? ' by the ccu-connection config node ' + name
4372
+ : ' by another process or an older ccu-connection config node') +
4373
+ ' - give this config node "' +
4374
+ (this.name || this.id) +
4375
+ '" (' +
4376
+ this.id +
4377
+ ') another ' +
4378
+ kind +
4379
+ ' listening port, or delete one of the two',
4380
+ );
4381
+ text = 'port ' + port + ' in use' + (other ? ' by ' + (other.name || other.id) : '');
4382
+ } else {
4383
+ const message = (err && err.message) || String(err);
4384
+ this.logger.error(kind + ' server on port ' + port + ': ' + message);
4385
+ text = kind + ' server: ' + ((err && err.code) || message);
4386
+ }
4387
+
4388
+ Object.keys(this.ifaceTypes).forEach((iface) => {
4389
+ if (this.enabledIfaces.includes(iface) && this.ifaceTypes[iface].protocol === protocol) {
4390
+ this.serverError[iface] = text;
4391
+ this.ifaceError[iface] = text;
4392
+ this.ifaceStatus[iface] = false;
4393
+ }
4394
+ });
4395
+ this.pushStatus();
4396
+ }
4397
+
4286
4398
  /**
4287
4399
  *
4288
4400
  * @param iface
@@ -4296,6 +4408,7 @@ module.exports = function (RED) {
4296
4408
  this.servers[protocol] = rpc.createServer({host: this.rpcServerHost, port}, () => {
4297
4409
  // Todo homematic-xmlrpc and binrpc module: clarify onListening callback params
4298
4410
  this.logger.info(protocol === 'binrpc' ? 'binrpc' : 'xmlrpc', 'server listening on', url);
4411
+ callbackPorts.set(port, {node: this, protocol});
4299
4412
  this.serverError[iface] = null;
4300
4413
  });
4301
4414
  if (this.servers[protocol].httpServer) {
@@ -4310,12 +4423,11 @@ module.exports = function (RED) {
4310
4423
  this.servers[protocol].httpServer.headersTimeout = KEEP_ALIVE_TIMEOUT_MS + 5000;
4311
4424
  }
4312
4425
 
4313
- // Todo binrpc module: emit error event on server object to eliminate the reach-in
4314
- const errorEmitter = protocol === 'binrpc' ? this.servers[protocol].server : this.servers[protocol];
4315
- errorEmitter.on('error', (err) => {
4316
- this.logger.error(protocol + ' ' + err.message);
4317
- this.serverError[iface] = err.message;
4318
- });
4426
+ // Both modules re-emit the errors of their listening socket on the server object.
4427
+ // The listener sits there: binrpc >= 4.2 re-emits on its Server, and an 'error'
4428
+ // without a listener is thrown - a taken callback port (EADDRINUSE) ended the
4429
+ // whole Node-RED process instead of this connection.
4430
+ this.servers[protocol].on('error', (err) => this.callbackServerError(protocol, port, err));
4319
4431
 
4320
4432
  Object.keys(this.rpcMethods).forEach((method) => {
4321
4433
  this.servers[protocol].on(method, (err, parameters, callback) => {
@@ -5010,6 +5122,10 @@ module.exports = function (RED) {
5010
5122
  this.saveMetadata();
5011
5123
  }
5012
5124
 
5125
+ if (iface && iface === this.logicIface) {
5126
+ this.logicAnnounced(devices);
5127
+ }
5128
+
5013
5129
  // B-37: a restart that kept the subscription gets a fresh init, no ping
5014
5130
  if (iface && !this.keptSubscription(iface, 'newDevices')) {
5015
5131
  this.deviceCallback(iface);
@@ -5,7 +5,7 @@
5
5
  defaults: {
6
6
  name: {value: ''},
7
7
  ccuConfig: {value: 'localhost', type: 'ccu-connection', required: true},
8
- topic: {value: 'ReGaHSS/${Name}'}
8
+ topic: {value: 'hm/status/program/${Name}'}
9
9
  },
10
10
  inputs: 1,
11
11
  outputs: 1,
@@ -5,7 +5,7 @@
5
5
  defaults: {
6
6
  name: {value: ''},
7
7
  ccuConfig: {value: 'localhost', type: 'ccu-connection', required: true},
8
- topic: {value: 'ReGaHSS/${Name}'},
8
+ topic: {value: 'hm/status/sysvar/${Name}'},
9
9
  change: {value: true},
10
10
  cache: {value: true},
11
11
  property: {value: 'payload'},
@@ -28,4 +28,9 @@
28
28
  </dl>
29
29
  </li>
30
30
  </ol>
31
+
32
+ <h3>Topic</h3>
33
+ <p><code>msg.topic</code> wird aus dem Feld <i>Topic</i> gebildet; <code>${Name}</code> steht für den Namen des Programms.
34
+ Ein neu platzierter Node hat <code>hm/status/program/${Name}</code>; ein schon vorhandener Node behält sein Topic
35
+ (<code>ReGaHSS/${Name}</code> bis 4.16.0).</p>
31
36
  </script>
@@ -35,12 +35,17 @@
35
35
  "lc": 1525197999611,
36
36
  "enum": ["nicht anwesend", "anwesend"],
37
37
  "id": 950,
38
- "topic": "ReGaHSS/Anwesenheit"
38
+ "topic": "hm/status/sysvar/Anwesenheit"
39
39
  }
40
40
  </code></pre>
41
41
  </li>
42
42
  </ol>
43
43
 
44
+ <h3>Topic</h3>
45
+ <p><code>msg.topic</code> wird aus dem Feld <i>Topic</i> gebildet; <code>${Name}</code> steht für den Namen der Variable.
46
+ Ein neu platzierter Node hat <code>hm/status/sysvar/${Name}</code>; ein schon vorhandener Node behält sein Topic
47
+ (<code>ReGaHSS/${Name}</code> bis 4.16.0).</p>
48
+
44
49
  <h3>Dynamische Konfiguration</h3>
45
50
  <p><code>msg.config</code> ist ein Objekt, dessen Eigenschaften die Konfiguration dieses Nodes für genau diese Nachricht überschreiben. Die gespeicherte Konfiguration bleibt unverändert.</p>
46
51
  <ul>
@@ -27,4 +27,9 @@
27
27
  </dl>
28
28
  </li>
29
29
  </ol>
30
+
31
+ <h3>Topic</h3>
32
+ <p><code>msg.topic</code> is built from the <i>Topic</i> field; <code>${Name}</code> stands for the program's name.
33
+ A newly placed node has <code>hm/status/program/${Name}</code>; a node placed before keeps the topic it has
34
+ (<code>ReGaHSS/${Name}</code> until 4.16.0).</p>
30
35
  </script>
@@ -34,12 +34,17 @@
34
34
  "lc": 1525197999611,
35
35
  "enum": ["absent", "present"],
36
36
  "id": 950,
37
- "topic": "ReGaHSS/Presence"
37
+ "topic": "hm/status/sysvar/Presence"
38
38
  }
39
39
  </code></pre>
40
40
  </li>
41
41
  </ol>
42
42
 
43
+ <h3>Topic</h3>
44
+ <p><code>msg.topic</code> is built from the <i>Topic</i> field; <code>${Name}</code> stands for the variable's name.
45
+ A newly placed node has <code>hm/status/sysvar/${Name}</code>; a node placed before keeps the topic it has
46
+ (<code>ReGaHSS/${Name}</code> until 4.16.0).</p>
47
+
43
48
  <h3>Dynamic configuration</h3>
44
49
  <p><code>msg.config</code> is an object whose properties override this node's configuration for that one message. The stored configuration is never modified.</p>
45
50
  <ul>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-ccu",
3
- "version": "4.16.0",
3
+ "version": "4.17.1",
4
4
  "license": "MIT",
5
5
  "main": "none",
6
6
  "keywords": [