Added Content

This commit is contained in:
2020-04-15 02:48:39 +02:00
parent cd2ec74ba9
commit 64ba0edfe6
20 changed files with 457 additions and 2 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
/.vs/node-red-contib-domoticzconverter/v16
/.vs

0
LICENSE Normal file
View File

View File

@@ -1,2 +0,0 @@
# node-red-contib-domoticzconverter

View 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>

View 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);
}

View 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>

View 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);
}

View 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>

View 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);
}

BIN
mqtt-domo-in/icons/domo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,37 @@
<script type="text/javascript">
RED.nodes.registerType('mqtt-domo-in-bright',{
category: 'Domoticz MQTT Input Formater',
color: '#00b0e2',
defaults: {
name: {value:""},
Savetocontex: {value: false},
idx: {value:""}
},
paletteLabel:"MQTT In Brightness converter",
inputs:1,
outputs:1,
icon: "domo.png",
label: function() {
return this.name||"MQTT In Brightness converter";
}
});
</script>
<script type="text/html" data-template-name="mqtt-domo-in-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-Savetocontex"><i class="icon-tag"></i> Save to context database</label>
<input type="checkbox" id="node-input-Savetocontex" >
</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="mqtt-domo-in-bright">
<p>A node that converts domoticz level to msg.payload and stores to context db</p>
</script>

View File

@@ -0,0 +1,21 @@
module.exports = function(RED) {
function mqttdomoinbright(config) {
RED.nodes.createNode(this,config);
this.idx = config.idx;
this.Savetocontex = config.Savetocontex;
var flowContext = this.context().flow;
var node = this;
node.on('input', function(msg) {
msg.payload = msg.payload.Level;
node.send(msg);
if (node.Savetocontex === true) {
if (node.idx === 'undefined' || node.idx === null || node.idx === "" ) {
node.warn("IDX not set");
} else{
flowContext.set(node.idx + "-brightness", msg.payload)
}
}
});
}
RED.nodes.registerType("mqtt-domo-in-bright",mqttdomoinbright);
}

View File

@@ -0,0 +1,37 @@
<script type="text/javascript">
RED.nodes.registerType('mqtt-domo-in-onoff',{
category: 'Domoticz MQTT Input Formater',
color: '#00b0e2',
defaults: {
name: {value:""},
Savetocontex: {value: false},
idx: {value:""}
},
paletteLabel:"MQTT In On/Off converter",
inputs:1,
outputs:1,
icon: "domo.png",
label: function() {
return this.name||"MQTT In On/Off converter";
}
});
</script>
<script type="text/html" data-template-name="mqtt-domo-in-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-Savetocontex"><i class="icon-tag"></i> Save to context database</label>
<input type="checkbox" id="node-input-Savetocontex" >
</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="mqtt-domo-in-onoff">
<p>A node that converts domoticz on to true and of to false</p>
</script>

View File

@@ -0,0 +1,26 @@
module.exports = function(RED) {
function mqttdomoinonoff(config) {
RED.nodes.createNode(this,config);
this.idx = config.idx;
this.Savetocontex = config.Savetocontex;
var flowContext = this.context().flow;
var node = this;
node.on('input', function(msg) {
var stat = msg.payload.nvalue;
if (stat === 0) {
msg.payload = false;
} else {
msg.payload = true;
}
node.send(msg);
if (node.Savetocontex === true) {
if (node.idx === 'undefined' || node.idx === null || node.idx === "" ) {
node.warn("IDX not set");
} else{
flowContext.set(node.idx + "-state", msg.payload)
}
}
});
}
RED.nodes.registerType("mqtt-domo-in-onoff",mqttdomoinonoff);
}

View File

@@ -0,0 +1,37 @@
<script type="text/javascript">
RED.nodes.registerType('mqtt-domo-in-rgb',{
category: 'Domoticz MQTT Input Formater',
color: '#00b0e2',
defaults: {
name: {value:""},
Savetocontex: {value: false},
idx: {value:""}
},
paletteLabel:"MQTT In RGB converter",
inputs:1,
outputs:1,
icon: "domo.png",
label: function() {
return this.name||"MQTT In RGB converter";
}
});
</script>
<script type="text/html" data-template-name="mqtt-domo-in-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-Savetocontex"><i class="icon-tag"></i> Save to context database</label>
<input type="checkbox" id="node-input-Savetocontex" >
</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="mqtt-domo-in-rgb">
<p>A node that converts domoticz rgb to hex</p>
</script>

