node-red-contrib-ccu 4.7.2 → 4.9.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/CHANGELOG.md CHANGED
@@ -5,6 +5,66 @@ 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.9.0 (2026-11-09)
9
+
10
+ ### Added
11
+
12
+ - **Pairing with an openccu-lite system from the connection node.** A
13
+ Node-RED that does not run on the system no longer needs a token copied
14
+ from the system's API tokens page: _Pair with the system_ asks the system
15
+ at the configured address for access, the dialog shows a six-digit code,
16
+ an administrator compares and approves it on the system's Status page, and
17
+ the dialog fills in the token and the fingerprint of the system's
18
+ certificate (and TLS, where the system redirects to https). After the
19
+ deploy the metadata API and lite-rpc accept exactly that certificate, so
20
+ the system's own self-signed certificate works without _Ignore invalid TLS
21
+ Certificates_; another certificate is refused before the token is sent. A
22
+ rejection, an expired request, a CCU or nothing at the address, pairing
23
+ switched off on the system or a request from outside its local networks
24
+ are said in the dialog. Closing the dialog withdraws a pending request.
25
+ Node-RED on the system itself (RedMatic on openccu-lite) is unchanged: it
26
+ configures itself, the dialog shows no pairing there and the runtime
27
+ refuses a pairing request for a local connection.
28
+
29
+ ## 4.8.0 (2026-10-29)
30
+
31
+ Less memory: the connection's own bookkeeping no longer grows with the
32
+ number of datapoints, and the paramset descriptions in memory are those of
33
+ the device types the system has. On a large system (a few thousand
34
+ datapoints, a few hundred subscriptions from value nodes, RedMatic-HomeKit
35
+ and RedMatic-Matter) that is on the order of 100 MB of live heap less, and
36
+ a deploy no longer adds to it. It is a reduction, not the whole of a large
37
+ Node-RED's memory: flows and the other nodes keep what they keep.
38
+
39
+ ### Changed
40
+
41
+ - **Datapoint subscriptions are dispatched through an index.** Until now the
42
+ connection remembered, for every datapoint, which subscriptions had matched
43
+ it and which had not - two sets of ids per datapoint name, so the memory
44
+ grew with datapoints × subscriptions (3,500 datapoints × 536 subscriptions
45
+ were about 70 MB of live heap on a CCU3), a subscription with `cache` on
46
+ walked every cached value at deploy time to fill them all, and - because
47
+ the replay and the event path stored the id in two different forms - a
48
+ redeploy left the old entries behind and grew the sets again. Now a
49
+ subscription is indexed by the most exact attribute of its filter (the
50
+ datapoint name, the channel, the device, ...), an event is tested only
51
+ against the subscriptions that can match it, and unsubscribe removes
52
+ exactly one entry. What a subscription receives, and in which order, is
53
+ unchanged (a randomised equivalence test against the old dispatch guards
54
+ it). In the benchmark (`test/bench/subscriptions.js`, 12,000 datapoints,
55
+ 1,000 subscriptions) the heap goes from 481 MB to 3 MB, a deploy from
56
+ 6.5 s to 40 ms, an event from 28 µs to 8 µs.
57
+ - **Paramset descriptions in memory only for the device types present.**
58
+ `paramsets.json` - the shipped 14 MB plus what a system fetched - was held
59
+ in memory whole: some 2,800 type/version keys, 16-20 MB of heap, where a
60
+ system uses the few dozen types it has (40 types are 3 MB). The file on
61
+ disk keeps every description in its format; the memory holds the ones the
62
+ device table needs, loaded at start and, for a device that arrives later,
63
+ from the file before the interface is asked. A fetched description is
64
+ merged into the file. The editor's device data is correspondingly smaller.
65
+ - An obsolete `ccu_paramsets_v2.json` (the format of 2019) still lying in a
66
+ userDir is removed at start, once, with a log line.
67
+
8
68
  ## 4.7.2 (2026-10-29)
9
69
 
10
70
  ### Fixed
package/README.md CHANGED
@@ -49,9 +49,15 @@ CCU-Jack keep their own connections.
49
49
  - Node-RED **on the system** (RedMatic from its addon catalogue): lite-rpc with RedMatic's own token, which the system
50
50
  mints for it from RedMatic's manifest (RedMatic 9.15.1 or later); the names come with the system's read-only token.
51
51
  Nothing to configure. An older RedMatic has no such token and connects the CCU way, the log says so.
