node-red-contrib-uos-nats 0.1.30 → 0.1.32
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/nodes/datahub-input.js +11 -4
- package/package.json +1 -1
package/nodes/datahub-input.js
CHANGED
|
@@ -48,11 +48,14 @@ module.exports = function (RED) {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const processStates = (states) => {
|
|
51
|
+
// Helper to find definition by ID (fuzzy match string/number)
|
|
52
|
+
const getDef = (id) => defMap.get(id) || defMap.get(String(id)) || defMap.get(Number(id));
|
|
53
|
+
|
|
51
54
|
return states
|
|
52
55
|
.map((state) => ({
|
|
53
56
|
providerId: this.providerId,
|
|
54
57
|
id: state.id,
|
|
55
|
-
key:
|
|
58
|
+
key: getDef(state.id)?.key || state.id,
|
|
56
59
|
value: state.value,
|
|
57
60
|
quality: state.quality,
|
|
58
61
|
timestampNs: state.timestampNs,
|
|
@@ -60,6 +63,8 @@ module.exports = function (RED) {
|
|
|
60
63
|
.filter((state) => shouldInclude(state.key));
|
|
61
64
|
};
|
|
62
65
|
|
|
66
|
+
let performSnapshot = async () => { }; // Placeholder
|
|
67
|
+
|
|
63
68
|
const start = async () => {
|
|
64
69
|
try {
|
|
65
70
|
this.status({ fill: 'yellow', shape: 'ring', text: 'connecting…' });
|
|
@@ -77,7 +82,7 @@ module.exports = function (RED) {
|
|
|
77
82
|
nc = await connection.acquire();
|
|
78
83
|
this.status({ fill: 'green', shape: 'dot', text: 'connected' });
|
|
79
84
|
|
|
80
|
-
|
|
85
|
+
performSnapshot = async () => {
|
|
81
86
|
// Only request snapshot if connected
|
|
82
87
|
if (!nc || nc.isClosed()) return;
|
|
83
88
|
try {
|
|
@@ -90,11 +95,13 @@ module.exports = function (RED) {
|
|
|
90
95
|
this.send({ payload: { type: 'snapshot', variables: filteredSnapshot } });
|
|
91
96
|
}
|
|
92
97
|
} catch (requestErr) {
|
|
93
|
-
//
|
|
94
|
-
|
|
98
|
+
// Log snapshot failures to help debugging
|
|
99
|
+
this.warn(`Snapshot failed: ${requestErr.message}`);
|
|
95
100
|
}
|
|
96
101
|
};
|
|
97
102
|
|
|
103
|
+
|
|
104
|
+
|
|
98
105
|
// Initial snapshot
|
|
99
106
|
await performSnapshot();
|
|
100
107
|
|