Added Content
This commit is contained in:
32
http-domo-out/hoBrightConv.html
Normal file
32
http-domo-out/hoBrightConv.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('http-domo-out-bright',{
|
||||
category: 'Domoticz HTTP Output Formater',
|
||||
color: '#00b0e2',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
idx: {value:""}
|
||||
},
|
||||
paletteLabel:"HTTP Output Brightness converter",
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "domo.png",
|
||||
label: function() {
|
||||
return this.name||"HTTP Output Brightness converter";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="http-domo-out-bright">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-idx"><i class="icon-tag"></i> IDX</label>
|
||||
<input type="number" id="node-input-idx" placeholder="IDX">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="http-domo-out-bright">
|
||||
<p>A node that converts msg.payload number between 0-100 to Domoticz level/command</p>
|
||||
</script>
|
||||
23
http-domo-out/hoBrightConv.js
Normal file
23
http-domo-out/hoBrightConv.js
Normal file
@@ -0,0 +1,23 @@
|
||||
module.exports = function(RED) {
|
||||
function httpdomooutbright(config) {
|
||||
RED.nodes.createNode(this,config);
|
||||
this.idx = parseInt(config.idx, 10);
|
||||
var node = this;
|
||||
node.on('input', function(msg) {
|
||||
if (node.idx === 'undefined' || isNaN(node.idx) || node.idx === null || node.idx === "" ) {
|
||||
node.error("IDX not set");
|
||||
return;
|
||||
}
|
||||
var newbright = msg.payload;
|
||||
msg.payload = {
|
||||
"idx": node.idx,
|
||||
"level": newbright,
|
||||
"type": "command",
|
||||
"param": "switchlight",
|
||||
"switchcmd": "Set Level"
|
||||
};
|
||||
node.send(msg);
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("http-domo-out-bright",httpdomooutbright);
|
||||
}
|
||||
32
http-domo-out/hoOnOffConv.html
Normal file
32
http-domo-out/hoOnOffConv.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('http-domo-out-onoff',{
|
||||
category: 'Domoticz HTTP Output Formater',
|
||||
color: '#00b0e2',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
idx: {value:""}
|
||||
},
|
||||
paletteLabel:"HTTP Output On/Off converter",
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "domo.png",
|
||||
label: function() {
|
||||
return this.name||"HTTP Output On/Off converter";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="http-domo-out-onoff">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-idx"><i class="icon-tag"></i> IDX</label>
|
||||
<input type="number" id="node-input-idx" placeholder="IDX">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="http-domo-out-onoff">
|
||||
<p>A node that converts msg.paylod true/false to domoticz on/off</p>
|
||||
</script>
|
||||
28
http-domo-out/hoOnOffConv.js
Normal file
28
http-domo-out/hoOnOffConv.js
Normal file
@@ -0,0 +1,28 @@
|
||||
module.exports = function(RED) {
|
||||
function httpdomooutonoff(config) {
|
||||
RED.nodes.createNode(this,config);
|
||||
this.idx = parseInt(config.idx, 10);
|
||||
var flowContext = this.context().flow;
|
||||
var node = this;
|
||||
node.on('input', function(msg) {
|
||||
if (node.idx === 'undefined' || isNaN(node.idx) || node.idx === null || node.idx === "" ) {
|
||||
node.error("IDX not set");
|
||||
return;
|
||||
}
|
||||
var setstat = msg.payload;
|
||||
if (setstat === true) {
|
||||
var newstat = "On";
|
||||
} else if (setstat === false) {
|
||||
var newstat = "Off";
|
||||
}
|
||||
msg.payload = {
|
||||
"idx": node.idx,
|
||||
"type": "command",
|
||||
"param": "switchlight",
|
||||
"switchcmd": newstat
|
||||
};
|
||||
node.send(msg);
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("http-domo-out-onoff",httpdomooutonoff);
|
||||
}
|
||||
32
http-domo-out/hoRGBConv.html
Normal file
32
http-domo-out/hoRGBConv.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('http-domo-out-rgb',{
|
||||
category: 'Domoticz HTTP Output Formater',
|
||||
color: '#00b0e2',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
idx: {value:""}
|
||||
},
|
||||
paletteLabel:"HTTP Output RGB converter",
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "domo.png",
|
||||
label: function() {
|
||||
return this.name||"HTTP Output RGB converter";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-template-name="http-domo-out-rgb">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-idx"><i class="icon-tag"></i> IDX</label>
|
||||
<input type="number" id="node-input-idx" placeholder="IDX">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="http-domo-out-rgb">
|
||||
<p>A node that generates a json string for domoticz</p>
|
||||
</script>
|
||||
33
http-domo-out/hoRGBConv.js
Normal file
33
http-domo-out/hoRGBConv.js
Normal file
@@ -0,0 +1,33 @@
|
||||
module.exports = function(RED) {
|
||||
function httpdomooutrgb(config) {
|
||||
RED.nodes.createNode(this,config);
|
||||
this.idx = parseInt(config.idx, 10);
|
||||
var flowContext = this.context().flow;
|
||||
var node = this;
|
||||
node.on('input', function(msg) {
|
||||
if (node.idx === 'undefined' || isNaN(node.idx) || node.idx === null || node.idx === "" ) {
|
||||
node.error("IDX not set");
|
||||
return;
|
||||
}
|
||||
var flowbrightness = flowContext.get(node.idx + "-brightness")
|
||||
if (flowbrightness === 'undefined' || isNaN(flowbrightness) || flowbrightness === null || flowbrightness === "" ) {
|
||||
node.warn("Brightness for this device is not defined in the flow, Setting to 100");
|
||||
var curbrightness = 100
|
||||
} else {
|
||||
var curbrightness = flowbrightness
|
||||
}
|
||||
|
||||
var newcolor = msg.payload;
|
||||
msg.payload = {
|
||||
"idx": node.idx,
|
||||
"hex": newcolor,
|
||||
"brightness": curbrightness,
|
||||
"type": "command",
|
||||
"param": "setcolbrightnessvalue",
|
||||
"iswhite": false
|
||||
};
|
||||
node.send(msg);
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("http-domo-out-rgb",httpdomooutrgb);
|
||||
}
|
||||
Reference in New Issue
Block a user