node-red-contrib-uos-nats 1.3.61 → 1.3.68
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 +3 -3
- package/nodes/datahub-write.html +2 -2
- package/nodes/uos-config.js +17 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ Reads values from existing providers (like `u_os_adm`).
|
|
|
77
77
|
### DataHub - Write
|
|
78
78
|
Changes values in other providers.
|
|
79
79
|
- **Single Mode:** Select a variable from the list. Send `msg.payload` = value.
|
|
80
|
-
- **Batch Mode:** Select NO variable (clear selection). Send `msg.payload` as a JSON object: `{"var_key": value, "
|
|
80
|
+
- **Batch Mode:** Select NO variable (clear selection). Send `msg.payload` as a FLAT JSON object: `{"var_key": value, "machine.status": value}` (uses Configured Provider). **Nested objects are NOT supported** (keys must use dot-notation).
|
|
81
81
|
- **Dynamic Mode:** Send a full target object to write anywhere:
|
|
82
82
|
```json
|
|
83
83
|
{
|
|
@@ -87,8 +87,8 @@ Changes values in other providers.
|
|
|
87
87
|
}
|
|
88
88
|
```json
|
|
89
89
|
{
|
|
90
|
-
"provider": "
|
|
91
|
-
"key": "
|
|
90
|
+
"provider": "u_os_sbm",
|
|
91
|
+
"key": "ur20_8do_p_1.process_data.channel_7.do",
|
|
92
92
|
"value": 123
|
|
93
93
|
}
|
|
94
94
|
```
|
package/nodes/datahub-write.html
CHANGED
|
@@ -250,12 +250,12 @@
|
|
|
250
250
|
</ol>
|
|
251
251
|
<p>If no variable is selected, the node works in <b>Batch Mode</b> or <b>Dynamic Mode</b>.</p>
|
|
252
252
|
<ul>
|
|
253
|
-
<li><b>Batch:</b> Send a JSON object to update multiple keys for the configured Provider: <code>{"key": value, "
|
|
253
|
+
<li><b>Batch:</b> Send a FLAT JSON object to update multiple keys for the configured Provider: <code>{"key": value, "machine.status": value}</code>. <br><b>Note:</b> Nested objects are NOT flattened automatically. Use dot-notation for keys!</li>
|
|
254
254
|
<li><b>Dynamic:</b> Send a specific object to target ANY Provider/Key:
|
|
255
255
|
<code>
|
|
256
256
|
{
|
|
257
257
|
"provider": "u_os_sbm",
|
|
258
|
-
"key": "
|
|
258
|
+
"key": "ur20_8do_p_1.process_data.channel_7.do",
|
|
259
259
|
"value": true
|
|
260
260
|
}
|
|
261
261
|
</code>
|
package/nodes/uos-config.js
CHANGED
|
@@ -187,6 +187,9 @@ module.exports = function (RED) {
|
|
|
187
187
|
// Ensure we have a valid token initially
|
|
188
188
|
await this.getToken();
|
|
189
189
|
|
|
190
|
+
// Sanitize clientName for Inbox usage (Strict NATS subjects)
|
|
191
|
+
const safeClientName = this.clientName.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
192
|
+
|
|
190
193
|
this.nc = await connect({
|
|
191
194
|
servers: `nats://${this.host}:${this.port}`,
|
|
192
195
|
// Authenticator must be SYNCHRONOUS. We rely on background refresh to keep this.tokenInfo current.
|
|
@@ -197,7 +200,10 @@ module.exports = function (RED) {
|
|
|
197
200
|
// REVERT: Use Configured Client Name for Connection.
|
|
198
201
|
// Using UUID caused "Authorization Violation" for some users.
|
|
199
202
|
name: this.clientName,
|
|
200
|
-
|
|
203
|
+
|
|
204
|
+
// inboxPrefix: `_INBOX.${safeClientName}`, // RESTORED: Spec requires strictly this format (ACLs enforce it).
|
|
205
|
+
// Using safeClientName avoids invalid subject errors.
|
|
206
|
+
inboxPrefix: `_INBOX.${safeClientName}`,
|
|
201
207
|
maxReconnectAttempts: -1, // Infinite reconnects
|
|
202
208
|
reconnectTimeWait: 2000,
|
|
203
209
|
});
|
|
@@ -457,10 +463,18 @@ module.exports = function (RED) {
|
|
|
457
463
|
if (!def || !def.variables) return null;
|
|
458
464
|
|
|
459
465
|
const v = def.variables.find(v => v.key === variableKey);
|
|
460
|
-
if (v)
|
|
466
|
+
if (v) {
|
|
467
|
+
return {
|
|
468
|
+
id: v.id,
|
|
469
|
+
fingerprint: def.fingerprint || BigInt(0),
|
|
470
|
+
dataType: v.dataType
|
|
471
|
+
};
|
|
472
|
+
}
|
|
461
473
|
|
|
462
474
|
// Try explicit numeric string fallback
|
|
463
|
-
if (!isNaN(variableKey))
|
|
475
|
+
if (!isNaN(variableKey)) {
|
|
476
|
+
return { id: parseInt(variableKey), fingerprint: BigInt(0) }; // Fallback, no fingerprint known
|
|
477
|
+
}
|
|
464
478
|
|
|
465
479
|
return null;
|
|
466
480
|
} catch (e) {
|
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.68",
|
|
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",
|