From 64ba0edfe6603e89a988622d459b5a8443c85f92 Mon Sep 17 00:00:00 2001 From: brammp Date: Wed, 15 Apr 2020 02:48:39 +0200 Subject: [PATCH] Added Content --- .gitignore | 6 ++++++ LICENSE | 0 README.md | 2 -- http-domo-out/hoBrightConv.html | 32 +++++++++++++++++++++++++++ http-domo-out/hoBrightConv.js | 23 ++++++++++++++++++++ http-domo-out/hoOnOffConv.html | 32 +++++++++++++++++++++++++++ http-domo-out/hoOnOffConv.js | 28 ++++++++++++++++++++++++ http-domo-out/hoRGBConv.html | 32 +++++++++++++++++++++++++++ http-domo-out/hoRGBConv.js | 33 ++++++++++++++++++++++++++++ mqtt-domo-in/icons/domo.png | Bin 0 -> 2112 bytes mqtt-domo-in/miBrightConv.html | 37 ++++++++++++++++++++++++++++++++ mqtt-domo-in/miBrightConv.js | 21 ++++++++++++++++++ mqtt-domo-in/miOnOffConv.html | 37 ++++++++++++++++++++++++++++++++ mqtt-domo-in/miOnOffConv.js | 26 ++++++++++++++++++++++ mqtt-domo-in/miRGBConv.html | 37 ++++++++++++++++++++++++++++++++ mqtt-domo-in/miRGBConv.js | 29 +++++++++++++++++++++++++ mqtt-domo-in/miTempConv.html | 32 +++++++++++++++++++++++++++ mqtt-domo-in/miTempConv.js | 16 ++++++++++++++ package.json | 18 ++++++++++++++++ package.json.bck | 18 ++++++++++++++++ 20 files changed, 457 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 http-domo-out/hoBrightConv.html create mode 100644 http-domo-out/hoBrightConv.js create mode 100644 http-domo-out/hoOnOffConv.html create mode 100644 http-domo-out/hoOnOffConv.js create mode 100644 http-domo-out/hoRGBConv.html create mode 100644 http-domo-out/hoRGBConv.js create mode 100644 mqtt-domo-in/icons/domo.png create mode 100644 mqtt-domo-in/miBrightConv.html create mode 100644 mqtt-domo-in/miBrightConv.js create mode 100644 mqtt-domo-in/miOnOffConv.html create mode 100644 mqtt-domo-in/miOnOffConv.js create mode 100644 mqtt-domo-in/miRGBConv.html create mode 100644 mqtt-domo-in/miRGBConv.js create mode 100644 mqtt-domo-in/miTempConv.html create mode 100644 mqtt-domo-in/miTempConv.js create mode 100644 package.json create mode 100644 package.json.bck diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d52e73d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/.vs/node-red-contib-domoticzconverter/v16 +/.vs diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 03a4893..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,2 +0,0 @@ -# node-red-contib-domoticzconverter - diff --git a/http-domo-out/hoBrightConv.html b/http-domo-out/hoBrightConv.html new file mode 100644 index 0000000..bd32e8e --- /dev/null +++ b/http-domo-out/hoBrightConv.html @@ -0,0 +1,32 @@ + + + + + diff --git a/http-domo-out/hoBrightConv.js b/http-domo-out/hoBrightConv.js new file mode 100644 index 0000000..893e87b --- /dev/null +++ b/http-domo-out/hoBrightConv.js @@ -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); +} diff --git a/http-domo-out/hoOnOffConv.html b/http-domo-out/hoOnOffConv.html new file mode 100644 index 0000000..a2e372f --- /dev/null +++ b/http-domo-out/hoOnOffConv.html @@ -0,0 +1,32 @@ + + + + + diff --git a/http-domo-out/hoOnOffConv.js b/http-domo-out/hoOnOffConv.js new file mode 100644 index 0000000..0494af8 --- /dev/null +++ b/http-domo-out/hoOnOffConv.js @@ -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); +} diff --git a/http-domo-out/hoRGBConv.html b/http-domo-out/hoRGBConv.html new file mode 100644 index 0000000..f3c3f8b --- /dev/null +++ b/http-domo-out/hoRGBConv.html @@ -0,0 +1,32 @@ + + + + + diff --git a/http-domo-out/hoRGBConv.js b/http-domo-out/hoRGBConv.js new file mode 100644 index 0000000..051f9c6 --- /dev/null +++ b/http-domo-out/hoRGBConv.js @@ -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); +} diff --git a/mqtt-domo-in/icons/domo.png b/mqtt-domo-in/icons/domo.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4feG3Jnq(X{}jwDjDt3;kOI& zh5IB~`0O$Gs>3D*PsT1TjViPLcjPx}P3HQ~hWnj9K^q2{H-b*5Qi5~mGX6SQUa0MY zhu*{l&L4V1HbT&#$M5I1M@zG4{7CWU>FGT}2FIR+Nl2H4Th~Oe_qY`vsyWTC?noO! zL0<}VOhZo2qznAgdSqE{wNil-8HX`kaM;D`t{yvXYq9suvGDM&Cb;AI2EjQQ8$k(B zu>6uKo5?%;3?P(jJapuw#rf;eJ~hjVOi*9FNW2>x9)AE{t?PzOdt1PU`*r-q$ibX! z?b&ahTQ-Z_1)tveNmKrYy}dmS7aqxjkZSDF2zW`;G~9T37Np^v3_+fe8s@->2Z(R1 z4(RH|G(uK<&@oASJmEGp>U7w&Vp_@O+e%N7dugk1^HX)3_Mhn60`$nFm7l=zj0lYA zr21Ixi8>tZCB>OFwbe`33W^8^39}#ksIJ}WS|s#%G{aIRK!<+mnzq;oX>b5UWQ(bz9m@bE53!L;M=*jZ{W$kJJb z6-Cm3RPdpR)S-=RqsFymW$v6v=LnJA2|^+{d+mEiI;@^@{Pq*I1oDdXo-j@wI-H-Q zZR@F7QbtiG+*YEAir@%*Bx_bJSbBNpQ(8^B&|Ch*iv~tczClS)hixepX;4v;`D*WL zx0z!(M~E3gDKCEBRP?XiXLmPuyXOOkXSig3mSYuQF3`5$S&_TC`rfieQ5%zlEN$Q2 zc+Fdfdmgv+F-z?>7sekW639ECgxDaBK05l qWJx)gEGY+*CFNkUq#R5RfFA+Z-oKK-$sno#0000 + 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"; + } + }); + + + + + diff --git a/mqtt-domo-in/miBrightConv.js b/mqtt-domo-in/miBrightConv.js new file mode 100644 index 0000000..e9a4071 --- /dev/null +++ b/mqtt-domo-in/miBrightConv.js @@ -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); +} diff --git a/mqtt-domo-in/miOnOffConv.html b/mqtt-domo-in/miOnOffConv.html new file mode 100644 index 0000000..a9d5736 --- /dev/null +++ b/mqtt-domo-in/miOnOffConv.html @@ -0,0 +1,37 @@ + + + + + diff --git a/mqtt-domo-in/miOnOffConv.js b/mqtt-domo-in/miOnOffConv.js new file mode 100644 index 0000000..56be26f --- /dev/null +++ b/mqtt-domo-in/miOnOffConv.js @@ -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); +} diff --git a/mqtt-domo-in/miRGBConv.html b/mqtt-domo-in/miRGBConv.html new file mode 100644 index 0000000..0b2c440 --- /dev/null +++ b/mqtt-domo-in/miRGBConv.html @@ -0,0 +1,37 @@ + + + + + diff --git a/mqtt-domo-in/miRGBConv.js b/mqtt-domo-in/miRGBConv.js new file mode 100644 index 0000000..32b8515 --- /dev/null +++ b/mqtt-domo-in/miRGBConv.js @@ -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); +} diff --git a/mqtt-domo-in/miTempConv.html b/mqtt-domo-in/miTempConv.html new file mode 100644 index 0000000..3340565 --- /dev/null +++ b/mqtt-domo-in/miTempConv.html @@ -0,0 +1,32 @@ + + + + + diff --git a/mqtt-domo-in/miTempConv.js b/mqtt-domo-in/miTempConv.js new file mode 100644 index 0000000..e22f9f0 --- /dev/null +++ b/mqtt-domo-in/miTempConv.js @@ -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); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..a95086f --- /dev/null +++ b/package.json @@ -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" + + } + } +} diff --git a/package.json.bck b/package.json.bck new file mode 100644 index 0000000..3f2314d --- /dev/null +++ b/package.json.bck @@ -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" + + } + } +}