node-red-contrib-mobius-flow-base 2.5.91 → 3.0.0-beta.12
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/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +16 -0
- package/.github/ISSUE_TEMPLATE/general.md +7 -0
- package/.github/workflows/build_publish.yml +80 -0
- package/README.md +4 -10
- package/dist/engine-api-calls.d.ts +18 -0
- package/dist/engine-api-calls.js +214 -0
- package/dist/engine-api-client.d.ts +7 -0
- package/dist/engine-api-client.js +92 -0
- package/dist/engine-websocket.d.ts +58 -0
- package/dist/engine-websocket.js +226 -0
- package/dist/node-red-ui-funcs.js +180 -0
- package/dist/nodes/common/mobsearch.js +576 -0
- package/dist/nodes/mobius-clear-resource.html +22 -3
- package/dist/nodes/mobius-clear-resource.js +17 -12
- package/dist/nodes/mobius-connection.html +30 -8
- package/dist/nodes/mobius-connection.js +194 -85
- package/dist/nodes/mobius-discover-object-list.html +185 -126
- package/dist/nodes/mobius-discover-object-list.js +24 -5
- package/dist/nodes/mobius-discover.js +7 -7
- package/dist/nodes/mobius-filter-by-rid-value.html +57 -41
- package/dist/nodes/mobius-filter-by-rid-value.js +38 -31
- package/dist/nodes/mobius-flow-inject.html +32 -2
- package/dist/nodes/mobius-get-multi-object.html +39 -5
- package/dist/nodes/mobius-get-multi-resource.html +36 -4
- package/dist/nodes/mobius-get-multi-resource.js +13 -12
- package/dist/nodes/mobius-get-object.html +25 -3
- package/dist/nodes/mobius-get-object.js +12 -9
- package/dist/nodes/mobius-get-resource.html +26 -3
- package/dist/nodes/mobius-get-resource.js +17 -12
- package/dist/nodes/mobius-object-cov.html +27 -3
- package/dist/nodes/mobius-object-cov.js +9 -6
- package/dist/nodes/mobius-resource-cov.html +23 -3
- package/dist/nodes/mobius-resource-cov.js +5 -5
- package/dist/nodes/mobius-set-multi-resource.html +24 -3
- package/dist/nodes/mobius-set-multi-resource.js +9 -11
- package/dist/nodes/mobius-set-resource.html +24 -3
- package/package.json +13 -7
- package/dist/nodes/node-red-ui-discover-devices.js +0 -103
|
@@ -53,10 +53,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
53
53
|
<option value="array">Array of Items</option>
|
|
54
54
|
</select>
|
|
55
55
|
</div>
|
|
56
|
-
<div class="form-row node-input-subs-container-row">
|
|
56
|
+
<div id="node-input-subs-container-row" class="form-row node-input-subs-container-row">
|
|
57
57
|
<label for="node-input-subs-container" style="width:105px;float:left;"><i class="fa fa-bars"></i> Discover</label>
|
|
58
58
|
<ol id="node-input-subs-container"></ol>
|
|
59
59
|
</div>
|
|
60
|
+
|
|
61
|
+
<div id="mobsearch"></div>
|
|
62
|
+
|
|
60
63
|
<div class="form-row">
|
|
61
64
|
<label for="node-input-useRIDValueFiltering" style="width:178px;float:left;"><i class="fa fa-filter"></i> Filter by Resource Value</label>
|
|
62
65
|
<input type="checkbox" id="node-input-useRIDValueFiltering" style="display: inline-block; width: auto; vertical-align: top;">
|
|
@@ -77,196 +80,252 @@ POSSIBILITY OF SUCH DAMAGE.
|
|
|
77
80
|
</div>
|
|
78
81
|
</script>
|
|
79
82
|
|
|
83
|
+
<script src="common/mobsearch.js"></script>
|
|
84
|
+
|
|
80
85
|
<script type="text/javascript">
|
|
81
86
|
RED.nodes.registerType('mobius discover object list', {
|
|
82
87
|
category: 'mobius',
|
|
83
88
|
defaults: {
|
|
84
|
-
name: {value:
|
|
85
|
-
useRIDValueFiltering: {value: false},
|
|
86
|
-
func: {value:
|
|
87
|
-
limit: {value:100, validate:RED.validators.number()},
|
|
88
|
-
rid: {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
89
|
+
name: { value: '' },
|
|
90
|
+
useRIDValueFiltering: { value: false },
|
|
91
|
+
func: { value: '' },
|
|
92
|
+
limit: { value: 100, validate: RED.validators.number() },
|
|
93
|
+
rid: {
|
|
94
|
+
value: '',
|
|
95
|
+
validate: function (v) {
|
|
96
|
+
if (v === '') {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (v.length === 2) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
output: { value: 'objects', required: true },
|
|
106
|
+
send: { value: 'individual', required: true },
|
|
107
|
+
subscriptions: { value: [{ uri: '', type: 'include' }] },
|
|
108
|
+
hid: {
|
|
109
|
+
value: '',
|
|
110
|
+
validate: function (v) {
|
|
111
|
+
if (v === '') {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (v.length === 6) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
connection: { type: 'mobius connection', required: true },
|
|
102
121
|
},
|
|
103
|
-
color:
|
|
104
|
-
inputs:1,
|
|
105
|
-
outputs:1,
|
|
106
|
-
outputLabels: [
|
|
107
|
-
icon:
|
|
108
|
-
align:
|
|
122
|
+
color: '#9ee3fa',
|
|
123
|
+
inputs: 1,
|
|
124
|
+
outputs: 1,
|
|
125
|
+
outputLabels: ['MOBiUS objects or URIs'],
|
|
126
|
+
icon: 'mobius.png',
|
|
127
|
+
align: 'left',
|
|
109
128
|
paletteLabel: 'discover object list',
|
|
110
|
-
label: function() {
|
|
111
|
-
if(this.name) {
|
|
129
|
+
label: function () {
|
|
130
|
+
if (this.name) {
|
|
112
131
|
return this.name;
|
|
113
132
|
} else {
|
|
114
|
-
return
|
|
133
|
+
return 'discover object list';
|
|
115
134
|
}
|
|
116
135
|
},
|
|
117
|
-
labelStyle: function() {
|
|
118
|
-
return this.name ?
|
|
136
|
+
labelStyle: function () {
|
|
137
|
+
return this.name ? 'node_label_italic' : '';
|
|
119
138
|
},
|
|
120
139
|
oneditprepare: function () {
|
|
121
140
|
var node = this;
|
|
141
|
+
let mobiusSrvc = $("#node-input-connection").val();
|
|
122
142
|
|
|
123
143
|
/** Create the subs container and populate it */
|
|
124
|
-
$('#node-input-subs-container')
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
$('#node-input-subs-container')
|
|
145
|
+
.css('min-height', '200px')
|
|
146
|
+
.css('min-width', '345px')
|
|
147
|
+
.editableList({
|
|
148
|
+
addButton: 'add uri',
|
|
149
|
+
removable: true,
|
|
150
|
+
sortable: true,
|
|
151
|
+
addItem: function (container, i, subscription) {
|
|
152
|
+
container.css({
|
|
153
|
+
overflow: 'hidden',
|
|
154
|
+
whiteSpace: 'nowrap',
|
|
155
|
+
});
|
|
133
156
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
157
|
+
// Add a default subscription if it does not exist
|
|
158
|
+
if (!subscription.hasOwnProperty('uri')) {
|
|
159
|
+
subscription = { uri: '', type: 'include' };
|
|
160
|
+
}
|
|
138
161
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
162
|
+
var row = $('<div>URI</div>').appendTo(container);
|
|
163
|
+
var uriField = $('<input/>', {
|
|
164
|
+
class: 'node-input-sub-uri',
|
|
165
|
+
type: 'text',
|
|
166
|
+
style: 'width: 150px; margin-left: 5px; text-align: left;',
|
|
167
|
+
}).appendTo(row);
|
|
144
168
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
});
|
|
169
|
+
// *** MOBSEARCH *** //
|
|
170
|
+
var searchField = $('<a class="searchbutton" style="margin-left: 5px; vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
|
|
171
|
+
// *** END MOBSEARCH *** //
|
|
150
172
|
|
|
151
|
-
|
|
173
|
+
var typeField = $('<select/>', {
|
|
174
|
+
class: 'node-input-sub-type',
|
|
175
|
+
style: 'width:auto; margin-left: 5px; text-align: center;',
|
|
176
|
+
}).appendTo(row);
|
|
177
|
+
typeField.append($('<option></option>').val('include').text('Include'));
|
|
178
|
+
typeField.append($('<option></option>').val('exclude').text('Exclude'));
|
|
179
|
+
|
|
180
|
+
// Populate the new stat
|
|
181
|
+
uriField.val(subscription.uri);
|
|
182
|
+
typeField.val(subscription.type);
|
|
183
|
+
|
|
184
|
+
// *** MOBSEARCH *** //
|
|
185
|
+
|
|
186
|
+
if (!node.subscriptions[i]) {
|
|
187
|
+
node.subscriptions[i] = {uri: '', type: 'include'}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
addMobsearchListButton(searchField, i, mobsearchOpts)
|
|
191
|
+
// *** END MOBSEARCH *** //
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
$('.red-ui-editableList-addButton').css('margin-left', '105px');
|
|
152
196
|
|
|
153
197
|
// If no stat exists, create a default one
|
|
154
198
|
if (!node.subscriptions) {
|
|
155
|
-
node.subscriptions = [subscription = {uri: '', type: 'include'}];
|
|
199
|
+
node.subscriptions = [(subscription = { uri: '', type: 'include' })];
|
|
156
200
|
}
|
|
201
|
+
|
|
202
|
+
// *** MOBSEARCH *** //
|
|
203
|
+
|
|
204
|
+
mobsearchOpts = {
|
|
205
|
+
htmlElementId: 'mobsearch',
|
|
206
|
+
list: node.subscriptions,
|
|
207
|
+
containerRowName: 'node-input-subs-container-row',
|
|
208
|
+
containerName: 'node-input-subs-container',
|
|
209
|
+
containerSecondFieldName: 'node-input-sub-type',
|
|
210
|
+
};
|
|
211
|
+
initMobsearch.toIns_listed(mobiusSrvc, mobsearchOpts);
|
|
212
|
+
|
|
213
|
+
// *** END MOBSEARCH *** //
|
|
214
|
+
|
|
157
215
|
// Populate list with all saved filters
|
|
158
216
|
for (let i = 0; i < node.subscriptions.length; i++) {
|
|
159
217
|
let subscription = node.subscriptions[i];
|
|
160
|
-
$(
|
|
218
|
+
$('#node-input-subs-container').editableList('addItem', subscription);
|
|
161
219
|
}
|
|
162
220
|
|
|
163
221
|
function showRIDFilterInputs() {
|
|
164
|
-
if($(
|
|
165
|
-
$(
|
|
222
|
+
if ($('#node-input-useRIDValueFiltering').is(':checked')) {
|
|
223
|
+
$('#use-rid-filter-row').show();
|
|
166
224
|
} else {
|
|
167
|
-
$(
|
|
225
|
+
$('#use-rid-filter-row').hide();
|
|
168
226
|
}
|
|
169
227
|
}
|
|
170
228
|
showRIDFilterInputs();
|
|
171
|
-
$(
|
|
229
|
+
$('#node-input-useRIDValueFiltering').change(function () {
|
|
172
230
|
showRIDFilterInputs();
|
|
173
231
|
});
|
|
174
232
|
|
|
175
233
|
this.editor = RED.editor.createEditor({
|
|
176
234
|
id: 'node-input-func-editor',
|
|
177
235
|
mode: 'ace/mode/javascript',
|
|
178
|
-
value: this.func
|
|
236
|
+
value: this.func,
|
|
179
237
|
});
|
|
180
238
|
},
|
|
181
239
|
oneditresize(size) {
|
|
182
|
-
var rows = $(
|
|
240
|
+
var rows = $('#dialog-form>div:not(.node-input-subs-container-row)');
|
|
183
241
|
var height = size.height;
|
|
184
|
-
for (var i=0; i<rows.size(); i++) {
|
|
242
|
+
for (var i = 0; i < rows.size(); i++) {
|
|
185
243
|
height -= $(rows[i]).outerHeight(true);
|
|
186
244
|
}
|
|
187
|
-
var editorRow = $(
|
|
188
|
-
height -=
|
|
245
|
+
var editorRow = $('#dialog-form>div.node-input-subs-container-row');
|
|
246
|
+
height -=
|
|
247
|
+
4 * (parseInt(editorRow.css('marginTop')) + parseInt(editorRow.css('marginBottom')));
|
|
189
248
|
|
|
190
|
-
$(
|
|
249
|
+
$('#node-input-subs-container').editableList('height', height);
|
|
191
250
|
},
|
|
192
|
-
oneditsave: function() {
|
|
193
|
-
let subscriptions = $(
|
|
251
|
+
oneditsave: function () {
|
|
252
|
+
let subscriptions = $('#node-input-subs-container').editableList('items');
|
|
194
253
|
let node = this;
|
|
195
|
-
node.subscriptions= [];
|
|
254
|
+
node.subscriptions = [];
|
|
196
255
|
subscriptions.each(function (i) {
|
|
197
256
|
var subscription = $(this);
|
|
198
|
-
let uri = subscription.find(
|
|
199
|
-
let type = subscription.find(
|
|
200
|
-
node.subscriptions.push({uri: uri, type: type});
|
|
257
|
+
let uri = subscription.find('.node-input-sub-uri').val();
|
|
258
|
+
let type = subscription.find('.node-input-sub-type').val();
|
|
259
|
+
node.subscriptions.push({ uri: uri, type: type });
|
|
201
260
|
});
|
|
202
261
|
|
|
203
262
|
this.func = this.editor.getValue();
|
|
204
263
|
this.editor.destroy();
|
|
205
264
|
delete this.editor;
|
|
206
265
|
},
|
|
207
|
-
oneditcancel: function() {
|
|
266
|
+
oneditcancel: function () {
|
|
208
267
|
this.editor.destroy();
|
|
209
268
|
delete this.editor;
|
|
210
|
-
}
|
|
269
|
+
},
|
|
211
270
|
});
|
|
212
271
|
</script>
|
|
213
272
|
|
|
214
273
|
<script type="text/x-red" data-help-name="mobius discover object list">
|
|
215
|
-
|
|
274
|
+
<p>Discover MOBiUS objects and return a filtered list of objects or URIs.</p>
|
|
216
275
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
</dl>
|
|
276
|
+
<h3>Configuration Page</h3>
|
|
277
|
+
<dl class="message-properties">
|
|
278
|
+
<dt>MOBiUS <span class="property-type">node</span></dt>
|
|
279
|
+
<dd>Shared MOBiUS connection for communication with the MOBiUS Hub.</dd>
|
|
280
|
+
<dt>HID <span class="property-type">string</span></dt>
|
|
281
|
+
<dd>Optional Mobius hub ID to use for discovery. Leave empty to use the local HID.</dd>
|
|
282
|
+
<dt>Output <span class="property-type">option</span></dt>
|
|
283
|
+
<dd>Output full MOBiUS objects or MOBiUS object URIs.</dd>
|
|
284
|
+
<dt>Send <span class="property-type">option</span></dt>
|
|
285
|
+
<dd>Send the outputs individually or as a single array.</dd>
|
|
286
|
+
<dt>Discover <span class="property-type">string</span></dt>
|
|
287
|
+
<dd>The MOBiUS URI of the objects to discover. This may contain MQTT type wildcards.</dd>
|
|
288
|
+
<dt>Filter by Resource Value <span class="property-type">checkbox</span></dt>
|
|
289
|
+
<dd>If checked the returned objects are also filtered by the value of a single resource.</dd>
|
|
290
|
+
<dt>RID <span class="property-type">string</span></dt>
|
|
291
|
+
<dd>The MOBiUS Object Resource ID of the resource to test.</dd>
|
|
292
|
+
<dt class="optional">Limit <span class="property-type">number</span></dt>
|
|
293
|
+
<dd>The maximum number of objects to return. Defaults to 100.</dd>
|
|
294
|
+
<dt>Function <span class="property-type">string</span></dt>
|
|
295
|
+
<dd>JavaScript used to test the resource value.</dd>
|
|
296
|
+
</dl>
|
|
238
297
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
298
|
+
<h3>Inputs</h3>
|
|
299
|
+
<ol class="node-ports">
|
|
300
|
+
<li>Input message to trigger discovery
|
|
301
|
+
<dl class="message-properties">
|
|
302
|
+
<dt class="optional">topic <span class="property-type">string</span></dt>
|
|
303
|
+
<dd>Topic is passed through to output.</dd>
|
|
304
|
+
</dl>
|
|
305
|
+
</li>
|
|
306
|
+
</ol>
|
|
248
307
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
308
|
+
<h3>Outputs</h3>
|
|
309
|
+
<ol class="node-ports">
|
|
310
|
+
<li>Array of URIs discovered.
|
|
311
|
+
<dl class="message-properties">
|
|
312
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
313
|
+
<dd>When outputting individual items the topic will be the object URI and when outputting arrays the topic is passed through from input.</dd>
|
|
314
|
+
<dt>payload <span class="property-type">array</span></dt>
|
|
315
|
+
<dd>Array or individual list of discovered objects or URIs.</dd>
|
|
316
|
+
</dl>
|
|
317
|
+
</li>
|
|
318
|
+
</ol>
|
|
260
319
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
320
|
+
<h3>Details</h3>
|
|
321
|
+
<p>
|
|
322
|
+
The <code>Function</code> configuration property is string containing the JavaScript function used to test the resource value. The function must return <b>true</b> or <b>false</b>.
|
|
323
|
+
A few examples are shown below (The name v is used to represent the resource values in the following example. You can use any identifier of your choice):</br>
|
|
324
|
+
<code>(v) => { return v === 5; }</code><br>
|
|
325
|
+
<code>function test (v) { return v > 10 && v < 100; }</code><br>
|
|
326
|
+
<code>(v) => { return v.includes('test-string'); }</code>
|
|
327
|
+
</p>
|
|
269
328
|
|
|
270
|
-
|
|
271
|
-
|
|
329
|
+
<br>
|
|
330
|
+
<p align="center" style="color:#000080">iaconnects © 2019</p>
|
|
272
331
|
</script>
|
|
@@ -121,7 +121,7 @@ module.exports = function (RED) {
|
|
|
121
121
|
return new Promise(async (resolve, reject) => {
|
|
122
122
|
let objectList = [];
|
|
123
123
|
try {
|
|
124
|
-
const hid = node.hid === '' ? node.serviceConn.
|
|
124
|
+
const hid = node.hid === '' ? node.serviceConn.hubId : node.hid;
|
|
125
125
|
const profiles = await discoverProfiles(node.serviceConn, hid, node.subscriptions);
|
|
126
126
|
|
|
127
127
|
for await (let entry of profiles.entries()) {
|
|
@@ -141,12 +141,12 @@ module.exports = function (RED) {
|
|
|
141
141
|
uri: serviceURI,
|
|
142
142
|
pids: pids,
|
|
143
143
|
rid: '00',
|
|
144
|
-
func: 'return true;',
|
|
144
|
+
func: '(v) => { return true; }',
|
|
145
145
|
limit: 512,
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
try {
|
|
149
|
-
let objects = await
|
|
149
|
+
let objects = await filterObjectsByRIDValue(node.serviceConn, discoverParams);
|
|
150
150
|
for (let lp = 0; lp < objects.value.length; lp++) {
|
|
151
151
|
objects.value[lp][
|
|
152
152
|
'uri'
|
|
@@ -174,13 +174,13 @@ module.exports = function (RED) {
|
|
|
174
174
|
return new Promise(async (resolve) => {
|
|
175
175
|
let discoveredProfiles = new Map();
|
|
176
176
|
let services = await discover(serviceConn, hid);
|
|
177
|
-
for (const service of services.
|
|
177
|
+
for (const service of services.data) {
|
|
178
178
|
if (service.status === 'online') {
|
|
179
179
|
let sid = service.id.split('/')[1];
|
|
180
180
|
if (isIncluded(`${hid}/${sid}/#`, subscriptions)) {
|
|
181
181
|
let profiles = await discover(serviceConn, `${hid}/${sid}`);
|
|
182
182
|
let pids = [];
|
|
183
|
-
for (const pid of profiles.
|
|
183
|
+
for (const pid of profiles.data) {
|
|
184
184
|
if (
|
|
185
185
|
isIncluded(`${hid}/${sid}/${pid}/#`, subscriptions) &&
|
|
186
186
|
!isExcluded(`${hid}/${sid}/${pid}/#`, subscriptions)
|
|
@@ -214,6 +214,25 @@ module.exports = function (RED) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
+
async function filterObjectsByRIDValue(serviceConn, params) {
|
|
218
|
+
return new Promise((resolve, reject) => {
|
|
219
|
+
serviceConn.filterObjectsByRIDValue(
|
|
220
|
+
params.uri,
|
|
221
|
+
params.pids,
|
|
222
|
+
params.rid,
|
|
223
|
+
params.limit,
|
|
224
|
+
eval('(' + params.func + ')'),
|
|
225
|
+
(err, response) => {
|
|
226
|
+
if (err) {
|
|
227
|
+
reject(err);
|
|
228
|
+
} else {
|
|
229
|
+
resolve(response);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
217
236
|
function isIncluded(uri, subscriptions) {
|
|
218
237
|
let include = false;
|
|
219
238
|
for (const subscription of subscriptions) {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
module.exports = function (RED) {
|
|
31
|
-
function MobiusDiscoverNode
|
|
31
|
+
function MobiusDiscoverNode(n) {
|
|
32
32
|
RED.nodes.createNode(this, n);
|
|
33
33
|
this.serviceConn = RED.nodes.getNode(n.connection);
|
|
34
34
|
var node = this;
|
|
@@ -37,7 +37,7 @@ module.exports = function (RED) {
|
|
|
37
37
|
node.status({
|
|
38
38
|
fill: 'red',
|
|
39
39
|
shape: 'ring',
|
|
40
|
-
text: 'Disconnected'
|
|
40
|
+
text: 'Disconnected',
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
node.on('input', function (msg) {
|
|
@@ -50,13 +50,13 @@ module.exports = function (RED) {
|
|
|
50
50
|
node.status({
|
|
51
51
|
fill: 'yellow',
|
|
52
52
|
shape: 'dot',
|
|
53
|
-
text: 'Error: Input message topic must contain a valid discovery URI'
|
|
53
|
+
text: 'Error: Input message topic must contain a valid discovery URI',
|
|
54
54
|
});
|
|
55
55
|
} else {
|
|
56
56
|
node.status({
|
|
57
57
|
fill: 'green',
|
|
58
58
|
shape: 'ring',
|
|
59
|
-
text: 'Busy'
|
|
59
|
+
text: 'Busy',
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
let parameters = {};
|
|
@@ -66,19 +66,19 @@ module.exports = function (RED) {
|
|
|
66
66
|
} else {
|
|
67
67
|
parameters['uri'] = path;
|
|
68
68
|
}
|
|
69
|
-
node.serviceConn.discover(parameters, (err, response) => {
|
|
69
|
+
node.serviceConn.discover(parameters.uri, (err, response) => {
|
|
70
70
|
if (err) {
|
|
71
71
|
node.status({
|
|
72
72
|
fill: 'yellow',
|
|
73
73
|
shape: 'dot',
|
|
74
|
-
text: 'Error: ' + JSON.stringify(err.code)
|
|
74
|
+
text: 'Error: ' + JSON.stringify(err.code),
|
|
75
75
|
});
|
|
76
76
|
node.send({ topic: path, payload: { error: true, response: err } });
|
|
77
77
|
} else {
|
|
78
78
|
node.status({
|
|
79
79
|
fill: 'green',
|
|
80
80
|
shape: 'dot',
|
|
81
|
-
text: JSON.stringify(response.uri)
|
|
81
|
+
text: JSON.stringify(response.uri),
|
|
82
82
|
});
|
|
83
83
|
node.send({ topic: path, payload: { error: false, response: response } });
|
|
84
84
|
}
|