Added Content
This commit is contained in:
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