29
mqtt-domo-in/miRGBConv.js Normal file
View File

@@ -0,0 +1,29 @@
module.exports = function(RED) {
function mqttdomoinrgb(config) {
RED.nodes.createNode(this,config);
this.idx = config.idx;
this.Savetocontex = config.Savetocontex;
var flowContext = this.context().flow;
var node = this;
node.on('input', function(msg) {
var r = msg.payload.Color.r;
var g = msg.payload.Color.g;
var b = msg.payload.Color.b;
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
msg.payload = "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
node.send(msg);
if (node.Savetocontex === true) {
if (node.idx === 'undefined' || node.idx === null || node.idx === "" ) {
node.warn("IDX not set");
} else{
flowContext.set(node.idx + "-color", msg.payload)
}
}
});
}
RED.nodes.registerType("mqtt-domo-in-rgb",mqttdomoinrgb);
}

View File

@@ -0,0 +1,32 @@
<script type="text/javascript">
RED.nodes.registerType('mqtt-domo-in-temp',{
category: 'Domoticz MQTT Input Formater',
color: '#00b0e2',
defaults: {
name: {value:""},
sname: {value:""}
},
paletteLabel:"MQTT In Temperature converter",
inputs:1,
outputs:1,
icon: "domo.png",
label: function() {
return this.name||"MQTT In Temperature converter";
}
});
</script>
<script type="text/html" data-template-name="mqtt-domo-in-temp">
<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> Sensor name</label>
<input type="text" id="node-input-sname" placeholder="Sensor name">
</div>
</script>
<script type="text/html" data-help-name="mqtt-domo-in-temp">
<p>A node that converts domoticz svalue1 to msg.payload and adds a confiurable topic for use with dashboad graph</p>
</script>

View File

@@ -0,0 +1,16 @@
module.exports = function(RED) {
function mqttdomointemp(config) {
RED.nodes.createNode(this,config);
this.sname = config.sname;
var node = this;
node.on('input', function(msg) {
msg.payload = msg.payload.svalue1;
if (node.sname === 'undefined' || node.sname === null || node.sname === "" ) {
} else{
msg.topic = node.sname
}
node.send(msg);
});
}
RED.nodes.registerType("mqtt-domo-in-temp",mqttdomointemp);
}

18
package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name" : "node-red-contib-domoticzconverter",
"version" : "0.0.3",
"description" : "Domoticz converter for use with dashboard",
"dependencies" : {} ,
"node-red" : {
"nodes": {
"domo-mmqtt-in-rgb": "mqtt-domo-in/miRGBConv.js",
"domo-mmqtt-in-onoff": "mqtt-domo-in/miOnOffConv.js",
"domo-mmqtt-in-temp": "mqtt-domo-in/miTempConv.js",
"domo-mmqtt-in-bright": "mqtt-domo-in/miBrightConv.js",
"domo-http-out-bright": "http-domo-out/hoOnOffConv.js",
"domo-http-out-onoff": "http-domo-out/hoBrightConv.js",
"domo-http-out-rgb": "http-domo-out/hoRGBConv.js"
}
}
}

18
package.json.bck Normal file
View File

@@ -0,0 +1,18 @@
{
"name" : "node-red-contib-domoticzconverter",
"version" : "0.0.3",
"description" : "Domoticz converter for use with dashboard",
"dependencies" : {} ,
"node-red" : {
"nodes": {
"domommqttin-rgb": "mqtt-domo-in/miRGBConv.js",
"domommqttin-onoff": "mqtt-domo-in/miOnOffConv.js",
"domommqttin-temp": "mqtt-domo-in/miTempConv.js",
"domommqttin-bright": "mqtt-domo-in/miBrightConv.js",
"domohttpout-bright": "http-domo-out/hoOnOffConv.js",
"domohttpout-onoff": "http-domo-out/hoBrightConv.js",
"domohttpout-rgb": "http-domo-out/hoRGBConv.js"
}
}
}