new
This commit is contained in:
+33
-33
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<script type="text/x-red" data-template-name="ioBroker in">
|
||||
<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="."/>
|
||||
@@ -50,8 +50,8 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="ioBroker in">
|
||||
<p>ioBroker input node. Connects to a ioBroker and subscribes to the specified topic. The topic may contain redis wildcards (*).</p>
|
||||
<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>
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
RED.nodes.registerType('ioBroker in',{
|
||||
RED.nodes.registerType('yunkong2 in',{
|
||||
category: 'input',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
@@ -84,19 +84,19 @@
|
||||
color:"#a8bfd8",
|
||||
inputs:0,
|
||||
outputs:1,
|
||||
icon: "ioBroker.png",
|
||||
icon: "yunkong2.png",
|
||||
label: function() {
|
||||
return this.name||this.topic||"ioBroker";
|
||||
return this.name||this.topic||"yunkong2";
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
if (!window.__iobroker) {
|
||||
$.getJSON("iobroker.json", function(data) {
|
||||
window.__iobroker = data;
|
||||
if (!window.__yunkong2) {
|
||||
$.getJSON("yunkong2.json", function(data) {
|
||||
window.__yunkong2 = data;
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
@@ -105,7 +105,7 @@
|
||||
});
|
||||
} else {
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
@@ -142,7 +142,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-template-name="ioBroker out">
|
||||
<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="."/>
|
||||
@@ -169,14 +169,14 @@
|
||||
<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="ioBroker out">
|
||||
<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>
|
||||
<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('ioBroker out',{
|
||||
RED.nodes.registerType('yunkong2 out',{
|
||||
category: 'output',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
@@ -187,20 +187,20 @@ RED.nodes.registerType('ioBroker out',{
|
||||
color:"#a8bfd8",
|
||||
inputs:1,
|
||||
outputs:0,
|
||||
icon: "ioBroker.png",
|
||||
icon: "yunkong2.png",
|
||||
align: "right",
|
||||
label: function() {
|
||||
return this.name||this.topic||"ioBroker";
|
||||
return this.name||this.topic||"yunkong2";
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
if (!window.__iobroker) {
|
||||
$.getJSON("iobroker.json", function(data) {
|
||||
window.__iobroker = data;
|
||||
if (!window.__yunkong2) {
|
||||
$.getJSON("yunkong2.json", function(data) {
|
||||
window.__yunkong2 = data;
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
@@ -209,7 +209,7 @@ RED.nodes.registerType('ioBroker out',{
|
||||
});
|
||||
} else {
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
@@ -236,7 +236,7 @@ RED.nodes.registerType('ioBroker out',{
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-template-name="ioBroker get">
|
||||
<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="."/>
|
||||
@@ -260,14 +260,14 @@ RED.nodes.registerType('ioBroker out',{
|
||||
<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="ioBroker get">
|
||||
<p>Connects to a ioBroker 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>
|
||||
<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('ioBroker get',{
|
||||
RED.nodes.registerType('yunkong2 get',{
|
||||
category: 'function',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
@@ -278,19 +278,19 @@ RED.nodes.registerType('ioBroker get',{
|
||||
color:"#a8bfd8",
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "ioBroker.png",
|
||||
icon: "yunkong2.png",
|
||||
label: function() {
|
||||
return this.name||this.topic||"ioBroker get";
|
||||
return this.name||this.topic||"yunkong2 get";
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
if (!window.__iobroker) {
|
||||
$.getJSON("iobroker.json", function(data) {
|
||||
window.__iobroker = data;
|
||||
if (!window.__yunkong2) {
|
||||
$.getJSON("yunkong2.json", function(data) {
|
||||
window.__yunkong2 = data;
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
@@ -299,7 +299,7 @@ RED.nodes.registerType('ioBroker get',{
|
||||
});
|
||||
} else {
|
||||
$('#dialog-select-member').selectId('init', {
|
||||
objects: window.__iobroker,
|
||||
objects: window.__yunkong2,
|
||||
noMultiselect: true,
|
||||
columns: ['name', 'role', 'enum', 'room'],
|
||||
states: null,
|
||||
|
||||
+17
-17
@@ -24,8 +24,8 @@ module.exports = function(RED) {
|
||||
// Get the redis address
|
||||
|
||||
var settings = require(process.env.NODE_RED_HOME + '/red/red').settings;
|
||||
var instance = settings.get('iobrokerInstance') || 0;
|
||||
var config = settings.get('iobrokerConfig');
|
||||
var instance = settings.get('yunkong2Instance') || 0;
|
||||
var config = settings.get('yunkong2Config');
|
||||
var valueConvert = settings.get('valueConvert');
|
||||
if (typeof config == 'string') {
|
||||
config = JSON.parse(config);
|
||||
@@ -47,7 +47,7 @@ module.exports = function(RED) {
|
||||
adapter.subscribeForeignStates('*');
|
||||
while (nodes.length) {
|
||||
var node = nodes.pop();
|
||||
if (node instanceof IOBrokerInNode) {
|
||||
if (node instanceof yunkong2InNode) {
|
||||
adapter.on('stateChange', node.stateChange);
|
||||
}
|
||||
node.status({fill: 'green', shape: 'dot', text: 'connected'});
|
||||
@@ -58,7 +58,7 @@ module.exports = function(RED) {
|
||||
nodeSetData.node.emit('input', nodeSetData.msg);
|
||||
count++;
|
||||
}
|
||||
if (count > 0) log(count + ' queued state values set in ioBroker');
|
||||
if (count > 0) log(count + ' queued state values set in yunkong2');
|
||||
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ module.exports = function(RED) {
|
||||
if (!obj) {
|
||||
adapter.getForeignObject(id, function (err, obj) {
|
||||
if (!obj) {
|
||||
log('State "' + id + '" was created in the ioBroker as ' + adapter._fixId(id));
|
||||
log('State "' + id + '" was created in the yunkong2 as ' + adapter._fixId(id));
|
||||
// Create object
|
||||
adapter.setObject(id, {
|
||||
common: {
|
||||
@@ -130,7 +130,7 @@ module.exports = function(RED) {
|
||||
});
|
||||
}
|
||||
|
||||
function IOBrokerInNode(n) {
|
||||
function yunkong2InNode(n) {
|
||||
var node = this;
|
||||
RED.nodes.createNode(node,n);
|
||||
node.topic = (n.topic || '*').replace(/\//g, '.');
|
||||
@@ -226,9 +226,9 @@ module.exports = function(RED) {
|
||||
nodes.push(node);
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType('ioBroker in', IOBrokerInNode);
|
||||
RED.nodes.registerType('yunkong2 in', yunkong2InNode);
|
||||
|
||||
function IOBrokerOutNode(n) {
|
||||
function yunkong2OutNode(n) {
|
||||
var node = this;
|
||||
RED.nodes.createNode(node,n);
|
||||
node.topic = n.topic;
|
||||
@@ -257,7 +257,7 @@ module.exports = function(RED) {
|
||||
var id = node.topic || msg.topic;
|
||||
if (!ready) {
|
||||
nodeSets.push({'node': node, 'msg': msg});
|
||||
//log('Message for "' + id + '" queued because ioBroker connection not initialized');
|
||||
//log('Message for "' + id + '" queued because yunkong2 connection not initialized');
|
||||
return;
|
||||
}
|
||||
if (id) {
|
||||
@@ -280,12 +280,12 @@ module.exports = function(RED) {
|
||||
adapter.setForeignState(id, {val: msg.payload, ack: node.ack});
|
||||
node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() });
|
||||
} else {
|
||||
log('State "' + id + '" does not exist in the ioBroker');
|
||||
log('State "' + id + '" does not exist in the yunkong2');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (id.indexOf('*') !== -1) {
|
||||
log('Invalid topic name "' + id + '" for ioBroker');
|
||||
log('Invalid topic name "' + id + '" for yunkong2');
|
||||
} else {
|
||||
setState(id, msg.payload, node.ack);
|
||||
node.status({fill: 'green', shape: 'dot', text: msg.payload.toString() });
|
||||
@@ -305,9 +305,9 @@ module.exports = function(RED) {
|
||||
// });
|
||||
|
||||
}
|
||||
RED.nodes.registerType('ioBroker out', IOBrokerOutNode);
|
||||
RED.nodes.registerType('yunkong2 out', yunkong2OutNode);
|
||||
|
||||
function IOBrokerGetNode(n) {
|
||||
function yunkong2GetNode(n) {
|
||||
var node = this;
|
||||
RED.nodes.createNode(node,n);
|
||||
node.topic = (typeof n.topic=== 'string' && n.topic.length > 0 ? n.topic.replace(/\//g, '.') : null) ;
|
||||
@@ -350,7 +350,7 @@ module.exports = function(RED) {
|
||||
});
|
||||
node.send(msg);
|
||||
} else {
|
||||
log('State "' + id + '" does not exist in the ioBroker');
|
||||
log('State "' + id + '" does not exist in the yunkong2');
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -359,7 +359,7 @@ module.exports = function(RED) {
|
||||
var id = node.topic || msg.topic;
|
||||
if (!ready) {
|
||||
nodeSets.push({'node': node, 'msg': msg});
|
||||
//log('Message for "' + id + '" queued because ioBroker connection not initialized');
|
||||
//log('Message for "' + id + '" queued because yunkong2 connection not initialized');
|
||||
return;
|
||||
}
|
||||
if (id) {
|
||||
@@ -370,7 +370,7 @@ module.exports = function(RED) {
|
||||
adapter.getForeignState(id, node.getStateValue(msg));
|
||||
} else {
|
||||
if (id.indexOf('*') !== -1) {
|
||||
log('Invalid topic name "' + id + '" for ioBroker');
|
||||
log('Invalid topic name "' + id + '" for yunkong2');
|
||||
} else {
|
||||
adapter.getState(id, node.getStateValue(msg));
|
||||
}
|
||||
@@ -385,5 +385,5 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
}
|
||||
RED.nodes.registerType('ioBroker get', IOBrokerGetNode);
|
||||
RED.nodes.registerType('yunkong2 get', yunkong2GetNode);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user