You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

331 lines
14 KiB

<!--
Copyright 2013-2017 bluefox<dogafox@gmail.com>.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="yunkong2 in">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<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="."/>
</div>
<div id="dialog-select-member" style="display:none"></div>
<div class="form-row">
<label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
<select id="node-input-payloadType" style="width:125px !important">
<option value="value">value</option>
<option value="object">object</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-onlyack" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-onlyack" style="width: 70%;">Send only on then ack==true</label>
</div>
<div class="form-row">
<label for="node-input-func"><i class="fa fa-wrench"></i> Mode</label>
<select type="text" id="node-input-func" style="width:74%;">
<option value="all">Send all events</option>
<option value="rbe">block unless value changes</option>
<option value="deadband">block unless changes by more than</option>
</select>
</div>
<div class="form-row" id="node-bandgap">
<label for="node-input-gap">&nbsp;</label>
<input type="text" id="node-input-gap" placeholder="e.g. 10 or 5%" style="width:71%;">
</div>
</script>
<script type="text/x-red" data-help-name="yunkong2 in">
<p>yunkong2 input node. Connects to a yunkong2 and subscribes to the specified topic. The topic may contain redis wildcards (*).</p>
<p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.timestamp, msg.lastchange and msg.acknowledged.</p>
<p>The checkbox determines whether only States with ack == true or all events are forwarded.</p>
<p>The select box Mode offers further filtering options. The options are the same as for the RBE node.</p>
</script>
<link rel="stylesheet" type="text/css" href="vendor/ui.fancytree.min.css"/>
<style type="text/css">
#dialog-select-member select{
height: 24px !important;
line-height: 24px !important;
}
</style>
<script type="text/javascript" src="vendor/jquery.fancytree-all.min.js"></script>
<script type="text/javascript" src="selectID.js"></script>
<script type="text/javascript">
RED.nodes.registerType('yunkong2 in',{
category: 'input',
defaults: {
name: {value:""},
topic: {value:"*",required:true},
payloadType: {value:'value'},
onlyack: {value:""},
func: {value:"all"},
gap: {value:"",validate:RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)}
},
color:"#a8bfd8",
inputs:0,
outputs:1,
icon: "yunkong2.png",
label: function() {
return this.name||this.topic||"yunkong2";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if (!window.__yunkong2) {
$.getJSON("yunkong2.json", function(data) {
window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
});
} else {
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
}
$('#node-input-topic-button').button({
icons: {primary: 'ui-icon-folder-open'},
text: false
}).click(function () {
$('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
var oldObj = $('#dialog-select-member').selectId('getInfo', oldId)
var newObj = $('#dialog-select-member').selectId('getInfo', newId)
$('#node-input-topic').val(newId);
var oldName = $('#node-input-name').val();
if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
$('#node-input-name').val(newObj.common.name);
}
});
});
$("#node-input-func").on("change",function() {
if ($("#node-input-func").val() == null) $("#node-input-func").val ("all");
if ($("#node-input-func").val() === "deadband") {
$("#node-bandgap").show();
} else {
$("#node-bandgap").hide();
}
});
}
});
</script>
<script type="text/x-red" data-template-name="yunkong2 out">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<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="."/>
</div>
<div id="dialog-select-member" style="display:none"></div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-ack"><i class="fa fa-arrow-up"></i> Type</label>
<select id="node-input-ack" style="width:73% !important">
<option value="true">value</option>
<option value="false">command</option>
</select>
</div>
<div class="form-row">
<label for="node-input-autoCreate"><i class="fa fa-arrow-up"></i> Auto create</label>
<select id="node-input-autoCreate" style="width:73% !important">
<option value="true">Create states if not exist</option>
<option value="false">Ignore messages for non existing states</option>
</select>
</div>
<div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
</script>
<script type="text/x-red" data-help-name="yunkong2 out">
<p>Connects to a yunkong2 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>
<p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
<p>If <b>msg.payload</b> contains "__create__", the object will be only created, but no value will be written.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('yunkong2 out',{
category: 'output',
defaults: {
name: {value:""},
topic: {value:""},
ack: {value:"false"},
autoCreate: {value: "false"}
},
color:"#a8bfd8",
inputs:1,
outputs:0,
icon: "yunkong2.png",
align: "right",
label: function() {
return this.name||this.topic||"yunkong2";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if (!window.__yunkong2) {
$.getJSON("yunkong2.json", function(data) {
window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
});
} else {
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
}
$('#node-input-topic-button').button({
icons: {primary: 'ui-icon-folder-open'},
text: false
}).click(function () {
$('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
var oldObj = $('#dialog-select-member').selectId('getInfo', oldId);
var newObj = $('#dialog-select-member').selectId('getInfo', newId);
$('#node-input-topic').val(newId);
var oldName = $('#node-input-name').val();
if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
$('#node-input-name').val(newObj.common.name);
}
});
});
}
});
</script>
<script type="text/x-red" data-template-name="yunkong2 get">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<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="."/>
</div>
<div id="dialog-select-member" style="display:none"></div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
<select id="node-input-payloadType" style="width:125px !important">
<option value="value">value</option>
<option value="object">object</option>
</select>
</div>
<div class="form-row">
<label for="node-input-attrname"><i class="fa fa-tag"></i> Attribute</label>
<input type="text" id="node-input-attrname" placeholder="attrname">
</div>
<div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
</script>
<script type="text/x-red" data-help-name="yunkong2 get">
<p>Connects to a yunkong2 and returns the requested value or the 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>
<p>The msg object also contains the attributs <b>msg.timestamp</b>, <b>msg.lastchange</b> and <b>msg.acknowledged</b>. All other attributes ob the input msg object will be passed to the output msg object.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('yunkong2 get',{
category: 'function',
defaults: {
name: {value:""},
topic: {value:""},
attrname: {value:"payload"},
payloadType: {value:'value'}
},
color:"#a8bfd8",
inputs:1,
outputs:1,
icon: "yunkong2.png",
label: function() {
return this.name||this.topic||"yunkong2 get";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if (!window.__yunkong2) {
$.getJSON("yunkong2.json", function(data) {
window.__yunkong2 = data;
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
});
} else {
$('#dialog-select-member').selectId('init', {
objects: window.__yunkong2,
noMultiselect: true,
columns: ['name', 'role', 'enum', 'room'],
states: null,
noImg: true
});
}
$('#node-input-topic-button').button({
icons: {primary: 'ui-icon-folder-open'},
text: false
}).click(function () {
$('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
var oldObj = $('#dialog-select-member').selectId('getInfo', oldId);
var newObj = $('#dialog-select-member').selectId('getInfo', newId);
$('#node-input-topic').val(newId);
var oldName = $('#node-input-name').val();
if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
$('#node-input-name').val(newObj.common.name);
}
});
});
}
});
</script>