node-red-contrib-uos-nats 1.3.52 → 1.3.55
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 +5 -1
- package/lib/payloads.js +8 -2
- package/nodes/datahub-input.js +18 -6
- package/nodes/uos-config.html +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
2
1
|
**Unofficial Node-RED Package for Weidmüller u-OS Data Hub**
|
|
3
2
|
|
|
4
3
|
Read, write, and provide variables via NATS protocol using **OAuth2 authentication**.
|
|
5
4
|
Optimized for high performance and real-time updates.
|
|
6
5
|
|
|
6
|
+
> **IMPORTANT:**
|
|
7
|
+
> These nodes **MUST** run directly on the **u-OS device** (e.g. as a simplified App or Snap).
|
|
8
|
+
> The system's NATS server is **NOT accessible from the outside** (blocked by firewall/binding).
|
|
9
|
+
> You cannot use this package from a remote Node-RED instance (e.g. on your Laptop) to connect to the device.
|
|
10
|
+
|
|
7
11
|
Maintained by [IoTUeli](https://iotueli.ch). Source: [GitHub](https://github.com/uiff/nats-NodeRed-Node-uc20)
|
|
8
12
|
|
|
9
13
|
---
|
package/lib/payloads.js
CHANGED
|
@@ -79,8 +79,14 @@ export function buildReadVariablesQuery(ids) {
|
|
|
79
79
|
const builder = new flatbuffers.Builder(128);
|
|
80
80
|
let idsOffset = 0;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// Safety: Filter invalid IDs to prevent crashes in C++ provider
|
|
83
|
+
// FlatBuffers requires strict types.
|
|
84
|
+
const validIds = (ids || [])
|
|
85
|
+
.map(id => Number(id))
|
|
86
|
+
.filter(id => Number.isInteger(id) && id >= 0);
|
|
87
|
+
|
|
88
|
+
if (validIds.length > 0) {
|
|
89
|
+
idsOffset = ReadVariablesQueryRequest.createIdsVector(builder, validIds);
|
|
84
90
|
}
|
|
85
91
|
|
|
86
92
|
ReadVariablesQueryRequest.startReadVariablesQueryRequest(builder);
|
package/nodes/datahub-input.js
CHANGED
|
@@ -283,8 +283,17 @@ module.exports = function (RED) {
|
|
|
283
283
|
this.send({ payload: { type: 'snapshot', variables: allResults } });
|
|
284
284
|
this.status({ fill: 'green', shape: 'dot', text: 'active' });
|
|
285
285
|
} else if (errors.length > 0) {
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
const errStr = errors.join('; ');
|
|
287
|
+
if (errStr.includes('503') || errStr.includes('no responders')) {
|
|
288
|
+
this.status({ fill: 'green', shape: 'ring', text: 'waiting for provider' });
|
|
289
|
+
this.debug(`Snapshot waiting: ${errStr}`);
|
|
290
|
+
} else if (errStr.includes('Authorization') || errStr.includes('Permission')) {
|
|
291
|
+
this.status({ fill: 'yellow', shape: 'ring', text: 'auth failed' });
|
|
292
|
+
this.warn(`Snapshot auth failed: ${errStr}`);
|
|
293
|
+
} else {
|
|
294
|
+
this.status({ fill: 'red', shape: 'ring', text: 'error' });
|
|
295
|
+
this.warn(`Snapshot errors: ${errStr}`);
|
|
296
|
+
}
|
|
288
297
|
} else {
|
|
289
298
|
this.status({ fill: 'green', shape: 'ring', text: 'empty' });
|
|
290
299
|
}
|
|
@@ -360,10 +369,13 @@ module.exports = function (RED) {
|
|
|
360
369
|
|
|
361
370
|
this.on('input', (msg, send, done) => {
|
|
362
371
|
let overrideItems = null;
|
|
363
|
-
if (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
372
|
+
if (msg.payload) {
|
|
373
|
+
if (Array.isArray(msg.payload) && msg.payload.length > 0) {
|
|
374
|
+
overrideItems = msg.payload;
|
|
375
|
+
} else if (typeof msg.payload === 'string' || (typeof msg.payload === 'object' && !Buffer.isBuffer(msg.payload))) {
|
|
376
|
+
// Allow single item dynamic read (convenience)
|
|
377
|
+
overrideItems = [msg.payload];
|
|
378
|
+
}
|
|
367
379
|
}
|
|
368
380
|
|
|
369
381
|
performSnapshot(overrideItems)
|
package/nodes/uos-config.html
CHANGED
|
@@ -230,6 +230,13 @@
|
|
|
230
230
|
|
|
231
231
|
<h3>Troubleshooting</h3>
|
|
232
232
|
|
|
233
|
+
<p style="color:var(--red-ui-text-color-error); font-weight:bold; border:1px solid var(--red-ui-text-color-error); padding:5px; border-radius:3px;">
|
|
234
|
+
⚠️ IMPORTANT:<br>
|
|
235
|
+
These nodes MUST run directly on the u-OS device (App/Snap).
|
|
236
|
+
The NATS server is NOT accessible from the outside.
|
|
237
|
+
You cannot use this node from a remote instance (e.g. Laptop).
|
|
238
|
+
</p>
|
|
239
|
+
|
|
233
240
|
<h4>Test Connection fails</h4>
|
|
234
241
|
<ul>
|
|
235
242
|
<li>Check Host/Port are correct and device is reachable</li>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-uos-nats",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.55",
|
|
4
4
|
"description": "Node-RED nodes for Weidmüller u-OS Data Hub. Read, write, and provide variables via NATS protocol with OAuth2 authentication. Features: Variable Key resolution, custom icons, example flows, and provider definition caching.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "IoTUeli",
|