UNPKG

22.8 kBHTMLView Raw
1<!--
2 Copyright 2013-2020 bluefox <dogafox@gmail.com>.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16
17<link rel="stylesheet" type="text/css" href="vendor/ui.fancytree.min.css"/>
18<style type="text/css">
19 #dialog-select-member select{
20 height: 24px !important;
21 line-height: 24px !important;
22 }
23</style>
24<script type="text/javascript" src="vendor/jquery.fancytree-all.min.js"></script>
25
26<script type="text/javascript" src="selectID.js"></script>
27
28<script type="text/javascript">
29 function initSelectId(allowAll, onChange) {
30 if (!window.__iobroker) {
31 $.getJSON('iobroker.json', function (data) {
32 window.__iobroker = data;
33 $('#dialog-select-member').selectId('init', {
34 objects: window.__iobroker,
35 noMultiselect: true,
36 allowSelectionOfNonExistingObjects: !!allowAll,
37 columns: ['name', 'role', 'enum', 'room'],
38 states: null,
39 noImg: true
40 });
41 });
42 } else {
43 $('#dialog-select-member').selectId('init', {
44 objects: window.__iobroker,
45 noMultiselect: true,
46 allowSelectionOfNonExistingObjects: !!allowAll,
47 columns: ['name', 'role', 'enum', 'room'],
48 states: null,
49 noImg: true
50 });
51 }
52
53 $('#node-input-topic-button').button({
54 icons: {primary: 'ui-icon-folder-open'},
55 text: false
56 }).click(function () {
57 $('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
58 var oldObj = $('#dialog-select-member').selectId('getInfo', oldId);
59 var newObj = $('#dialog-select-member').selectId('getInfo', newId);
60 $('#node-input-topic').val(newId);
61
62 if (newObj) {
63 var oldName = $('#node-input-name').val();
64 if (!oldName || !oldObj || (oldObj.common && oldName === oldObj.common.name && newObj.common)) {
65 $('#node-input-name').val(newObj.common.name);
66 }
67 }
68 if (typeof onChange === 'function') {
69 onChange(newId, oldId, newObj, oldObj);
70 }
71 });
72 });
73 }
74</script>
75
76<script type="text/x-red" data-template-name="ioBroker in">
77 <div class="form-row">
78 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
79 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="..."/>
80 </div>
81 <div id="dialog-select-member" style="display:none"></div>
82 <div class="form-row">
83 <label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
84 <select id="node-input-payloadType" style="width:125px !important">
85 <option value="value">value</option>
86 <option value="object">object</option>
87 </select>
88 </div>
89 <div class="form-row">
90 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
91 <input type="text" id="node-input-name" placeholder="Name">
92 </div>
93 <div class="form-row">
94 <label>&nbsp;</label>
95 <input type="checkbox" id="node-input-onlyack" style="display: inline-block; width: auto; vertical-align: top;">
96 <label for="node-input-onlyack" style="width: 70%;">Send only on then ack==true</label>
97 </div>
98 <div class="form-row">
99 <label for="node-input-func"><i class="fa fa-wrench"></i> Mode</label>
100 <select type="text" id="node-input-func" style="width:74%;">
101 <option value="all">Send all events</option>
102 <option value="rbe">block unless value changes</option>
103 <option value="deadband">block unless changes by more than</option>
104 </select>
105 </div>
106 <div class="form-row" id="node-bandgap">
107 <label for="node-input-gap">&nbsp;</label>
108 <input type="text" id="node-input-gap" placeholder="e.g. 10 or 5%" style="width:71%;">
109 </div>
110 <div class="form-row">
111 <label for="node-input-fireOnStart"><i class="fa fa-arrow-up"></i> Fire by start</label>
112 <select id="node-input-fireOnStart" style="width:73% !important">
113 <option value="true">send message at start</option>
114 <option value="false">send no message at start</option>
115 </select>
116 </div>
117</script>
118
119<script type="text/x-red" data-help-name="ioBroker in">
120 <p>ioBroker input node. Connects to a ioBroker and subscribes to the specified topic. The topic may contain redis wildcards (*).</p>
121 <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.timestamp, msg.lastchange and msg.acknowledged.</p>
122 <p>The checkbox determines whether only States with ack == true or all events are forwarded.</p>
123 <p>The select box Mode offers further filtering options. The options are the same as for the RBE node.</p>
124</script>
125
126<script type="text/javascript">
127 RED.nodes.registerType('ioBroker in', {
128 category: 'ioBroker',
129 defaults: {
130 name: {value: ''},
131 topic: {value: '*', required: true},
132 payloadType: {value: 'value'},
133 onlyack: {value: ''},
134 func: {value: 'all'},
135 gap: {value: '', validate: RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)},
136 fireOnStart: {value: 'false'}
137 },
138 color: '#a8bfd8',
139 inputs: 0,
140 outputs: 1,
141 icon: 'ioBroker.png',
142 label: function () {
143 return this.name || this.topic || 'IoB subscribe';
144 },
145 labelStyle: function () {
146 return this.name ? 'node_label_italic' : '';
147 },
148 oneditprepare: function () {
149 initSelectId();
150
151 $('#node-input-func').on('change', function () {
152 var val = $('#node-input-func').val();
153 if (val === null || val === 'null') {
154 $('#node-input-func').val ('all');
155 }
156 if (val === 'deadband') {
157 $('#node-bandgap').show();
158 } else {
159 $('#node-bandgap').hide();
160 }
161 });
162 }
163 });
164</script>
165
166<script type="text/x-red" data-template-name="ioBroker out">
167 <div class="form-row">
168 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
169 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="..."/>
170 </div>
171 <div id="dialog-select-member" style="display: none"></div>
172 <div class="form-row">
173 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
174 </div>
175 <div class="form-row">
176 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
177 <input type="text" id="node-input-name" placeholder="Name">
178 </div>
179 <div class="form-row">
180 <label for="node-input-ack"><i class="fa fa-arrow-up"></i> Type</label>
181 <select id="node-input-ack" style="width:73% !important">
182 <option value="true">value</option>
183 <option value="false">command</option>
184 </select>
185 </div>
186 <div class="form-row">
187 <label for="node-input-autoCreate"><i class="fa fa-arrow-up"></i> Auto create</label>
188 <select id="node-input-autoCreate" style="width:73% !important">
189 <option value="true">Create states if not exist</option>
190 <option value="false">Ignore messages for non existing states</option>
191 </select>
192 </div>
193 <div class="form-row input-autoCreate">
194 <div class="form-tips">Tip: Leave below options blank if you want to set them via msg properties.</div>
195 </div>
196 <div class="form-row input-autoCreate">
197 <label for="node-input-stateName"><i class="fa fa-tag"></i> State Name</label>
198 <input type="text" id="node-input-stateName" placeholder="">
199 </div>
200 <div class="form-row input-autoCreate">
201 <label for="node-input-role"><i class="fa fa-tag"></i> Role</label>
202 <input type="text" id="node-input-role" placeholder="">
203 </div>
204 <div class="form-row input-autoCreate">
205 <label for="node-input-payloadType"><i class="fa fa-arrow-up"></i> Payload type</label>
206 <select id="node-input-payloadType" style="width:73% !important">
207 <option value="string">String</option>
208 <option value="number">Number</option>
209 <option value="boolean">Boolean</option>
210 <option value="array">Array</option>
211 <option value="object">Object</option>
212 <option value="mixed">Mixed</option>
213 <option value="file">File</option>
214 </select>
215 </div>
216 <div class="form-row input-autoCreate">
217 <label for="node-input-readonly"><i class="fa fa-arrow-up"></i> Readonly</label>
218 <select id="node-input-readonly" style="width:73% !important">
219 <option value="true">Object is readonly</option>
220 <option value="false">Object is writeable</option>
221 </select>
222 </div>
223 <div class="form-row input-autoCreate">
224 <label for="node-input-stateUnit"><i class="fa fa-tag"></i> Unit</label>
225 <input type="text" id="node-input-stateUnit" placeholder="">
226 </div>
227 <div class="form-row input-autoCreate">
228 <label for="node-input-stateMin"><i class="fa fa-tag"></i> Min</label>
229 <input type="text" id="node-input-stateMin" placeholder="">
230 </div>
231 <div class="form-row input-autoCreate">
232 <label for="node-input-stateMax"><i class="fa fa-tag"></i> Max</label>
233 <input type="text" id="node-input-stateMax" placeholder="">
234 </div>
235 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
236</script>
237
238<script type="text/x-red" data-help-name="ioBroker out">
239 <p>Connects to a ioBroker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
240 <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
241 <p>If <b>msg.payload</b> contains "__create__", the object will be only created, but no value will be written.</p>
242 <p>If <b>msg.stateName</b> is defined, the created object name will be set as this value. If <b>msg.stateName</b> is not defined, but <b>Name</b> is set, use this instead. If both node and msg do not set state name, the name will same as topic</p>
243 <p>If <b>msg.stateRole</b> is defined, the created object role will be set as this value. If <b>msg.stateRole</b> is not defined, but <b>Role</b> is set, use this instead.</p>
244 <p>If <b>msg.stateType</b> is defined, the created object common type will be set as this value. If <b>msg.stateType</b> is not defined, but <b>Type</b> is set, use this instead. If both node and msg do not set type, the type will be type of payload</p>
245 <p>If <b>msg.stateReadonly</b> is defined, the created object writeable will be set as this value. If <b>msg.stateReadonly</b> is not defined, but <b>Readonly</b> is set, use this instead.If both node and msg do not set readonly, it will be readonly</p>
246 <p>If <b>msg.stateUnit</b> is defined, the created object role will be set as this value. If <b>msg.stateUint</b> is not defined, but <b>Uint</b> is set, use this instead.</p>
247 <p>If <b>msg.stateMin</b> is defined, the created object role will be set as this value. If <b>msg.stateMin</b> is not defined, but <b>Min</b> is set, use this instead.</p>
248 <p>If <b>msg.stateMax</b> is defined, the created object role will be set as this value. If <b>msg.stateMax</b> is not defined, but <b>Max</b> is set, use this instead.</p>
249</script>
250
251<script type="text/javascript">
252RED.nodes.registerType('ioBroker out', {
253 category: 'ioBroker',
254 defaults: {
255 name: {value: ''},
256 topic: {value: ''},
257 ack: {value: 'false'},
258 autoCreate: {value: 'false'},
259
260 stateName: {value: ''},
261 role: {value: ''},
262 payloadType: {value: ''},
263 readonly: {value: ''},
264 stateUnit: {value: ''},
265 stateMin: {value: ''},
266 stateMax: {value: ''}
267 },
268 color: '#a8bfd8',
269 inputs: 1,
270 outputs: 0,
271 icon: 'ioBroker.png',
272 align: 'right',
273 label: function () {
274 return this.name || this.topic || 'IoB write value';
275 },
276 labelStyle: function () {
277 return this.name ? 'node_label_italic' : '';
278 },
279 oneditprepare: function () {
280 initSelectId();
281
282 $('#node-input-autoCreate').on('change', function () {
283 var val = $('#node-input-autoCreate').val();
284 if (val === null || val === 'null') {
285 $('#node-input-autoCreate').val ('false');
286 }
287 if (val === 'true') {
288 $('.input-autoCreate').show();
289 } else {
290 $('.input-autoCreate').hide();
291 }
292 });
293 }
294 });
295</script>
296
297<script type="text/x-red" data-template-name="ioBroker get">
298 <div class="form-row">
299 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
300 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="..."/>
301 </div>
302 <div id="dialog-select-member" style="display:none"></div>
303 <div class="form-row">
304 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
305 <input type="text" id="node-input-name" placeholder="Name">
306 </div>
307 <div class="form-row">
308 <label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
309 <select id="node-input-payloadType" style="width:125px !important">
310 <option value="value">value</option>
311 <option value="object">object</option>
312 </select>
313 </div>
314 <div class="form-row">
315 <label for="node-input-attrname"><i class="fa fa-tag"></i> Attribute</label>
316 <input type="text" id="node-input-attrname" placeholder="attrname">
317 </div>
318 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
319</script>
320
321<script type="text/x-red" data-help-name="ioBroker get">
322 <p>Connects to a ioBroker and returns the requested value or the object in the message attribute in the properties dialog, e.g. <b>msg.payload</b>. The object could be identified either by the <b>msg.topic</b> or specified in the poperties dialog. The value in the poperties dialog has precedence.</p>
323 <p>The msg object also contains the attributes <b>msg.timestamp</b>, <b>msg.lastchange</b> and <b>msg.acknowledged</b>. All other attributes of the input msg object will be passed to the output msg object.</p>
324</script>
325
326<script type="text/javascript">
327RED.nodes.registerType('ioBroker get', {
328 category: 'ioBroker',
329 defaults: {
330 name: {value: ''},
331 topic: {value: ''},
332 attrname: {value: 'payload'},
333 payloadType: {value: 'value'}
334 },
335 color: '#a8bfd8',
336 inputs: 1,
337 outputs: 1,
338 icon: 'ioBroker.png',
339 label: function() {
340 return this.name || this.topic || 'IoB read value';
341 },
342 labelStyle: function () {
343 return this.name ? 'node_label_italic' : '';
344 },
345 oneditprepare: function () {
346 initSelectId();
347 }
348 });
349</script>
350
351<script type="text/x-red" data-template-name="ioBroker get object">
352 <div class="form-row">
353 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
354 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="..."/>
355 </div>
356 <div id="dialog-select-member" style="display:none"></div>
357 <div class="form-row">
358 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
359 <input type="text" id="node-input-name" placeholder="Name">
360 </div>
361 <div class="form-row">
362 <label for="node-input-attrname"><i class="fa fa-tag"></i> Attribute</label>
363 <input type="text" id="node-input-attrname" placeholder="attrname">
364 </div>
365 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
366</script>
367
368<script type="text/x-red" data-help-name="ioBroker get object">
369 <p>Connects to a ioBroker and returns the requested object in the massage attribute in the properties dialog, e.g. <b>msg.payload</b>. The object could be identified either by the <b>msg.topic</b> or specified in the poperties dialog. The value in the poperties dialog has precedence.</p>
370</script>
371
372<script type="text/javascript">
373 RED.nodes.registerType('ioBroker get object', {
374 category: 'ioBroker',
375 defaults: {
376 name: {value: ''},
377 topic: {value: ''},
378 attrname: {value: 'payload'}
379 },
380 color: '#a8bfd8',
381 inputs: 1,
382 outputs: 1,
383 icon: 'ioBroker.png',
384 label: function () {
385 return this.name || this.topic || 'IoB read object';
386 },
387 labelStyle: function () {
388 return this.name ? 'node_label_italic' : '';
389 },
390 oneditprepare: function () {
391 initSelectId();
392 }
393 });
394</script>
395
396<script type="text/x-red" data-template-name="ioBroker list">
397 <div class="form-row">
398 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
399 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="..."/>
400 </div>
401 <div id="dialog-select-member" style="display:none"></div>
402 <div class="form-row">
403 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
404 <input type="text" id="node-input-name" placeholder="Name">
405 </div>
406 <div class="form-row">
407 <label for="node-input-objType"><i class="fa fa-tag"></i> Type</label>
408 <select id="node-input-objType" style="width:73% !important">
409 <option value="">Any</option>
410 <option value="state">State</option>
411 <option value="channel">Channel</option>
412 <option value="device">Device</option>
413 <option value="meta">Meta</option>
414 <option value="instance">Instance</option>
415 <option value="adapter">Adapter</option>
416 <option value="folder">Folder</option>
417 </select>
418 </div>
419 <div class="form-row">
420 <label for="node-input-asArray"><i class="fa fa-tag"></i> As array</label>
421 <select id="node-input-asArray" style="width:73% !important">
422 <option value="true">Return one array of IDs</option>
423 <option value="false">For every ID the message will be generated</option>
424 </select>
425 </div>
426 <div class="form-row">
427 <label for="node-input-onlyIDs"><i class="fa fa-tag"></i> Only IDs</label>
428 <select id="node-input-onlyIDs" style="width:73% !important">
429 <option value="true">Returns only IDs of object</option>
430 <option value="false">Returns whole objects</option>
431 </select>
432 </div>
433 <div class="form-row">
434 <label for="node-input-withValues"><i class="fa fa-tag"></i> With values</label>
435 <select id="node-input-withValues" style="width:73% !important">
436 <option value="true">Read state's values and add them to payload</option>
437 <option value="false">Do not read values</option>
438 </select>
439 </div>
440 <div class="form-row">
441 <label for="node-input-regex"><i class="fa fa-tag"></i> Optional regex</label>
442 <input type="text" id="node-input-regex" placeholder="Optional regular expression">
443 </div>
444 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
445</script>
446
447<script type="text/x-red" data-help-name="ioBroker list">
448 <p>Connects to a ioBroker and returns the list of IDs for pattern.
449 The filter can be defined in topic as "node-red.0.*" or in msg.topic.
450 Additionally you can provide regular expression to filter received list.
451 </p>
452</script>
453
454<script type="text/javascript">
455 RED.nodes.registerType('ioBroker list', {
456 category: 'ioBroker',
457 defaults: {
458 name: {value: ''},
459 topic: {value: ''},
460 objType: {value: 'state'},
461 regex: {value: ''},
462 asArray: {value: 'false'},
463 onlyIDs: {value: 'true'},
464 withValues: {value: 'false'}
465 },
466 color: '#a8bfd8',
467 inputs: 1,
468 outputs: 1,
469 icon: 'ioBroker.png',
470 label: function () {
471 return this.name || this.topic || 'IoB list';
472 },
473 labelStyle: function () {
474 return this.name ? 'node_label_italic' : '';
475 },
476 oneditprepare: function () {
477 initSelectId(true, function (newId) {
478 if (newId.indexOf('*') === -1) {
479 newId += '.*';
480 $('#node-input-topic').val(newId);
481 }
482 });
483 }
484 });
485</script>