node-red-contrib-mobius-flow-base 3.1.0 → 3.1.2
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/dist/engine-api-calls.js +12 -5
- package/dist/engine-websocket.js +5 -3
- package/dist/node-red-ui-funcs.js +53 -25
- package/dist/nodes/mobius-change-admin-password.js +1 -1
- package/dist/nodes/mobius-clear-resource.js +29 -6
- package/dist/nodes/mobius-connection.js +167 -62
- package/dist/nodes/mobius-discover-object-list.html +24 -10
- package/dist/nodes/mobius-discover-object-list.js +46 -13
- package/dist/nodes/mobius-get-multi-object.js +14 -10
- package/dist/nodes/mobius-get-multi-resource.js +10 -2
- package/dist/nodes/mobius-get-object.js +19 -4
- package/dist/nodes/mobius-get-resource.js +24 -5
- package/dist/nodes/mobius-send-dcmd.js +43 -19
- package/dist/nodes/mobius-set-multi-resource.js +51 -26
- package/dist/nodes/mobius-set-resource.js +132 -58
- package/package.json +1 -1
package/dist/engine-api-calls.js
CHANGED
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EngineApiCalls = void 0;
|
|
4
4
|
class EngineApiCalls {
|
|
5
5
|
apiClient = null;
|
|
6
|
-
constructor() {
|
|
7
|
-
}
|
|
6
|
+
constructor() { }
|
|
8
7
|
setApiClient = (apiClient) => {
|
|
9
8
|
this.apiClient = apiClient;
|
|
10
9
|
};
|
|
@@ -111,7 +110,7 @@ class EngineApiCalls {
|
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
catch (err) {
|
|
114
|
-
throw `Failed to send broadcast command: ${
|
|
113
|
+
throw `Failed to send broadcast command: ${err.code}, ${err.message ? err.message : ''}`;
|
|
115
114
|
}
|
|
116
115
|
};
|
|
117
116
|
sendDirectCommand = async (uri, cid, commandData, timeout, callback) => {
|
|
@@ -194,10 +193,18 @@ class EngineApiCalls {
|
|
|
194
193
|
objects.push(object.data.data);
|
|
195
194
|
}
|
|
196
195
|
if (objects.length >= limit) {
|
|
197
|
-
return callback(null, {
|
|
196
|
+
return callback(null, {
|
|
197
|
+
uri,
|
|
198
|
+
ts: new Date().toISOString(),
|
|
199
|
+
value: objects,
|
|
200
|
+
});
|
|
198
201
|
}
|
|
199
202
|
}
|
|
200
|
-
return callback(null, {
|
|
203
|
+
return callback(null, {
|
|
204
|
+
uri,
|
|
205
|
+
ts: new Date().toISOString(),
|
|
206
|
+
value: objects,
|
|
207
|
+
});
|
|
201
208
|
}
|
|
202
209
|
catch (err) {
|
|
203
210
|
callback(err);
|
package/dist/engine-websocket.js
CHANGED
|
@@ -70,7 +70,7 @@ class EngineWebSocket extends stream_1.EventEmitter {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
|
-
console.log(`(${this.hostname}) -> Error parsing message
|
|
73
|
+
console.log(`(${this.hostname}) -> Error parsing message: ${e.code}, ${e.message ? e.message : ''}`);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
this.webSocket.on('error', (e) => {
|
|
@@ -78,7 +78,7 @@ class EngineWebSocket extends stream_1.EventEmitter {
|
|
|
78
78
|
this.emit('disconnected');
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
console.error(`(${this.hostname}) -> Engine API Subscription WebSocket Client Error:
|
|
81
|
+
console.error(`(${this.hostname}) -> Engine API Subscription WebSocket Client Error: ${e.code}, ${e.message ? e.message : ''}`);
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
};
|
|
@@ -114,7 +114,9 @@ class EngineWebSocket extends stream_1.EventEmitter {
|
|
|
114
114
|
.filter((cb) => cb.topic === message.topic)
|
|
115
115
|
.map((cb) => cb.callback);
|
|
116
116
|
if (!message.payload.timestamp) {
|
|
117
|
-
message.payload.timestamp = message.timestamp
|
|
117
|
+
message.payload.timestamp = message.timestamp
|
|
118
|
+
? message.timestamp
|
|
119
|
+
: new Date().toISOString();
|
|
118
120
|
}
|
|
119
121
|
callbacks.forEach((cb) => cb(message.payload));
|
|
120
122
|
};
|
|
@@ -30,9 +30,8 @@ const _ = require('lodash');
|
|
|
30
30
|
const excludedSpids = ['0004', '0012'];
|
|
31
31
|
|
|
32
32
|
module.exports = {
|
|
33
|
-
|
|
34
33
|
// Promisified version of discover
|
|
35
|
-
discover
|
|
34
|
+
discover(connection, uri) {
|
|
36
35
|
return new Promise((resolve, reject) => {
|
|
37
36
|
connection.discover(uri, (err, response) => {
|
|
38
37
|
if (err) {
|
|
@@ -45,7 +44,7 @@ module.exports = {
|
|
|
45
44
|
},
|
|
46
45
|
|
|
47
46
|
// Promisified version of getServiceConfig
|
|
48
|
-
getNodeConfig
|
|
47
|
+
getNodeConfig(connection, hid) {
|
|
49
48
|
return new Promise((resolve, reject) => {
|
|
50
49
|
connection.getNodeConfig(hid, (err, response) => {
|
|
51
50
|
if (!err) {
|
|
@@ -58,7 +57,7 @@ module.exports = {
|
|
|
58
57
|
},
|
|
59
58
|
|
|
60
59
|
// Promisified version of getServiceConfig
|
|
61
|
-
getServiceConfig
|
|
60
|
+
getServiceConfig(connection, hid, sid) {
|
|
62
61
|
return new Promise((resolve, reject) => {
|
|
63
62
|
connection.getServiceConfig(hid, sid, (err, response) => {
|
|
64
63
|
if (!err) {
|
|
@@ -71,7 +70,7 @@ module.exports = {
|
|
|
71
70
|
},
|
|
72
71
|
|
|
73
72
|
// Promisified version of getNodeConfigTree
|
|
74
|
-
getNodeConfigTree
|
|
73
|
+
getNodeConfigTree(connection, hid) {
|
|
75
74
|
return new Promise((resolve, reject) => {
|
|
76
75
|
connection.getNodeConfigTree(hid, (err, response) => {
|
|
77
76
|
if (!err) {
|
|
@@ -84,7 +83,7 @@ module.exports = {
|
|
|
84
83
|
},
|
|
85
84
|
|
|
86
85
|
// Promisified version of getProfileByPid
|
|
87
|
-
getProfileByPid
|
|
86
|
+
getProfileByPid(connection, hid, pid) {
|
|
88
87
|
return new Promise((resolve, reject) => {
|
|
89
88
|
connection.getProfileByPid(hid, pid, (err, response) => {
|
|
90
89
|
if (!err) {
|
|
@@ -97,7 +96,7 @@ module.exports = {
|
|
|
97
96
|
},
|
|
98
97
|
|
|
99
98
|
// Promisified version of getAllObjectProfiles
|
|
100
|
-
getAllObjectProfiles
|
|
99
|
+
getAllObjectProfiles(connection, hid) {
|
|
101
100
|
return new Promise((resolve, reject) => {
|
|
102
101
|
connection.getAllObjectProfiles(hid, (err, response) => {
|
|
103
102
|
if (!err) {
|
|
@@ -110,7 +109,7 @@ module.exports = {
|
|
|
110
109
|
},
|
|
111
110
|
|
|
112
111
|
// Discover object by By PID
|
|
113
|
-
async discoverDevicesByPID
|
|
112
|
+
async discoverDevicesByPID(RED, connection, hid, spids, pid) {
|
|
114
113
|
let devices = [];
|
|
115
114
|
if (!hid || hid === '') {
|
|
116
115
|
hid = connection.service.hubId;
|
|
@@ -123,12 +122,19 @@ module.exports = {
|
|
|
123
122
|
throw new Error(`Discover devices failed (${hid}) - ${err.message}`);
|
|
124
123
|
}
|
|
125
124
|
for (let srvcLoop = 0; srvcLoop < services.data.length; srvcLoop++) {
|
|
126
|
-
if (
|
|
127
|
-
|
|
125
|
+
if (
|
|
126
|
+
services.data[srvcLoop].status === 'online' &&
|
|
127
|
+
(spids.length === 0 || spids.includes(services.data[srvcLoop].spid))
|
|
128
|
+
) {
|
|
129
|
+
let insURI = `${hid}/${
|
|
130
|
+
services.data[srvcLoop].id.split('/')[1]
|
|
131
|
+
}/${pid}`;
|
|
128
132
|
try {
|
|
129
133
|
let instances = await this.discover(connection, insURI);
|
|
130
134
|
for (let insLoop = 0; insLoop < instances.data.length; insLoop++) {
|
|
131
|
-
let deviceURI = `${hid}/${
|
|
135
|
+
let deviceURI = `${hid}/${
|
|
136
|
+
services.data[srvcLoop].id.split('/')[1]
|
|
137
|
+
}/${pid}/${instances.data[insLoop]}`;
|
|
132
138
|
let device = await this.discover(connection, deviceURI);
|
|
133
139
|
let resourcesByName = _.keyBy(device.data[0].resources, 'name');
|
|
134
140
|
let deviceName = resourcesByName['name'].pv;
|
|
@@ -147,7 +153,7 @@ module.exports = {
|
|
|
147
153
|
},
|
|
148
154
|
|
|
149
155
|
// Discover services by SPID
|
|
150
|
-
async discoverServicesBySPID
|
|
156
|
+
async discoverServicesBySPID(RED, connection, hid, spid) {
|
|
151
157
|
if (!hid || hid === '') {
|
|
152
158
|
hid = connection.service.hubId;
|
|
153
159
|
}
|
|
@@ -160,7 +166,10 @@ module.exports = {
|
|
|
160
166
|
}
|
|
161
167
|
let srvcs = [];
|
|
162
168
|
for (let srvcLoop = 0; srvcLoop < services.data.length; srvcLoop++) {
|
|
163
|
-
if (
|
|
169
|
+
if (
|
|
170
|
+
services.data[srvcLoop].status === 'online' &&
|
|
171
|
+
services.data[srvcLoop].spid === spid
|
|
172
|
+
) {
|
|
164
173
|
srvcs.push(`${hid}/${services.data[srvcLoop].id.split('/')[1]}`);
|
|
165
174
|
}
|
|
166
175
|
}
|
|
@@ -190,7 +199,9 @@ module.exports = {
|
|
|
190
199
|
}
|
|
191
200
|
return services;
|
|
192
201
|
} catch (err) {
|
|
193
|
-
throw
|
|
202
|
+
throw `Error getting service list for Flows UI: ${err.code}, ${
|
|
203
|
+
err.message ? err.message : ''
|
|
204
|
+
}`;
|
|
194
205
|
}
|
|
195
206
|
},
|
|
196
207
|
|
|
@@ -201,7 +212,10 @@ module.exports = {
|
|
|
201
212
|
const serviceResponse = await this.discover(connection, `${hid}/${sid}`);
|
|
202
213
|
const pids = [...new Set(serviceResponse.data)];
|
|
203
214
|
for (let i = 0; i < pids.length; i++) {
|
|
204
|
-
const inssResponse = await this.discover(
|
|
215
|
+
const inssResponse = await this.discover(
|
|
216
|
+
connection,
|
|
217
|
+
`${hid}/${sid}/${pids[i]}`
|
|
218
|
+
);
|
|
205
219
|
const inss = inssResponse.data;
|
|
206
220
|
for (let j = 0; j < inss.length; j++) {
|
|
207
221
|
const objResponse = await this.discover(
|
|
@@ -213,7 +227,9 @@ module.exports = {
|
|
|
213
227
|
}
|
|
214
228
|
return objectList;
|
|
215
229
|
} catch (err) {
|
|
216
|
-
throw
|
|
230
|
+
throw `Error getting object list for Flows UI: ${err.code}, ${
|
|
231
|
+
err.message ? err.message : ''
|
|
232
|
+
}`;
|
|
217
233
|
}
|
|
218
234
|
},
|
|
219
235
|
|
|
@@ -221,15 +237,24 @@ module.exports = {
|
|
|
221
237
|
try {
|
|
222
238
|
let objectList = [];
|
|
223
239
|
const configTreeResponse = await this.getNodeConfigTree(connection, hid);
|
|
224
|
-
const service = configTreeResponse.data.find(
|
|
240
|
+
const service = configTreeResponse.data.find(
|
|
241
|
+
(service) => service.sid === sid
|
|
242
|
+
);
|
|
225
243
|
for (let i = 0; i < service.objects.length; i++) {
|
|
226
244
|
objectList = objectList.concat(service.objects[i].objects);
|
|
227
245
|
}
|
|
228
246
|
let formattedObjectList = [];
|
|
229
|
-
const getProfilesResponse = await this.getAllObjectProfiles(
|
|
247
|
+
const getProfilesResponse = await this.getAllObjectProfiles(
|
|
248
|
+
connection,
|
|
249
|
+
hid
|
|
250
|
+
);
|
|
230
251
|
const objectProfiles = getProfilesResponse.data;
|
|
231
252
|
for (let i = 0; i < objectList.length; i++) {
|
|
232
|
-
const profile = Object.values(objectProfiles).find(
|
|
253
|
+
const profile = Object.values(objectProfiles).find(
|
|
254
|
+
(profile) =>
|
|
255
|
+
profile.header.pid === parseInt(objectList[i].pid, 16) ||
|
|
256
|
+
profile.header.pid === `${parseInt(objectList[i].pid, 16)}`
|
|
257
|
+
);
|
|
233
258
|
const profileName = profile ? profile.header.uiname : '';
|
|
234
259
|
// const rids = objectList[i].rids;
|
|
235
260
|
// let resources = [];
|
|
@@ -248,8 +273,11 @@ module.exports = {
|
|
|
248
273
|
// pv: rids[j].pv,
|
|
249
274
|
// })
|
|
250
275
|
// }
|
|
251
|
-
const foundObjectName = objectList[i].rids.filter(
|
|
252
|
-
|
|
276
|
+
const foundObjectName = objectList[i].rids.filter(
|
|
277
|
+
(rid) => rid.rid === '01'
|
|
278
|
+
);
|
|
279
|
+
const objName =
|
|
280
|
+
foundObjectName.length > 0 ? foundObjectName[0].settings.pv : '';
|
|
253
281
|
formattedObjectList.push({
|
|
254
282
|
pid: objectList[i].pid,
|
|
255
283
|
ins: objectList[i].ins,
|
|
@@ -259,7 +287,9 @@ module.exports = {
|
|
|
259
287
|
}
|
|
260
288
|
return formattedObjectList;
|
|
261
289
|
} catch (err) {
|
|
262
|
-
throw
|
|
290
|
+
throw `Error getting config objects list for Flows UI: ${err.code}, ${
|
|
291
|
+
err.message ? err.message : ''
|
|
292
|
+
}`;
|
|
263
293
|
}
|
|
264
294
|
},
|
|
265
295
|
|
|
@@ -277,7 +307,5 @@ module.exports = {
|
|
|
277
307
|
});
|
|
278
308
|
}
|
|
279
309
|
return result;
|
|
280
|
-
}
|
|
281
|
-
|
|
310
|
+
},
|
|
282
311
|
};
|
|
283
|
-
|
|
@@ -63,7 +63,7 @@ module.exports = function (RED) {
|
|
|
63
63
|
shape: 'dot',
|
|
64
64
|
text: 'Error: ' + JSON.stringify(err.code),
|
|
65
65
|
});
|
|
66
|
-
node.error(
|
|
66
|
+
node.error(`Mobius error setting admin password: ${err.code}, ${err.message ? err.message : ''}`);
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
node.status({
|
|
@@ -45,7 +45,10 @@ module.exports = function (RED) {
|
|
|
45
45
|
node.on('input', function (msg) {
|
|
46
46
|
let uri = node.resource;
|
|
47
47
|
let pri = parseInt(node.priority);
|
|
48
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
msg.hasOwnProperty('topic') &&
|
|
50
|
+
require('./validateURI')(msg.topic, 5)
|
|
51
|
+
) {
|
|
49
52
|
uri = msg.topic;
|
|
50
53
|
}
|
|
51
54
|
if (msg.hasOwnProperty('priority')) {
|
|
@@ -66,13 +69,21 @@ module.exports = function (RED) {
|
|
|
66
69
|
shape: 'dot',
|
|
67
70
|
text: 'Error: ' + JSON.stringify(err.code),
|
|
68
71
|
});
|
|
69
|
-
node.error(
|
|
72
|
+
node.error(
|
|
73
|
+
`Mobius error clearing resource priority: ${err.code}, ${
|
|
74
|
+
err.message ? err.message : ''
|
|
75
|
+
}`
|
|
76
|
+
);
|
|
70
77
|
if (node.detailedOutput === true) {
|
|
71
78
|
node.send([
|
|
72
79
|
null,
|
|
73
80
|
null,
|
|
74
81
|
null,
|
|
75
|
-
{
|
|
82
|
+
{
|
|
83
|
+
...msg,
|
|
84
|
+
topic: uri,
|
|
85
|
+
payload: { error: true, response: err },
|
|
86
|
+
},
|
|
76
87
|
]);
|
|
77
88
|
}
|
|
78
89
|
} else {
|
|
@@ -84,14 +95,26 @@ module.exports = function (RED) {
|
|
|
84
95
|
if (node.detailedOutput === true) {
|
|
85
96
|
node.send([
|
|
86
97
|
{ ...msg, topic: uri, payload: response.data.pv },
|
|
87
|
-
{
|
|
98
|
+
{
|
|
99
|
+
...msg,
|
|
100
|
+
topic: uri,
|
|
101
|
+
payload: { pv: response.data.pv, name: response.data.name },
|
|
102
|
+
},
|
|
88
103
|
{ ...msg, topic: uri, payload: response.data },
|
|
89
|
-
{
|
|
104
|
+
{
|
|
105
|
+
...msg,
|
|
106
|
+
topic: uri,
|
|
107
|
+
payload: { error: false, response: response },
|
|
108
|
+
},
|
|
90
109
|
]);
|
|
91
110
|
} else {
|
|
92
111
|
node.send([
|
|
93
112
|
{ ...msg, topic: uri, payload: response.data.pv },
|
|
94
|
-
{
|
|
113
|
+
{
|
|
114
|
+
...msg,
|
|
115
|
+
topic: uri,
|
|
116
|
+
payload: { pv: response.data.pv, name: response.data.name },
|
|
117
|
+
},
|
|
95
118
|
]);
|
|
96
119
|
}
|
|
97
120
|
}
|