52
- - Node-RED **elsewhere**: an API token of the system goes into the connection node's **openccu-lite token** field -
53
- for lite-rpc it needs the `rpc:*` scope of what the flow does (`rpc:read` for events and reads, `rpc:operate` for
54
- `setValue`, `rpc:configure` for paramsets and links, `rpc:admin` for the rest; the rpc node may call anything).
52
+ - Node-RED **elsewhere**: enter the system's address and press **Pair with the system** in the connection node. The
53
+ dialog shows a six-digit code; an administrator compares it on the system's Status page and approves the request.
54
+ The token and the fingerprint of the system's certificate are filled in, TLS is switched on where the system
55
+ offers https, and after the deploy the connection accepts exactly that certificate - no "ignore invalid
56
+ certificates" needed for the system's own self-signed one. Pairing asks for devices at the _administer_ level (the
57
+ rpc node may call any method) and for reading the names. Alternatively an API token made on the system goes into
58
+ the **openccu-lite token** field by hand - for lite-rpc it needs the `rpc:*` scope of what the flow does
59
+ (`rpc:read` for events and reads, `rpc:operate` for `setValue`, `rpc:configure` for paramsets and links,
60
+ `rpc:admin` for the rest).
55
61
  - **System variables, programs and HM-Script do not exist there.** The `ccu-sysvar`, `ccu-program`, `ccu-script` and
56
62
  `ccu-poll` nodes stay in the flows and answer every message with an error.
57
63
 
@@ -1,4 +1,19 @@
1
1
  <script type="text/javascript">
