node-red-contrib-uos-nats 0.2.45 → 0.2.47

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.
@@ -63,10 +63,13 @@ module.exports = function (RED) {
63
63
  this.error('Please select a u-OS config node.');
64
64
  return;
65
65
  }
66
- this.providerId = config.providerId || connection.clientName || 'nodered';
66
+ // Retrieve configuration node
67
+ this.providerId = (config.providerId || 'nodered').trim();
68
+ const uosConfig = RED.nodes.getNode(config.uosConfig);
69
+ this.definitions = config.definitions || [];
67
70
 
68
71
  const defMap = new Map();
69
- const definitions = [];
72
+ // const definitions = []; // This line is effectively replaced by this.definitions
70
73
  const stateMap = new Map();
71
74
  let nextId = 100;
72
75
  let fingerprint = 0;
@@ -144,9 +147,13 @@ module.exports = function (RED) {
144
147
 
145
148
  // Debug: Log complete HEX dump to verify flatbuffer structure
146
149
  const hex = Buffer.from(payload).toString('hex');
150
+
151
+ const subject = loadedSubjects.varsChangedEvent(this.providerId);
152
+ console.log(`[DataHub Output] Sending Heartbeat to '${subject}'`);
147
153
  console.log(`[DataHub Output] Packet HEX (${payload.length} bytes): ${hex}`);
148
154
 
149
- await nc.publish(loadedSubjects.varsChangedEvent(this.providerId), payload);
155
+ await nc.publish(subject, payload);
156
+ await nc.flush(); // Ensure NATS accepts the packet (catches Permission Errors)
150
157
  console.log(`[DataHub Output] Heartbeat sent. State count: ${Object.keys(stateObj).length}`);
151
158
  } catch (err) {
152
159
  this.warn(`Heartbeat error: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-uos-nats",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
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",