2
+ // pairing with an openccu-lite system: the request the open dialog runs, withdrawn when it closes
3
+ let ccuActivePairing = null;
4
+ const ccuStopPairing = withdraw => {
5
+ if (!ccuActivePairing) {
6
+ return;
7
+ }
8
+
9
+ clearTimeout(ccuActivePairing.timer);
10
+ if (withdraw && ccuActivePairing.id) {
11
+ $.ajax({url: 'ccu/pair/' + ccuActivePairing.id, type: 'DELETE'});
12
+ }
13
+
14
+ ccuActivePairing = null;
15
+ };
16
+
2
17
  RED.nodes.registerType('ccu-connection', {
3
18
  category: 'config',
4
19
  defaults: {
@@ -48,12 +63,22 @@
48
63
  // credentials (flows_cred.json, encrypted, never exported), not in the flow
49
64
  credentials: {
50
65
  password: {type: 'password'},
51
- metaToken: {type: 'password'}
66
+ metaToken: {type: 'password'},
67
+ // the system's certificate as pinned at pairing - no secret, shown in the dialog
68
+ fingerprint256: {type: 'text'}
52
69
  },
53
70
  label() {
54
71
  return this.name || this.host;
55
72
  },
56
73
 
74
+ oneditsave() {
75
+ ccuStopPairing(true);
76
+ },
77
+
78
+ oneditcancel() {
79
+ ccuStopPairing(true);
80
+ },
81
+
57
82
  oneditprepare() {
58
83
  // pre-4.3.0 config nodes have neither property - show the defaults
59
84
  // the runtime uses rather than an unchecked box / empty field
@@ -164,10 +189,129 @@
164
189
  $('#node-config-auth-fields, #node-config-auth-hint').toggle(!local);
165
190
  $('#node-config-input-username, #node-config-input-password').closest('.form-row').toggle(!local);
166
191
  $('#node-config-auth-local').toggle(local);
192
+ // on the system itself the connection configures itself: nothing to pair
193
+ $('#node-config-pair, #node-config-pair-status').toggle(!local);
194
+ $('#node-config-pair-local').toggle(local);
167
195
  };
168
196
  $nodeConfigInputHost.on('change keyup', showAuthRows);
169
197
  showAuthRows();
170
198
 
199
+ // pairing with an openccu-lite system (lib/pairing.js): the runtime asks the system, the
200
+ // dialog shows the code, an administrator approves it on the system's Status page, and
201
+ // the token and the pinned certificate land in the fields - then the user deploys
202
+ const $pair = $('#node-config-pair');
203
+ const $pairStatus = $('#node-config-pair-status');
204
+ const pairIdle = $pairStatus.html();
205
+ const pairButton = () => $pair.text(ccuActivePairing ? 'Cancel pairing' : 'Pair with the system');
206
+ const pairSay = text => $pairStatus.text(text);
207
+
208
+ const pairShow = view => {
209
+ switch (view.state) {
210
+ case 'waiting': {
211
+ $pairStatus.empty().append('Code ', $('<b>').text(view.code), ' - approve it on the Status page of the system:');
212
+ $pairStatus.append(' ', $('<a target="_blank" rel="noopener">').attr('href', view.url + '/').text(view.url));
213
+ return true;
214
+ }
215
+
216
+ case 'approved': {
217
+ $('#node-config-input-metaToken').val(view.token);
218
+ $('#node-config-input-fingerprint256').val(view.fingerprint256 || '');
219
+ $('#node-config-input-tls').prop('checked', Boolean(view.tls));
220
+ $('#node-config-input-metaPort').val(view.port || '');
221
+ if (view.fingerprint256) {
222
+ $('#node-config-input-inSecure').prop('checked', false);
223
+ }
224
+
225
+ pairSay('Paired as "' + view.name + '"' + (view.fingerprint256 ? ', the certificate of the system pinned' : ' (plain HTTP, no certificate to pin)') + '. Deploy to use it.');
226
+ return false;
227
+ }
228
+
229
+ case 'failed':
230
+ case 'cancelled': {
231
+ pairSay(view.message || 'Pairing failed.');
232
+ return false;
233
+ }
234
+
235
+ default: {
236
+ pairSay('Asking the system ...');
237
+ return true;
238
+ }
239
+ }
240
+ };
241
+
242
+ const pairPoll = () => {
243
+ const pairing = ccuActivePairing;
244
+ if (!pairing) {
245
+ return;
246
+ }
247
+
248
+ $.getJSON('ccu/pair/' + pairing.id)
249
+ .done(view => {
250
+ if (ccuActivePairing !== pairing) {
251
+ return;
252
+ }
253
+
254
+ if (pairShow(view)) {
255
+ pairing.timer = setTimeout(pairPoll, 1000);
256
+ } else {
257
+ ccuStopPairing(false);
258
+ pairButton();
259
+ }
260
+ })
261
+ .fail(xhr => {
262
+ if (ccuActivePairing !== pairing) {
263
+ return;
264
+ }
265
+
266
+ pairSay((xhr.responseJSON && xhr.responseJSON.message) || 'Pairing failed: ' + xhr.statusText);
267
+ ccuStopPairing(false);
268
+ pairButton();
269
+ });
270
+ };
271
+
272
+ $pair.on('click', () => {
273
+ if (ccuActivePairing) {
274
+ ccuStopPairing(true);
275
+ $pairStatus.html(pairIdle);
276
+ pairButton();
277
+ return;
278
+ }
279
+
280
+ ccuActivePairing = {id: null, timer: null};
281
+ const pairing = ccuActivePairing;
282
+ pairButton();
283
+ pairSay('Asking the system ...');
284
+ $.ajax({
285
+ url: 'ccu/pair',
286
+ type: 'POST',
287
+ contentType: 'application/json',
288
+ dataType: 'json',
289
+ data: JSON.stringify({
290
+ host: $nodeConfigInputHost.val(),
291
+ tls: $('#node-config-input-tls').is(':checked'),
292
+ port: $('#node-config-input-metaPort').val()
293
+ })
294
+ })
295
+ .done(answer => {
296
+ if (ccuActivePairing !== pairing) {
297
+ $.ajax({url: 'ccu/pair/' + answer.id, type: 'DELETE'});
298
+ return;
299
+ }
300
+
301
+ pairing.id = answer.id;
302
+ pairPoll();
303
+ })
304
+ .fail(xhr => {
305
+ if (ccuActivePairing !== pairing) {
306
+ return;
307
+ }
308
+
309
+ pairSay((xhr.responseJSON && xhr.responseJSON.message) || 'Pairing failed: ' + xhr.statusText);
310
+ ccuStopPairing(false);
311
+ pairButton();
312
+ });
313
+ });
314
+
171
315
  // task 9: re-read the device table of the deployed connection
172
316
  const $reread = $('#node-config-reread');
173
317
  const $rereadStatus = $('#node-config-reread-status');
@@ -321,10 +465,23 @@
321
465
  <option value="ccu">CCU: directly, with callbacks (XML-RPC/BIN-RPC) - on openccu-lite too</option>
322
466
  </select>
323
467
  </div>
468
+ <div class="form-row">
469
+ <label for="node-config-pair"><i class="icon-tag"></i> openccu-lite pairing</label>
470
+ <div style="width: 70%; display: inline-block; vertical-align: text-top;">
471
+ <button type="button" class="red-ui-button" id="node-config-pair">Pair with the system</button><br>
472
+ <small id="node-config-pair-status">For an openccu-lite system on the network: asks it for access, shows a code to approve on its Status page, and fills the token and the certificate below. Deploy afterwards.</small>
473
+ <small id="node-config-pair-local" style="display: none;">Node-RED runs on the system itself: the connection configures itself, nothing to pair.</small>
474
+ </div>
475
+ </div>
324
476
  <div class="form-row">
325
477
  <label for="node-config-input-metaToken"><i class="icon-tag"></i> openccu-lite token</label>
326
478
  <input type="password" id="node-config-input-metaToken" placeholder="olt_...">
327
- <small>Only for openccu-lite (a CCU ignores this). Leave empty when Node-RED runs on the system itself (RedMatic).</small>
479
+ <small>Only for openccu-lite (a CCU ignores this): filled by pairing, or a token made on the system's API tokens page. Leave empty when Node-RED runs on the system itself (RedMatic).</small>
480
+ </div>
481
+ <div class="form-row">
482
+ <label for="node-config-input-fingerprint256"><i class="icon-tag"></i> Pinned certificate</label>
483
+ <input type="text" id="node-config-input-fingerprint256" placeholder="SHA-256, filled by pairing">
484
+ <small>With TLS, the openccu-lite connection accepts exactly this certificate of the system (no need to ignore invalid certificates). Empty: the usual certificate checks.</small>
328
485
  </div>
329
486
  <div class="form-row">
330
487
  <label for="node-config-input-metaPort"><i class="icon-tag"></i> openccu-lite port</label>