From 18b1190029e9b79b36257a5d5d1194078d962b18 Mon Sep 17 00:00:00 2001
From: Sean Bedford See the PiBorg site for more information. You can also now use a msg.payload in the standard hex format "#rrggbb". The clip levels are :
0x00 - 0x57 = off
0x58 - 0xA7 = 50%
0xA8 - 0xFF = fully on
You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yeloow, orange, pink, purple, +
You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple, white, warmwhite, black
From 9adc2b2687db66b42eab01efb18dd50720137ab9 Mon Sep 17 00:00:00 2001 From: Dave C-JVQ_3%2T5Uc7LR;VWs525k9fd)#kJM zNZ_$wl_Zs<(ipOH7hl@{Z*Dx%!;7-Rtlk8b(G<5Bqpy;DD6}%Zr&~OmO!sqRKBLiv z0(0~FzABvputKO(3m^+%17BZJ)dwbXtRkmfq6wg;5!;j1@Kia}y_>%xHP*R{7Iki1 zidR~{v@A*FM)0^AdWD%GrPQP%RDdQDMX=<8E4hsXF1ngj!q^!eQssLiz1Z7wnXG){ z0siggN735Siq#sx@?6;zPvR;FBLE>HvVh~K^gV86$0BxP-l;jN`X|rUhi9$K z{6t$OtGN(|k)oV&vf^77W2eIuPxRoph(xB3Su>Ben?s5O%l~;|a$b_GU5Y+{Rwx(% z(Wf?`%^t%?g{1O;a QRWBO= zPVkS@79?IYfxH@golfCB8tK%4--L5Fr1-`t^J9E|uxkqK+(M X zZ)8 zn`g#~U>|@T&NvUnE78&YrSz@ZD2Hce2cBL_m1y7rktly*0$EAr>SPU8Rn-?xQkWLa zN%Ue#)BxB(@|v?63extY8vv3ZInzb}5ET>WBsxPVOIgFb6u8(#3$dNB_^xXU<#Z@; zVG$Az# Wi-w2Lfa+xNGXRw(x2feaIpH0X zrM@d4P68@trJO9bzq1+DwN2KyGs!>G4$RE4p>EzrWw)x12A 5I=Phr*S+v-IFE0WACL8ON#HU* z?e7*1%XnNwtov*E<{KF+TT}qEjE{8T9+5&jI!mXgv@`m_Xcy0FMfv`pNKK|wd@M|X ztuO;iRLd>3%b49qs4<#W< yJ69_ 0yX`C+=6t7@9oCk>#a)&4cqW#RgF`)hzqS!W`7!LPYmz(i zX*5(MxF(iB<78v)*%*x`P@fsZ3*BGIKl%?Nz3MuyIsbCpZAEZ>;K|P17~2|}tuGgR z+d0swYwBCj24by t;$fEB?K-xViOh2_R)LnJCK0HFq-K=2oL z9RI1TwGNi`>J W+QOj;aR9*EiD Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i^t* z6&5c^W?UTr00G8HL_t(o!|j*5N<%>qhG#Z+2!etSAP7M$#Lh}YY%FY23$}I!1PRz! z`UF;joo|prlstijg)d=YZ4u08vw`Jg&z?OOypgHSnVFsa=dwGqA`ANK1Za_e;0$;M zUVxn{fP|=%AzydwoX(hKfOG*9kheU11GKGt*%LW{W^`JzJg^40GjwWJZ (+Z z(P@f2?v0TCtWbfYq#m#ZT*iPo0d@l$ye2kV0d76I_do+!@_?a|RK*q}&`_b_aQSJ+6=;jdM}pl{)rn8Pp3!w(&y9#o?e{}us1F^`TIEDAR}V#Q>=2m} zv&v`H4jTDI^zXp*f7{CwPaosQ(q!+l9xxJ-iHNKf>O~a-8rT y{D6rKpubH3={|s6!Nto(*OVg{z*hZR7l6wmAh(HK@^6++2@#(h*|`E z03i^p1glgcViU{w0Je5oh+0_K2tI)}78c?gq!1-fppe4G&elRnAznH8Y-Y#Vli73j z$whF%z|5MRWYNT`Qc6O75uH(v10) 3`iz|YLz01Lo(U>VqnYtwxb;8(jiL}viLR)SqD1S78h0gQn!z`a63fA^_p)z^KP ztEWoPRNA)M6#TZ38nckHwYMK?4KOY25eQ8(I4au(9s{?_>Cc9%ou8 g;6-80UjHZq_6AA&%?!# )+k~HL-Q{61=-P7R|cnW{4^}J*Ip`Qny4}|wx{Lt-# zv@d(rPwM@w{`K8%RH>Q!0zS#ccQaT_K7bmeOFf0XQ-J%lM1gfR-7dyroZ15Ln}~6Z z+D-C)uLf3?^(2{GCdC`pY!nGL@6XgJmh;&3u*I_BAKQNuaO0o>=Os;z9OFp+aGa0| utOA=c*tsO*3>act2d+oSe5`0S0Q>=5%9G-Z;1P!a0000 Date: Sat, 7 Jun 2014 08:31:34 +0100 Subject: [PATCH 031/134] resize a couple of icons --- social/xmpp/icons/xmpp.png | Bin 2358 -> 1042 bytes time/icons/sun.png | Bin 383 -> 581 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/social/xmpp/icons/xmpp.png b/social/xmpp/icons/xmpp.png index 57e43fc43f1ed502352dcb68468a080d340483dd..636847e38011ca4a10791d5457c84a5da2f63bf1 100644 GIT binary patch delta 997 zcmV {>iD O>$jBD}^0l=!EG#ViXW@;Fjllct zmDm-((B|gm6(ZU;vwb33nw_1!69mDpmlgNkKhtivuZ3aw9uZwL;Ce7NHg-TnzY)<3 zMNxdJs)r)-9e_IkR*C2yGwUGHgM$N%j*gC**@BtPsp{PL`1n+w=V0cNe~3;90NU;L z=KvN(1QQbz6a)d7xiqsb5iK(F_k$o=mIY?E1K ;5=1GjqfMKtx}jUPz0g001T;REe!Y0OuTn zAb_ei%*=?0i3mxO7!eUOf3E@nx7%&BTCGE7zRk>>=Q+#_%#7;8X9q!shlio6PgMn( znNhu7*J?F(r>CcX>U28bR_nA-Rs8@!EF$K;w@SwVJg2I)K_DWUH!~0s13;1_#LNU> z5dfy9rojE=R;#rG;A0{pGlPg&mHe`*HqC4h=S2VtK#53`Bmpyje_N~7e&{FgnW~n| ztea&Smt{$+ssM(V`KA6pdSF+ lfQ>ycz)l#UJn4!?RH=9^?K%<6IB%v zF%h|WW@n8%=St_Ce`Z-GaU5Hx)A{7^@Q`+QcQ3YuZnp~n2*dELD2mK`FM3M4TbAYH zWm)ziOIengb55Oe7KY(hM@L6P|JZ-}t#&${caM*cwJb|fRTGh072rmeWtL@`I_E5k zqTAcs+x)MMt`7>s@QpN0V-Zm^v!W>8anAkWoHOT~#Bu!LfAaD&@9*zl&QbUF_E34- z^Cu@KTX~*~nOW7v-6)C{0U(a!%g=-~P4C~waeUKzuX&!wWm#HTmLHi}tvbk;nh6i? zqASk1_p>b9@!qdH=jQS}|5`*s5m{B$tAD3Q7l6jh>`fw?0MG^S&Ct-${b80Q$<=zj z{+gLxuhnYzI{ lU6i=pU+Nd1-A&x%*y%%Jh T8Bw3!00000NkvXXu0mjfklEJR delta 2323 zcmV+u3GDWg2(}U-iBL{Q4GJ0x0000DNk~Le0000m0000o2nGNE02<0zjFBNdf87QM z6(cr7e*1j@00_28L_t(&-tAdkj9pa~{=U7>J@-zfv?HB6oj?17I6!GDwuX@MVqyUy zS}BBRh$f;Bs4>LogFYDI3kh$=gcu(HL0>e8U=v{~wrGo}p-`*|w6>N?JA 1q-%3fAPc #+qP{3Q54-ALiltX#{-g )&>2E6yz4h|0POVe~O zfamM=`kwdF=rm1N0@wgxaAag;<>=_>)ggq{Bn?TB^lbo*M&qcY{Q#C1H~X_J>yM)7 z7D)$ U)S@BJPCZx~}vkWA-l`1JI2!x(c# z2w@F?Pmo*>pj%Q5V4=0v#Bq#zy^bh~%GVB)JXQrTT&vagk!?l|f5sTrYBfqSk`_yX zF{T?pFMuln93}azq+bKrKW7>wmrJ@2K) ?^!E0O slI#M|IS&e5AgQ<1`L=W0AuDUGLI`azl8yn`-qX`F^$q}K0R-?!!Lw}! zDw0`cGMC8&e;@|1cpkgIRMHg{kF%P<#uyl5RCs?3z%!DLS9P2Mpr@xNIOn!Y+9N3` zya4Y#oO7oDsN~8LNekx)U `n3zD(75o6euG8r;XIbO`$#0XKDtnSV&yi*A%_uo~ zAcXLxGqfC4?q`xDmrGg!z*K8X(K;y4b4F1Fe@R~_`PXK%sW|~?Hk;mB`>LdGl05F5 zL!RfMbaxp>0BR%$C9U(`$7j;n(a|AE_W<~C*|HQ3n&LQC2*IRjnvi^q y)GNp_ya1Iqw>X2x@})|PqZy!Sgv{@57v zf3LIIXU-*Fmo8m8Me;!aPfBuWn$kIk5JJ1`ONsz&B6-zWj*Xj04gj!~Vn_gNwOUBi z^yPvwcXf4jh4TUc0J^%m4v>6M(yyFzELo{+HHyP_Q_^R>_sdViY%56KO|o7w9+H@4 z8S^}U%{lj2y tN%Xa5^f1Xx$ zvh>8QB){do@0ggFFp{n(xv7{oRNHe0;Egm*zaK*QS$}{3c^%c9RfdO$Zy6mOeQIK2 zVmiyRP=u2&3iX@b`){;bt-&No9!ipAJV_E2pU`Tx!qn8%?#ao?uk78s_p gW%+-K-kJb+z zIuzAvweC2MKi|>OabFZgmqbw%NScCaT6vy#6l`UTF=>({fA-#g#~AbSqD7063u1aa zJUrYzK0bc)`1tsisi~=xS(cSOpRz1dp64OY^WEd)<6j#a8(VwezyW(ff6ng5#>T$e zYPAk$StjRP`{TWr_kPQsJ$n|P&-KjtQk16Y!Zc0S)$8?-SZg~Arg_7AzrS+M9ayz$ z)rO*xJAePs%vD;gmLb_F`kD;@zDRO4fG(0F03LVF9gm{uE^F;_k^#Uz0NY4D4B!ZW zq#TvM=PYE5=>u@Rq#KHzA|NR?lwb~uVn2#0> z-9Z3P7anl{{z3BC%sJ_K1(0P~kEAb1`gk!vdI`YpTCMhX09i4`X+C4vS!)+3NwO-A z _0RU98ae7Mos+4;eGz1{_2 tvG+a$aL^d@R;^a^xF{FpqWpizzX2O#aoGg`T1Ef>002ovPDHLkV1lu!R7d~- diff --git a/time/icons/sun.png b/time/icons/sun.png index c4918e5621be46bb2484c7430a498b7e17341648..6e4daba46c8be583daf855f64ce7dc586c9ab304 100644 GIT binary patch delta 552 zcmV+@0@wZj0>uO&iBL{Q4GJ0x0000DNk~Le0000P0000P2nGNE0L1BqW04^i3I729 z0RN!9r<0LD7k>Z;bV*G`2i^t-3NRV?ab{)!00G5GL_t(Y$L*CdYg9oLh0j@{7&IU# zTBQ*JVqqbYE@0s=NMS@Q1S< MeBBqGg*`@FYBoHDJJ5!1QK?7C`=d;+^ zWqeuLeVa eNI>mpDB%1(9Hrx1hihuL7BwN7KG4{V3@5xCd-LQQZ z=q9;+l57D3b4liab3+o_?*U0d(sq&uC*XMn9N9hsUe_caY^!`@`}veve3bOWHh^q1 zBmwL`%TK_Pt^<#oo7g^(v?J+YgeYE0x H*kqnFT (NHOG1(! za0u)Hi<4}!FnAjCPO@5+;TQ@bz-kdpo%zDB> v*i#sN^vtybZ)j)>^CIM1KW}=*q)Vi&n5DC z+gBug2QEw6E#2xiebVRiE!(@}gwSP5l OWbM%V&K60000 <{9 z008+zyMK{D7k>c~Nkl u_ZN24M*XsaUJ@(vHx>>m^hO zCE+I+IQY9DA>uqg$5t>#Q4~c{3{nG- sTTc8D`RK~fHllkNAh zvC>F56pOj*0iH_E`s|W$ClqJ6CzjMyQpoHwNt_*Df`4}Ihtfh0nZTPTN-`r^k!(qJ zB){(2y7$>0t(lX2a2^kmxs;HK>!_xhqsNR_1{Tyzqn;At6*Cr;;7HUV-v{uy(Vuu% z^XG=uz60n&v&&AjTC?%dYho>r(B;at=Ubo`t^hvKp@#wPRUtGXiZxe=Qb `0s#Z zXN BVxuga;!D2k#eiW1=m$I8L_cFqeA00000NkvXXu0mjfO&gcm From 94d19b2a41b77d4f1a3141de2d20a02720469587 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 9 Jun 2014 08:12:34 +0100 Subject: [PATCH 032/134] Update rawserial (roughly) in line with main serial node. (Now has binary and timout modes) --- io/rawserial/26-rawserial.html | 42 ++++++++++++++++++++++----- io/rawserial/26-rawserial.js | 52 +++++++++++++++++++++++++++------- 2 files changed, 77 insertions(+), 17 deletions(-) diff --git a/io/rawserial/26-rawserial.html b/io/rawserial/26-rawserial.html index c7b7c362..5bf3a7e3 100644 --- a/io/rawserial/26-rawserial.html +++ b/io/rawserial/26-rawserial.html @@ -16,17 +16,43 @@ diff --git a/io/rawserial/26-rawserial.js b/io/rawserial/26-rawserial.js index da53dfe8..11762005 100644 --- a/io/rawserial/26-rawserial.js +++ b/io/rawserial/26-rawserial.js @@ -29,25 +29,57 @@ if (!plat.match(/^win/)) { function RawSerialInNode(n) { RED.nodes.createNode(this,n); this.port = n.port; - this.split = n.split||null; - if (this.split == '\\n') this.split = "\n"; - if (this.split == '\\r') this.split = "\r"; + this.splitc = n.splitc||null; + this.out = n.out||"char"; + this.bin = n.bin||false; + if (this.splitc == '\\n') this.splitc = "\n"; + if (this.splitc == '\\r') this.splitc = "\r"; + if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } + console.log("Split is",this.out,this.splitc); var node = this; var setupSerial = function() { node.inp = fs.createReadStream(pre+node.port); node.log("opened "+pre+node.port); - node.inp.setEncoding('utf8'); + node.tout = null; var line = ""; + var buf = new Buffer(32768); + var i = 0; node.inp.on('data', function (data) { - if (node.split != null) { - if (data == node.split) { - node.send({payload:line}); - line = ""; + for (var z = 0; z < data.length; z++) { + if ((node.out === "time") && (node.splitc != 0)) { + if (node.tout) { + i += 1; + buf[i] = data[z]; + } + else { + node.tout = setTimeout(function () { + node.tout = null; + var m = new Buffer(i+1); + buf.copy(m,0,0,i+1); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload": m}); + }, node.splitc); + i = 0; + buf[0] = data[z]; + } + } + else if ((node.out == "char") && (node.splitc != null)) { + buf[i] = data[z]; + i += 1; + if ((data[z] === node.splitc.charCodeAt(0)) || (i === 32768)) { + var m = new Buffer(i); + buf.copy(m,0,0,i); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload":m}); + i = 0; + } + } + else { + if (node.bin !== "true") { node.send({"payload": String.fromCharCode(data[z])}); } + else { node.send({"payload": new Buffer([data[z]])});} } - else { line += data; } } - else { node.send({payload:data}); } }); //node.inp.on('end', function (error) {console.log("End", error);}); node.inp.on('close', function (error) { From 9b487098ae5a0c77350876f366ab8eabc2f8e359 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 10 Jun 2014 22:28:06 +0100 Subject: [PATCH 033/134] Tidy up rawserial node logging --- io/rawserial/26-rawserial.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/io/rawserial/26-rawserial.js b/io/rawserial/26-rawserial.js index 11762005..0a991fed 100644 --- a/io/rawserial/26-rawserial.js +++ b/io/rawserial/26-rawserial.js @@ -35,12 +35,11 @@ function RawSerialInNode(n) { if (this.splitc == '\\n') this.splitc = "\n"; if (this.splitc == '\\r') this.splitc = "\r"; if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } - console.log("Split is",this.out,this.splitc); var node = this; var setupSerial = function() { node.inp = fs.createReadStream(pre+node.port); - node.log("opened "+pre+node.port); + node.log("open "+pre+node.port); node.tout = null; var line = ""; var buf = new Buffer(32768); @@ -83,14 +82,14 @@ function RawSerialInNode(n) { }); //node.inp.on('end', function (error) {console.log("End", error);}); node.inp.on('close', function (error) { - util.log("[rawserial] "+node.port+" closed"); + node.log(node.port+" closed"); node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); }); node.inp.on('error', function(error) { - if (error.code == "ENOENT") { util.log("[rawserial] port "+node.port+" not found"); } - else { util.log("[rawserial] "+node.port+" error "+error); } + if (error.code == "ENOENT") { node.log(node.port+" not found"); } + else { node.log(node.port+" error "+error); } node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); @@ -119,18 +118,18 @@ function RawSerialOutNode(n) { node.oup.write(msg.payload); } }); - node.oup.on('open', function (error) { util.log("[rawserial] opened "+node.port); }); - node.oup.on('end', function (error) { console.log("End",error); }); + node.oup.on('open', function (error) { node.log("opened "+node.port); }); + node.oup.on('end', function (error) { node.log("end :"+error); }); node.oup.on('close', function (error) { - util.log("[rawserial] "+node.port+" closed"); + node.log(node.port+" closed"); node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); }); node.oup.on('error', function(error) { - if (error.code == "EACCES") { util.log("[rawserial] can't access port "+node.port); } - else if (error.code == "EIO") { util.log("[rawserial] can't write to port "+node.port); } - else { util.log("[rawserial] "+node.port+" error "+error); } + if (error.code == "EACCES") { node.log("can't access port "+node.port); } + else if (error.code == "EIO") { node.log("can't write to port "+node.port); } + else { node.log(node.port+" error "+error); } node.tout = setTimeout(function() { setupSerial(); },settings.serialReconnectTime); From 62956b0bb8dbb0655574024b6bccf3d606a48f71 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 28 Jun 2014 23:34:59 +0100 Subject: [PATCH 034/134] Update node-red-nodes social nodes to use strict and pass jshint scan --- social/nma/57-nma.js | 114 ++++++------- social/notify/57-notify.js | 44 ++--- social/prowl/57-prowl.js | 162 ++++++++++--------- social/pushbullet/57-pushbullet.js | 176 ++++++++++---------- social/pusher/114-pusher.js | 249 ++++++++++++++--------------- social/pushover/57-pushover.js | 170 ++++++++++---------- 6 files changed, 462 insertions(+), 453 deletions(-) diff --git a/social/nma/57-nma.js b/social/nma/57-nma.js index 2c1e517e..00f8ad6d 100644 --- a/social/nma/57-nma.js +++ b/social/nma/57-nma.js @@ -14,68 +14,70 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var nma = require('nma'); -var util = require('util'); +module.exports = function(RED) { + "use strict"; + var nma = require('nma'); + var util = require('util'); -function NMANode(n) { - RED.nodes.createNode(this,n); - this.title = n.title; - var credentials = RED.nodes.getCredentials(n.id); - if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } - else { this.error("No NMA API key set"); } - var node = this; - this.on("input",function(msg) { - var titl = this.title||msg.topic||"Node-RED"; - if (typeof(msg.payload) === 'object') { - msg.payload = JSON.stringify(msg.payload); - } - else { msg.payload = msg.payload.toString(); } - if (node.pushkey) { - try { - nma(node.pushkey, "Node-RED", titl, msg.payload, 0 ); - } catch (e) { - node.warn("NMA error: "+ e); + function NMANode(n) { + RED.nodes.createNode(this,n); + this.title = n.title; + var credentials = RED.nodes.getCredentials(n.id); + if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } + else { this.error("No NMA API key set"); } + var node = this; + this.on("input",function(msg) { + var titl = this.title||msg.topic||"Node-RED"; + if (typeof(msg.payload) === 'object') { + msg.payload = JSON.stringify(msg.payload); } - } - else { - node.warn("NMA credentials not set."); - } - }); -} - -RED.nodes.registerType("nma",NMANode); - -var querystring = require('querystring'); - -RED.httpAdmin.get('/nma/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!="")})); - } else { - res.send(JSON.stringify({})); + else { msg.payload = msg.payload.toString(); } + if (node.pushkey) { + try { + nma(node.pushkey, "Node-RED", titl, msg.payload, 0 ); + } catch (e) { + node.warn("NMA error: "+ e); + } + } + else { + node.warn("NMA credentials not set."); + } + }); } -}); -RED.httpAdmin.delete('/nma/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); + RED.nodes.registerType("nma",NMANode); -RED.httpAdmin.post('/nma/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; - }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.pushkey == "") { - delete credentials.pushkey; + var querystring = require('querystring'); + + RED.httpAdmin.get('/nma/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")})); } else { - credentials.pushkey = newCreds.pushkey||credentials.pushkey; + res.send(JSON.stringify({})); } - RED.nodes.addCredentials(req.params.id,credentials); + }); + + RED.httpAdmin.delete('/nma/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/nma/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.pushkey === "") { + delete credentials.pushkey; + } else { + credentials.pushkey = newCreds.pushkey||credentials.pushkey; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); +} diff --git a/social/notify/57-notify.js b/social/notify/57-notify.js index b36d6b82..764effb7 100644 --- a/social/notify/57-notify.js +++ b/social/notify/57-notify.js @@ -14,26 +14,28 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var growl = require('growl'); -var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png"; +module.exports = function(RED) { + "use strict"; + var growl = require('growl'); + var imagefile = process.env.NODE_RED_HOME+"/public/node-red.png"; -function NotifyNode(n) { - RED.nodes.createNode(this,n); - this.title = n.title; - var node = this; - this.on("input",function(msg) { - var titl = this.title || msg.topic; - if (typeof(msg.payload) == 'object') { - msg.payload = JSON.stringify(msg.payload); - } - if (typeof(titl) != 'undefined') { - growl(msg.payload, { title: titl, image: imagefile }); - } - else { - growl(msg.payload, { image: imagefile }); - } - }); + function NotifyNode(n) { + RED.nodes.createNode(this,n); + this.title = n.title; + var node = this; + this.on("input",function(msg) { + var titl = this.title || msg.topic; + if (typeof(msg.payload) == 'object') { + msg.payload = JSON.stringify(msg.payload); + } + if (typeof(titl) != 'undefined') { + growl(msg.payload, { title: titl, image: imagefile }); + } + else { + growl(msg.payload, { image: imagefile }); + } + }); + } + + RED.nodes.registerType("notify",NotifyNode); } - -RED.nodes.registerType("notify",NotifyNode); diff --git a/social/prowl/57-prowl.js b/social/prowl/57-prowl.js index efe9117c..184664d9 100644 --- a/social/prowl/57-prowl.js +++ b/social/prowl/57-prowl.js @@ -14,97 +14,99 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var Prowl = require('node-prowl'); -var util = require('util'); +module.exports = function(RED) { + "use strict"; + var Prowl = require('node-prowl'); + var util = require('util'); -// Either add a line like this to settings.js -// prowl: {prowlkey:'My-API-KEY'}, -// or create pushkey.js in dir ABOVE node-red, it just needs to be like -// module.exports = {prowlkey:'My-API-KEY'} + // Either add a line like this to settings.js + // prowl: {prowlkey:'My-API-KEY'}, + // or create pushkey.js in dir ABOVE node-red, it just needs to be like + // module.exports = {prowlkey:'My-API-KEY'} -try { - var pushkeys = RED.settings.prowl || require(process.env.NODE_RED_HOME+"/../pushkey.js"); -} -catch(err) { } - -function ProwlNode(n) { - RED.nodes.createNode(this,n); - this.title = n.title; - this.priority = parseInt(n.priority); - if (this.priority > 2) this.priority = 2; - if (this.priority < -2) this.priority = -2; - var credentials = RED.nodes.getCredentials(n.id); - if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } - else { - if (pushkeys) { this.pushkey = pushkeys.prowlkey; } - else { this.error("No Prowl credentials set."); } + try { + var pushkeys = RED.settings.prowl || require(process.env.NODE_RED_HOME+"/../pushkey.js"); } - this.prowl = false; - if (this.pushkey) { this.prowl = new Prowl(this.pushkey); } - var node = this; + catch(err) { } - this.on("input",function(msg) { - var titl = this.title||msg.topic||"Node-RED"; - var pri = msg.priority||this.priority; - if (typeof(msg.payload) === 'object') { - msg.payload = JSON.stringify(msg.payload); + function ProwlNode(n) { + RED.nodes.createNode(this,n); + this.title = n.title; + this.priority = parseInt(n.priority); + if (this.priority > 2) { this.priority = 2; } + if (this.priority < -2) { this.priority = -2; } + var credentials = RED.nodes.getCredentials(n.id); + if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } + else { + if (pushkeys) { this.pushkey = pushkeys.prowlkey; } + else { this.error("No Prowl credentials set."); } } - else { msg.payload = msg.payload.toString(); } - if (node.pushkey) { - try { - node.prowl.push(msg.payload, titl, { priority: pri }, function(err, remaining) { - if (err) node.error(err); - node.log( remaining + ' calls to Prowl api during current hour.' ); - }); + this.prowl = false; + if (this.pushkey) { this.prowl = new Prowl(this.pushkey); } + var node = this; + + this.on("input",function(msg) { + var titl = this.title||msg.topic||"Node-RED"; + var pri = msg.priority||this.priority; + if (typeof(msg.payload) === 'object') { + msg.payload = JSON.stringify(msg.payload); } - catch (err) { - node.error(err); + else { msg.payload = msg.payload.toString(); } + if (node.pushkey) { + try { + node.prowl.push(msg.payload, titl, { priority: pri }, function(err, remaining) { + if (err) { node.error(err); } + node.log( remaining + ' calls to Prowl api during current hour.' ); + }); + } + catch (err) { + node.error(err); + } } + else { + node.warn("Prowl credentials not set."); + } + }); + } + RED.nodes.registerType("prowl",ProwlNode); + + var querystring = require('querystring'); + + RED.httpAdmin.get('/prowl/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=="")})); + } + else if (pushkeys && pushkeys.prowlkey) { + RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true}); + credentials = RED.nodes.getCredentials(req.params.id); + res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!==""),global:credentials.global})); } else { - node.warn("Prowl credentials not set."); + res.send(JSON.stringify({})); } }); -} -RED.nodes.registerType("prowl",ProwlNode); -var querystring = require('querystring'); - -RED.httpAdmin.get('/prowl/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!="")})); - } - else if (pushkeys && pushkeys.prowlkey) { - RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.prowlkey,global:true}); - credentials = RED.nodes.getCredentials(req.params.id); - res.send(JSON.stringify({hasPassword:(credentials.pushkey&&credentials.pushkey!=""),global:credentials.global}));; - } - else { - res.send(JSON.stringify({})); - } -}); - -RED.httpAdmin.delete('/prowl/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); - -RED.httpAdmin.post('/prowl/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; - }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.pushkey == "") { - delete credentials.pushkey; - } else { - credentials.pushkey = newCreds.pushkey||credentials.pushkey; - } - RED.nodes.addCredentials(req.params.id,credentials); + RED.httpAdmin.delete('/prowl/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/prowl/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.pushkey === "") { + delete credentials.pushkey; + } else { + credentials.pushkey = newCreds.pushkey||credentials.pushkey; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); +} diff --git a/social/pushbullet/57-pushbullet.js b/social/pushbullet/57-pushbullet.js index 92f497fb..d8858330 100644 --- a/social/pushbullet/57-pushbullet.js +++ b/social/pushbullet/57-pushbullet.js @@ -14,105 +14,107 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var PushBullet = require('pushbullet'); -var util = require('util'); +module.exports = function(RED) { + "use strict"; + var PushBullet = require('pushbullet'); + var util = require('util'); -// Either create pushkey.js in dir ABOVE node-red, it just needs to be like -// module.exports = {pushbullet:'My-API-KEY', deviceid:'12345'} -// or set them per node in the edit dialog + // Either create pushkey.js in dir ABOVE node-red, it just needs to be like + // module.exports = {pushbullet:'My-API-KEY', deviceid:'12345'} + // or set them per node in the edit dialog -try { - var pushkeys = RED.settings.pushbullet || require(process.env.NODE_RED_HOME+"/../pushkey.js"); -} -catch(err) { - //util.log("[57-pushbullet.js] Warning: Failed to load global PushBullet credentials"); -} - -function PushbulletNode(n) { - RED.nodes.createNode(this,n); - this.title = n.title; - var credentials = RED.nodes.getCredentials(n.id); - if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } - else { - if (pushkeys) { this.pushkey = pushkeys.pushbullet; } - else { this.error("No Pushbullet API key set"); } + try { + var pushkeys = RED.settings.pushbullet || require(process.env.NODE_RED_HOME+"/../pushkey.js"); } - if ((credentials) && (credentials.hasOwnProperty("deviceid"))) { this.deviceid = credentials.deviceid; } - else { - if (pushkeys) { this.deviceid = pushkeys.deviceid; } - else { this.warn("No deviceid set"); } + catch(err) { + //util.log("[57-pushbullet.js] Warning: Failed to load global PushBullet credentials"); } - this.pusher = new PushBullet(this.pushkey); - var node = this; - this.on("input",function(msg) { - var titl = node.title||msg.topic||"Node-RED"; - var dev = msg.deviceid||node.deviceid; - if (typeof(msg.payload) === 'object') { - msg.payload = JSON.stringify(msg.payload); + function PushbulletNode(n) { + RED.nodes.createNode(this,n); + this.title = n.title; + var credentials = RED.nodes.getCredentials(n.id); + if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } + else { + if (pushkeys) { this.pushkey = pushkeys.pushbullet; } + else { this.error("No Pushbullet API key set"); } } - else { msg.payload = msg.payload.toString(); } - if (node.pushkey && dev) { - try { - if (!isNaN(dev)) { dev = Number(dev); } - node.pusher.note(dev, titl, msg.payload, function(err, response) { - if (err) node.error("Pushbullet error: "+err); - //console.log(response); - }); + if ((credentials) && (credentials.hasOwnProperty("deviceid"))) { this.deviceid = credentials.deviceid; } + else { + if (pushkeys) { this.deviceid = pushkeys.deviceid; } + else { this.warn("No deviceid set"); } + } + this.pusher = new PushBullet(this.pushkey); + var node = this; + + this.on("input",function(msg) { + var titl = node.title||msg.topic||"Node-RED"; + var dev = msg.deviceid||node.deviceid; + if (typeof(msg.payload) === 'object') { + msg.payload = JSON.stringify(msg.payload); } - catch (err) { - node.error(err); + else { msg.payload = msg.payload.toString(); } + if (node.pushkey && dev) { + try { + if (!isNaN(dev)) { dev = Number(dev); } + node.pusher.note(dev, titl, msg.payload, function(err, response) { + if (err) { node.error("Pushbullet error: "+err); } + //console.log(response); + }); + } + catch (err) { + node.error(err); + } } + else { + node.warn("Pushbullet credentials not set/found. See node info."); + } + }); + } + RED.nodes.registerType("pushbullet",PushbulletNode); + + var querystring = require('querystring'); + + RED.httpAdmin.get('/pushbullet/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")})); + } + else if (pushkeys && pushkeys.pushbullet && pushkeys.deviceid) { + RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.pushbullet,deviceid:pushkeys.deviceid,global:true}); + credentials = RED.nodes.getCredentials(req.params.id); + res.send(JSON.stringify({deviceid:credentials.deviceid,global:credentials.global,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")})); } else { - node.warn("Pushbullet credentials not set/found. See node info."); + res.send(JSON.stringify({})); } }); -} -RED.nodes.registerType("pushbullet",PushbulletNode); -var querystring = require('querystring'); - -RED.httpAdmin.get('/pushbullet/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!="")})); - } - else if (pushkeys && pushkeys.pushbullet && pushkeys.deviceid) { - RED.nodes.addCredentials(req.params.id,{pushkey:pushkeys.pushbullet,deviceid:pushkeys.deviceid,global:true}); - credentials = RED.nodes.getCredentials(req.params.id); - res.send(JSON.stringify({deviceid:credentials.deviceid,global:credentials.global,hasPassword:(credentials.pushkey&&credentials.pushkey!="")}));; - } - else { - res.send(JSON.stringify({})); - } -}); - -RED.httpAdmin.delete('/pushbullet/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); - -RED.httpAdmin.post('/pushbullet/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; - }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.deviceid == null || newCreds.deviceid == "") { - delete credentials.deviceid; - } else { - credentials.deviceid = newCreds.deviceid; - } - if (newCreds.pushkey == "") { - delete credentials.pushkey; - } else { - credentials.pushkey = newCreds.pushkey||credentials.pushkey; - } - RED.nodes.addCredentials(req.params.id,credentials); + RED.httpAdmin.delete('/pushbullet/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/pushbullet/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.deviceid === null || newCreds.deviceid === "") { + delete credentials.deviceid; + } else { + credentials.deviceid = newCreds.deviceid; + } + if (newCreds.pushkey === "") { + delete credentials.pushkey; + } else { + credentials.pushkey = newCreds.pushkey||credentials.pushkey; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); +} diff --git a/social/pusher/114-pusher.js b/social/pusher/114-pusher.js index e9908df3..13bf5268 100644 --- a/social/pusher/114-pusher.js +++ b/social/pusher/114-pusher.js @@ -17,142 +17,141 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ +module.exports = function(RED) { + "use strict"; + var Pusher = require('pusher'); + var PusherClient = require('pusher-client'); -var Pusher = require('pusher'); -var PusherClient = require('pusher-client'); + //node for subscribing to an event/channel + function PusherNode(n) { + // Create a RED node + RED.nodes.createNode(this,n); -// Require main module -var RED = require(process.env.NODE_RED_HOME+"/red/red"); + var node = this; + var credentials = RED.nodes.getCredentials(n.id); -//node for subscribing to an event/channel - function PusherNode(n) { - // Create a RED node - RED.nodes.createNode(this,n); + if ((credentials) && (credentials.hasOwnProperty("pusherappkey_sub"))) { this.appkey = credentials.pusherappkey_sub; } + else { this.error("No Pusher app key set for input node"); } - var node = this; - var credentials = RED.nodes.getCredentials(n.id); + //get parameters from user + this.channel = n.channel; + this.eventname = n.eventname; - if ((credentials) && (credentials.hasOwnProperty("pusherappkey_sub"))) { this.appkey = credentials.pusherappkey_sub; } - else { this.error("No Pusher app key set for input node"); } + //create a subscription to the channel and event defined by user + var socket = new PusherClient(''+this.appkey); + var my_channel = socket.subscribe(''+this.channel); + socket.bind(''+this.eventname, + function(data) { + var msg = {}; + if (data.hasOwnProperty("payload")) { msg.payload = data.payload; } + else { msg.payload = data; } + node.send(msg); + } + ); - //get parameters from user - this.channel = n.channel; - this.eventname = n.eventname; - - //create a subscription to the channel and event defined by user - var socket = new PusherClient(''+this.appkey); - var my_channel = socket.subscribe(''+this.channel); - socket.bind(''+this.eventname, - function(data) { - var msg = {}; - if (data.hasOwnProperty("payload")) { msg.payload = data.payload; } - else { msg.payload = data; } - node.send(msg); - } - ); - - this.on("close", function() { - socket.disconnect(); - }); -} - -//Node for sending Pusher events -function PusherNodeSend(n) { - // Create a RED node - RED.nodes.createNode(this,n); - - var node = this; - - var credentials = RED.nodes.getCredentials(n.id); - - if ((credentials) && (credentials.hasOwnProperty("pusherappid"))) { this.appid = credentials.pusherappid; } - else { this.error("No Pusher api token set"); } - if ((credentials) && (credentials.hasOwnProperty("pusherappsecret"))) { this.appsecret = credentials.pusherappsecret; } - else { this.error("No Pusher user secret set"); } - if ((credentials) && (credentials.hasOwnProperty("pusherappkey"))) { this.appkey = credentials.pusherappkey; } - else { this.error("No Pusher user key set"); } - - //get parameters from user - this.channel = n.channel; - this.eventname = n.eventname; - - var pusher = new Pusher({ - appId: this.appid, - key: this.appkey, - secret: this.appsecret - }); - - this.on("input", function(msg){ - pusher.trigger(this.channel, this.eventname, { - "payload": msg.payload + this.on("close", function() { + socket.disconnect(); }); - }); - - this.on("close", function() { - }); - } - - //debugging on the output: -var displayResult = function(result) { - node.log(result); -}; - -var displayError = function(err) { - node.log("Error: "+err); -}; - -RED.nodes.registerType("pusher in",PusherNode); -RED.nodes.registerType("pusher out",PusherNodeSend); - -var querystring = require('querystring'); - -RED.httpAdmin.get('/pusher/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({pusherappid:credentials.pusherappid,pusherappsecret:credentials.pusherappsecret, pusherappkey:credentials.pusherappkey, pusherappkey_sub:credentials.pusherappkey_sub})); - } else { - res.send(JSON.stringify({})); } -}); -RED.httpAdmin.delete('/pusher/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); + //Node for sending Pusher events + function PusherNodeSend(n) { + // Create a RED node + RED.nodes.createNode(this,n); -RED.httpAdmin.post('/pusher/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; + var node = this; + + var credentials = RED.nodes.getCredentials(n.id); + + if ((credentials) && (credentials.hasOwnProperty("pusherappid"))) { this.appid = credentials.pusherappid; } + else { this.error("No Pusher api token set"); } + if ((credentials) && (credentials.hasOwnProperty("pusherappsecret"))) { this.appsecret = credentials.pusherappsecret; } + else { this.error("No Pusher user secret set"); } + if ((credentials) && (credentials.hasOwnProperty("pusherappkey"))) { this.appkey = credentials.pusherappkey; } + else { this.error("No Pusher user key set"); } + + //get parameters from user + this.channel = n.channel; + this.eventname = n.eventname; + + var pusher = new Pusher({ + appId: this.appid, + key: this.appkey, + secret: this.appsecret + }); + + this.on("input", function(msg){ + pusher.trigger(this.channel, this.eventname, { + "payload": msg.payload + }); + }); + + this.on("close", function() { + }); + } + + //debugging on the output: + var displayResult = function(result) { + node.log(result); + }; + + var displayError = function(err) { + node.log("Error: "+err); + }; + + RED.nodes.registerType("pusher in",PusherNode); + RED.nodes.registerType("pusher out",PusherNodeSend); + + var querystring = require('querystring'); + + RED.httpAdmin.get('/pusher/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({pusherappid:credentials.pusherappid,pusherappsecret:credentials.pusherappsecret, pusherappkey:credentials.pusherappkey, pusherappkey_sub:credentials.pusherappkey_sub})); + } else { + res.send(JSON.stringify({})); + } }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.pusherappid == null || newCreds.pusherappid == "") { - delete credentials.pusherappid; - } else { - credentials.pusherappid = newCreds.pusherappid; - } - if (newCreds.pusherappkey == "") { - delete credentials.pusherappkey; - } else { - credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey; - } - - if (newCreds.pusherappsecret == "") { - delete credentials.pusherappsecret; - } else { - credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret; - } - - if (newCreds.pusherappkey_sub == "") { - delete credentials.pusherappkey_sub; - } else { - credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub; - } - - RED.nodes.addCredentials(req.params.id,credentials); + RED.httpAdmin.delete('/pusher/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/pusher/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + + if (newCreds.pusherappid === null || newCreds.pusherappid === "") { + delete credentials.pusherappid; + } else { + credentials.pusherappid = newCreds.pusherappid; + } + if (newCreds.pusherappkey === "") { + delete credentials.pusherappkey; + } else { + credentials.pusherappkey = newCreds.pusherappkey||credentials.pusherappkey; + } + + if (newCreds.pusherappsecret === "") { + delete credentials.pusherappsecret; + } else { + credentials.pusherappsecret = newCreds.pusherappsecret||credentials.pusherappsecret; + } + + if (newCreds.pusherappkey_sub === "") { + delete credentials.pusherappkey_sub; + } else { + credentials.pusherappkey_sub = newCreds.pusherappkey_sub||credentials.pusherappkey_sub; + } + + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); +} diff --git a/social/pushover/57-pushover.js b/social/pushover/57-pushover.js index ef2543db..d309260f 100644 --- a/social/pushover/57-pushover.js +++ b/social/pushover/57-pushover.js @@ -14,97 +14,99 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var PushOver = require('pushover-notifications'); -var util = require('util'); +module.exports = function(RED) { + "use strict"; + var PushOver = require('pushover-notifications'); + var util = require('util'); -function PushoverNode(n) { - RED.nodes.createNode(this,n); - this.title = n.title; - this.priority = n.priority; - var credentials = RED.nodes.getCredentials(n.id); - if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } - else { this.error("No Pushover api token set"); } - if ((credentials) && (credentials.hasOwnProperty("deviceid"))) { this.deviceid = credentials.deviceid; } - else { this.error("No Pushover user key set"); } - var pusher = false; - if (this.pushkey && this.deviceid) { - pusher = new PushOver({ - user: this.deviceid, - token: this.pushkey, - onerror: function(err) { - util.log('[57-pushover.js] Error: '+err); + function PushoverNode(n) { + RED.nodes.createNode(this,n); + this.title = n.title; + this.priority = n.priority; + var credentials = RED.nodes.getCredentials(n.id); + if ((credentials) && (credentials.hasOwnProperty("pushkey"))) { this.pushkey = credentials.pushkey; } + else { this.error("No Pushover api token set"); } + if ((credentials) && (credentials.hasOwnProperty("deviceid"))) { this.deviceid = credentials.deviceid; } + else { this.error("No Pushover user key set"); } + var pusher = false; + if (this.pushkey && this.deviceid) { + pusher = new PushOver({ + user: this.deviceid, + token: this.pushkey, + onerror: function(err) { + util.log('[57-pushover.js] Error: '+err); + } + }); + } + var node = this; + + this.on("input",function(msg) { + var titl = this.title || msg.topic || "Node-RED"; + var pri = this.priority || msg.priority || 0; + if (isNaN(pri)) {pri=0;} + if (pri > 2) {pri = 2;} + if (pri < -1) {pri = -1;} + if (typeof(msg.payload) === 'object') { + msg.payload = JSON.stringify(msg.payload); + } + else { msg.payload = msg.payload.toString(); } + if (pusher) { + var pushmsg = { + message: msg.payload, + title: titl, + priority: pri, + retry: 30, + expire: 600 + }; + //console.log("Sending",pushmsg); + pusher.send( pushmsg, function(err, response) { + if (err) { node.error("Pushover Error: "+err); } + //console.log(response); + }); + } + else { + node.warn("Pushover credentials not set."); } }); } - var node = this; + RED.nodes.registerType("pushover",PushoverNode); - this.on("input",function(msg) { - var titl = this.title || msg.topic || "Node-RED"; - var pri = this.priority || msg.priority || 0; - if (isNaN(pri)) {pri=0;} - if (pri > 2) {pri = 2;} - if (pri < -1) {pri = -1;} - if (typeof(msg.payload) === 'object') { - msg.payload = JSON.stringify(msg.payload); - } - else { msg.payload = msg.payload.toString(); } - if (pusher) { - var pushmsg = { - message: msg.payload, - title: titl, - priority: pri, - retry: 30, - expire: 600 - }; - //console.log("Sending",pushmsg); - pusher.send( pushmsg, function(err, response) { - if (err) node.error("Pushover Error: "+err); - //console.log(response); - }); - } - else { - node.warn("Pushover credentials not set."); + var querystring = require('querystring'); + + RED.httpAdmin.get('/pushover/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!=="")})); + } else { + res.send(JSON.stringify({})); } }); -} -RED.nodes.registerType("pushover",PushoverNode); -var querystring = require('querystring'); - -RED.httpAdmin.get('/pushover/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({deviceid:credentials.deviceid,hasPassword:(credentials.pushkey&&credentials.pushkey!="")})); - } else { - res.send(JSON.stringify({})); - } -}); - -RED.httpAdmin.delete('/pushover/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); - -RED.httpAdmin.post('/pushover/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; - }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.deviceid == null || newCreds.deviceid == "") { - delete credentials.deviceid; - } else { - credentials.deviceid = newCreds.deviceid; - } - if (newCreds.pushkey == "") { - delete credentials.pushkey; - } else { - credentials.pushkey = newCreds.pushkey||credentials.pushkey; - } - RED.nodes.addCredentials(req.params.id,credentials); + RED.httpAdmin.delete('/pushover/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/pushover/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.deviceid === null || newCreds.deviceid === "") { + delete credentials.deviceid; + } else { + credentials.deviceid = newCreds.deviceid; + } + if (newCreds.pushkey === "") { + delete credentials.pushkey; + } else { + credentials.pushkey = newCreds.pushkey||credentials.pushkey; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); +} From 9e0585a721ad8ca011ddfe1c84a96ae257d74e95 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 28 Jun 2014 23:35:21 +0100 Subject: [PATCH 035/134] Update node-red-nodes hardware nodes to use strict and pass jshint scan --- hardware/Pi/37-rpi-piface.js | 250 ++++++++++++++-------------- hardware/Pi/38-rpi-pibrella.js | 286 ++++++++++++++++---------------- hardware/Pi/78-ledborg.js | 80 ++++----- hardware/blink/76-blinkstick.js | 68 ++++---- hardware/blink/77-blink1.js | 121 +++++++------- hardware/digiRGB/78-digiRGB.js | 94 ++++++----- hardware/wemo/60-wemo.js | 78 ++++----- 7 files changed, 496 insertions(+), 481 deletions(-) diff --git a/hardware/Pi/37-rpi-piface.js b/hardware/Pi/37-rpi-piface.js index 17a1482f..6616d8da 100644 --- a/hardware/Pi/37-rpi-piface.js +++ b/hardware/Pi/37-rpi-piface.js @@ -14,138 +14,140 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var util = require("util"); -var exec = require('child_process').exec; -var fs = require('fs'); +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var exec = require('child_process').exec; + var fs = require('fs'); -if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - throw "Info : Ignoring Raspberry Pi specific node."; -} + if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi + throw "Info : Ignoring Raspberry Pi specific node."; + } -if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed - throw "Info : Can't find Raspberry Pi wiringPi gpio command."; -} + if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed + throw "Info : Can't find Raspberry Pi wiringPi gpio command."; + } -// Map names of pins to Gordon's gpio PiFace pin numbers -var pintable = { -// Physical : WiringPi - "Button S1":"200", - "Button S2":"201", - "Button S3":"202", - "Button S4":"203", - "Input 5":"204", - "Input 6":"205", - "Input 7":"206", - "Input 8":"207", - "Output0":"208", - "Output1":"209", - "Output2":"210", - "Output3":"211", - "Output4":"212", - "Output5":"213", - "Output6":"214", - "Output7":"215", - "LED 0 / Relay 0":"200", - "LED 1 / Relay 1":"201", - "LED 2":"202", - "LED 3":"203", - "LED 4":"204", - "LED 5":"205", - "LED 6":"206", - "LED 7":"207" -} -var tablepin = { -// WiringPi : Physical - "200":"S1", - "201":"S2", - "202":"S3", - "203":"S4", - "204":"I5", - "205":"I6", - "206":"I7", - "207":"I8", - "208":"O0", - "209":"O1", - "210":"O2", - "211":"O3", - "212":"O4", - "213":"O5", - "214":"O6", - "215":"O7", - "200":"L0", - "201":"L1", - "202":"L2", - "203":"L3", - "204":"L4", - "205":"L5", - "206":"L6", - "207":"L7" -} + // Map names of pins to Gordon's gpio PiFace pin numbers + var pintable = { + // Physical : WiringPi + "Button S1":"200", + "Button S2":"201", + "Button S3":"202", + "Button S4":"203", + "Input 5":"204", + "Input 6":"205", + "Input 7":"206", + "Input 8":"207", + "Output0":"208", + "Output1":"209", + "Output2":"210", + "Output3":"211", + "Output4":"212", + "Output5":"213", + "Output6":"214", + "Output7":"215", + "LED 0 / Relay 0":"200", + "LED 1 / Relay 1":"201", + "LED 2":"202", + "LED 3":"203", + "LED 4":"204", + "LED 5":"205", + "LED 6":"206", + "LED 7":"207" + } + var tablepin = { + // WiringPi : Physical + "200":"S1", + "201":"S2", + "202":"S3", + "203":"S4", + "204":"I5", + "205":"I6", + "206":"I7", + "207":"I8", + "208":"O0", + "209":"O1", + "210":"O2", + "211":"O3", + "212":"O4", + "213":"O5", + "214":"O6", + "215":"O7", + "200":"L0", + "201":"L1", + "202":"L2", + "203":"L3", + "204":"L4", + "205":"L5", + "206":"L6", + "207":"L7" + } -function PiFACEInNode(n) { - RED.nodes.createNode(this,n); - this.buttonState = -1; - this.pin = pintable[n.pin]; - this.intype = n.intype; - var node = this; - if (node.pin) { - exec("gpio -p mode "+node.pin+" "+node.intype, function(err,stdout,stderr) { - if (err) node.error(err); - else { - node._interval = setInterval( function() { - exec("gpio -p read "+node.pin, function(err,stdout,stderr) { - if (err) node.error(err); - else { - if (node.buttonState !== Number(stdout)) { - var previousState = node.buttonState; - node.buttonState = Number(stdout); - if (previousState !== -1) { - var msg = {topic:"piface/"+tablepin[node.pin], payload:node.buttonState}; - node.send(msg); + function PiFACEInNode(n) { + RED.nodes.createNode(this,n); + this.buttonState = -1; + this.pin = pintable[n.pin]; + this.intype = n.intype; + var node = this; + if (node.pin) { + exec("gpio -p mode "+node.pin+" "+node.intype, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + node._interval = setInterval( function() { + exec("gpio -p read "+node.pin, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + if (node.buttonState !== Number(stdout)) { + var previousState = node.buttonState; + node.buttonState = Number(stdout); + if (previousState !== -1) { + var msg = {topic:"piface/"+tablepin[node.pin], payload:node.buttonState}; + node.send(msg); + } } } - } - }); - }, 200); - } + }); + }, 200); + } + }); + } + else { + node.error("Invalid PiFACE pin: "+node.pin); + } + node.on("close", function() { + clearInterval(node._interval); }); } - else { - node.error("Invalid PiFACE pin: "+node.pin); + + function PiFACEOutNode(n) { + RED.nodes.createNode(this,n); + this.pin = pintable[n.pin]; + var node = this; + if (node.pin) { + node.on("input", function(msg) { + if (msg.payload === "true") { msg.payload = true; } + if (msg.payload === "false") { msg.payload = false; } + var out = Number(msg.payload); + if ((out === 0)|(out === 1)) { + exec("gpio -p write "+node.pin+" "+out, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } + else { node.warn("Invalid input - not 0 or 1"); } + }); + } + else { + node.error("Invalid PiFACE pin: "+node.pin); + } } - node.on("close", function() { - clearInterval(node._interval); + + + exec("gpio load spi",function(err,stdout,stderr) { + if (err) { + util.log('[37-rpi-piface.js] Error: "gpio load spi" command failed for some reason.'); + } + RED.nodes.registerType("rpi-piface in",PiFACEInNode); + RED.nodes.registerType("rpi-piface out",PiFACEOutNode); }); } - -function PiFACEOutNode(n) { - RED.nodes.createNode(this,n); - this.pin = pintable[n.pin]; - var node = this; - if (node.pin) { - node.on("input", function(msg) { - if (msg.payload === "true") msg.payload = true; - if (msg.payload === "false") msg.payload = false; - var out = Number(msg.payload); - if ((out == 0)|(out == 1)) { - exec("gpio -p write "+node.pin+" "+out, function(err,stdout,stderr) { - if (err) node.error(err); - }); - } - else node.warn("Invalid input - not 0 or 1"); - }); - } - else { - node.error("Invalid PiFACE pin: "+node.pin); - } -} - - -exec("gpio load spi",function(err,stdout,stderr) { - if (err) { - util.log('[37-rpi-piface.js] Error: "gpio load spi" command failed for some reason.'); - } - RED.nodes.registerType("rpi-piface in",PiFACEInNode); - RED.nodes.registerType("rpi-piface out",PiFACEOutNode); -}); diff --git a/hardware/Pi/38-rpi-pibrella.js b/hardware/Pi/38-rpi-pibrella.js index ad2c3339..eaa8c96e 100644 --- a/hardware/Pi/38-rpi-pibrella.js +++ b/hardware/Pi/38-rpi-pibrella.js @@ -14,159 +14,161 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var util = require("util"); -var exec = require('child_process').exec; -var fs = require('fs'); +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var exec = require('child_process').exec; + var fs = require('fs'); -if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - throw "Info : Ignoring Raspberry Pi specific node."; -} + if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi + throw "Info : Ignoring Raspberry Pi specific node."; + } -if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed - throw "Info : Can't find Raspberry Pi wiringPi gpio command."; -} + if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed + throw "Info : Can't find Raspberry Pi wiringPi gpio command."; + } -// Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) -var pintable = { -// Physical : WiringPi - "Amber LED":"0", - "Buzzer ":"1", - "Red LED":"2", - "Out E":"3", - "Out F":"4", - "Out G":"5", - "Out H":"6", - "Green LED":"7", - "In C":"10", - "In B":"11", - "In D":"12", - "In A":"13", - "Red Button":"14", -} -var tablepin = { -// WiringPi : Physical - "0":"Amber", - "1":"Buzzer", - "2":"Red", - "3":"E", - "4":"F", - "5":"G", - "6":"H", - "7":"Green", - "10":"C", - "11":"B", - "12":"D", - "13":"A", - "14":"R", -} + // Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) + var pintable = { + // Physical : WiringPi + "Amber LED":"0", + "Buzzer ":"1", + "Red LED":"2", + "Out E":"3", + "Out F":"4", + "Out G":"5", + "Out H":"6", + "Green LED":"7", + "In C":"10", + "In B":"11", + "In D":"12", + "In A":"13", + "Red Button":"14", + } + var tablepin = { + // WiringPi : Physical + "0":"Amber", + "1":"Buzzer", + "2":"Red", + "3":"E", + "4":"F", + "5":"G", + "6":"H", + "7":"Green", + "10":"C", + "11":"B", + "12":"D", + "13":"A", + "14":"R", + } -function PibrellaIn(n) { - RED.nodes.createNode(this,n); - this.buttonState = -1; - this.pin = pintable[n.pin]; - var node = this; + function PibrellaIn(n) { + RED.nodes.createNode(this,n); + this.buttonState = -1; + this.pin = pintable[n.pin]; + var node = this; - if (node.pin) { - exec("gpio mode "+node.pin+" in", function(err,stdout,stderr) { - if (err) node.error(err); - else { - node._interval = setInterval( function() { - exec("gpio read "+node.pin, function(err,stdout,stderr) { - if (err) node.error(err); - else { - if (node.buttonState !== Number(stdout)) { - var previousState = node.buttonState; - node.buttonState = Number(stdout); - if (previousState !== -1) { - var msg = {topic:"pibrella/"+tablepin[node.pin], payload:node.buttonState}; - node.send(msg); + if (node.pin) { + exec("gpio mode "+node.pin+" in", function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + node._interval = setInterval( function() { + exec("gpio read "+node.pin, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + if (node.buttonState !== Number(stdout)) { + var previousState = node.buttonState; + node.buttonState = Number(stdout); + if (previousState !== -1) { + var msg = {topic:"pibrella/"+tablepin[node.pin], payload:node.buttonState}; + node.send(msg); + } } } - } - }); - }, 200); - } - }); - } - else { - node.error("Invalid GPIO pin: "+node.pin); - } - - node.on("close", function() { - clearInterval(node._interval); - }); -} - -function PibrellaOut(n) { - RED.nodes.createNode(this,n); - this.pin = pintable[n.pin]; - var node = this; - - if (node.pin == "1") { - exec("gpio mode 1 pwm"); - process.nextTick(function() { - exec("gpio pwm-ms"); - node.on("input", function(msg) { - var out = Number(msg.payload); - if (out == 1) { // fixed buzz - exec("gpio pwm 1 511"); - exec("gpio pwmc 100"); - } - else if ((out >= 2) && (out <= 9999)) { // set buzz to a value - exec("gpio pwm 1 511"); - exec("gpio pwmc "+out); - } - else { exec("gpio pwm 1 0"); } // turn it off - }); - }); - } - else if (node.pin) { - process.nextTick(function() { - exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) { - if (err) node.error(err); - else { - node.on("input", function(msg) { - if (msg.payload === "true") msg.payload = true; - if (msg.payload === "false") msg.payload = false; - var out = Number(msg.payload); - if ((out == 0)|(out == 1)) { - exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) { - if (err) node.error(err); - }); - } - else node.warn("Invalid input - not 0 or 1"); - }); + }); + }, 200); } }); + } + else { + node.error("Invalid GPIO pin: "+node.pin); + } + + node.on("close", function() { + clearInterval(node._interval); }); } - else { - node.error("Invalid GPIO pin: "+node.pin); + + function PibrellaOut(n) { + RED.nodes.createNode(this,n); + this.pin = pintable[n.pin]; + var node = this; + + if (node.pin == "1") { + exec("gpio mode 1 pwm"); + process.nextTick(function() { + exec("gpio pwm-ms"); + node.on("input", function(msg) { + var out = Number(msg.payload); + if (out == 1) { // fixed buzz + exec("gpio pwm 1 511"); + exec("gpio pwmc 100"); + } + else if ((out >= 2) && (out <= 9999)) { // set buzz to a value + exec("gpio pwm 1 511"); + exec("gpio pwmc "+out); + } + else { exec("gpio pwm 1 0"); } // turn it off + }); + }); + } + else if (node.pin) { + process.nextTick(function() { + exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + node.on("input", function(msg) { + if (msg.payload === "true") { msg.payload = true; } + if (msg.payload === "false") { msg.payload = false; } + var out = Number(msg.payload); + if ((out === 0)|(out === 1)) { + exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } + else { node.warn("Invalid input - not 0 or 1"); } + }); + } + }); + }); + } + else { + node.error("Invalid GPIO pin: "+node.pin); + } + + node.on("close", function() { + exec("gpio mode "+node.pin+" in"); + }); } - node.on("close", function() { - exec("gpio mode "+node.pin+" in"); - }); + //exec("gpio mode 0 out",function(err,stdout,stderr) { + //if (err) { + //util.log('[36-rpi-gpio.js] Error: "gpio" command failed for some reason.'); + //} + //exec("gpio mode 1 out"); + //exec("gpio mode 2 out"); + //exec("gpio mode 3 out"); + //exec("gpio mode 4 out"); + //exec("gpio mode 5 out"); + //exec("gpio mode 6 out"); + //exec("gpio mode 7 out"); + //exec("gpio mode 10 in"); + //exec("gpio mode 11 in"); + //exec("gpio mode 12 in"); + //exec("gpio mode 13 in"); + //exec("gpio mode 14 in"); + //}); + + RED.nodes.registerType("rpi-pibrella in",PibrellaIn); + RED.nodes.registerType("rpi-pibrella out",PibrellaOut); } - -//exec("gpio mode 0 out",function(err,stdout,stderr) { - //if (err) { - //util.log('[36-rpi-gpio.js] Error: "gpio" command failed for some reason.'); - //} - //exec("gpio mode 1 out"); - //exec("gpio mode 2 out"); - //exec("gpio mode 3 out"); - //exec("gpio mode 4 out"); - //exec("gpio mode 5 out"); - //exec("gpio mode 6 out"); - //exec("gpio mode 7 out"); - //exec("gpio mode 10 in"); - //exec("gpio mode 11 in"); - //exec("gpio mode 12 in"); - //exec("gpio mode 13 in"); - //exec("gpio mode 14 in"); -//}); - -RED.nodes.registerType("rpi-pibrella in",PibrellaIn); -RED.nodes.registerType("rpi-pibrella out",PibrellaOut); diff --git a/hardware/Pi/78-ledborg.js b/hardware/Pi/78-ledborg.js index 9aa6453e..ee43ca9d 100644 --- a/hardware/Pi/78-ledborg.js +++ b/hardware/Pi/78-ledborg.js @@ -14,50 +14,52 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var util = require('util'); -var fs = require('fs'); +module.exports = function(RED) { + "use strict"; + var util = require('util'); + var fs = require('fs'); -// check if /dev/ledborg exists - if not then don't even show the node. -if (!fs.existsSync("/dev/ledborg")) { - throw "Info : PiBorg hardware : LedBorg not found"; -} + // check if /dev/ledborg exists - if not then don't even show the node. + if (!fs.existsSync("/dev/ledborg")) { + throw "Info : PiBorg hardware : LedBorg not found"; + } -function LedBorgNode(n) { - RED.nodes.createNode(this,n); - var p1 = /^[0-2][0-2][0-2]$/ - var p2 = /^\#[A-Fa-f0-9]{6}$/ - var node = this; + function LedBorgNode(n) { + RED.nodes.createNode(this,n); + var p1 = /^[0-2][0-2][0-2]$/ + var p2 = /^\#[A-Fa-f0-9]{6}$/ + var node = this; - this.on("input", function(msg) { - if (p1.test(msg.payload)) { - fs.writeFile('/dev/ledborg', msg.payload, function (err) { - if (err) node.warn(msg.payload+" : No LedBorg found"); - }); - } - else if (p2.test(msg.payload)) { - var r = Math.floor(parseInt(msg.payload.slice(1,3),16)/88).toString(); - var g = Math.floor(parseInt(msg.payload.slice(3,5),16)/88).toString(); - var b = Math.floor(parseInt(msg.payload.slice(5),16)/88).toString(); - fs.writeFile('/dev/ledborg', r+g+b, function (err) { - if (err) node.warn(r+g+b+" : No LedBorg found"); - }); - } - else { - // you can add fancy colours by name here if you want... - // these are the @cheerlight ones. - var colors = {"red":"200","green":"020","blue":"002","cyan":"022","white":"222","pink":"201", - "warmwhite":"221","purple":"101","magenta":"202","yellow":"220","amber":"220","orange":"210","black":"000"} - if (msg.payload.toLowerCase() in colors) { - var c = colors[msg.payload.toLowerCase()]; - fs.writeFile('/dev/ledborg', c, function (err) { - if (err) node.warn(msg.payload+" : No LedBorg found"); + this.on("input", function(msg) { + if (p1.test(msg.payload)) { + fs.writeFile('/dev/ledborg', msg.payload, function (err) { + if (err) { node.warn(msg.payload+" : No LedBorg found"); } + }); + } + else if (p2.test(msg.payload)) { + var r = Math.floor(parseInt(msg.payload.slice(1,3),16)/88).toString(); + var g = Math.floor(parseInt(msg.payload.slice(3,5),16)/88).toString(); + var b = Math.floor(parseInt(msg.payload.slice(5),16)/88).toString(); + fs.writeFile('/dev/ledborg', r+g+b, function (err) { + if (err) { node.warn(r+g+b+" : No LedBorg found"); } }); } else { - node.warn("Invalid LedBorg colour code"); + // you can add fancy colours by name here if you want... + // these are the @cheerlight ones. + var colors = {"red":"200","green":"020","blue":"002","cyan":"022","white":"222","pink":"201", + "warmwhite":"221","purple":"101","magenta":"202","yellow":"220","amber":"220","orange":"210","black":"000"} + if (msg.payload.toLowerCase() in colors) { + var c = colors[msg.payload.toLowerCase()]; + fs.writeFile('/dev/ledborg', c, function (err) { + if (err) { node.warn(msg.payload+" : No LedBorg found"); } + }); + } + else { + node.warn("Invalid LedBorg colour code"); + } } - } - }); + }); + } + RED.nodes.registerType("ledborg",LedBorgNode); } -RED.nodes.registerType("ledborg",LedBorgNode); diff --git a/hardware/blink/76-blinkstick.js b/hardware/blink/76-blinkstick.js index ebbdacc7..389dd605 100644 --- a/hardware/blink/76-blinkstick.js +++ b/hardware/blink/76-blinkstick.js @@ -14,49 +14,51 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var blinkstick = require("blinkstick"); +module.exports = function(RED) { + "use strict"; + var blinkstick = require("blinkstick"); -Object.size = function(obj) { - var size = 0, key; - for (key in obj) { if (obj.hasOwnProperty(key)) size++; } - return size; -}; + Object.size = function(obj) { + var size = 0; + for (var key in obj) { if (obj.hasOwnProperty(key)) { size++; } } + return size; + }; -function BlinkStick(n) { - RED.nodes.createNode(this,n); - var p1 = /^\#[A-Fa-f0-9]{6}$/ - var p2 = /[0-9]+,[0-9]+,[0-9]+/ - this.led = blinkstick.findFirst(); // maybe try findAll() (one day) - var node = this; + function BlinkStick(n) { + RED.nodes.createNode(this,n); + var p1 = /^\#[A-Fa-f0-9]{6}$/ + var p2 = /[0-9]+,[0-9]+,[0-9]+/ + this.led = blinkstick.findFirst(); // maybe try findAll() (one day) + var node = this; - this.on("input", function(msg) { - if (msg != null) { - if (Object.size(node.led) !== 0) { - try { - if (p2.test(msg.payload)) { - var rgb = msg.payload.split(","); - node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); + this.on("input", function(msg) { + if (msg != null) { + if (Object.size(node.led) !== 0) { + try { + if (p2.test(msg.payload)) { + var rgb = msg.payload.split(","); + node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); + } + else { + node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,'')); + } } - else { - node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,'')); + catch (err) { + node.warn("BlinkStick missing ?"); + node.led = blinkstick.findFirst(); } } - catch (err) { - node.warn("BlinkStick missing ?"); + else { + //node.warn("No BlinkStick found"); node.led = blinkstick.findFirst(); } } - else { - //node.warn("No BlinkStick found"); - node.led = blinkstick.findFirst(); - } + }); + if (Object.size(node.led) === 0) { + node.error("No BlinkStick found"); } - }); - if (Object.size(node.led) === 0) { - node.error("No BlinkStick found"); + } + RED.nodes.registerType("blinkstick",BlinkStick); } - -RED.nodes.registerType("blinkstick",BlinkStick); diff --git a/hardware/blink/77-blink1.js b/hardware/blink/77-blink1.js index 474164d9..dfefd143 100644 --- a/hardware/blink/77-blink1.js +++ b/hardware/blink/77-blink1.js @@ -14,70 +14,73 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var Blink1 = require("node-blink1"); -// create a single global blink1 object -// all blink1 nodes affect the same (single) led -var blink1 = null; +module.exports = function(RED) { + "use strict"; + var Blink1 = require("node-blink1"); + // create a single global blink1 object + // all blink1 nodes affect the same (single) led + var blink1 = null; -function Blink1Node(n) { - RED.nodes.createNode(this,n); - this.fade = Number(n.fade) || 0; - var node = this; + function Blink1Node(n) { + RED.nodes.createNode(this,n); + this.fade = Number(n.fade) || 0; + var node = this; - try { - var p1 = /^\#[A-Fa-f0-9]{6}$/ - var p2 = /[0-9]+,[0-9]+,[0-9]+/ - this.on("input", function(msg) { - blink1 = blink1 || new Blink1.Blink1(); - if (blink1) { - try { - if (p1.test(msg.payload)) { - // if it is a hex colour string - var r = parseInt(msg.payload.slice(1,3),16); - var g = parseInt(msg.payload.slice(3,5),16); - var b = parseInt(msg.payload.slice(5),16); - if (node.fade == 0) { blink1.setRGB( r, g, b ); } - else { blink1.fadeToRGB(node.fade, r, g, b ); } - } - else if (p2.test(msg.payload)) { - // if it is a r,g,b triple - var rgb = msg.payload.split(','); - if (node.fade == 0) { blink1.setRGB(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); } - else { blink1.fadeToRGB(node.fade, parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); } - } - else { - // you can add fancy colours by name here if you want... - // these are the @cheerlight ones. - var colors = {"red":"#FF0000","green":"#008000","blue":"#0000FF","cyan":"#00FFFF","white":"#FFFFFF","warmwhite":"#FDF5E6", - "purple":"#800080","magenta":"#FF00FF","yellow":"#FFFF00","amber":"#FFD200","orange":"#FFA500","black":"#000000"} - if (msg.payload.toLowerCase() in colors) { - var c = colors[msg.payload.toLowerCase()]; - var r = parseInt(c.slice(1,3),16); - var g = parseInt(c.slice(3,5),16); - var b = parseInt(c.slice(5),16); - if (node.fade == 0) { blink1.setRGB( r, g, b ); } + try { + var p1 = /^\#[A-Fa-f0-9]{6}$/ + var p2 = /[0-9]+,[0-9]+,[0-9]+/ + this.on("input", function(msg) { + blink1 = blink1 || new Blink1.Blink1(); + if (blink1) { + var r,g,b; + try { + if (p1.test(msg.payload)) { + // if it is a hex colour string + r = parseInt(msg.payload.slice(1,3),16); + g = parseInt(msg.payload.slice(3,5),16); + b = parseInt(msg.payload.slice(5),16); + if (node.fade === 0) { blink1.setRGB( r, g, b ); } else { blink1.fadeToRGB(node.fade, r, g, b ); } } - else { - node.warn("Blink1 : invalid msg : "+msg.payload); + else if (p2.test(msg.payload)) { + // if it is a r,g,b triple + var rgb = msg.payload.split(','); + if (node.fade === 0) { blink1.setRGB(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); } + else { blink1.fadeToRGB(node.fade, parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); } } + else { + // you can add fancy colours by name here if you want... + // these are the @cheerlight ones. + var colors = {"red":"#FF0000","green":"#008000","blue":"#0000FF","cyan":"#00FFFF","white":"#FFFFFF","warmwhite":"#FDF5E6", + "purple":"#800080","magenta":"#FF00FF","yellow":"#FFFF00","amber":"#FFD200","orange":"#FFA500","black":"#000000"} + if (msg.payload.toLowerCase() in colors) { + var c = colors[msg.payload.toLowerCase()]; + r = parseInt(c.slice(1,3),16); + g = parseInt(c.slice(3,5),16); + b = parseInt(c.slice(5),16); + if (node.fade === 0) { blink1.setRGB( r, g, b ); } + else { blink1.fadeToRGB(node.fade, r, g, b ); } + } + else { + node.warn("Blink1 : invalid msg : "+msg.payload); + } + } + } catch (e) { node.warn("Blink1 : error"); blink1 = null; } } - } catch (e) { node.warn("Blink1 : error"); blink1 = null; } - } - else { - node.warn("Blink1 : not found"); - } - }); - this.on("close", function() { - if (blink1 && typeof blink1.close == "function") { - //blink1.close(); //This ought to work but seems to cause more hangs on closing than not... - } - blink1 = null; - }); - } - catch(e) { - node.error("No Blink1 found (" + e + ")"); + else { + node.warn("Blink1 : not found"); + } + }); + this.on("close", function() { + if (blink1 && typeof blink1.close == "function") { + //blink1.close(); //This ought to work but seems to cause more hangs on closing than not... + } + blink1 = null; + }); + } + catch(e) { + node.error("No Blink1 found (" + e + ")"); + } } + RED.nodes.registerType("blink1",Blink1Node); } -RED.nodes.registerType("blink1",Blink1Node); diff --git a/hardware/digiRGB/78-digiRGB.js b/hardware/digiRGB/78-digiRGB.js index cb2cf0cf..3c7b49e8 100644 --- a/hardware/digiRGB/78-digiRGB.js +++ b/hardware/digiRGB/78-digiRGB.js @@ -14,56 +14,58 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var HID = require('node-hid'); -var device; -var node; +module.exports = function(RED) { + "use strict"; + var HID = require('node-hid'); + var device; + var node; -function DigiRGBNode(n) { - RED.nodes.createNode(this,n); - node=this; + function DigiRGBNode(n) { + RED.nodes.createNode(this,n); + node=this; - var devices = HID.devices(0x16c0,0x05df); - for (var i=0; i< devices.length; i++) { - if (devices[i].product == 'DigiUSB') { - path = devices[i].path; - node.log("found: " + path); - try { - device = new HID.HID(devices[i].path); - break; - } catch (e) { - node.log(e) - } - } - } - - var p1 = /^\#[A-Fa-f0-9]{6}$/ - var p2 = /[0-9]+,[0-9]+,[0-9]+/ - - if (device) { - this.on("input", function(msg) { - if (msg != null) { - if (p1.test(msg.payload)) { - var r = parseInt(msg.payload.slice(1,3),16); - var g = parseInt(msg.payload.slice(3,5),16); - var b = parseInt(msg.payload.slice(5),16); - device.sendFeatureReport([115,r,g,b]); - } else if (p2.test(msg.payload)) { - var args = msg.payload.split(','); - if (args.length == 3) { - device.sendFeatureReport([115,parseInt(args[0]),parseInt(args[1]),parseInt(args[2])]); + var devices = HID.devices(0x16c0,0x05df); + for (var i=0; i< devices.length; i++) { + if (devices[i].product == 'DigiUSB') { + path = devices[i].path; + node.log("found: " + path); + try { + device = new HID.HID(devices[i].path); + break; + } catch (e) { + node.log(e) } - } else { - node.warn("incompatable input - " + msg.payload); } } - }); - } else { - node.warn("no digispark RGB found"); - } - this.on('close', function() { - if (device) { device.close(); } - }); + var p1 = /^\#[A-Fa-f0-9]{6}$/ + var p2 = /[0-9]+,[0-9]+,[0-9]+/ + + if (device) { + this.on("input", function(msg) { + if (msg != null) { + if (p1.test(msg.payload)) { + var r = parseInt(msg.payload.slice(1,3),16); + var g = parseInt(msg.payload.slice(3,5),16); + var b = parseInt(msg.payload.slice(5),16); + device.sendFeatureReport([115,r,g,b]); + } else if (p2.test(msg.payload)) { + var args = msg.payload.split(','); + if (args.length == 3) { + device.sendFeatureReport([115,parseInt(args[0]),parseInt(args[1]),parseInt(args[2])]); + } + } else { + node.warn("incompatable input - " + msg.payload); + } + } + }); + } else { + node.warn("no digispark RGB found"); + } + + this.on('close', function() { + if (device) { device.close(); } + }); + } + RED.nodes.registerType("digiRGB",DigiRGBNode); } -RED.nodes.registerType("digiRGB",DigiRGBNode); diff --git a/hardware/wemo/60-wemo.js b/hardware/wemo/60-wemo.js index 34391dee..c2e89e2c 100644 --- a/hardware/wemo/60-wemo.js +++ b/hardware/wemo/60-wemo.js @@ -14,47 +14,49 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var WeMo = new require('wemo'); +module.exports = function(RED) { + "use strict"; + var WeMo = new require('wemo'); -function WeMoOut(n) { - RED.nodes.createNode(this,n); - this.ipaddr = n.ipaddr; - this.wemoSwitch = new WeMo(n.ipaddr); - var node = this; + function WeMoOut(n) { + RED.nodes.createNode(this,n); + this.ipaddr = n.ipaddr; + this.wemoSwitch = new WeMo(n.ipaddr); + var node = this; - this.on("input", function(msg) { - if (msg != null) { - var state = 0; - if ( msg.payload == 1 || msg.payload == true || msg.payload == "on" ) { var state = 1; } - node.wemoSwitch.setBinaryState(state, function(err, result) { - if (err) node.warn(err); - //else { node.log(result); } - }); - } - }); -} -RED.nodes.registerType("wemo out",WeMoOut); - -function WeMoIn(n) { - RED.nodes.createNode(this,n); - this.ipaddr = n.ipaddr; - this.wemoSwitch = new WeMo(n.ipaddr); - this.wemoSwitch.state = 0; - var node = this; - - var tick = setInterval(function() { - wemoSwitch.getBinaryState(function(err, result) { - if (err) node.warn(err); - if (parseInt(result) != wemoSwitch.state) { - wemoSwitch.state = parseInt(result); - node.send({payload:wemoSwitch.state,topic:"wemo/"+node.ipaddr}); + this.on("input", function(msg) { + if (msg != null) { + var state = 0; + if ( msg.payload == 1 || msg.payload === true || msg.payload == "on" ) { state = 1; } + node.wemoSwitch.setBinaryState(state, function(err, result) { + if (err) { node.warn(err); } + //else { node.log(result); } + }); } }); - }, 2000); + } + RED.nodes.registerType("wemo out",WeMoOut); - this.on("close", function() { - clearInterval(tick); - }); + function WeMoIn(n) { + RED.nodes.createNode(this,n); + this.ipaddr = n.ipaddr; + this.wemoSwitch = new WeMo(n.ipaddr); + this.wemoSwitch.state = 0; + var node = this; + + var tick = setInterval(function() { + wemoSwitch.getBinaryState(function(err, result) { + if (err) { node.warn(err); } + if (parseInt(result) != wemoSwitch.state) { + wemoSwitch.state = parseInt(result); + node.send({payload:wemoSwitch.state,topic:"wemo/"+node.ipaddr}); + } + }); + }, 2000); + + this.on("close", function() { + clearInterval(tick); + }); + } + RED.nodes.registerType("wemo in",WeMoOut); } -RED.nodes.registerType("wemo in",WeMoOut); From 052a7d587de91e8ab62129e4832ef48abb5f4f5b Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 28 Jun 2014 23:35:33 +0100 Subject: [PATCH 036/134] Update node-red-nodes io nodes to use strict and pass jshint scan --- io/ping/88-ping.js | 72 +++++------ io/rawserial/26-rawserial.js | 236 ++++++++++++++++++----------------- io/stomp/18-stomp.js | 6 +- io/wol/39-wol.js | 42 ++++--- 4 files changed, 182 insertions(+), 174 deletions(-) diff --git a/io/ping/88-ping.js b/io/ping/88-ping.js index c2b98de5..2d25d7a3 100644 --- a/io/ping/88-ping.js +++ b/io/ping/88-ping.js @@ -14,42 +14,44 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var spawn = require('child_process').spawn; -var plat = require('os').platform(); +module.exports = function(RED) { + "use strict"; + var spawn = require('child_process').spawn; + var plat = require('os').platform(); -function PingNode(n) { - RED.nodes.createNode(this,n); - this.host = n.host; - this.timer = n.timer * 1000; - var node = this; + function PingNode(n) { + RED.nodes.createNode(this,n); + this.host = n.host; + this.timer = n.timer * 1000; + var node = this; - node.tout = setInterval(function() { - var ex; - if (plat == "linux") ex = spawn('ping', ['-n', '-w', '5', '-c', '1', node.host]); - else if (plat.match(/^win/)) ex = spawn('ping', ['-n', '1', '-w', '5000', node.host]); - else if (plat == "darwin") ex = spawn('ping', ['-n', '-t', '5', '-c', '1', node.host]); - else node.error("Sorry - your platform - "+plat+" - is not recognised."); - var res = false; - ex.stdout.on('data', function (data) { - //console.log('[ping] stdout: ' + data.toString()); - var regex = /from.*time.(.*)ms/; - var m = regex.exec(data.toString())||""; - if (m != '') { res = Number(m[1]); } - }); - ex.stderr.on('data', function (data) { - //console.log('[ping] stderr: ' + data); - }); - ex.on('close', function (code) { - //console.log('[ping] result: ' + code); - var msg = { payload:false, topic:node.host }; - if (code == 0) msg = { payload:res, topic:node.host }; - node.send(msg); - }); - }, node.timer); + node.tout = setInterval(function() { + var ex; + if (plat == "linux") { ex = spawn('ping', ['-n', '-w', '5', '-c', '1', node.host]); } + else if (plat.match(/^win/)) { ex = spawn('ping', ['-n', '1', '-w', '5000', node.host]); } + else if (plat == "darwin") { ex = spawn('ping', ['-n', '-t', '5', '-c', '1', node.host]); } + else { node.error("Sorry - your platform - "+plat+" - is not recognised."); } + var res = false; + ex.stdout.on('data', function (data) { + //console.log('[ping] stdout: ' + data.toString()); + var regex = /from.*time.(.*)ms/; + var m = regex.exec(data.toString())||""; + if (m !== '') { res = Number(m[1]); } + }); + ex.stderr.on('data', function (data) { + //console.log('[ping] stderr: ' + data); + }); + ex.on('close', function (code) { + //console.log('[ping] result: ' + code); + var msg = { payload:false, topic:node.host }; + if (code === 0) { msg = { payload:res, topic:node.host }; } + node.send(msg); + }); + }, node.timer); - this.on("close", function() { - clearInterval(this.tout); - }); + this.on("close", function() { + clearInterval(this.tout); + }); + } + RED.nodes.registerType("ping",PingNode); } -RED.nodes.registerType("ping",PingNode); diff --git a/io/rawserial/26-rawserial.js b/io/rawserial/26-rawserial.js index 0a991fed..0ba158f1 100644 --- a/io/rawserial/26-rawserial.js +++ b/io/rawserial/26-rawserial.js @@ -14,131 +14,135 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var settings = RED.settings; -var util = require("util"); -var fs = require('fs'); -var plat = require('os').platform(); -var pre = "\\\\.\\"; +module.exports = function(RED) { + "use strict"; + var settings = RED.settings; + var util = require("util"); + var fs = require('fs'); + var plat = require('os').platform(); + var pre = "\\\\.\\"; -if (!plat.match(/^win/)) { - util.log("[26-rawserial.js] Info : only really needed for Windows boxes without serialport npm module installed."); - pre = ""; -} + if (!plat.match(/^win/)) { + util.log("[26-rawserial.js] Info : only really needed for Windows boxes without serialport npm module installed."); + pre = ""; + } -function RawSerialInNode(n) { - RED.nodes.createNode(this,n); - this.port = n.port; - this.splitc = n.splitc||null; - this.out = n.out||"char"; - this.bin = n.bin||false; - if (this.splitc == '\\n') this.splitc = "\n"; - if (this.splitc == '\\r') this.splitc = "\r"; - if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } - var node = this; + function RawSerialInNode(n) { + RED.nodes.createNode(this,n); + this.port = n.port; + this.splitc = n.splitc||null; + this.out = n.out||"char"; + this.bin = n.bin||false; + if (this.splitc == '\\n') { this.splitc = "\n"; } + if (this.splitc == '\\r') { this.splitc = "\r"; } + if (!isNaN(parseInt(this.splitc))) { this.splitc = parseInt(this.splitc); } + var node = this; - var setupSerial = function() { - node.inp = fs.createReadStream(pre+node.port); - node.log("open "+pre+node.port); - node.tout = null; - var line = ""; - var buf = new Buffer(32768); - var i = 0; - node.inp.on('data', function (data) { - for (var z = 0; z < data.length; z++) { - if ((node.out === "time") && (node.splitc != 0)) { - if (node.tout) { - i += 1; + var setupSerial = function() { + node.inp = fs.createReadStream(pre+node.port); + node.log("open "+pre+node.port); + node.tout = null; + var line = ""; + var buf = new Buffer(32768); + var i = 0; + node.inp.on('data', function (data) { + for (var z = 0; z < data.length; z++) { + if ((node.out === "time") && (node.splitc !== 0)) { + if (node.tout) { + i += 1; + buf[i] = data[z]; + } + else { + node.tout = setTimeout(function () { + node.tout = null; + var m = new Buffer(i+1); + buf.copy(m,0,0,i+1); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload": m}); + m = null; + }, node.splitc); + i = 0; + buf[0] = data[z]; + } + } + else if ((node.out == "char") && (node.splitc != null)) { buf[i] = data[z]; + i += 1; + if ((data[z] === node.splitc.charCodeAt(0)) || (i === 32768)) { + var m = new Buffer(i); + buf.copy(m,0,0,i); + if (node.bin !== "true") { m = m.toString(); } + node.send({"payload":m}); + m = null; + i = 0; + } } else { - node.tout = setTimeout(function () { - node.tout = null; - var m = new Buffer(i+1); - buf.copy(m,0,0,i+1); - if (node.bin !== "true") { m = m.toString(); } - node.send({"payload": m}); - }, node.splitc); - i = 0; - buf[0] = data[z]; + if (node.bin !== "true") { node.send({"payload": String.fromCharCode(data[z])}); } + else { node.send({"payload": new Buffer([data[z]])});} } } - else if ((node.out == "char") && (node.splitc != null)) { - buf[i] = data[z]; - i += 1; - if ((data[z] === node.splitc.charCodeAt(0)) || (i === 32768)) { - var m = new Buffer(i); - buf.copy(m,0,0,i); - if (node.bin !== "true") { m = m.toString(); } - node.send({"payload":m}); - i = 0; - } - } - else { - if (node.bin !== "true") { node.send({"payload": String.fromCharCode(data[z])}); } - else { node.send({"payload": new Buffer([data[z]])});} - } - } + }); + //node.inp.on('end', function (error) {console.log("End", error);}); + node.inp.on('close', function (error) { + node.log(node.port+" closed"); + node.tout = setTimeout(function() { + setupSerial(); + },settings.serialReconnectTime); + }); + node.inp.on('error', function(error) { + if (error.code == "ENOENT") { node.log(node.port+" not found"); } + else { node.log(node.port+" error "+error); } + node.tout = setTimeout(function() { + setupSerial(); + },settings.serialReconnectTime); + }); + } + setupSerial(); + + node.on('close', function() { + if (node.tout) { clearTimeout(node.tout); } + if (node.inp) { node.inp.pause(); } }); - //node.inp.on('end', function (error) {console.log("End", error);}); - node.inp.on('close', function (error) { - node.log(node.port+" closed"); - node.tout = setTimeout(function() { - setupSerial(); - },settings.serialReconnectTime); - }); - node.inp.on('error', function(error) { - if (error.code == "ENOENT") { node.log(node.port+" not found"); } - else { node.log(node.port+" error "+error); } - node.tout = setTimeout(function() { - setupSerial(); - },settings.serialReconnectTime); + + } + RED.nodes.registerType("rawserial in",RawSerialInNode); + + + function RawSerialOutNode(n) { + RED.nodes.createNode(this,n); + this.port = n.port; + var node = this; + + var setupSerial = function() { + node.oup = fs.createWriteStream(pre+node.port,{ flags:'w', encoding:'utf8', mode:'0666' }); + node.on("input", function(msg) { + if (msg.payload != null) { + node.oup.write(msg.payload); + } + }); + node.oup.on('open', function (error) { node.log("opened "+node.port); }); + node.oup.on('end', function (error) { node.log("end :"+error); }); + node.oup.on('close', function (error) { + node.log(node.port+" closed"); + node.tout = setTimeout(function() { + setupSerial(); + },settings.serialReconnectTime); + }); + node.oup.on('error', function(error) { + if (error.code == "EACCES") { node.log("can't access port "+node.port); } + else if (error.code == "EIO") { node.log("can't write to port "+node.port); } + else { node.log(node.port+" error "+error); } + node.tout = setTimeout(function() { + setupSerial(); + },settings.serialReconnectTime); + }); + } + setupSerial(); + + node.on('close', function() { + if (node.tout) { clearTimeout(node.tout); } }); } - setupSerial(); - - node.on('close', function() { - if (node.tout) { clearTimeout(node.tout); } - if (node.inp) { node.inp.pause(); } - }); - + RED.nodes.registerType("rawserial out",RawSerialOutNode); } -RED.nodes.registerType("rawserial in",RawSerialInNode); - - -function RawSerialOutNode(n) { - RED.nodes.createNode(this,n); - this.port = n.port; - var node = this; - - var setupSerial = function() { - node.oup = fs.createWriteStream(pre+node.port,{ flags:'w', encoding:'utf8', mode:0666 }); - node.on("input", function(msg) { - if (msg.payload != null) { - node.oup.write(msg.payload); - } - }); - node.oup.on('open', function (error) { node.log("opened "+node.port); }); - node.oup.on('end', function (error) { node.log("end :"+error); }); - node.oup.on('close', function (error) { - node.log(node.port+" closed"); - node.tout = setTimeout(function() { - setupSerial(); - },settings.serialReconnectTime); - }); - node.oup.on('error', function(error) { - if (error.code == "EACCES") { node.log("can't access port "+node.port); } - else if (error.code == "EIO") { node.log("can't write to port "+node.port); } - else { node.log(node.port+" error "+error); } - node.tout = setTimeout(function() { - setupSerial(); - },settings.serialReconnectTime); - }); - } - setupSerial(); - - node.on('close', function() { - if (node.tout) { clearTimeout(node.tout); } - }); -} -RED.nodes.registerType("rawserial out",RawSerialOutNode); diff --git a/io/stomp/18-stomp.js b/io/stomp/18-stomp.js index adbadb8e..6f9ce3ff 100644 --- a/io/stomp/18-stomp.js +++ b/io/stomp/18-stomp.js @@ -35,7 +35,7 @@ module.exports = function(RED) { RED.httpAdmin.get('/stomp-server/:id',function(req,res) { var credentials = RED.nodes.getCredentials(req.params.id); if (credentials) { - res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")})); + res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")})); } else { res.send(JSON.stringify({})); } @@ -54,12 +54,12 @@ module.exports = function(RED) { req.on('end', function(){ var newCreds = querystring.parse(body); var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.user == null || newCreds.user == "") { + if (newCreds.user == null || newCreds.user === "") { delete credentials.user; } else { credentials.user = newCreds.user; } - if (newCreds.password == "") { + if (newCreds.password === "") { delete credentials.password; } else { credentials.password = newCreds.password||credentials.password; diff --git a/io/wol/39-wol.js b/io/wol/39-wol.js index aa033542..e9174560 100644 --- a/io/wol/39-wol.js +++ b/io/wol/39-wol.js @@ -14,28 +14,30 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var wol = require('wake_on_lan'); -var chk = /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/; +module.exports = function(RED) { + "use strict"; + var wol = require('wake_on_lan'); + var chk = /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/; -function WOLnode(n) { - RED.nodes.createNode(this,n); - this.mac = n.mac.trim(); - var node = this; + function WOLnode(n) { + RED.nodes.createNode(this,n); + this.mac = n.mac.trim(); + var node = this; - this.on("input", function(msg) { - if (msg != null) { - var mac = this.mac || msg.mac || null; - if (mac != null) { - if (chk.test(mac)) { - wol.wake(mac, function(error) { - if (error) { node.warn(error); } - }); + this.on("input", function(msg) { + if (msg != null) { + var mac = this.mac || msg.mac || null; + if (mac != null) { + if (chk.test(mac)) { + wol.wake(mac, function(error) { + if (error) { node.warn(error); } + }); + } + else { node.warn('WOL: bad mac address "'+mac+'"'); } } - else { node.warn('WOL: bad mac address "'+mac+'"'); } + else { node.warn("WOL: no mac address specified"); } } - else { node.warn("WOL: no mac address specified"); } - } - }); + }); + } + RED.nodes.registerType("wake on lan",WOLnode); } -RED.nodes.registerType("wake on lan",WOLnode); From 43dfded402f0e0a9863173fcfae842f24c7717ea Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 28 Jun 2014 23:36:36 +0100 Subject: [PATCH 037/134] Update node-red-nodes social nodes to use strict and pass jshint scan --- social/dweetio/55-dweetio.html | 95 +++++++++++++++++++++ social/dweetio/55-dweetio.js | 67 +++++++++++++++ social/music/69-mpd.js | 152 +++++++++++++++++---------------- social/xmpp/92-xmpp.js | 10 +-- 4 files changed, 244 insertions(+), 80 deletions(-) create mode 100644 social/dweetio/55-dweetio.html create mode 100644 social/dweetio/55-dweetio.js diff --git a/social/dweetio/55-dweetio.html b/social/dweetio/55-dweetio.html new file mode 100644 index 00000000..e9efe0b5 --- /dev/null +++ b/social/dweetio/55-dweetio.html @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + diff --git a/social/dweetio/55-dweetio.js b/social/dweetio/55-dweetio.js new file mode 100644 index 00000000..67f5a6d8 --- /dev/null +++ b/social/dweetio/55-dweetio.js @@ -0,0 +1,67 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var DweetClient = require("node-dweetio"); + var util = require('util'); + var dweetio = null; + + function DweetioOutNode(n) { + RED.nodes.createNode(this,n); + this.thing = n.thing; + if (dweetio == null) { dweetio = new DweetClient(); } + var node = this; + + this.on("input",function(msg) { + //if (typeof(msg.payload) === 'object') { + var thing = node.thing || msg.thing; + try { + dweetio.dweet_for(thing, {some:msg.payload}, function(err, dweet) { + //console.log(dweet.thing); // "my-thing" + //console.log(dweet.content); // The content of the dweet + //console.log(dweet.created); // The create date of the dweet + }); + } + catch (err) { + node.log(err); + } + //} else { node.warn("Dweetio only sends payload objects."); } + }); + + } + RED.nodes.registerType("dweetio out",DweetioOutNode); + + function DweetioInNode(n) { + RED.nodes.createNode(this,n); + this.thing = n.thing; + if (dweetio == null) { dweetio = new DweetClient(); } + var node = this; + + dweetio.listen_for(node.thing, function(dweet){ + // This will be called anytime there is a new dweet for my-thing + dweet.payload = dweet.content.some; + delete dweet.content; + node.send(dweet); + }); + + this.on("close", function() { + dweetio.stop_listening_for(node.thing); + }); + + } + RED.nodes.registerType("dweetio in",DweetioInNode); +} diff --git a/social/music/69-mpd.js b/social/music/69-mpd.js index a93b37ec..8fa4941a 100644 --- a/social/music/69-mpd.js +++ b/social/music/69-mpd.js @@ -14,89 +14,91 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var util = require("util"); -var exec = require('child_process').exec; -var komponist = require('komponist'); -var mpc = null; -exec("which mpd",function(err,stdout,stderr) { - if (stdout.indexOf('mpd') == -1) { - throw 'Error: Cannot find "mpd" command. Please install MPD.'; - } -}); - -exec("netstat -an | grep LISTEN | grep 6600",function(err,stdout,stderr) { - if (stdout.indexOf('6600') == -1) { - throw '[69-mpd.js] Error: MPD daemon not listening on port 6600. Please start MPD.'; - } - komponist.createConnection(6600, 'localhost', function(err, client) { - if (err) node.error("MPD: Failed to connect to MPD server"); - mpc = client; +module.exports = function(RED) { + "use strict"; + var util = require("util"); + var exec = require('child_process').exec; + var komponist = require('komponist'); + var mpc = null; + exec("which mpd",function(err,stdout,stderr) { + if (stdout.indexOf('mpd') == -1) { + throw 'Error: Cannot find "mpd" command. Please install MPD.'; + } }); -}); - -function MPDOut(n) { - RED.nodes.createNode(this,n); - var node = this; - node.mpc = mpc; - - if (mpc != null) { - this.on("input", function(msg) { - if (msg != null) { - try { - //node.mpc.command(msg.payload); - node.mpc.command(msg.payload, msg.param, function(err, results) { - if (err) { node.log("error: "+err); } - //else { console.log(results); } - }); - } catch (err) { node.log("error: "+err); } - } + exec("netstat -an | grep LISTEN | grep 6600",function(err,stdout,stderr) { + if (stdout.indexOf('6600') == -1) { + throw '[69-mpd.js] Error: MPD daemon not listening on port 6600. Please start MPD.'; + } + komponist.createConnection(6600, 'localhost', function(err, client) { + if (err) { node.error("MPD: Failed to connect to MPD server"); } + mpc = client; }); + }); - node.mpc.on('error', function(err) { - node.log("error: "+err); - }); - } - else { node.warn("MPD not running"); } -} -RED.nodes.registerType("mpd out",MPDOut); -function MPDIn(n) { - RED.nodes.createNode(this,n); - var node = this; - node.mpc = mpc; - var oldMsg = ""; + function MPDOut(n) { + RED.nodes.createNode(this,n); + var node = this; + node.mpc = mpc; - if (mpc != null) { - getSong(); - - function getSong() { - node.mpc.currentsong(function(err, info) { - if (err) node.log(err); - else { - var msg = {payload:{},topic:"music"}; - msg.payload.Artist = info.Artist; - msg.payload.Album = info.Album; - msg.payload.Title = info.Title; - msg.payload.Genre = info.Genre; - msg.payload.Date = info.Date; - if (JSON.stringify(msg) != oldMsg) { - node.send(msg); - oldMsg = JSON.stringify(msg); - } + if (mpc != null) { + this.on("input", function(msg) { + if (msg != null) { + try { + //node.mpc.command(msg.payload); + node.mpc.command(msg.payload, msg.param, function(err, results) { + if (err) { node.log("error: "+err); } + //else { console.log(results); } + }); + } catch (err) { node.log("error: "+err); } } }); + + node.mpc.on('error', function(err) { + node.log("error: "+err); + }); } - - node.mpc.on('changed', function(system) { - getSong(); - }); - - this.on("close", function() { - // node.mpc.command("stop"); - }); + else { node.warn("MPD not running"); } } - else { node.warn("MPD not running"); } + RED.nodes.registerType("mpd out",MPDOut); + + function MPDIn(n) { + RED.nodes.createNode(this,n); + var node = this; + node.mpc = mpc; + var oldMsg = ""; + + if (mpc != null) { + getSong(); + + var getSong = function() { + node.mpc.currentsong(function(err, info) { + if (err) { node.log(err); } + else { + var msg = {payload:{},topic:"music"}; + msg.payload.Artist = info.Artist; + msg.payload.Album = info.Album; + msg.payload.Title = info.Title; + msg.payload.Genre = info.Genre; + msg.payload.Date = info.Date; + if (JSON.stringify(msg) != oldMsg) { + node.send(msg); + oldMsg = JSON.stringify(msg); + } + } + }); + } + + node.mpc.on('changed', function(system) { + getSong(); + }); + + this.on("close", function() { + // node.mpc.command("stop"); + }); + } + else { node.warn("MPD not running"); } + } + RED.nodes.registerType("mpd in",MPDIn); } -RED.nodes.registerType("mpd in",MPDIn); diff --git a/social/xmpp/92-xmpp.js b/social/xmpp/92-xmpp.js index 8bcb2955..06373a6e 100644 --- a/social/xmpp/92-xmpp.js +++ b/social/xmpp/92-xmpp.js @@ -39,11 +39,11 @@ var querystring = require('querystring'); RED.httpAdmin.get('/xmpp-server/:id',function(req,res) { var credentials = RED.nodes.getCredentials(req.params.id); if (credentials) { - res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")})); + res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")})); } else if (xmppkey && xmppkey.jid && xmppkey.password) { RED.nodes.addCredentials(req.params.id,{user:xmppkey.jid, password:xmppkey.password, global:true}); credentials = RED.nodes.getCredentials(req.params.id); - res.send(JSON.stringify({user:credentials.user,global:credentials.global,hasPassword:(credentials.password&&credentials.password!="")})); + res.send(JSON.stringify({user:credentials.user,global:credentials.global,hasPassword:(credentials.password&&credentials.password!=="")})); } else { res.send(JSON.stringify({})); } @@ -62,12 +62,12 @@ RED.httpAdmin.post('/xmpp-server/:id',function(req,res) { req.on('end', function(){ var newCreds = querystring.parse(body); var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.user == null || newCreds.user == "") { + if (newCreds.user == null || newCreds.user === "") { delete credentials.user; } else { credentials.user = newCreds.user; } - if (newCreds.password == "") { + if (newCreds.password === "") { delete credentials.password; } else { credentials.password = newCreds.password||credentials.password; @@ -228,7 +228,7 @@ function XmppOutNode(n) { } else { var to = msg.topic; - if (node.to != "") { to = node.to; } + if (node.to !== "") { to = node.to; } if (node.sendAll) { xmpp.send(to, JSON.stringify(msg), node.join); } From ebf950d81805be8bbe088dcd368286b7533e3aa8 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 28 Jun 2014 23:37:19 +0100 Subject: [PATCH 038/134] Update node-red-nodes sample, analysis, storage and time nodes to use strict and pass jshint scan --- 99-sample.js.demo | 52 +++-- analysis/swearfilter/74-swearfilter.js | 28 +-- analysis/wordpos/72-wordpos.js | 26 ++- storage/leveldb/67-leveldb.js | 134 +++++------ storage/mysql/68-mysql.js | 306 +++++++++++++------------ time/79-suncalc.js | 1 + 6 files changed, 279 insertions(+), 268 deletions(-) diff --git a/99-sample.js.demo b/99-sample.js.demo index bb458c81..0bba1818 100644 --- a/99-sample.js.demo +++ b/99-sample.js.demo @@ -19,34 +19,36 @@ // Sample Node-RED node file // Require main module -var RED = require(process.env.NODE_RED_HOME+"/red/red"); +module.exports = function(RED) { + "use strict"; -// The main node definition - most things happen in here -function SampleNode(n) { - // Create a RED node - RED.nodes.createNode(this,n); + // The main node definition - most things happen in here + function SampleNode(n) { + // Create a RED node + RED.nodes.createNode(this,n); - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; - // Do whatever you need to do in here - declare callbacks etc - // Note: this sample doesn't do anything much - it will only send - // this message once at startup... - // Look at other real nodes for some better ideas of what to do.... - var msg = {}; - msg.topic = this.topic; - msg.payload = "Hello world !" + // Do whatever you need to do in here - declare callbacks etc + // Note: this sample doesn't do anything much - it will only send + // this message once at startup... + // Look at other real nodes for some better ideas of what to do.... + var msg = {}; + msg.topic = this.topic; + msg.payload = "Hello world !" - // send out the message to the rest of the workspace. - this.send(msg); + // send out the message to the rest of the workspace. + this.send(msg); - this.on("close", function() { - // Called when the node is shutdown - eg on redeploy. - // Allows ports to be closed, connections dropped etc. - // eg: this.client.disconnect(); - }); + this.on("close", function() { + // Called when the node is shutdown - eg on redeploy. + // Allows ports to be closed, connections dropped etc. + // eg: this.client.disconnect(); + }); + } + + // Register the node by name. This must be called before overriding any of the + // Node functions. + RED.nodes.registerType("sample",SampleNode); } - -// Register the node by name. This must be called before overriding any of the -// Node functions. -RED.nodes.registerType("sample",SampleNode); diff --git a/analysis/swearfilter/74-swearfilter.js b/analysis/swearfilter/74-swearfilter.js index 394bca40..670f8a93 100644 --- a/analysis/swearfilter/74-swearfilter.js +++ b/analysis/swearfilter/74-swearfilter.js @@ -14,18 +14,20 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var badwords = require('badwords'); -if (badwords.length == 0 ) { return; } -var badwordsRegExp = require('badwords/regexp'); +module.exports = function(RED) { + "use strict"; + var badwords = require('badwords'); + if (badwords.length === 0 ) { return; } + var badwordsRegExp = require('badwords/regexp'); -function BadwordsNode(n) { - RED.nodes.createNode(this,n); - var node = this; - this.on("input", function(msg) { - if (typeof msg.payload === "string") { - if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); } - } - }); + function BadwordsNode(n) { + RED.nodes.createNode(this,n); + var node = this; + this.on("input", function(msg) { + if (typeof msg.payload === "string") { + if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); } + } + }); + } + RED.nodes.registerType("badwords",BadwordsNode); } -RED.nodes.registerType("badwords",BadwordsNode); diff --git a/analysis/wordpos/72-wordpos.js b/analysis/wordpos/72-wordpos.js index 6f472781..87200559 100644 --- a/analysis/wordpos/72-wordpos.js +++ b/analysis/wordpos/72-wordpos.js @@ -14,18 +14,20 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var WordPos = require('wordpos'); -var wordpos = new WordPos(); +module.exports = function(RED) { + "use strict"; + var WordPos = require('wordpos'); + var wordpos = new WordPos(); -function WordPOSNode(n) { - RED.nodes.createNode(this,n); - this.on("input", function(msg) { - var node = this; - wordpos.getPOS(msg.payload, function (result) { - msg.pos = result; - node.send(msg); + function WordPOSNode(n) { + RED.nodes.createNode(this,n); + this.on("input", function(msg) { + var node = this; + wordpos.getPOS(msg.payload, function (result) { + msg.pos = result; + node.send(msg); + }); }); - }); + } + RED.nodes.registerType("wordpos",WordPOSNode); } -RED.nodes.registerType("wordpos",WordPOSNode); diff --git a/storage/leveldb/67-leveldb.js b/storage/leveldb/67-leveldb.js index f4a91db6..9e1d56bf 100644 --- a/storage/leveldb/67-leveldb.js +++ b/storage/leveldb/67-leveldb.js @@ -14,81 +14,83 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var lvldb = require('level'); +module.exports = function(RED) { + "use strict"; + var lvldb = require('level'); -function LevelNode(n) { - RED.nodes.createNode(this,n); - this.dbname = n.db; - var node = this; - lvldb(this.dbname, function(err, db) { - if (err) node.error(err); - node.db = db; - }); - this.on('close', function() { - if (node.db) { node.db.close(); } - }); -} -RED.nodes.registerType("leveldbase",LevelNode); - - -function LevelDBNodeIn(n) { - RED.nodes.createNode(this,n); - this.level = n.level; - this.levelConfig = RED.nodes.getNode(this.level); - - if (this.levelConfig) { + function LevelNode(n) { + RED.nodes.createNode(this,n); + this.dbname = n.db; var node = this; - node.on("input", function(msg) { - if (typeof msg.topic === 'string') { - node.levelConfig.db.get(msg.topic, function(err, value) { - if (err) { - //node.warn(err); - // for some reason they treat nothing found as an error... - msg.payload = null; // so we should return null - } - else { msg.payload = value; } - node.send(msg); - }); - } - else { - if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); - } + lvldb(this.dbname, function(err, db) { + if (err) { node.error(err); } + node.db = db; + }); + this.on('close', function() { + if (node.db) { node.db.close(); } }); } - else { - this.error("LevelDB database name not configured"); - } -} -RED.nodes.registerType("leveldb in",LevelDBNodeIn); + RED.nodes.registerType("leveldbase",LevelNode); -function LevelDBNodeOut(n) { - RED.nodes.createNode(this,n); - this.level = n.level; - this.operation = n.operation; - this.levelConfig = RED.nodes.getNode(this.level); + function LevelDBNodeIn(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.levelConfig = RED.nodes.getNode(this.level); - if (this.levelConfig) { - var node = this; - node.on("input", function(msg) { - if (typeof msg.topic === 'string') { - if (node.operation === "delete") { - node.levelConfig.db.del(msg.topic); - } - else { - node.levelConfig.db.put(msg.topic, msg.payload, function(err) { - if (err) node.error(err); + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + node.levelConfig.db.get(msg.topic, function(err, value) { + if (err) { + //node.warn(err); + // for some reason they treat nothing found as an error... + msg.payload = null; // so we should return null + } + else { msg.payload = value; } + node.send(msg); }); } - } - else { - if (typeof msg.topic !== 'string') node.error("msg.topic (the key is not defined"); - } - }); + else { + if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); } + } + }); + } + else { + this.error("LevelDB database name not configured"); + } } - else { - this.error("LevelDB database name not configured"); + RED.nodes.registerType("leveldb in",LevelDBNodeIn); + + + function LevelDBNodeOut(n) { + RED.nodes.createNode(this,n); + this.level = n.level; + this.operation = n.operation; + this.levelConfig = RED.nodes.getNode(this.level); + + if (this.levelConfig) { + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + if (node.operation === "delete") { + node.levelConfig.db.del(msg.topic); + } + else { + node.levelConfig.db.put(msg.topic, msg.payload, function(err) { + if (err) { node.error(err); } + }); + } + } + else { + if (typeof msg.topic !== 'string') { node.error("msg.topic (the key is not defined"); } + } + }); + } + else { + this.error("LevelDB database name not configured"); + } } + RED.nodes.registerType("leveldb out",LevelDBNodeOut); } -RED.nodes.registerType("leveldb out",LevelDBNodeOut); diff --git a/storage/mysql/68-mysql.js b/storage/mysql/68-mysql.js index d4141130..4647d1d6 100644 --- a/storage/mysql/68-mysql.js +++ b/storage/mysql/68-mysql.js @@ -14,182 +14,184 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var reconnect = RED.settings.mysqlReconnectTime || 30000; -var mysqldb = require('mysql'); -var querystring = require('querystring'); +module.exports = function(RED) { + "use strict"; + var reconnect = RED.settings.mysqlReconnectTime || 30000; + var mysqldb = require('mysql'); + var querystring = require('querystring'); -RED.httpAdmin.get('/MySQLdatabase/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!="")})); - } else { - res.send(JSON.stringify({})); - } -}); - -RED.httpAdmin.delete('/MySQLdatabase/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); - -RED.httpAdmin.post('/MySQLdatabase/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; + RED.httpAdmin.get('/MySQLdatabase/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")})); + } else { + res.send(JSON.stringify({})); + } }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.user == null || newCreds.user == "") { - delete credentials.user; - } else { - credentials.user = newCreds.user; - } - if (newCreds.password == "") { - delete credentials.password; - } else { - credentials.password = newCreds.password||credentials.password; - } - RED.nodes.addCredentials(req.params.id,credentials); + + RED.httpAdmin.delete('/MySQLdatabase/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); + + RED.httpAdmin.post('/MySQLdatabase/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.user == null || newCreds.user === "") { + delete credentials.user; + } else { + credentials.user = newCreds.user; + } + if (newCreds.password === "") { + delete credentials.password; + } else { + credentials.password = newCreds.password||credentials.password; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); + }); -function MySQLNode(n) { - RED.nodes.createNode(this,n); - this.host = n.host; - this.port = n.port; + function MySQLNode(n) { + RED.nodes.createNode(this,n); + this.host = n.host; + this.port = n.port; - this.connected = false; - this.connecting = false; + this.connected = false; + this.connecting = false; - if (n.user) { var credentials = {}; - credentials.user = n.user; - credentials.password = n.pass; - RED.nodes.addCredentials(n.id,credentials); - this.user = n.user; - this.password = n.pass; - } else { - var credentials = RED.nodes.getCredentials(n.id); - if (credentials) { - this.user = credentials.user; - this.password = credentials.password; - } - } - - this.dbname = n.db; - var node = this; - - function doConnect() { - node.connecting = true; - node.connection = mysqldb.createConnection({ - host : node.host, - port : node.port, - user : node.user, - password : node.password, - database : node.dbname, - insecureAuth: true - }); - - node.connection.connect(function(err) { - node.connecting = false; - if (err) { - node.warn(err); - node.tick = setTimeout(doConnect, reconnect); - } else { - node.connected = true; + if (n.user) { + credentials.user = n.user; + credentials.password = n.pass; + RED.nodes.addCredentials(n.id,credentials); + this.user = n.user; + this.password = n.pass; + } else { + credentials = RED.nodes.getCredentials(n.id); + if (credentials) { + this.user = credentials.user; + this.password = credentials.password; } - }); - - node.connection.on('error', function(err) { - node.connected = false; - if (err.code === 'PROTOCOL_CONNECTION_LOST') { - doConnect(); // silently reconnect... - } else { - node.error(err); - doConnect(); - } - }); - } - - this.connect = function() { - if (!this.connected && !this.connecting) { - doConnect(); } - } - this.on('close', function () { - if (this.tick) { clearTimeout(this.tick); } - if (this.connection) { - node.connection.end(function(err) { - if (err) node.error(err); + this.dbname = n.db; + var node = this; + + function doConnect() { + node.connecting = true; + node.connection = mysqldb.createConnection({ + host : node.host, + port : node.port, + user : node.user, + password : node.password, + database : node.dbname, + insecureAuth: true + }); + + node.connection.connect(function(err) { + node.connecting = false; + if (err) { + node.warn(err); + node.tick = setTimeout(doConnect, reconnect); + } else { + node.connected = true; + } + }); + + node.connection.on('error', function(err) { + node.connected = false; + if (err.code === 'PROTOCOL_CONNECTION_LOST') { + doConnect(); // silently reconnect... + } else { + node.error(err); + doConnect(); + } }); } - }); -} -RED.nodes.registerType("MySQLdatabase",MySQLNode); - -function MysqlDBNodeIn(n) { - RED.nodes.createNode(this,n); - this.mydb = n.mydb; - this.mydbConfig = RED.nodes.getNode(this.mydb); - - if (this.mydbConfig) { - this.mydbConfig.connect(); - var node = this; - node.on("input", function(msg) { - if (typeof msg.topic === 'string') { - //console.log("query:",msg.topic); - node.mydbConfig.connection.query(msg.topic, function(err, rows) { - if (err) { node.warn(err); } - else { - msg.payload = rows; - node.send(msg); - } - }); + this.connect = function() { + if (!this.connected && !this.connecting) { + doConnect(); } - else { - if (typeof msg.topic !== 'string') node.error("msg.topic : the query is not defined as a string"); + } + + this.on('close', function () { + if (this.tick) { clearTimeout(this.tick); } + if (this.connection) { + node.connection.end(function(err) { + if (err) { node.error(err); } + }); } }); } - else { - this.error("MySQL database not configured"); + RED.nodes.registerType("MySQLdatabase",MySQLNode); + + + function MysqlDBNodeIn(n) { + RED.nodes.createNode(this,n); + this.mydb = n.mydb; + this.mydbConfig = RED.nodes.getNode(this.mydb); + + if (this.mydbConfig) { + this.mydbConfig.connect(); + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + //console.log("query:",msg.topic); + node.mydbConfig.connection.query(msg.topic, function(err, rows) { + if (err) { node.warn(err); } + else { + msg.payload = rows; + node.send(msg); + } + }); + } + else { + if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); } + } + }); + } + else { + this.error("MySQL database not configured"); + } } -} -RED.nodes.registerType("mysql",MysqlDBNodeIn); + RED.nodes.registerType("mysql",MysqlDBNodeIn); -//function MysqlDBNodeOut(n) { - //RED.nodes.createNode(this,n); - //this.level = n.level; - //this.operation = n.operation; - //this.levelConfig = RED.nodes.getNode(this.level); + //function MysqlDBNodeOut(n) { + //RED.nodes.createNode(this,n); + //this.level = n.level; + //this.operation = n.operation; + //this.levelConfig = RED.nodes.getNode(this.level); - //if (this.levelConfig) { - //var node = this; - //node.on("input", function(msg) { - //if (typeof msg.topic === 'string') { - //if (node.operation === "delete") { - //node.levelConfig.db.del(msg.topic); + //if (this.levelConfig) { + //var node = this; + //node.on("input", function(msg) { + //if (typeof msg.topic === 'string') { + //if (node.operation === "delete") { + //node.levelConfig.db.del(msg.topic); + //} + //else { + //node.levelConfig.db.put(msg.topic, msg.payload, function(err) { + //if (err) node.error(err); + //}); + //} //} //else { - //node.levelConfig.db.put(msg.topic, msg.payload, function(err) { - //if (err) node.error(err); - //}); + //if (typeof msg.topic !== 'string') node.error("msg.topic : the key is not defined"); //} - //} - //else { - //if (typeof msg.topic !== 'string') node.error("msg.topic : the key is not defined"); - //} - //}); + //}); + //} + //else { + //this.error("MySQL database not configured"); + //} //} - //else { - //this.error("MySQL database not configured"); - //} -//} -//RED.nodes.registerType("mysql out",MysqlDBNodeOut); + //RED.nodes.registerType("mysql out",MysqlDBNodeOut); +} diff --git a/time/79-suncalc.js b/time/79-suncalc.js index 6e2d3096..eef222a4 100644 --- a/time/79-suncalc.js +++ b/time/79-suncalc.js @@ -15,6 +15,7 @@ **/ module.exports = function(RED) { + "use strict"; var SunCalc = require('suncalc'); function SunNode(n) { From c14364d7526c68c3181a88167e36a3d365ee3cd5 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sun, 29 Jun 2014 17:49:38 +0100 Subject: [PATCH 039/134] Make Piface work with "strict" --- hardware/Pi/37-rpi-piface.js | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/hardware/Pi/37-rpi-piface.js b/hardware/Pi/37-rpi-piface.js index 6616d8da..6083f259 100644 --- a/hardware/Pi/37-rpi-piface.js +++ b/hardware/Pi/37-rpi-piface.js @@ -56,37 +56,11 @@ module.exports = function(RED) { "LED 6":"206", "LED 7":"207" } - var tablepin = { - // WiringPi : Physical - "200":"S1", - "201":"S2", - "202":"S3", - "203":"S4", - "204":"I5", - "205":"I6", - "206":"I7", - "207":"I8", - "208":"O0", - "209":"O1", - "210":"O2", - "211":"O3", - "212":"O4", - "213":"O5", - "214":"O6", - "215":"O7", - "200":"L0", - "201":"L1", - "202":"L2", - "203":"L3", - "204":"L4", - "205":"L5", - "206":"L6", - "207":"L7" - } function PiFACEInNode(n) { RED.nodes.createNode(this,n); this.buttonState = -1; + this.npin = n.pin; this.pin = pintable[n.pin]; this.intype = n.intype; var node = this; @@ -102,7 +76,7 @@ module.exports = function(RED) { var previousState = node.buttonState; node.buttonState = Number(stdout); if (previousState !== -1) { - var msg = {topic:"piface/"+tablepin[node.pin], payload:node.buttonState}; + var msg = {topic:"piface/"+node.npin, payload:node.buttonState}; node.send(msg); } } From 999874f2b5a540dafb413b58907dcd0a68db07ca Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 30 Jun 2014 23:41:38 +0100 Subject: [PATCH 040/134] jsHint passing versions of BBB, scanBLE and wemo nodes. Also fixe and in vs out issue on wemo... no way it could have been working previously.. --- hardware/BBB/145-BBB-hardware.js | 895 ++++++++++++++++--------------- hardware/scanBLE/101-scanBLE.js | 27 +- hardware/wemo/60-wemo.js | 12 +- 3 files changed, 469 insertions(+), 465 deletions(-) diff --git a/hardware/BBB/145-BBB-hardware.js b/hardware/BBB/145-BBB-hardware.js index 78ba7151..af5a70df 100644 --- a/hardware/BBB/145-BBB-hardware.js +++ b/hardware/BBB/145-BBB-hardware.js @@ -14,489 +14,492 @@ * limitations under the License. **/ -// Require main module -var RED = require(process.env.NODE_RED_HOME + "/red/red"); -var bonescript = require("bonescript"); +module.exports = function(RED) { + "use strict"; + var bonescript = require("bonescript"); -// Node constructor for bbb-analogue-in -function AnalogueInputNode(n) { - // Create a RED node - RED.nodes.createNode(this, n); + // Node constructor for bbb-analogue-in + function AnalogueInputNode(n) { + // Create a RED node + RED.nodes.createNode(this, n); - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; - this.pin = n.pin; - this.breakpoints = n.breakpoints; - this.averaging = n.averaging; - if (this.averaging) { - this.averages = 10; - } else { - this.averages = 1; - } + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; + this.pin = n.pin; + this.breakpoints = n.breakpoints; + this.averaging = n.averaging; + if (this.averaging) { + this.averages = 10; + } else { + this.averages = 1; + } - // Define 'node' to allow us to access 'this' from within callbacks - var node = this; + // Define 'node' to allow us to access 'this' from within callbacks + var node = this; - // Variables used for input averaging - var sum; // accumulates the input readings to be averaged - var count; // keep track of the number of measurements made + // Variables used for input averaging + var sum; // accumulates the input readings to be averaged + var count; // keep track of the number of measurements made - // The callback function for analogRead. Accumulates the required number of - // measurements, then divides the total number, applies output scaling and - // sends the result - var analogReadCallback = function (x) { - sum = sum + x.value; - count = count - 1; - if (count > 0) { - bonescript.analogRead(node.pin, analogReadCallback); - } else { - var msg = {}; - msg.topic = node.topic; - sum = sum/node.averages; - // i is the index of the first breakpoint where the 'input' value is strictly - // greater than the measurement (note: a measurement can never be == 1) - var i = node.breakpoints.map(function (breakpoint) { return sum >= breakpoint.input; }).indexOf(false); - msg.payload = node.breakpoints[i-1].output + (node.breakpoints[i].output - node.breakpoints[i-1].output) * - (sum - node.breakpoints[i-1].input)/(node.breakpoints[i].input - node.breakpoints[i-1].input); - node.send(msg); - } - }; - - // If we have a valid pin, set the input event handler to Bonescript's analogRead - if (["P9_39", "P9_40", "P9_37", "P9_38", "P9_33", "P9_36", "P9_35"].indexOf(node.pin) >= 0) { - node.on("input", function (msg) { - sum = 0; - count = node.averages; - bonescript.analogRead(node.pin, analogReadCallback); - }); - } else { - node.error("Unconfigured input pin"); - } -} - -// Node constructor for bbb-discrete-in -function DiscreteInputNode(n) { - RED.nodes.createNode(this, n); - - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; // the topic is not currently used - this.pin = n.pin; // The Beaglebone Black pin identifying string - if (n.activeLow) // Set the 'active' state 0 or 1 as appropriate - this.activeState = 0; - else - this.activeState = 1; - this.updateInterval = n.updateInterval * 1000; // How often to send totalActiveTime messages - this.debounce = n.debounce; // Enable switch contact debouncing algorithm - if (n.outputOn === "rising") { - this.activeEdges = [false, true]; - } else if (n.outputOn === "falling") { - this.activeEdges = [true, false]; - } else if (n.outputOn === "both") { - this.activeEdges = [true, true]; - } else { - node.error("Invalid edge type: " + n.outputOn); - } - - // Working variables - this.interruptAttached = false; // Flag: should we detach interrupt when we are closed? - this.intervalId = null; // Remember the timer ID so we can delete it when we are closed - this.currentState = 0; // The pin input state "1" or "0" - this.lastActiveTime = NaN; // The date (in ms since epoch) when the pin last went high - // switch to process.hrtime() - this.totalActiveTime = 0; // The total time in ms that the pin has been high (since reset) - this.starting = true; - this.debouncing = false; // True after a change of state while waiting for the 7ms debounce time to elapse - this.debounceTimer = null; - - // Define 'node' to allow us to access 'this' from within callbacks - var node = this; - - // This function is called by the input pin change-of-state interrupt. If - // debounce is disabled, send the output message. Otherwise, if we are - // currently debouncing, ignore this interrupt. If we are not debouncing, - // schedule a re-read of the input pin in 7ms time, and set the debouncing flag - // Note: this function gets called spuriously when the interrupt is first enabled: - // in this case x.value is undefined - we must test for this - var interruptCallback = function (x) { - if (x.value !== undefined && node.currentState !== Number(x.value)) { - if (node.debounce) { - if (node.debouncing === false) { - node.debouncing = true; - node.debounceTimer = setTimeout(function () { bonescript.digitalRead(node.pin, debounceCallback); }, 7); - } + // The callback function for analogRead. Accumulates the required number of + // measurements, then divides the total number, applies output scaling and + // sends the result + var analogReadCallback = function (x) { + sum = sum + x.value; + count = count - 1; + if (count > 0) { + bonescript.analogRead(node.pin, analogReadCallback); } else { + var msg = {}; + msg.topic = node.topic; + sum = sum/node.averages; + // i is the index of the first breakpoint where the 'input' value is strictly + // greater than the measurement (note: a measurement can never be == 1) + var i = node.breakpoints.map(function (breakpoint) { return sum >= breakpoint.input; }).indexOf(false); + msg.payload = node.breakpoints[i-1].output + (node.breakpoints[i].output - node.breakpoints[i-1].output) * + (sum - node.breakpoints[i-1].input)/(node.breakpoints[i].input - node.breakpoints[i-1].input); + node.send(msg); + } + }; + + // If we have a valid pin, set the input event handler to Bonescript's analogRead + if (["P9_39", "P9_40", "P9_37", "P9_38", "P9_33", "P9_36", "P9_35"].indexOf(node.pin) >= 0) { + node.on("input", function (msg) { + sum = 0; + count = node.averages; + bonescript.analogRead(node.pin, analogReadCallback); + }); + } else { + node.error("Unconfigured input pin"); + } + } + + // Node constructor for bbb-discrete-in + function DiscreteInputNode(n) { + RED.nodes.createNode(this, n); + + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; // the topic is not currently used + this.pin = n.pin; // The Beaglebone Black pin identifying string + if (n.activeLow) { // Set the 'active' state 0 or 1 as appropriate + this.activeState = 0; + } + else { + this.activeState = 1; + } + this.updateInterval = n.updateInterval * 1000; // How often to send totalActiveTime messages + this.debounce = n.debounce; // Enable switch contact debouncing algorithm + if (n.outputOn === "rising") { + this.activeEdges = [false, true]; + } else if (n.outputOn === "falling") { + this.activeEdges = [true, false]; + } else if (n.outputOn === "both") { + this.activeEdges = [true, true]; + } else { + node.error("Invalid edge type: " + n.outputOn); + } + + // Working variables + this.interruptAttached = false; // Flag: should we detach interrupt when we are closed? + this.intervalId = null; // Remember the timer ID so we can delete it when we are closed + this.currentState = 0; // The pin input state "1" or "0" + this.lastActiveTime = NaN; // The date (in ms since epoch) when the pin last went high + // switch to process.hrtime() + this.totalActiveTime = 0; // The total time in ms that the pin has been high (since reset) + this.starting = true; + this.debouncing = false; // True after a change of state while waiting for the 7ms debounce time to elapse + this.debounceTimer = null; + + // Define 'node' to allow us to access 'this' from within callbacks + var node = this; + + // This function is called by the input pin change-of-state interrupt. If + // debounce is disabled, send the output message. Otherwise, if we are + // currently debouncing, ignore this interrupt. If we are not debouncing, + // schedule a re-read of the input pin in 7ms time, and set the debouncing flag + // Note: this function gets called spuriously when the interrupt is first enabled: + // in this case x.value is undefined - we must test for this + var interruptCallback = function (x) { + if (x.value !== undefined && node.currentState !== Number(x.value)) { + if (node.debounce) { + if (node.debouncing === false) { + node.debouncing = true; + node.debounceTimer = setTimeout(function () { bonescript.digitalRead(node.pin, debounceCallback); }, 7); + } + } else { + sendStateMessage(x); + } + } + }; + + // This function is called approx 7ms after a potential change-of-state which is + // being debounced. Terminate the debounce, and send a message if the state has + // actually changed + var debounceCallback = function (x) { + node.debounceTimer = null; + node.debouncing = false; + if (x.value !== undefined && node.currentState !== Number(x.value)) { sendStateMessage(x); } - } - }; + }; - // This function is called approx 7ms after a potential change-of-state which is - // being debounced. Terminate the debounce, and send a message if the state has - // actually changed - var debounceCallback = function (x) { - node.debounceTimer = null; - node.debouncing = false; - if (x.value !== undefined && node.currentState !== Number(x.value)) { - sendStateMessage(x); - } - }; + // This function is called when either the interruptCallback or the debounceCallback + // have determined we have a 'genuine' change of state. Update the currentState and + // ActiveTime variables, and send a message on the first output with the new state + var sendStateMessage = function (x) { + node.currentState = Number(x.value); + var now = Date.now(); + if (node.currentState === node.activeState) { + node.lastActiveTime = now; + } else if (!isNaN(node.lastActiveTime)) { + node.totalActiveTime += now - node.lastActiveTime; + } + if (node.activeEdges[node.currentState]) { + var msg = {}; + msg.topic = node.topic; + msg.payload = node.currentState; + node.send([msg, null]); + } + }; - // This function is called when either the interruptCallback or the debounceCallback - // have determined we have a 'genuine' change of state. Update the currentState and - // ActiveTime variables, and send a message on the first output with the new state - var sendStateMessage = function (x) { - node.currentState = Number(x.value); - var now = Date.now(); - if (node.currentState === node.activeState) { - node.lastActiveTime = now; - } else if (!isNaN(node.lastActiveTime)) { - node.totalActiveTime += now - node.lastActiveTime; - } - if (node.activeEdges[node.currentState]) { + // This function is called by the timer. It updates the ActiveTime variables, and sends a + // message on the second output with the latest value of the total active time, in seconds + var timerCallback = function () { + if (node.currentState === node.activeState) { + var now = Date.now(); + node.totalActiveTime += now - node.lastActiveTime; + node.lastActiveTime = now; + } var msg = {}; msg.topic = node.topic; - msg.payload = node.currentState; - node.send([msg, null]); - } - }; - - // This function is called by the timer. It updates the ActiveTime variables, and sends a - // message on the second output with the latest value of the total active time, in seconds - var timerCallback = function () { - if (node.currentState === node.activeState) { - var now = Date.now(); - node.totalActiveTime += now - node.lastActiveTime; - node.lastActiveTime = now; - } - var msg = {}; - msg.topic = node.topic; - msg.payload = node.totalActiveTime / 1000; - node.send([null, msg]); - // Re-synchronise the pin state if we have missed a state change interrupt for some - // reason, and we are not in the process of debouncing one - if (node.debouncing === false) { - bonescript.digitalRead(node.pin, interruptCallback); - } - }; - - // This function is called when we receive an input message. If the topic contains - // 'load' (case insensitive) set the totalActiveTime to the numeric value of the - // payload, if possible. Otherwise clear the totalActiveTime (so we start counting - // from zero again) - var inputCallback = function (ipMsg) { - if (String(ipMsg.topic).search(/load/i) < 0 || isFinite(ipMsg.payload) == false) { - node.totalActiveTime = 0; - } else { - node.totalActiveTime = Number(ipMsg.payload); - } - if (node.currentState === node.activeState) { - node.lastActiveTime = Date.now(); - } - // On startup, send an initial activeTime message, but only send an - // initial currentState message if we are in both edges active mode - if (node.starting) { - node.starting = false; - var msg; - if (node.activeEdges[0] && node.activeEdges[1]) { - msg = [{topic:node.topic}, {topic:node.topic}]; - msg[0].payload = node.currentState; - } else { - msg = [null, {topic:node.topic}]; + msg.payload = node.totalActiveTime / 1000; + node.send([null, msg]); + // Re-synchronise the pin state if we have missed a state change interrupt for some + // reason, and we are not in the process of debouncing one + if (node.debouncing === false) { + bonescript.digitalRead(node.pin, interruptCallback); } - msg[1].payload = node.totalActiveTime; - node.send(msg); - } - }; + }; - // If we have a valid pin, set it as an input and read the (digital) state - if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", - "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", - "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", - "P9_27", "P9_30", "P9_41", "P9_42"].indexOf(node.pin) >= 0) { - // Don't set up interrupts & intervals until after the close event handler has been installed - bonescript.detachInterrupt(node.pin); - process.nextTick(function () { - bonescript.pinMode(node.pin, bonescript.INPUT); - bonescript.digitalRead(node.pin, function (x) { - // Initialise the currentState and lastActveTime variables based on the value read - node.currentState = Number(x.value); - if (node.currentState === node.activeState) { - node.lastActiveTime = Date.now(); - // switch to process.hrtime() - } - // Attempt to attach a change-of-state interrupt handler to the pin. If we succeed, - // set the input event and interval handlers, then send an initial message with the - // pin state on the first output - if (bonescript.attachInterrupt(node.pin, true, bonescript.CHANGE, interruptCallback)) { - node.interruptAttached = true; - node.on("input", inputCallback); - node.intervalId = setInterval(timerCallback, node.updateInterval); - } else { - node.error("Failed to attach interrupt"); - } - setTimeout(function () { node.emit("input", {}); }, 50); - }); - }); - } else { - node.error("Unconfigured input pin"); - } -} + // This function is called when we receive an input message. If the topic contains + // 'load' (case insensitive) set the totalActiveTime to the numeric value of the + // payload, if possible. Otherwise clear the totalActiveTime (so we start counting + // from zero again) + var inputCallback = function (ipMsg) { + if (String(ipMsg.topic).search(/load/i) < 0 || isFinite(ipMsg.payload) === false) { + node.totalActiveTime = 0; + } else { + node.totalActiveTime = Number(ipMsg.payload); + } + if (node.currentState === node.activeState) { + node.lastActiveTime = Date.now(); + } + // On startup, send an initial activeTime message, but only send an + // initial currentState message if we are in both edges active mode + if (node.starting) { + node.starting = false; + var msg; + if (node.activeEdges[0] && node.activeEdges[1]) { + msg = [{topic:node.topic}, {topic:node.topic}]; + msg[0].payload = node.currentState; + } else { + msg = [null, {topic:node.topic}]; + } + msg[1].payload = node.totalActiveTime; + node.send(msg); + } + }; -// Node constructor for bbb-pulse-in -function PulseInputNode(n) { - RED.nodes.createNode(this, n); - - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; // the topic is not currently used - this.pin = n.pin; // The Beaglebone Black pin identifying string - this.updateInterval = n.updateInterval * 1000; // How often to send output messages - this.countType = n.countType; // Sets either 'edge' or 'pulse' counting - this.countUnit = n.countUnit; // Scaling appling to count output - this.countRate = n.countRate; // Scaling applied to rate output - - // Working variables - this.interruptAttached = false; // Flag: should we detach interrupt when we are closed? - this.intervalId = null; // Remember the timer ID so we can delete it when we are closed - this.pulseCount = 0; // (Unscaled) total pulse count - // Hold the hrtime of the last two pulses (with ns resolution) - this.pulseTime = [[NaN, NaN], [NaN, NaN]]; - - // Define 'node' to allow us to access 'this' from within callbacks - var node = this; - - // Called by the edge or pulse interrupt. If this is a valid interrupt, record the - // pulse time and count the pulse - var interruptCallback = function (x) { - if (x.value !== undefined) { - node.pulseTime = [node.pulseTime[1], process.hrtime()]; - node.pulseCount = node.pulseCount + 1; - } - }; - - // Called when an input message arrives. If the topic contains 'load' (case - // insensitive) and the payload is a valid number, set the count to that - // number, otherwise set it to zero - var inputCallback = function (msg) { - if (String(msg.topic).search(/load/i) < 0 || isFinite(msg.payload) == false) { - node.pulseCount = 0; - } else { - node.pulseCount = Number(msg.payload); - } - }; - - // Called by the message timer. Send two messages: the scaled pulse count on - // the first output and the scaled instantaneous pulse rate on the second. - // The instantaneous pulse rate is the reciprocal of the larger of either the - // time interval between the last two pulses, or the time interval since the last pulse. - var timerCallback = function () { - var now = process.hrtime(); - var lastTime = node.pulseTime[1][0] - node.pulseTime[0][0] + (node.pulseTime[1][1] - node.pulseTime[0][1]) / 1e9; - var thisTime = now[0] - node.pulseTime[1][0] + (now[1] - node.pulseTime[1][1]) / 1e9; - var msg = [{ topic:node.topic }, { topic:node.topic }]; - msg[0].payload = node.countUnit * node.pulseCount; - // At startup, pulseTime contains NaN's: force the rate output to 0 - msg[1].payload = node.countRate / Math.max(thisTime, lastTime) || 0; - node.send(msg); - }; - - // If we have a valid pin, set it as an input and read the (digital) state - if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", - "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", - "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", - "P9_27", "P9_30", "P9_41", "P9_42"].indexOf(node.pin) >= 0) { - // Don't set up interrupts & intervals until after the close event handler has been installed - bonescript.detachInterrupt(node.pin); - process.nextTick(function () { + // If we have a valid pin, set it as an input and read the (digital) state + if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", + "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", + "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", + "P9_27", "P9_30", "P9_41", "P9_42"].indexOf(node.pin) >= 0) { + // Don't set up interrupts & intervals until after the close event handler has been installed + bonescript.detachInterrupt(node.pin); + process.nextTick(function () { bonescript.pinMode(node.pin, bonescript.INPUT); bonescript.digitalRead(node.pin, function (x) { - // Initialise the currentState based on the value read - node.currentState = Number(x.value); - // Attempt to attach an interrupt handler to the pin. If we succeed, - // set the input event and interval handlers - var interruptType; - if (node.countType === "pulse") { - // interruptType = bonescript.FALLING; <- doesn't work in v0.2.4 - interruptType = bonescript.RISING; - } else { - interruptType = bonescript.CHANGE; - } - if (bonescript.attachInterrupt(node.pin, true, interruptType, interruptCallback)) { - node.interruptAttached = true; - node.on("input", inputCallback); - node.intervalId = setInterval(timerCallback, node.updateInterval); - } else { - node.error("Failed to attach interrupt"); - } + // Initialise the currentState and lastActveTime variables based on the value read + node.currentState = Number(x.value); + if (node.currentState === node.activeState) { + node.lastActiveTime = Date.now(); + // switch to process.hrtime() + } + // Attempt to attach a change-of-state interrupt handler to the pin. If we succeed, + // set the input event and interval handlers, then send an initial message with the + // pin state on the first output + if (bonescript.attachInterrupt(node.pin, true, bonescript.CHANGE, interruptCallback)) { + node.interruptAttached = true; + node.on("input", inputCallback); + node.intervalId = setInterval(timerCallback, node.updateInterval); + } else { + node.error("Failed to attach interrupt"); + } + setTimeout(function () { node.emit("input", {}); }, 50); + }); }); - }); - } else { - node.error("Unconfigured input pin"); + } else { + node.error("Unconfigured input pin"); + } } -} -// Node constructor for bbb-discrete-out -function DiscreteOutputNode(n) { - RED.nodes.createNode(this, n); + // Node constructor for bbb-pulse-in + function PulseInputNode(n) { + RED.nodes.createNode(this, n); - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; // the topic is not currently used - this.pin = n.pin; // The Beaglebone Black pin identifying string - this.defaultState = Number(n.defaultState); // What state to set up as - this.inverting = n.inverting; - this.toggle = n.toggle; + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; // the topic is not currently used + this.pin = n.pin; // The Beaglebone Black pin identifying string + this.updateInterval = n.updateInterval * 1000; // How often to send output messages + this.countType = n.countType; // Sets either 'edge' or 'pulse' counting + this.countUnit = n.countUnit; // Scaling appling to count output + this.countRate = n.countRate; // Scaling applied to rate output - // Working variables - this.currentState = this.defaultState; + // Working variables + this.interruptAttached = false; // Flag: should we detach interrupt when we are closed? + this.intervalId = null; // Remember the timer ID so we can delete it when we are closed + this.pulseCount = 0; // (Unscaled) total pulse count + // Hold the hrtime of the last two pulses (with ns resolution) + this.pulseTime = [[NaN, NaN], [NaN, NaN]]; - var node = this; + // Define 'node' to allow us to access 'this' from within callbacks + var node = this; - // If the input message paylod is numeric, values > 0.5 are 'true', otherwise use - // the truthiness of the payload. Apply the inversion flag before setting the output - var inputCallback = function (msg) { - var newState; - if (node.toggle) { - newState = node.currentState === 0 ? 1 : 0; - } else { - if (isFinite(Number(msg.payload))) { - newState = Number(msg.payload) > 0.5 ? true : false; - } else if (msg.payload) { - newState = true; + // Called by the edge or pulse interrupt. If this is a valid interrupt, record the + // pulse time and count the pulse + var interruptCallback = function (x) { + if (x.value !== undefined) { + node.pulseTime = [node.pulseTime[1], process.hrtime()]; + node.pulseCount = node.pulseCount + 1; + } + }; + + // Called when an input message arrives. If the topic contains 'load' (case + // insensitive) and the payload is a valid number, set the count to that + // number, otherwise set it to zero + var inputCallback = function (msg) { + if (String(msg.topic).search(/load/i) < 0 || isFinite(msg.payload) === false) { + node.pulseCount = 0; } else { - newState = false; + node.pulseCount = Number(msg.payload); } - if (node.inverting) { - newState = !newState; - } - } - bonescript.digitalWrite(node.pin, newState ? 1 : 0); - node.send({ topic:node.topic, payload:newState }); - node.currentState = newState; - }; + }; - // If we have a valid pin, set it as an output and set the default state - if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", - "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", - "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", - "P9_27", "P9_30", "P9_41", "P9_42", "USR0", "USR1", "USR2", "USR3"].indexOf(node.pin) >= 0) { - // Don't set up interrupts & intervals until after the close event handler has been installed - bonescript.detachInterrupt(node.pin); - process.nextTick(function () { - bonescript.pinMode(node.pin, bonescript.OUTPUT); - node.on("input", inputCallback); - setTimeout(function () { bonescript.digitalWrite(node.pin, node.defaultState); }, 50); - }); - } else { - node.error("Unconfigured output pin"); + // Called by the message timer. Send two messages: the scaled pulse count on + // the first output and the scaled instantaneous pulse rate on the second. + // The instantaneous pulse rate is the reciprocal of the larger of either the + // time interval between the last two pulses, or the time interval since the last pulse. + var timerCallback = function () { + var now = process.hrtime(); + var lastTime = node.pulseTime[1][0] - node.pulseTime[0][0] + (node.pulseTime[1][1] - node.pulseTime[0][1]) / 1e9; + var thisTime = now[0] - node.pulseTime[1][0] + (now[1] - node.pulseTime[1][1]) / 1e9; + var msg = [{ topic:node.topic }, { topic:node.topic }]; + msg[0].payload = node.countUnit * node.pulseCount; + // At startup, pulseTime contains NaN's: force the rate output to 0 + msg[1].payload = node.countRate / Math.max(thisTime, lastTime) || 0; + node.send(msg); + }; + + // If we have a valid pin, set it as an input and read the (digital) state + if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", + "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", + "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", + "P9_27", "P9_30", "P9_41", "P9_42"].indexOf(node.pin) >= 0) { + // Don't set up interrupts & intervals until after the close event handler has been installed + bonescript.detachInterrupt(node.pin); + process.nextTick(function () { + bonescript.pinMode(node.pin, bonescript.INPUT); + bonescript.digitalRead(node.pin, function (x) { + // Initialise the currentState based on the value read + node.currentState = Number(x.value); + // Attempt to attach an interrupt handler to the pin. If we succeed, + // set the input event and interval handlers + var interruptType; + if (node.countType === "pulse") { + // interruptType = bonescript.FALLING; <- doesn't work in v0.2.4 + interruptType = bonescript.RISING; + } else { + interruptType = bonescript.CHANGE; + } + if (bonescript.attachInterrupt(node.pin, true, interruptType, interruptCallback)) { + node.interruptAttached = true; + node.on("input", inputCallback); + node.intervalId = setInterval(timerCallback, node.updateInterval); + } else { + node.error("Failed to attach interrupt"); + } + }); + }); + } else { + node.error("Unconfigured input pin"); + } } -} -// Node constructor for bbb-pulse-out -function PulseOutputNode(n) { - RED.nodes.createNode(this, n); + // Node constructor for bbb-discrete-out + function DiscreteOutputNode(n) { + RED.nodes.createNode(this, n); - // Store local copies of the node configuration (as defined in the .html) - this.topic = n.topic; // the topic is not currently used - this.pin = n.pin; // The Beaglebone Black pin identifying string - this.pulseState = Number(n.pulseState); // What state the pulse will be.. - this.defaultState = this.pulseState === 1 ? 0 : 1; - this.retriggerable = n.retriggerable; - this.pulseTime = n.pulseTime * 1000; // Pulse width in milliseconds + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; // the topic is not currently used + this.pin = n.pin; // The Beaglebone Black pin identifying string + this.defaultState = Number(n.defaultState); // What state to set up as + this.inverting = n.inverting; + this.toggle = n.toggle; - // Working variables - this.pulseTimer = null; // Non-null while a pulse is being generated + // Working variables + this.currentState = this.defaultState; - var node = this; + var node = this; - // Generate a pulse in response to an input message. If the topic includes the text - // 'time' (case insensitive) and the payload is numeric, use this value as the - // pulse time. Otherwise use the value from the properties dialog. - // If the resulting pulse time is < 1ms, do nothing. - // If the pulse mode is not retriggerable, then if no pulseTimer is active, generate - // a pulse. If the pulse mode is retriggerable, and a pulseTimer is active, cancel it. - // If no timer is active, set the pulse output. In both cases schedule a new pulse - // timer. - var inputCallback = function (msg) { - var time = node.pulseTime; - if (String(msg.topic).search(/time/i) >= 0 && isFinite(msg.payload)) { - time = msg.payload * 1000; - } - if (time >= 1) { - if (node.retriggerable === false) { - if (node.pulseTimer === null) { - node.pulseTimer = setTimeout(endPulseCallback, time); - bonescript.digitalWrite(node.pin, node.pulseState); - node.send({ topic:node.topic, payload:node.pulseState }); - } + // If the input message paylod is numeric, values > 0.5 are 'true', otherwise use + // the truthiness of the payload. Apply the inversion flag before setting the output + var inputCallback = function (msg) { + var newState; + if (node.toggle) { + newState = node.currentState === 0 ? 1 : 0; } else { - if (node.pulseTimer !== null) { - clearTimeout(node.pulseTimer); + if (isFinite(Number(msg.payload))) { + newState = Number(msg.payload) > 0.5 ? true : false; + } else if (msg.payload) { + newState = true; } else { - bonescript.digitalWrite(node.pin, node.pulseState); - node.send({ topic:node.topic, payload:node.pulseState }); + newState = false; + } + if (node.inverting) { + newState = !newState; } - node.pulseTimer = setTimeout(endPulseCallback, time); } - } - }; + bonescript.digitalWrite(node.pin, newState ? 1 : 0); + node.send({ topic:node.topic, payload:newState }); + node.currentState = newState; + }; - // At the end of the pulse, restore the default state and set the timer to null - var endPulseCallback = function () { - node.pulseTimer = null; - bonescript.digitalWrite(node.pin, node.defaultState); - node.send({ topic:node.topic, payload:node.defaultState }); - }; - - // If we have a valid pin, set it as an output and set the default state - if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", - "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", - "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", - "P9_27", "P9_30", "P9_41", "P9_42", "USR0", "USR1", "USR2", "USR3"].indexOf(node.pin) >= 0) { - // Don't set up interrupts & intervals until after the close event handler has been installed - bonescript.detachInterrupt(node.pin); - process.nextTick(function () { - bonescript.pinMode(node.pin, bonescript.OUTPUT); - node.on("input", inputCallback); - // Set the pin to the default stte once the dust settles - setTimeout(endPulseCallback, 50); - }); - } else { - node.error("Unconfigured output pin"); + // If we have a valid pin, set it as an output and set the default state + if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", + "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", + "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", + "P9_27", "P9_30", "P9_41", "P9_42", "USR0", "USR1", "USR2", "USR3"].indexOf(node.pin) >= 0) { + // Don't set up interrupts & intervals until after the close event handler has been installed + bonescript.detachInterrupt(node.pin); + process.nextTick(function () { + bonescript.pinMode(node.pin, bonescript.OUTPUT); + node.on("input", inputCallback); + setTimeout(function () { bonescript.digitalWrite(node.pin, node.defaultState); }, 50); + }); + } else { + node.error("Unconfigured output pin"); + } } + + // Node constructor for bbb-pulse-out + function PulseOutputNode(n) { + RED.nodes.createNode(this, n); + + // Store local copies of the node configuration (as defined in the .html) + this.topic = n.topic; // the topic is not currently used + this.pin = n.pin; // The Beaglebone Black pin identifying string + this.pulseState = Number(n.pulseState); // What state the pulse will be.. + this.defaultState = this.pulseState === 1 ? 0 : 1; + this.retriggerable = n.retriggerable; + this.pulseTime = n.pulseTime * 1000; // Pulse width in milliseconds + + // Working variables + this.pulseTimer = null; // Non-null while a pulse is being generated + + var node = this; + + // Generate a pulse in response to an input message. If the topic includes the text + // 'time' (case insensitive) and the payload is numeric, use this value as the + // pulse time. Otherwise use the value from the properties dialog. + // If the resulting pulse time is < 1ms, do nothing. + // If the pulse mode is not retriggerable, then if no pulseTimer is active, generate + // a pulse. If the pulse mode is retriggerable, and a pulseTimer is active, cancel it. + // If no timer is active, set the pulse output. In both cases schedule a new pulse + // timer. + var inputCallback = function (msg) { + var time = node.pulseTime; + if (String(msg.topic).search(/time/i) >= 0 && isFinite(msg.payload)) { + time = msg.payload * 1000; + } + if (time >= 1) { + if (node.retriggerable === false) { + if (node.pulseTimer === null) { + node.pulseTimer = setTimeout(endPulseCallback, time); + bonescript.digitalWrite(node.pin, node.pulseState); + node.send({ topic:node.topic, payload:node.pulseState }); + } + } else { + if (node.pulseTimer !== null) { + clearTimeout(node.pulseTimer); + } else { + bonescript.digitalWrite(node.pin, node.pulseState); + node.send({ topic:node.topic, payload:node.pulseState }); + } + node.pulseTimer = setTimeout(endPulseCallback, time); + } + } + }; + + // At the end of the pulse, restore the default state and set the timer to null + var endPulseCallback = function () { + node.pulseTimer = null; + bonescript.digitalWrite(node.pin, node.defaultState); + node.send({ topic:node.topic, payload:node.defaultState }); + }; + + // If we have a valid pin, set it as an output and set the default state + if (["P8_7", "P8_8", "P8_9", "P8_10", "P8_11", "P8_12", "P8_13", "P8_14", "P8_15", + "P8_16", "P8_17", "P8_18", "P8_19", "P8_26", "P9_11", "P9_12", "P9_13", "P9_14", + "P9_15", "P9_16", "P9_17", "P9_18", "P9_21", "P9_22", "P9_23", "P9_24", "P9_26", + "P9_27", "P9_30", "P9_41", "P9_42", "USR0", "USR1", "USR2", "USR3"].indexOf(node.pin) >= 0) { + // Don't set up interrupts & intervals until after the close event handler has been installed + bonescript.detachInterrupt(node.pin); + process.nextTick(function () { + bonescript.pinMode(node.pin, bonescript.OUTPUT); + node.on("input", inputCallback); + // Set the pin to the default stte once the dust settles + setTimeout(endPulseCallback, 50); + }); + } else { + node.error("Unconfigured output pin"); + } + } + + // Register the nodes by name. This must be called before overriding any of the Node functions. + RED.nodes.registerType("bbb-analogue-in", AnalogueInputNode); + RED.nodes.registerType("bbb-discrete-in", DiscreteInputNode); + RED.nodes.registerType("bbb-pulse-in", PulseInputNode); + RED.nodes.registerType("bbb-discrete-out", DiscreteOutputNode); + RED.nodes.registerType("bbb-pulse-out", PulseOutputNode); + + // On close, detach the interrupt (if we attached one) and clear any active timers + DiscreteInputNode.prototype.close = function () { + if (this.interruptAttached) { + bonescript.detachInterrupt(this.pin); + } + if (this.intervalId !== null) { + clearInterval(this.intervalId); + } + if (this.debounceTimer !== null) { + clearTimeout(this.debounceTimer); + } + }; + + // On close, detach the interrupt (if we attached one) and clear the interval (if we set one) + PulseInputNode.prototype.close = function () { + if (this.interruptAttached) { + bonescript.detachInterrupt(this.pin); + } + if (this.intervalId !== null) { + clearInterval(this.intervalId); + } + }; + + // On close, clear an active pulse timer + PulseOutputNode.prototype.close = function () { + if (this.pulseTimer !== null) { + clearTimeout(this.pulseTimer); + } + }; } - -// Register the nodes by name. This must be called before overriding any of the Node functions. -RED.nodes.registerType("bbb-analogue-in", AnalogueInputNode); -RED.nodes.registerType("bbb-discrete-in", DiscreteInputNode); -RED.nodes.registerType("bbb-pulse-in", PulseInputNode); -RED.nodes.registerType("bbb-discrete-out", DiscreteOutputNode); -RED.nodes.registerType("bbb-pulse-out", PulseOutputNode); - -// On close, detach the interrupt (if we attached one) and clear any active timers -DiscreteInputNode.prototype.close = function () { - if (this.interruptAttached) { - bonescript.detachInterrupt(this.pin); - } - if (this.intervalId !== null) { - clearInterval(this.intervalId); - } - if (this.debounceTimer !== null) { - clearTimeout(this.debounceTimer); - } -}; - -// On close, detach the interrupt (if we attached one) and clear the interval (if we set one) -PulseInputNode.prototype.close = function () { - if (this.interruptAttached) { - bonescript.detachInterrupt(this.pin); - } - if (this.intervalId !== null) { - clearInterval(this.intervalId); - } -}; - -// On close, clear an active pulse timer -PulseOutputNode.prototype.close = function () { - if (this.pulseTimer !== null) { - clearTimeout(this.pulseTimer); - } -}; diff --git a/hardware/scanBLE/101-scanBLE.js b/hardware/scanBLE/101-scanBLE.js index 24532e37..bf07e549 100644 --- a/hardware/scanBLE/101-scanBLE.js +++ b/hardware/scanBLE/101-scanBLE.js @@ -37,29 +37,30 @@ function BleScan(n) { this.ble_name = n.ble_name; this.ble_uuid = n.ble_uuid; - this.on("input", function(msg){ - noble.startScanning(); - }); - noble.on('scanStart', function(msg) { - var msg = {}; + this.on("input", function(msg){ + noble.startScanning(); + }); + + noble.on('scanStart', function(msg) { + msg = {}; msg.topic = node.topic; msg.payload = "Scanning initiated..." //debugging - //console.log('scanning initiated...'); - node.send(msg); - }); - - noble.on('discover', function(peripheral) { + //console.log('scanning initiated...'); + node.send(msg); + }); + noble.on('discover', function(peripheral) { var msg = {}; - msg.topic = node.topic; + msg.topic = node.topic; msg.payload = "not found"; //check for the device name and the UUID (first one from the UUID list) if(peripheral.advertisement.localName==node.ble_name && peripheral.advertisement.serviceUuids[0]==node.ble_uuid) { msg.payload=peripheral.advertisement.localName; - noble.stopScanning(); } + noble.stopScanning(); + } node.send(msg); -}); + }); this.on("close", function() { try { noble.stopScanning(); } diff --git a/hardware/wemo/60-wemo.js b/hardware/wemo/60-wemo.js index c2e89e2c..3f75f8d2 100644 --- a/hardware/wemo/60-wemo.js +++ b/hardware/wemo/60-wemo.js @@ -16,12 +16,12 @@ module.exports = function(RED) { "use strict"; - var WeMo = new require('wemo'); + var Wemo = require('wemo'); - function WeMoOut(n) { + function WemoOut(n) { RED.nodes.createNode(this,n); this.ipaddr = n.ipaddr; - this.wemoSwitch = new WeMo(n.ipaddr); + this.wemoSwitch = new Wemo(n.ipaddr); var node = this; this.on("input", function(msg) { @@ -35,9 +35,9 @@ module.exports = function(RED) { } }); } - RED.nodes.registerType("wemo out",WeMoOut); + RED.nodes.registerType("wemo out",WemoOut); - function WeMoIn(n) { + function WemoIn(n) { RED.nodes.createNode(this,n); this.ipaddr = n.ipaddr; this.wemoSwitch = new WeMo(n.ipaddr); @@ -58,5 +58,5 @@ module.exports = function(RED) { clearInterval(tick); }); } - RED.nodes.registerType("wemo in",WeMoOut); + RED.nodes.registerType("wemo in",WemoIn); } From 78d758bf85af8bdd11c8b889915ec4b265f8b3be Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 14:51:55 +0100 Subject: [PATCH 041/134] Start moving nodes for npm install-ability (split Blink nodes. and try blinkstick) --- hardware/{blink => blink1}/77-blink1.html | 0 hardware/{blink => blink1}/77-blink1.js | 0 .../{blink => blinkstick}/76-blinkstick.html | 0 .../{blink => blinkstick}/76-blinkstick.js | 0 hardware/blinkstick/LICENSE | 177 ++++++++++++++++++ hardware/blinkstick/README.md | 23 +++ hardware/blinkstick/package.json | 24 +++ 7 files changed, 224 insertions(+) rename hardware/{blink => blink1}/77-blink1.html (100%) rename hardware/{blink => blink1}/77-blink1.js (100%) rename hardware/{blink => blinkstick}/76-blinkstick.html (100%) rename hardware/{blink => blinkstick}/76-blinkstick.js (100%) create mode 100644 hardware/blinkstick/LICENSE create mode 100644 hardware/blinkstick/README.md create mode 100644 hardware/blinkstick/package.json diff --git a/hardware/blink/77-blink1.html b/hardware/blink1/77-blink1.html similarity index 100% rename from hardware/blink/77-blink1.html rename to hardware/blink1/77-blink1.html diff --git a/hardware/blink/77-blink1.js b/hardware/blink1/77-blink1.js similarity index 100% rename from hardware/blink/77-blink1.js rename to hardware/blink1/77-blink1.js diff --git a/hardware/blink/76-blinkstick.html b/hardware/blinkstick/76-blinkstick.html similarity index 100% rename from hardware/blink/76-blinkstick.html rename to hardware/blinkstick/76-blinkstick.html diff --git a/hardware/blink/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js similarity index 100% rename from hardware/blink/76-blinkstick.js rename to hardware/blinkstick/76-blinkstick.js diff --git a/hardware/blinkstick/LICENSE b/hardware/blinkstick/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/blinkstick/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/blinkstick/README.md b/hardware/blinkstick/README.md new file mode 100644 index 00000000..8d56ac57 --- /dev/null +++ b/hardware/blinkstick/README.md @@ -0,0 +1,23 @@ +node-red-node-blinkstick +======================== +A Node-Red node to control a Blinkstick. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-blinkstick + + +Usage +----- + +The BlinkStick output node expects a msg.payload with either a hex string #rrggbb triple or red,green,blue as three 0-255 values. + + +It can also accept standard HTML colour names. + +NOTE: currently only works with a single BlinkStick. (As it uses the findFirst() function to attach). + +For more info see the BlinkStick website or the blinkstick npm documentation. diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json new file mode 100644 index 00000000..5d4a659c --- /dev/null +++ b/hardware/blinkstick/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-blinkstick", + "version" : "0.0.1", + "description" : "A Node-RED node to control a Blinkstick", + "dependencies" : { + "blinkstick" : "0.1.*" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes.git" + }, + "license": "Apache", + "keywords": [ "node-red", "blinkstick" ], + "node-red" : { + "nodes" : { + "blinkstick": "blinkstick.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 96c3ba0282210996d4d98e2ab7deea64e2d26876 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 15:07:26 +0100 Subject: [PATCH 042/134] Tweak blinkstick readme --- hardware/blinkstick/README.md | 2 +- hardware/blinkstick/package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hardware/blinkstick/README.md b/hardware/blinkstick/README.md index 8d56ac57..4bc440d6 100644 --- a/hardware/blinkstick/README.md +++ b/hardware/blinkstick/README.md @@ -1,6 +1,6 @@ node-red-node-blinkstick ======================== -A Node-Red node to control a Blinkstick. +A Node-RED node to control a Blinkstick. Install ------- diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json index 5d4a659c..d17111d7 100644 --- a/hardware/blinkstick/package.json +++ b/hardware/blinkstick/package.json @@ -1,13 +1,13 @@ { "name" : "node-red-node-blinkstick", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "A Node-RED node to control a Blinkstick", "dependencies" : { "blinkstick" : "0.1.*" }, "repository" : { "type":"git", - "url":"https://github.com/node-red/node-red-nodes.git" + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/blinkstick" }, "license": "Apache", "keywords": [ "node-red", "blinkstick" ], From cbaecd402afcaade837d2ce51ff0df01a3defb2c Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 16:11:34 +0100 Subject: [PATCH 043/134] correct Blinkstick package.json --- hardware/{Pi => LEDborg}/78-ledborg.html | 0 hardware/{Pi => LEDborg}/78-ledborg.js | 0 hardware/{Pi => PiFace}/37-rpi-piface.html | 0 hardware/{Pi => PiFace}/37-rpi-piface.js | 0 hardware/{Pi => Pibrella}/38-rpi-pibrella.html | 0 hardware/{Pi => Pibrella}/38-rpi-pibrella.js | 0 hardware/blinkstick/package.json | 4 ++-- 7 files changed, 2 insertions(+), 2 deletions(-) rename hardware/{Pi => LEDborg}/78-ledborg.html (100%) rename hardware/{Pi => LEDborg}/78-ledborg.js (100%) rename hardware/{Pi => PiFace}/37-rpi-piface.html (100%) rename hardware/{Pi => PiFace}/37-rpi-piface.js (100%) rename hardware/{Pi => Pibrella}/38-rpi-pibrella.html (100%) rename hardware/{Pi => Pibrella}/38-rpi-pibrella.js (100%) diff --git a/hardware/Pi/78-ledborg.html b/hardware/LEDborg/78-ledborg.html similarity index 100% rename from hardware/Pi/78-ledborg.html rename to hardware/LEDborg/78-ledborg.html diff --git a/hardware/Pi/78-ledborg.js b/hardware/LEDborg/78-ledborg.js similarity index 100% rename from hardware/Pi/78-ledborg.js rename to hardware/LEDborg/78-ledborg.js diff --git a/hardware/Pi/37-rpi-piface.html b/hardware/PiFace/37-rpi-piface.html similarity index 100% rename from hardware/Pi/37-rpi-piface.html rename to hardware/PiFace/37-rpi-piface.html diff --git a/hardware/Pi/37-rpi-piface.js b/hardware/PiFace/37-rpi-piface.js similarity index 100% rename from hardware/Pi/37-rpi-piface.js rename to hardware/PiFace/37-rpi-piface.js diff --git a/hardware/Pi/38-rpi-pibrella.html b/hardware/Pibrella/38-rpi-pibrella.html similarity index 100% rename from hardware/Pi/38-rpi-pibrella.html rename to hardware/Pibrella/38-rpi-pibrella.html diff --git a/hardware/Pi/38-rpi-pibrella.js b/hardware/Pibrella/38-rpi-pibrella.js similarity index 100% rename from hardware/Pi/38-rpi-pibrella.js rename to hardware/Pibrella/38-rpi-pibrella.js diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json index d17111d7..dd957728 100644 --- a/hardware/blinkstick/package.json +++ b/hardware/blinkstick/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-blinkstick", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node to control a Blinkstick", "dependencies" : { "blinkstick" : "0.1.*" @@ -13,7 +13,7 @@ "keywords": [ "node-red", "blinkstick" ], "node-red" : { "nodes" : { - "blinkstick": "blinkstick.js" + "blinkstick": "76-blinkstick.js" } }, "author": { From 7ef175962101cf7479a79af258e03a1672c7d9b5 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 16:12:00 +0100 Subject: [PATCH 044/134] Add sqlite node to node-red-nodes (and npm) --- storage/sqlite/LICENSE | 201 ++++++++++++++++++++++++++ storage/sqlite/README.md | 16 ++ storage/sqlite/nodes/icons/sqlite.png | Bin 0 -> 1124 bytes storage/sqlite/nodes/sqlite.html | 77 ++++++++++ storage/sqlite/nodes/sqlite.js | 80 ++++++++++ storage/sqlite/package.json | 24 +++ 6 files changed, 398 insertions(+) create mode 100644 storage/sqlite/LICENSE create mode 100644 storage/sqlite/README.md create mode 100644 storage/sqlite/nodes/icons/sqlite.png create mode 100644 storage/sqlite/nodes/sqlite.html create mode 100644 storage/sqlite/nodes/sqlite.js create mode 100644 storage/sqlite/package.json diff --git a/storage/sqlite/LICENSE b/storage/sqlite/LICENSE new file mode 100644 index 00000000..ad410e11 --- /dev/null +++ b/storage/sqlite/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/storage/sqlite/README.md b/storage/sqlite/README.md new file mode 100644 index 00000000..0ac7335d --- /dev/null +++ b/storage/sqlite/README.md @@ -0,0 +1,16 @@ +node-red-contrib-sqlite +======================= +A Node-Red node to read and write a local sqlite database. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-contrib-sqlite + + +Usage +----- + +tbd diff --git a/storage/sqlite/nodes/icons/sqlite.png b/storage/sqlite/nodes/icons/sqlite.png new file mode 100644 index 0000000000000000000000000000000000000000..c4a82f949ff8e89f6f3ac90c8f84d9fb8bf6157d GIT binary patch literal 1124 zcmV-q1e^PbP) C3<00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_000B`Nkl iGaw34F(K+k7siDecW#Uyw7(FI3C0b<6}WI?Oe7}iXpk{P z1hfYRn1P<2>N#%CO-{<8tGfHr<4r16UEN*v)O+4@?x`y>3^NmeBr~(mfIYy&KpWTq z`jWbJ*HI1-N#@620f&5h#DB5{TmpWV^zj3ONg%GqlfVnW0#K%(04?9I0Kbk>s67o# z067Lc3v>cVdf070eh#=Y>UzbrJ^}UtOAe9% zwvZjhK|Tjw2Ij-f(lz_QbxFqpoH 7Q>~!xpOW78@RSwR zl4mx6^;`xnytqXl2)O4y`N6}(4#lqkt_SZ-1`|^GAh1}upatodb_h=zrPrO4Q^BMe z*(bp=c*THH(ko_mAtZw;u!S4|Jw(e8ZQtkOL3yc@I_|ye3 zko3BleFr=?qDAQgmn$Kk*fXcSQBvi9zxeT?5ylj7C8-iZJ|0YXiUYtymHA~|(pzTs zt*c^{jZkq{#!1&Y<1U1nLd7dDx+hfG%nRX9l0K;mPoprI*_V~lFW`=(H_hyu(5qM_ zgId5 ;xy9ey|8*ccy!&PSY$PIrj`A1TBoDkK*nAv4Xht2GUtFq)@%?CBMfi+1- z@Ap2HOPPJ4igx@a=e-(l0h . + +Use the other node to get, or retrieve the data already saved in the database. + +Again use msg.topic to hold the key for the database, and the result is returned in msg.payload. If nothing is found for the key then null is returned. diff --git a/storage/leveldb/package.json b/storage/leveldb/package.json new file mode 100644 index 00000000..066c9362 --- /dev/null +++ b/storage/leveldb/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-leveldb", + "version" : "0.0.1", + "description" : "A Node-RED node to read and write to a LevelDB database", + "dependencies" : { + "level" : "0.18.0" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/storage/leveldb" + }, + "license": "Apache", + "keywords": [ "node-red", "leveldb" ], + "node-red" : { + "nodes" : { + "leveldb": "67-leveldb.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/time/LICENSE b/time/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/time/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/time/README.md b/time/README.md new file mode 100644 index 00000000..c81aa32f --- /dev/null +++ b/time/README.md @@ -0,0 +1,25 @@ +node-red-node-suncalc +===================== + +A Node-RED node to provide a signal at sunrise and sunset. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-suncalc + + +Usage +----- + +Uses the suncalc npm to generate an output at sunrise and sunset based on a specified location. + +Several choices of definition of sunrise and sunset are available, see the suncalc module for details. + +The node provide two outputs. The first output emits a msg.payload of 1 or 0 every minute depending if day-time (1) or night-time (0). + +The second output emits only on the transition between night to day (-> 1) or day to night (-> 0). + +It also sets the msg.topic to sun and msg.moon to the fraction of the moon currently visible (a value between 0 for no moon and 1 for full moon). diff --git a/time/package.json b/time/package.json new file mode 100644 index 00000000..97de88e9 --- /dev/null +++ b/time/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-suncalc", + "version" : "0.0.1", + "description" : "A Node-RED node to provide a signal at sunrise and sunset", + "dependencies" : { + "suncalc" : "1.5.*" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/time" + }, + "license": "Apache", + "keywords": [ "node-red", "suncalc" ], + "node-red" : { + "nodes" : { + "suncalc": "79-suncalc.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From c58ed99115ed3f3188180f8d171f94a013c6e718 Mon Sep 17 00:00:00 2001 From: Dave C-JM9_|Ffj-xFAgoyy>d6!z8%qpUs=8o|)b8bHAnV zOw#BVHIw9lP-Fh~{S&_5V`jJf`z_#tq>m;EPm>DV3t7~WblkIOZijcIWng{WR367O z9Wz_?@FeK{ejNMTtKR8#nR1K@Qwl*lG}6xmkhae~%j1;%NtL+ R^UVmP}^_Gw?>d qwW}~*`cH;6xm{N#tt1R*0rM};3dp;J@DR=b0000 + + + + + + + + + + + diff --git a/storage/sqlite/nodes/sqlite.js b/storage/sqlite/nodes/sqlite.js new file mode 100644 index 00000000..9a7e3b34 --- /dev/null +++ b/storage/sqlite/nodes/sqlite.js @@ -0,0 +1,80 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var reconnect = RED.settings.sqliteReconnectTime || 20000; + var sqlite3 = require('sqlite3'); + + function SqliteNodeDB(n) { + RED.nodes.createNode(this,n); + + this.dbname = n.db; + var node = this; + + node.doConnect = function() { + node.db = new sqlite3.Database(node.dbname); + node.db.on('open',function(err) { + if (node.tick) { clearTimeout(node.tick); } + node.log("opened "+node.dbname+" ok"); + }); + node.db.on('error', function(err) { + node.warn(err); + node.log("failed to open "+node.dbname); + node.tick = setTimeout(doConnect, reconnect); + }); + } + + node.on('close', function () { + if (node.tick) { clearTimeout(node.tick); } + if (node.db) { node.db.close(); } + }); + } + RED.nodes.registerType("sqlitedb",SqliteNodeDB); + + + function SqliteNodeIn(n) { + RED.nodes.createNode(this,n); + this.mydb = n.mydb; + this.mydbConfig = RED.nodes.getNode(this.mydb); + + if (this.mydbConfig) { + this.mydbConfig.doConnect(); + var node = this; + node.on("input", function(msg) { + if (typeof msg.topic === 'string') { + //console.log("query:",msg.topic); + node.mydbConfig.db.all(msg.topic, function(err, row) { + if (err) { node.warn(err); } + else { + msg.payload = row; + node.send(msg); + } + }); + } + else { + if (typeof msg.topic !== 'string') { + node.error("msg.topic : the query is not defined as a string"); + } + } + }); + } + else { + this.error("Sqlite database not configured"); + } + } + RED.nodes.registerType("sqlite",SqliteNodeIn); +} diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json new file mode 100644 index 00000000..e5fcd20b --- /dev/null +++ b/storage/sqlite/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-contrib-sqlite", + "version" : "0.0.2", + "description" : "A sqlite node for Node-RED", + "dependencies" : { + "sqlite3" : "2.x" + }, + "repository" : { + "type":"git", + "url":"https://github.com/dceejay/node-red-contrib-sqlite.git" + }, + "license": "Apache", + "keywords": [ "node-red", "sqlite" ], + "node-red" : { + "nodes" : { + "sqlite": "nodes/sqlite.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 10f40b016178b8c55b6bdf4acad568144cd0c7bc Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 16:12:19 +0100 Subject: [PATCH 045/134] Add Pibrella npm --- hardware/Pibrella/LICENSE | 177 +++++++++++++++++++++++++++++++++ hardware/Pibrella/README.md | 37 +++++++ hardware/Pibrella/package.json | 23 +++++ 3 files changed, 237 insertions(+) create mode 100644 hardware/Pibrella/LICENSE create mode 100644 hardware/Pibrella/README.md create mode 100644 hardware/Pibrella/package.json diff --git a/hardware/Pibrella/LICENSE b/hardware/Pibrella/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/Pibrella/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/Pibrella/README.md b/hardware/Pibrella/README.md new file mode 100644 index 00000000..b0b303a4 --- /dev/null +++ b/hardware/Pibrella/README.md @@ -0,0 +1,37 @@ +node-red-node-pibrella +====================== +A Node-RED node to control a Pibrella add-on board for a Raspberry-Pi. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-pibrella + + +Pre-reqs +-------- + +Requires the WiringPi gpio command to be installed in order to work. See the WiringPi site for details on how to do this. + + +Usage +----- + +A pair of input and output Node-RED nodes for the Raspberry Pi Pibrella from Pimoroni. + +###Output + +The output node will set the selected output high (on) or low (off) depending on the value passed in. Expects a msg.payload with either a 0 or 1 (or true or false). + +The Buzzer is a divider so low numbers are high notes. 0 is off, and the sensible lowest note is around 250-300. 2 is the highest note. 1 is just a buzz - so you can use 0/1 type inputs. + + +###Input + +The input node generates a msg.payload with either a 0 or 1 depending on the state of the input pin. + +The msg.topic is set to pibrella/{the pin id} - which will be A, B, C, D or R. + +Note: This node currently polls the pin every 250mS. This is not ideal as it loads the cpu. diff --git a/hardware/Pibrella/package.json b/hardware/Pibrella/package.json new file mode 100644 index 00000000..518c5e58 --- /dev/null +++ b/hardware/Pibrella/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-pibrella", + "version" : "0.0.1", + "description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/Pibrella" + }, + "license": "Apache", + "keywords": [ "node-red", "pibrella" ], + "node-red" : { + "nodes" : { + "pibrella": "38-rpi-pirella.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 43de38453eb0ba4234a1bd73d7e37cc52c9489d0 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 17:25:47 +0100 Subject: [PATCH 046/134] Tweak Pibrella package.json (mis-spelt) --- hardware/Pibrella/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware/Pibrella/package.json b/hardware/Pibrella/package.json index 518c5e58..69dc32e2 100644 --- a/hardware/Pibrella/package.json +++ b/hardware/Pibrella/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pibrella", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board", "dependencies" : { }, @@ -12,7 +12,7 @@ "keywords": [ "node-red", "pibrella" ], "node-red" : { "nodes" : { - "pibrella": "38-rpi-pirella.js" + "pibrella": "38-rpi-pibrella.js" } }, "author": { From dac2c7e7780d54f8166caf2b0dab52046f9e036e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 4 Jul 2014 17:26:20 +0100 Subject: [PATCH 047/134] Update MySQL node - fa icons, add timezone, make npm installable --- storage/mysql/68-mysql.html | 25 +++-- storage/mysql/68-mysql.js | 33 +------ storage/mysql/LICENSE | 177 ++++++++++++++++++++++++++++++++++++ storage/mysql/README.md | 29 ++++++ storage/mysql/package.json | 24 +++++ 5 files changed, 247 insertions(+), 41 deletions(-) create mode 100644 storage/mysql/LICENSE create mode 100644 storage/mysql/README.md create mode 100644 storage/mysql/package.json diff --git a/storage/mysql/68-mysql.html b/storage/mysql/68-mysql.html index a68e642b..f0c5c63a 100644 --- a/storage/mysql/68-mysql.html +++ b/storage/mysql/68-mysql.html @@ -16,25 +16,29 @@ diff --git a/storage/mysql/68-mysql.js b/storage/mysql/68-mysql.js index 4647d1d6..c4f889ed 100644 --- a/storage/mysql/68-mysql.js +++ b/storage/mysql/68-mysql.js @@ -62,6 +62,7 @@ module.exports = function(RED) { RED.nodes.createNode(this,n); this.host = n.host; this.port = n.port; + this.tz = n.tz || "local"; this.connected = false; this.connecting = false; @@ -92,6 +93,7 @@ module.exports = function(RED) { user : node.user, password : node.password, database : node.dbname, + timezone : node.tz, insecureAuth: true }); @@ -163,35 +165,4 @@ module.exports = function(RED) { } } RED.nodes.registerType("mysql",MysqlDBNodeIn); - - - //function MysqlDBNodeOut(n) { - //RED.nodes.createNode(this,n); - //this.level = n.level; - //this.operation = n.operation; - //this.levelConfig = RED.nodes.getNode(this.level); - - //if (this.levelConfig) { - //var node = this; - //node.on("input", function(msg) { - //if (typeof msg.topic === 'string') { - //if (node.operation === "delete") { - //node.levelConfig.db.del(msg.topic); - //} - //else { - //node.levelConfig.db.put(msg.topic, msg.payload, function(err) { - //if (err) node.error(err); - //}); - //} - //} - //else { - //if (typeof msg.topic !== 'string') node.error("msg.topic : the key is not defined"); - //} - //}); - //} - //else { - //this.error("MySQL database not configured"); - //} - //} - //RED.nodes.registerType("mysql out",MysqlDBNodeOut); } diff --git a/storage/mysql/LICENSE b/storage/mysql/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/storage/mysql/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/storage/mysql/README.md b/storage/mysql/README.md new file mode 100644 index 00000000..a2be5cb0 --- /dev/null +++ b/storage/mysql/README.md @@ -0,0 +1,29 @@ +node-red-node-mysql +======================== +A Node-RED node to read and write to a MySQL database. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-mysql + + +Usage +----- + +Allows basic access to a MySQL database. + +This node uses the query operation against the configured database. This does allow both INSERTS and DELETES. + +By it's very nature it allows SQL injection... so be careful out there... + +The msg.topic must hold the query for the database, and the result is returned in msg.payload. + +Typically the returned payload will be an array of the result rows. + +If nothing is found for the key then null is returned. + +The reconnect retry timeout in milliseconds can be changed by adding a line to settings.js + mysqlReconnectTime: 30000,diff --git a/storage/mysql/package.json b/storage/mysql/package.json new file mode 100644 index 00000000..724f1336 --- /dev/null +++ b/storage/mysql/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-mysql", + "version" : "0.0.3", + "description" : "A Node-RED node to read and write to a MySQL database", + "dependencies" : { + "mysql" : "2.3.*" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/storage/mysql" + }, + "license": "Apache", + "keywords": [ "node-red", "mysql" ], + "node-red" : { + "nodes" : { + "mysql": "68-mysql.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 647fe4f5d8a7b4ee8f24a55409d90346294e1208 Mon Sep 17 00:00:00 2001 From: Dave C-JDate: Sun, 6 Jul 2014 20:58:52 +0100 Subject: [PATCH 048/134] Add xmpp, suncalc and leveldb as npms... --- social/xmpp/LICENSE | 177 +++++++++++++++++++++++++++++++++++ social/xmpp/README.md | 44 +++++++++ social/xmpp/package.json | 24 +++++ storage/leveldb/LICENSE | 177 +++++++++++++++++++++++++++++++++++ storage/leveldb/README.md | 26 +++++ storage/leveldb/package.json | 24 +++++ time/LICENSE | 177 +++++++++++++++++++++++++++++++++++ time/README.md | 25 +++++ time/package.json | 24 +++++ 9 files changed, 698 insertions(+) create mode 100644 social/xmpp/LICENSE create mode 100644 social/xmpp/README.md create mode 100644 social/xmpp/package.json create mode 100644 storage/leveldb/LICENSE create mode 100644 storage/leveldb/README.md create mode 100644 storage/leveldb/package.json create mode 100644 time/LICENSE create mode 100644 time/README.md create mode 100644 time/package.json diff --git a/social/xmpp/LICENSE b/social/xmpp/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/social/xmpp/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/social/xmpp/README.md b/social/xmpp/README.md new file mode 100644 index 00000000..e9aed75e --- /dev/null +++ b/social/xmpp/README.md @@ -0,0 +1,44 @@ +node-red-node-xmpp +================== + +A Node-RED node to talk to an XMPP server. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-xmpp + + +Usage +----- + +Provides two nodes - one to send messages, and one to receive. + +###Receive + +Connects to an XMPP server to receive messages. + +The Buddy field is the id of the buddy or room you want to receive messages from. + +Incoming messages will appear as msg.payload on the first output, while msg.topic will contain who it is from. + +The second output will show the presence and status of a user in msg.payload. Again msg.topic will hold the user. + +###Send + +Connects to an XMPP server to send messages. + +The To field is optional. If not set the msg.topic property of the message is used to set that value. + +If you are joining a chat room then the To field must be filled in with the room name. + +You may also send a msg with msg.presence to set your presence to one of + + 1. chat + 2. away + 3. dnd + 4. xa + +If you do so then the msg.payload is used to set your status message. diff --git a/social/xmpp/package.json b/social/xmpp/package.json new file mode 100644 index 00000000..367be0ed --- /dev/null +++ b/social/xmpp/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-xmpp", + "version" : "0.0.1", + "description" : "A Node-RED node to talk to an XMPP server", + "dependencies" : { + "simple-xmpp" : "0.1.19" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/social/xmpp" + }, + "license": "Apache", + "keywords": [ "node-red", "xmpp" ], + "node-red" : { + "nodes" : { + "xmpp": "92-xmpp.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/storage/leveldb/LICENSE b/storage/leveldb/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/storage/leveldb/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/storage/leveldb/README.md b/storage/leveldb/README.md new file mode 100644 index 00000000..7dbc770d --- /dev/null +++ b/storage/leveldb/README.md @@ -0,0 +1,26 @@ +node-red-node-leveldb +===================== +A Node-RED node to read and write to a LevelDB database. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-leveldb + + +Usage +----- + +Allows basic access to a LevelDB database. + +Uses LevelDB for a simple key value pair database. + +There are two node to choose from... + +Use one node to either put (store) the msg.payload to the named database file, using msg.topic as the key, or to delete information select delete in the properties dialogue and again use msg.topic as the key. Date: Sun, 6 Jul 2014 21:29:30 +0100 Subject: [PATCH 049/134] Update swearfilter and wordpos as npms --- analysis/swearfilter/LICENSE | 177 ++++++++++++++++++++++++++++++ analysis/swearfilter/README.md | 21 ++++ analysis/swearfilter/package.json | 24 ++++ analysis/wordpos/LICENSE | 177 ++++++++++++++++++++++++++++++ analysis/wordpos/README.md | 27 +++++ analysis/wordpos/package.json | 24 ++++ 6 files changed, 450 insertions(+) create mode 100644 analysis/swearfilter/LICENSE create mode 100644 analysis/swearfilter/README.md create mode 100644 analysis/swearfilter/package.json create mode 100644 analysis/wordpos/LICENSE create mode 100644 analysis/wordpos/README.md create mode 100644 analysis/wordpos/package.json diff --git a/analysis/swearfilter/LICENSE b/analysis/swearfilter/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/analysis/swearfilter/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/analysis/swearfilter/README.md b/analysis/swearfilter/README.md new file mode 100644 index 00000000..1bda6198 --- /dev/null +++ b/analysis/swearfilter/README.md @@ -0,0 +1,21 @@ +node-red-node-badwords +====================== + +A Node-RED node that attempts to filter out messages containing swearwords. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-badwords + + +Usage +----- + +Uses the badwords npm to attempt to filter out messages containing swearwords. + +Analyses the **msg.payload** and tries to filter out any messages containing bad swear words. If the payload contains a bad word then the whole message is blocked. + +**Note** : this only operates on payloads of type string. Everything else is blocked. diff --git a/analysis/swearfilter/package.json b/analysis/swearfilter/package.json new file mode 100644 index 00000000..88e3e473 --- /dev/null +++ b/analysis/swearfilter/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-badwords", + "version" : "0.0.1", + "description" : "A Node-RED node that attempts to filter out messages containing swearwords.", + "dependencies" : { + "badwords" : "0.0.1" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/analysis/swearfilter" + }, + "license": "Apache", + "keywords": [ "node-red", "badwords", "swearfilter" ], + "node-red" : { + "nodes" : { + "badwords": "74-swearfilter.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/analysis/wordpos/LICENSE b/analysis/wordpos/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/analysis/wordpos/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/analysis/wordpos/README.md b/analysis/wordpos/README.md new file mode 100644 index 00000000..2e8b6e85 --- /dev/null +++ b/analysis/wordpos/README.md @@ -0,0 +1,27 @@ +node-red-node-wordpos +===================== + +A Node-RED node that breaks a sentance into the various parts of (English) speech. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-wordpos + + +Usage +----- + +Uses the wordpos npm to analyse the **msg.payload** and classify the part-of-speech of each word. + +The resulting message has a **msg.pos** object added with the results split into the following: + + nouns:[], + verbs:[], + adjectives:[], + adverbs:[], + rest:[] + +**Note:** a word may appear in multiple POS (eg, 'great' is both a noun and an adjective). diff --git a/analysis/wordpos/package.json b/analysis/wordpos/package.json new file mode 100644 index 00000000..6f10d151 --- /dev/null +++ b/analysis/wordpos/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-wordpos", + "version" : "0.0.1", + "description" : "A Node-RED node that breaks a sentence into the various parts of (English) speech.", + "dependencies" : { + "wordpos" : "0.1.*" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/analysis/wordpos" + }, + "license": "Apache", + "keywords": [ "node-red", "wordpos" ], + "node-red" : { + "nodes" : { + "wordpos": "72-wordpos.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 34b81c3c1825d5ad5843aa0cd49b550e521a0824 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 8 Jul 2014 22:56:30 +0100 Subject: [PATCH 050/134] Move Heatmiser nodes into a single directory --- hardware/{heatmiser-in => heatmiser}/100-heatmiser-in.html | 0 hardware/{heatmiser-in => heatmiser}/100-heatmiser-in.js | 0 hardware/{heatmiser-out => heatmiser}/101-heatmiser-out.html | 0 hardware/{heatmiser-out => heatmiser}/101-heatmiser-out.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename hardware/{heatmiser-in => heatmiser}/100-heatmiser-in.html (100%) rename hardware/{heatmiser-in => heatmiser}/100-heatmiser-in.js (100%) rename hardware/{heatmiser-out => heatmiser}/101-heatmiser-out.html (100%) rename hardware/{heatmiser-out => heatmiser}/101-heatmiser-out.js (100%) diff --git a/hardware/heatmiser-in/100-heatmiser-in.html b/hardware/heatmiser/100-heatmiser-in.html similarity index 100% rename from hardware/heatmiser-in/100-heatmiser-in.html rename to hardware/heatmiser/100-heatmiser-in.html diff --git a/hardware/heatmiser-in/100-heatmiser-in.js b/hardware/heatmiser/100-heatmiser-in.js similarity index 100% rename from hardware/heatmiser-in/100-heatmiser-in.js rename to hardware/heatmiser/100-heatmiser-in.js diff --git a/hardware/heatmiser-out/101-heatmiser-out.html b/hardware/heatmiser/101-heatmiser-out.html similarity index 100% rename from hardware/heatmiser-out/101-heatmiser-out.html rename to hardware/heatmiser/101-heatmiser-out.html diff --git a/hardware/heatmiser-out/101-heatmiser-out.js b/hardware/heatmiser/101-heatmiser-out.js similarity index 100% rename from hardware/heatmiser-out/101-heatmiser-out.js rename to hardware/heatmiser/101-heatmiser-out.js From dc722f9ae0494b754839ed075e7c9d4f59ea3a7a Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 8 Jul 2014 22:56:58 +0100 Subject: [PATCH 051/134] Add MakeyMakey node and npm --- hardware/makey/42-makey.html | 53 +++++++++++ hardware/makey/42-makey.js | 86 +++++++++++++++++ hardware/makey/LICENSE | 177 +++++++++++++++++++++++++++++++++++ hardware/makey/README.md | 33 +++++++ hardware/makey/package.json | 24 +++++ 5 files changed, 373 insertions(+) create mode 100644 hardware/makey/42-makey.html create mode 100644 hardware/makey/42-makey.js create mode 100644 hardware/makey/LICENSE create mode 100644 hardware/makey/README.md create mode 100644 hardware/makey/package.json diff --git a/hardware/makey/42-makey.html b/hardware/makey/42-makey.html new file mode 100644 index 00000000..a194e1cb --- /dev/null +++ b/hardware/makey/42-makey.html @@ -0,0 +1,53 @@ + + + + + + + diff --git a/hardware/makey/42-makey.js b/hardware/makey/42-makey.js new file mode 100644 index 00000000..75a95da1 --- /dev/null +++ b/hardware/makey/42-makey.js @@ -0,0 +1,86 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +var RED = require(process.env.NODE_RED_HOME+"/red/red"); +var hids = require('hidstream'); + +function MakeyNode(n) { + RED.nodes.createNode(this,n); + this.vid = 0x1b4f; // MakeyMakey vendor ID + this.pid = 0x2b75; // MakeyMakey product ID + var node = this; + //node.log("Want:"+node.vid.toString(16)+":"+node.pid.toString(16)); + var path = null; + var tout; + var click = false; + var keylookup = { "44":"space", "82":"up", "81":"down", "79":"right", "80":"left", + "26":"w", "4":"a", "22":"s", "7":"d", "9":"f", "10":"g" }; + + var findmakey = function() { + node.log("looking for MakeyMakey"); + var devices = hids.getDevices(); + for (var dev = 0; dev < devices.length; dev++) { + //node.log("Find:"+devices[dev].vendorId.toString(16)+":"+devices[dev].productId.toString(16)); + if ((devices[dev].vendorId == node.vid) && (devices[dev].productId == node.pid)) { + path = devices[dev].path; + node.log("found MakeyMakey at: "+path); //path = "0003:0004:00"; + break; // stop on first match + } + } + if (path === null) { + tout = setTimeout( function () { + findmakey(); + },15000); + } + } + findmakey(); + + if (path != null) { + try { + node.makey = new hids.device(path); + node.makey.on("data", function(key) { + var msg = {payload:[]}; + //console.log(key); + if (key.modKeys[0] === "shift") { + for (var keys = 0; keys < key.keyCodes.length; keys++) { + node.log(key.keyCodes[keys]+" : "+keylookup[key.keyCodes[keys].toString()]); + msg.payload.push(keylookup[key.keyCodes[keys].toString()]); + } + msg.payload = msg.payload.join(); + node.send(msg); + } + else if (key.modKeys[0] === "ctrl") { + if (key.charCodes.length === 0) { + click = !click; + (click) ? (msg.payload = "click") : (msg.payload = "clock"); + node.send(msg); + } + } + else { console.log(key); } + }); + + } catch(err) { node.warn("can't open MakeyMakey: Do you need root access ?"); } + } + else { + findmakey(); + } + + this.on("close", function() { + if (tout) { clearTimeout(tout); } + if (node.makey) { node.makey.device.close(); } + }); +} +RED.nodes.registerType("makeymakey",MakeyNode); diff --git a/hardware/makey/LICENSE b/hardware/makey/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/makey/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/makey/README.md b/hardware/makey/README.md new file mode 100644 index 00000000..56fbb4e0 --- /dev/null +++ b/hardware/makey/README.md @@ -0,0 +1,33 @@ +node-red-node-makeymakey +======================== +A Node-RED node to read from a MakeyMakey input device. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-makeymakey + + +Pre-reqs +-------- + +As this requires an underlying npm this also requires it's pre-reqs, see Node-hid npm for more details. + + - libudev-dev (Linux only) + - libusb-1.0-0-dev (Ubuntu versions missing libusb.h only) + +Usage +----- + +Provides "keyboard" like input from a MakeyMakey device. + +This uses the hidstream npm module that by default only supports the basic keyboard keys and **NOT** the mouse inputs, fn keys, keypad keys, cursor keys etc. This means that the extra mouse emulation jumpers won't work. + +The MakeyMakey can of course be re-programmed to re-assign the keys - but this node doesn't know about that... + +Known Issues +------------ + +Every now and then something causes the MakeyMakey HID to become detached (lose focus) from this app and re-attach to another (the in focus) app... whereupon the emulated keys will end up in the wrong window... - Any ideas on how to stop this would be greatly appreciated - but I suspect it's a fundamental issue with the MakeyMakey pretending to be a HID. diff --git a/hardware/makey/package.json b/hardware/makey/package.json new file mode 100644 index 00000000..e4e573b1 --- /dev/null +++ b/hardware/makey/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-makeymakey", + "version" : "0.0.1", + "description" : "A Node-RED node to read from a MakeyMakey input device.", + "dependencies" : { + "hidstream": "0.0.3" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/makey" + }, + "license": "Apache", + "keywords": [ "node-red", "makeymakey" ], + "node-red" : { + "nodes" : { + "makeymakey": "42-makey.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From cdec6f842df846fcade5b3d4f1feac1ba7490fe4 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 8 Jul 2014 22:57:42 +0100 Subject: [PATCH 052/134] Add npms for various hardware nodes, Blink1, DigiRGB, LEDBorg, PiFace --- hardware/LEDborg/LICENSE | 177 ++++++++++++++++++++++++++++++++++ hardware/LEDborg/README.md | 25 +++++ hardware/LEDborg/package.json | 23 +++++ hardware/PiFace/LICENSE | 177 ++++++++++++++++++++++++++++++++++ hardware/PiFace/README.md | 41 ++++++++ hardware/PiFace/package.json | 23 +++++ hardware/blink1/LICENSE | 177 ++++++++++++++++++++++++++++++++++ hardware/blink1/README.md | 23 +++++ hardware/blink1/package.json | 24 +++++ hardware/digiRGB/LICENSE | 177 ++++++++++++++++++++++++++++++++++ hardware/digiRGB/README.md | 19 ++++ hardware/digiRGB/package.json | 24 +++++ 12 files changed, 910 insertions(+) create mode 100644 hardware/LEDborg/LICENSE create mode 100644 hardware/LEDborg/README.md create mode 100644 hardware/LEDborg/package.json create mode 100644 hardware/PiFace/LICENSE create mode 100644 hardware/PiFace/README.md create mode 100644 hardware/PiFace/package.json create mode 100644 hardware/blink1/LICENSE create mode 100644 hardware/blink1/README.md create mode 100644 hardware/blink1/package.json create mode 100644 hardware/digiRGB/LICENSE create mode 100644 hardware/digiRGB/README.md create mode 100644 hardware/digiRGB/package.json diff --git a/hardware/LEDborg/LICENSE b/hardware/LEDborg/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/LEDborg/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/LEDborg/README.md b/hardware/LEDborg/README.md new file mode 100644 index 00000000..3eda3b75 --- /dev/null +++ b/hardware/LEDborg/README.md @@ -0,0 +1,25 @@ +node-red-node-ledborg +===================== + +A Node-RED node to control a PiBorg LedBorg baord for a Raspberry Pi. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-ledborg + + +Usage +----- + +A PiBorg LedBorg LED output node that expects a msg.payload with a three digit rgb triple, from 000 to 222. I.E. there are only 27 possible colours. + +See the PiBorg site for more information. + +You can also now use a msg.payload in the standard hex format "#rrggbb". The clip levels are : + +> 0x00 - 0x57 = off+ +You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple, white, warmwhite, black diff --git a/hardware/LEDborg/package.json b/hardware/LEDborg/package.json new file mode 100644 index 00000000..46ac1c36 --- /dev/null +++ b/hardware/LEDborg/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-ledborg", + "version" : "0.0.1", + "description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/ledborg" + }, + "license": "Apache", + "keywords": [ "node-red", "ledborg" ], + "node-red" : { + "nodes" : { + "ledborg": "78-ledborg.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/hardware/PiFace/LICENSE b/hardware/PiFace/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/PiFace/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/PiFace/README.md b/hardware/PiFace/README.md new file mode 100644 index 00000000..08cadc17 --- /dev/null +++ b/hardware/PiFace/README.md @@ -0,0 +1,41 @@ +node-red-node-piface +==================== + +Node-RED nodes to control a PiFace Digital add-on board for a Raspberry-Pi. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-piface + + +Pre-reqs +-------- + +Requires the WiringPi gpio command to be installed in order to work. See the WiringPi site for details on how to do this. + + +Usage +----- + +A pair of input and output Node-RED nodes for the Raspberry Pi PiFace Digital add-on board. + +###Output + +The PiFace output node will set the selected relay, LED, or pin on or off depending on the value passed in. Expects a msg.payload with either a 1 or 0 (or true or false). + +Requires the WiringPi gpio command in order to work (see pre-reqs). + +###Input + +The PiFace input node generates a msg.payload with either a 0 or 1 depending on the state of the input pin. + +You may also enable the input pullup resistor if required. + +The msg.topic is set to piface/{the pin number} + +Requires the WiringPi gpio command in order to work (see pre-reqs). + +Note: This node currently polls the pin every 250mS. This is not ideal as it loads the cpu. diff --git a/hardware/PiFace/package.json b/hardware/PiFace/package.json new file mode 100644 index 00000000..b98f08ba --- /dev/null +++ b/hardware/PiFace/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-piface", + "version" : "0.0.1", + "description" : "Node-RED nodes to read from and write to a PiFace Digital Raspberry Pi add-on board", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/PiFace" + }, + "license": "Apache", + "keywords": [ "node-red", "piface" ], + "node-red" : { + "nodes" : { + "piface": "37-rpi-piface.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/hardware/blink1/LICENSE b/hardware/blink1/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/blink1/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/blink1/README.md b/hardware/blink1/README.md new file mode 100644 index 00000000..701fc2cc --- /dev/null +++ b/hardware/blink1/README.md @@ -0,0 +1,23 @@ +node-red-node-blink1 +==================== + +A Node-RED node to control a Thingm Blink(1) LED. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-blink1 + + +Usage +----- + +Sends the msg.payload to a Thingm Blink(1) LED device. The payload can be any of the following: + + - a three part csv string of r,g,b - e.g. red is 255,0,0 + - a hex colour #rrggbb - e.g. green is #00FF00 + - a @cheerlights colour name - e.g. blue + + The @cheerlights colours are - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple, white, warmwhite, black diff --git a/hardware/blink1/package.json b/hardware/blink1/package.json new file mode 100644 index 00000000..0b4a09fa --- /dev/null +++ b/hardware/blink1/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-blink1", + "version" : "0.0.1", + "description" : "A Node-RED node to control a Thingm Blink(1)", + "dependencies" : { + "node-blink1" : "0.1.2" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/blink1" + }, + "license": "Apache", + "keywords": [ "node-red", "blink1" ], + "node-red" : { + "nodes" : { + "blink1": "77-blink1.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/hardware/digiRGB/LICENSE b/hardware/digiRGB/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/digiRGB/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/digiRGB/README.md b/hardware/digiRGB/README.md new file mode 100644 index 00000000..d389751e --- /dev/null +++ b/hardware/digiRGB/README.md @@ -0,0 +1,19 @@ +node-red-node-digirgb +===================== + +A Node-RED node to control a Digispark RGB LED. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-digirgb + + +Usage +----- + +Simple output node to drive a Digispark RGB LED. + +Requires a msg.payload to be of the form 'r,g,b' - for example 255,0,0 for red. diff --git a/hardware/digiRGB/package.json b/hardware/digiRGB/package.json new file mode 100644 index 00000000..340cb6bf --- /dev/null +++ b/hardware/digiRGB/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-digirgb", + "version" : "0.0.1", + "description" : "A Node-RED node to control a Digispark RGB LED", + "dependencies" : { + "node-hid" : "0.3.1" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/digiRGB" + }, + "license": "Apache", + "keywords": [ "node-red", "digiRGB" ], + "node-red" : { + "nodes" : { + "digiRGB": "78-digiRGB.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 132ceaffc5b7f2a3fea6c521638d433f188f6f2d Mon Sep 17 00:00:00 2001 From: Dave C-J
0x58 - 0xA7 = 50%
0xA8 - 0xFF = fully onDate: Tue, 15 Jul 2014 10:15:04 +0100 Subject: [PATCH 053/134] update suncalc to use fa icons --- time/79-suncalc.html | 10 +++++----- time/79-suncalc.js | 2 +- time/package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/time/79-suncalc.html b/time/79-suncalc.html index 7e595f86..112b75a3 100644 --- a/time/79-suncalc.html +++ b/time/79-suncalc.html @@ -16,15 +16,15 @@ diff --git a/time/79-suncalc.js b/time/79-suncalc.js index eef222a4..a8a667cc 100644 --- a/time/79-suncalc.js +++ b/time/79-suncalc.js @@ -40,7 +40,7 @@ module.exports = function(RED) { var e1 = (hour*60+mins) - (hour1*60+mins1); var e2 = (hour*60+mins) - (hour2*60+mins2); var moon = SunCalc.getMoonIllumination(now).fraction; - msg = { payload:0, topic:"sun", moon:moon }; + var msg = { payload:0, topic:"sun", moon:moon }; if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; } if (oldval == null) { oldval = msg.payload; } if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"}); } diff --git a/time/package.json b/time/package.json index 97de88e9..9f7becd6 100644 --- a/time/package.json +++ b/time/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-suncalc", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "A Node-RED node to provide a signal at sunrise and sunset", "dependencies" : { "suncalc" : "1.5.*" From a2553d69b8a569e10a92b2205ad5a45fe5a74acf Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 15 Jul 2014 10:15:34 +0100 Subject: [PATCH 054/134] add BBB, Twilio and Pushbullet as npms --- hardware/BBB/LICENSE | 177 +++++++++++++++++++++++++++++++++ hardware/BBB/README.md | 96 ++++++++++++++++++ hardware/BBB/package.json | 22 ++++ social/pushbullet/LICENSE | 177 +++++++++++++++++++++++++++++++++ social/pushbullet/README.md | 21 ++++ social/pushbullet/package.json | 24 +++++ social/twilio/LICENSE | 177 +++++++++++++++++++++++++++++++++ social/twilio/README.md | 24 +++++ social/twilio/package.json | 23 +++++ 9 files changed, 741 insertions(+) create mode 100644 hardware/BBB/LICENSE create mode 100644 hardware/BBB/README.md create mode 100644 hardware/BBB/package.json create mode 100644 social/pushbullet/LICENSE create mode 100644 social/pushbullet/README.md create mode 100644 social/pushbullet/package.json create mode 100644 social/twilio/LICENSE create mode 100644 social/twilio/README.md create mode 100644 social/twilio/package.json diff --git a/hardware/BBB/LICENSE b/hardware/BBB/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/BBB/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/BBB/README.md b/hardware/BBB/README.md new file mode 100644 index 00000000..e6c93002 --- /dev/null +++ b/hardware/BBB/README.md @@ -0,0 +1,96 @@ +node-red-node-beaglebone +======================== +A set of Node-RED nodes to interface with the GPIO pins of a Beaglebone Black. + +Pre-requisites +-------------- + +Only of use on a BeagleboneBlack board. Should ideally be running the latest Debian image - as that has node.js v0.10.x and the bonescript npm preinstalled. +it does also need bonescript - but this is also pre-installed so no need to mark as a dependency... + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-beaglebone + + +Usage +----- + +This package provides 5 nodes for use with the BeagleboneBlack board. + +###Analogue Input + +Reads an analogue pin when triggered by +a message. + +The output message topic is the node topic: the output message value is the +scaled analogue input or NaN if a read error occurs. + + +Simple linear scaling is defined by setting the output values required for input +values of 0 and 1. You can apply more complicated scaling, e.g. for sensor linearisation, +by defining breakpoints at intermediate input values, with the desired output for +each. Values between breakpoints are linearly interpolated. + + +To reduce the effect of noise, enable averaging. This will read the input pin +voltage ten times in rapid succession for each input message and output the mean value. + +###Digital Input + +Sends a message with payload 0 or 1 on the first output when the pin changes state, and logs the total time in the active state. + +Sends a message with a payload of the current total active time +(in seconds) on the second output at selectable intervals. An input message with topic 'load' +and a numeric payload will set the total active time to that value: any other input message +will reset it to zero. + +The active state may be set to be high or low: this only affects the calculation +of the active time, not the pin state value sent on the first output. + +The pin state messages may be generated for both directions of change, or for just 0 to 1 +or just 1 to 0 changes. This is useful to generate a single message from a button +press. When using buttons or switches, enable debouncing to improve reliability. + +###Pulse Input + +Pulse input for the Beaglebone Black. Counts input pulses or pulse edges: outputs +total counts and the rate of counts/sec, with scaling. + +Sends the total count message on the first output, and the current count +rate message on the second output, at the chosen interval. An input message with topic 'load' +and a numeric payload will set the total count to that value (no scaling is applied): +any other input message will reset it to zero. + +###Digital Output + +Sets the output pin high or low depending on the payload of the input message. Numeric +payloads > 0.5 are 'high' (1), payloads <= 0.5 are 'low' (0). Other payloads which +evaluate to true are 'high', if not then 'low'. Selecting the Inverting checkbox will +switch the sense of the pin output. + + +If the Toggle state checkbox is checked, the message content is ignored: successive +messages cause the pin to toggle between 0 and 1. + + +The pin will be initially set to the given Startup state until the first message arrives: +the Inverting property is not applied to this value. + +###Pulse Output + +Pulses the output pin for the set time after receiving an input message, unless the +message has a topic including the text 'time' and a numeric payload. In this case, the +the pulse time will be the value of the payload in seconds. If the time from either +source is < 0.001 seconds, no pulse is generated. + +In retriggerable mode, a second message within the pulse period will extend the duration +of the pulse by the time value: in non-retriggerable mode, input messages arriving during +the duration of the pulse are ignored. + +The pin state of the pulse may be set to either 0 or 1: the output pin will switch +back to the other state after the pulse time. An output message is generated each time +the pin changes state: its payload is the new state (0 or 1). diff --git a/hardware/BBB/package.json b/hardware/BBB/package.json new file mode 100644 index 00000000..12aff6f1 --- /dev/null +++ b/hardware/BBB/package.json @@ -0,0 +1,22 @@ +{ + "name" : "node-red-node-beaglebone", + "version" : "0.0.2", + "description" : "A set of Node-RED nodes to interface to the GPIO pins of a Beaglebone Black board", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/BBB" + }, + "license": "Apache-v2.0", + "keywords": [ "node-red", "beagleboneblack", "beaglebone", "bbb" ], + "node-red" : { + "nodes" : { + "bbb": "145-BBB-hardware.js" + } + }, + "contributors": [ + {"name": "Max Hadley"}, + {"name": "Dave Conway-Jones"} + ] +} diff --git a/social/pushbullet/LICENSE b/social/pushbullet/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/social/pushbullet/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/social/pushbullet/README.md b/social/pushbullet/README.md new file mode 100644 index 00000000..4084eea1 --- /dev/null +++ b/social/pushbullet/README.md @@ -0,0 +1,21 @@ +node-red-node-pushbullet +======================== + +A Node-RED node to send alerts via Pushbullet. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-pushbullet + + +Usage +----- + +Uses PushBullet to push the msg.payload to a device that has the PushBullet app installed. + +Optionally uses msg.topic to set the title, if not already set in the properties. + +You need to configure both your API key and the target device ID. The device ID may be passed in as msg.deviceid. You can set these per node in the edit dialog. diff --git a/social/pushbullet/package.json b/social/pushbullet/package.json new file mode 100644 index 00000000..d3648d4b --- /dev/null +++ b/social/pushbullet/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-pushbullet", + "version" : "0.0.1", + "description" : "A Node-RED node to send alerts via Pushbullet", + "dependencies" : { + "pushbullet" : "1.*.*" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/pushbullet" + }, + "license": "Apache", + "keywords": [ "node-red", "pushbullet" ], + "node-red" : { + "nodes" : { + "pushbullet": "57-pushbullet.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/social/twilio/LICENSE b/social/twilio/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/social/twilio/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/social/twilio/README.md b/social/twilio/README.md new file mode 100644 index 00000000..e0e5b146 --- /dev/null +++ b/social/twilio/README.md @@ -0,0 +1,24 @@ +node-red-node-pushbullet +======================== + +A Node-RED node to send SMS messages via the Twilio service. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-twilio + + +Usage +----- + +Sends an SMS message using the Twilio service. + +msg.payload is used as the body of the message. The node can be configured with the number + to send the message to. Alternatively, if the number is left blank, it can be set using msg.topic. + +You must have an account with Twilio to use this node. You can register for one here. + +There is an example of using this node to create a simple IVR here. diff --git a/social/twilio/package.json b/social/twilio/package.json new file mode 100644 index 00000000..c9ab8e37 --- /dev/null +++ b/social/twilio/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-twilio", + "version" : "0.0.3", + "description" : "A Node-RED node to send SMS messages via the Twilio service.", + "dependencies" : { + "twilio" : "1.6.0" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/social/twilio" + }, + "license": "Apache-v2.0", + "keywords": [ "node-red", "twilio", "sms" ], + "node-red" : { + "nodes" : { + "twilio": "56-twilio.js" + } + }, + "contributors": [ + {"name": "Andrew Lindsay"}, + {"name": "Dave Conway-Jones"} + ] +} From 46b23274783f5ddbbc255981e8951298133cd5d2 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 18 Jul 2014 09:40:59 +0100 Subject: [PATCH 055/134] tweak MakeyMakey to add rules for USB access on Debian --- hardware/makey/82-makey.rules | 1 + hardware/makey/README.md | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 hardware/makey/82-makey.rules diff --git a/hardware/makey/82-makey.rules b/hardware/makey/82-makey.rules new file mode 100644 index 00000000..acbefc8a --- /dev/null +++ b/hardware/makey/82-makey.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTR{idVendor}=="1b4f", ATTR{idProduct}=="2b74", MODE="0666" diff --git a/hardware/makey/README.md b/hardware/makey/README.md index 56fbb4e0..90c5eff2 100644 --- a/hardware/makey/README.md +++ b/hardware/makey/README.md @@ -18,6 +18,8 @@ As this requires an underlying npm this also requires it's pre-reqs, see Date: Fri, 18 Jul 2014 10:28:57 +0100 Subject: [PATCH 056/134] Fix typo bugs. --- hardware/wemo/60-wemo.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hardware/wemo/60-wemo.js b/hardware/wemo/60-wemo.js index 3f75f8d2..57415ea2 100644 --- a/hardware/wemo/60-wemo.js +++ b/hardware/wemo/60-wemo.js @@ -40,16 +40,16 @@ module.exports = function(RED) { function WemoIn(n) { RED.nodes.createNode(this,n); this.ipaddr = n.ipaddr; - this.wemoSwitch = new WeMo(n.ipaddr); + this.wemoSwitch = new Wemo(n.ipaddr); this.wemoSwitch.state = 0; var node = this; var tick = setInterval(function() { - wemoSwitch.getBinaryState(function(err, result) { + node.wemoSwitch.getBinaryState(function(err, result) { if (err) { node.warn(err); } - if (parseInt(result) != wemoSwitch.state) { - wemoSwitch.state = parseInt(result); - node.send({payload:wemoSwitch.state,topic:"wemo/"+node.ipaddr}); + if (parseInt(result) != node.wemoSwitch.state) { + node.wemoSwitch.state = parseInt(result); + node.send({payload:node.wemoSwitch.state,topic:"wemo/"+node.ipaddr}); } }); }, 2000); From 9d6d9917b8a7d970c1c8c951503e711ac9587909 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 18 Jul 2014 16:50:13 +0100 Subject: [PATCH 057/134] tweak to makey udev rules file.... --- hardware/makey/82-makey.rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/makey/82-makey.rules b/hardware/makey/82-makey.rules index acbefc8a..1269f8a9 100644 --- a/hardware/makey/82-makey.rules +++ b/hardware/makey/82-makey.rules @@ -1 +1 @@ -SUBSYSTEM=="usb", ATTR{idVendor}=="1b4f", ATTR{idProduct}=="2b74", MODE="0666" +SUBSYSTEM=="usb", ATTR{idVendor}=="1b4f", ATTR{idProduct}=="2b75", MODE="0666" From 232a11983b1327ba57af3279acab4e366e5596ee Mon Sep 17 00:00:00 2001 From: Dave C-J string. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-geohash + + +Usage +----- + +This function encodes a lat,lon string to and from a geohash. + +If the **msg.payload** is a string it tries to see if it's a geohash - + if so it tries to decode it and outputs a payload object containing + + - latitude + - longitude + - errorlatitude + - error.longitude + +If the **msg.payload** is an object with properties **lat** or **latitude** and **lon** or **longitude** - it will add a geohash property to the payload. + +The precision can be set by **msg.payload.precision** from 1 to 9. + + +Example flow +------------ + +Date: Fri, 18 Jul 2014 17:04:22 +0100 Subject: [PATCH 058/134] More tweaks to makey node - colours, jshint fixes, icons, readme etc. --- hardware/makey/42-makey.html | 4 ++-- hardware/makey/42-makey.js | 4 +--- hardware/makey/{82-makey.rules => 42-makey.rules} | 0 hardware/makey/README.md | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) rename hardware/makey/{82-makey.rules => 42-makey.rules} (100%) diff --git a/hardware/makey/42-makey.html b/hardware/makey/42-makey.html index a194e1cb..57949c14 100644 --- a/hardware/makey/42-makey.html +++ b/hardware/makey/42-makey.html @@ -16,7 +16,7 @@ @@ -33,7 +33,7 @@ + + + + diff --git a/hardware/PiLiter/39-rpi-piliter.js b/hardware/PiLiter/39-rpi-piliter.js new file mode 100644 index 00000000..22e94f5c --- /dev/null +++ b/hardware/PiLiter/39-rpi-piliter.js @@ -0,0 +1,142 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var exec = require('child_process').exec; + var fs = require('fs'); + + if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi + throw "Info : Ignoring Raspberry Pi specific node."; + } + + if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed + throw "Info : Can't find Raspberry Pi wiringPi gpio command."; + } + + // Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) + var pintable = { + // Physical : WiringPi + "LED1":"7", + "LED2":"0", + "LED3":"2", + "LED4":"1", + "LED5":"3", + "LED6":"4", + "LED7":"5", + "LED8":"6" + } + + var tablepin = { + // WiringPi : Physical + "0":"LED2", + "1":"LED4", + "2":"LED3", + "3":"LED5", + "4":"LED6", + "5":"LED7", + "6":"LED8", + "7":"LED1" + } + + var barpins = { + "1":"128", + "2":"129", + "3":"133", + "4":"135", + "5":"143", + "6":"159", + "7":"191", + "8":"255", + } + + var meterpins = { + "1":"128", + "2":"1", + "3":"4", + "4":"2", + "5":"8", + "6":"16", + "7":"32", + "8":"64", + } + + function PiLiter(n) { + RED.nodes.createNode(this,n); + this.pin = pintable[n.pin]; + this.pinv = n.pin; + var node = this; + + //Set all pins to outputs + for (var p = 0; p < 8; p++) { + exec("gpio mode "+p+" out"); + } + if (this.pinv === "bar") { + node.on("input", function(msg) { + var out = Number(msg.payload); + if ((out >= 1)&&(out <= 8)) { exec("gpio wb "+barpins[out]); } + else { exec("gpio wb 0"); } + }); + } + else if (this.pinv === "meter") { + node.on("input", function(msg) { + var out = Number(msg.payload); + if ((out >= 1)&&(out <= 8)) { exec("gpio wb "+meterpins[out]); } + else { exec("gpio wb 0"); } + }); + } + else if (this.pinv === "all") { + node.on("input", function(msg) { + var out = msg.payload; + if ((out === 1)|(out === true)|(out === "1")|(out === "on")) { + exec("gpio wb 255"); + } + else { exec("gpio wb 0"); } + }); + } + else if (this.pinv === "pin") { + node.on("input", function(msg) { + if (typeof msg.payload === "object") { + var out = Number(msg.payload.led); + var l = msg.payload.state; + if ((out >= 1)&&(out <= 8)) { + exec("gpio write "+pintable["LED"+out]+" "+l); + } + else { node.warn("Not a valid object - see Info panel."); } + } + else { node.warn("Not a valid object - see Info panel."); } + }); + } + else { + node.on("input", function(msg) { + var out = Number(msg.payload); + if ((out >= 0)&&(out <= 255)) { + var val = 0; + for (var i = 0; i < 8; i ++) { + val += ((out & 0x01) << pintable["LED"+(i+1)]); + out = out >> 1; + } + exec("gpio wb "+val); + } + else { node.warn("Invalid input - not between 0 and 255"); } + }); + } + node.on("close", function() { + exec("gpio wb 0"); + }); + } + RED.nodes.registerType("rpi-liter",PiLiter); +} diff --git a/hardware/PiLiter/LICENSE b/hardware/PiLiter/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/PiLiter/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/PiLiter/README.md b/hardware/PiLiter/README.md new file mode 100644 index 00000000..242fb550 --- /dev/null +++ b/hardware/PiLiter/README.md @@ -0,0 +1,33 @@ +node-red-node-piliter +===================== + +A Node-RED node to control a Pimorini Pi-LITEr 8 LED add-on board for a Raspberry-Pi. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-piliter + + +Pre-reqs +-------- + +Requires the WiringPi gpio command to be installed in order to work. See the WiringPi site for details on how to do this. + + +Usage +----- + +Raspberry Pi-LITEr output node. The Pi-LITEr must be fitted. + +Operates in one of 5 different modes : + + - Byte Mode - expects a value between 0 and 255, and each of the LEDs represent 1 bit. + - Meter Mode - expects a value between 0 and 8, the led lit corresponds to the input value - like a meter needle. + - Bar Mode - expects a value between 0 and 8, similar to meter - but all the leds up to the value are turned on - like a mini bar chart. + - All LEDs Mode - expects a 1 or 0 - turns on and off ALL the LEDs + - Object Mode - expects a object specifying the LED and state eg. {led:3,state:0}
to set LED3 off. + +Requires the WiringPi gpio command in order to work. diff --git a/hardware/PiLiter/package.json b/hardware/PiLiter/package.json new file mode 100644 index 00000000..c110950c --- /dev/null +++ b/hardware/PiLiter/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-pilter", + "version" : "0.0.1", + "description" : "A Node-RED node to drive a Raspberry Pi Pi-LITEr 8 LED board.", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/PiLiter" + }, + "license": "Apache", + "keywords": [ "node-red", "piliter" ], + "node-red" : { + "nodes" : { + "rpi-piliter": "39-rpi-piliter.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From f121f2683d83b08b95a6da677694e1c25c8eab7f Mon Sep 17 00:00:00 2001 From: Dave C-JDate: Fri, 25 Jul 2014 10:09:35 +0100 Subject: [PATCH 061/134] Tidy ups to ping (doc), dweet (unrequired util) and ddbout (JSHint) --- io/ping/88-ping.html | 2 +- social/dweetio/55-dweetio.js | 1 - storage/ddb/69-ddbout.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/io/ping/88-ping.html b/io/ping/88-ping.html index 06e3028f..45bdce99 100644 --- a/io/ping/88-ping.html +++ b/io/ping/88-ping.html @@ -31,7 +31,7 @@ diff --git a/social/dweetio/55-dweetio.js b/social/dweetio/55-dweetio.js index 67f5a6d8..fa450573 100644 --- a/social/dweetio/55-dweetio.js +++ b/social/dweetio/55-dweetio.js @@ -17,7 +17,6 @@ module.exports = function(RED) { "use strict"; var DweetClient = require("node-dweetio"); - var util = require('util'); var dweetio = null; function DweetioOutNode(n) { diff --git a/storage/ddb/69-ddbout.js b/storage/ddb/69-ddbout.js index 939d7d23..b013cf7a 100644 --- a/storage/ddb/69-ddbout.js +++ b/storage/ddb/69-ddbout.js @@ -36,7 +36,7 @@ function DDBOutNode(n) { ddb.putItem({ "TableName": this.table, "Item": attrWrapper.wrap(msg.payload) }, function(err, data) { - err && util.log(err); + if (err) { util.log(err); } }); } }); From 2d44105ae64ff79f8a378e368b8ba670500cdb1e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 25 Jul 2014 10:10:06 +0100 Subject: [PATCH 062/134] Realign sqlite files to be similar to other nodes --- storage/sqlite/{nodes => }/icons/sqlite.png | Bin storage/sqlite/package.json | 4 ++-- storage/sqlite/{nodes => }/sqlite.html | 0 storage/sqlite/{nodes => }/sqlite.js | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename storage/sqlite/{nodes => }/icons/sqlite.png (100%) rename storage/sqlite/{nodes => }/sqlite.html (100%) rename storage/sqlite/{nodes => }/sqlite.js (100%) diff --git a/storage/sqlite/nodes/icons/sqlite.png b/storage/sqlite/icons/sqlite.png similarity index 100% rename from storage/sqlite/nodes/icons/sqlite.png rename to storage/sqlite/icons/sqlite.png diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index e5fcd20b..ee1e5124 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-contrib-sqlite", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A sqlite node for Node-RED", "dependencies" : { "sqlite3" : "2.x" @@ -13,7 +13,7 @@ "keywords": [ "node-red", "sqlite" ], "node-red" : { "nodes" : { - "sqlite": "nodes/sqlite.js" + "sqlite": "sqlite.js" } }, "author": { diff --git a/storage/sqlite/nodes/sqlite.html b/storage/sqlite/sqlite.html similarity index 100% rename from storage/sqlite/nodes/sqlite.html rename to storage/sqlite/sqlite.html diff --git a/storage/sqlite/nodes/sqlite.js b/storage/sqlite/sqlite.js similarity index 100% rename from storage/sqlite/nodes/sqlite.js rename to storage/sqlite/sqlite.js From c95970a4aee02c510e90f1d38ebf448e79a0f736 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 25 Jul 2014 12:30:00 +0100 Subject: [PATCH 063/134] Once again Dave's quality speeling causes a problem... --- hardware/PiLiter/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/PiLiter/package.json b/hardware/PiLiter/package.json index c110950c..1f9aef51 100644 --- a/hardware/PiLiter/package.json +++ b/hardware/PiLiter/package.json @@ -1,5 +1,5 @@ { - "name" : "node-red-node-pilter", + "name" : "node-red-node-piliter", "version" : "0.0.1", "description" : "A Node-RED node to drive a Raspberry Pi Pi-LITEr 8 LED board.", "dependencies" : { From f21a08afe63e264f6b385d7debfe86015d2ebf25 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sun, 27 Jul 2014 16:09:50 +0100 Subject: [PATCH 064/134] Add prowl, nma and pushover to npm, update all to fa icons --- social/nma/57-nma.html | 6 +- social/nma/57-nma.js | 1 - social/nma/LICENSE | 177 +++++++++++++++++++++++++++++++ social/nma/README.md | 23 ++++ social/nma/package.json | 24 +++++ social/prowl/57-prowl.html | 8 +- social/prowl/57-prowl.js | 1 - social/prowl/LICENSE | 177 +++++++++++++++++++++++++++++++ social/prowl/README.md | 23 ++++ social/prowl/package.json | 24 +++++ social/pushover/57-pushover.html | 10 +- social/pushover/LICENSE | 177 +++++++++++++++++++++++++++++++ social/pushover/README.md | 23 ++++ social/pushover/package.json | 24 +++++ storage/sqlite/README.md | 15 ++- storage/sqlite/package.json | 6 +- storage/sqlite/sqlite.html | 6 +- 17 files changed, 704 insertions(+), 21 deletions(-) create mode 100644 social/nma/LICENSE create mode 100644 social/nma/README.md create mode 100644 social/nma/package.json create mode 100644 social/prowl/LICENSE create mode 100644 social/prowl/README.md create mode 100644 social/prowl/package.json create mode 100644 social/pushover/LICENSE create mode 100644 social/pushover/README.md create mode 100644 social/pushover/package.json diff --git a/social/nma/57-nma.html b/social/nma/57-nma.html index c6f88d7b..72efa216 100644 --- a/social/nma/57-nma.html +++ b/social/nma/57-nma.html @@ -16,16 +16,16 @@ diff --git a/social/nma/57-nma.js b/social/nma/57-nma.js index 00f8ad6d..017345b1 100644 --- a/social/nma/57-nma.js +++ b/social/nma/57-nma.js @@ -17,7 +17,6 @@ module.exports = function(RED) { "use strict"; var nma = require('nma'); - var util = require('util'); function NMANode(n) { RED.nodes.createNode(this,n); diff --git a/social/nma/LICENSE b/social/nma/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/social/nma/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/social/nma/README.md b/social/nma/README.md new file mode 100644 index 00000000..2ae013cf --- /dev/null +++ b/social/nma/README.md @@ -0,0 +1,23 @@ +node-red-node-nma +================= + +A Node-RED node to send alerts via Notify-My-Android. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-nma + + +Usage +----- + +Uses Notify-My-Android (NMA) to push the **msg.payload** to an Android device that has Notify-My-Android app installed. + +Optionally uses **msg.topic** to set the title, if not already set in the properties. + +The API-key is stored in a separate credentials file. + +Uses Notify-My-Android. See this link for more details. diff --git a/social/nma/package.json b/social/nma/package.json new file mode 100644 index 00000000..7004dd69 --- /dev/null +++ b/social/nma/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-nma", + "version" : "0.0.1", + "description" : "A Node-RED node to send alerts via Notify-My-Android", + "dependencies" : { + "nma" : "0.1.8" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/social/nma" + }, + "license": "Apache", + "keywords": [ "node-red", "nma", "notify my android" ], + "node-red" : { + "nodes" : { + "nma": "57-nma.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/social/prowl/57-prowl.html b/social/prowl/57-prowl.html index 8c9229ff..bc90e6df 100644 --- a/social/prowl/57-prowl.html +++ b/social/prowl/57-prowl.html @@ -16,20 +16,20 @@ @@ -36,11 +36,11 @@ From 434d9808a96d3e23e02ab4483b249a819e75c717 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sun, 27 Jul 2014 18:05:23 +0100 Subject: [PATCH 065/134] Add stomp, ping, wol, wemo nodes to npm and add fa icons --- hardware/wemo/60-wemo.html | 8 +- hardware/wemo/LICENSE | 177 +++++++++++++++++++++++++++++++++++++ hardware/wemo/README.md | 26 ++++++ hardware/wemo/package.json | 24 +++++ io/ping/88-ping.html | 6 +- io/ping/LICENSE | 177 +++++++++++++++++++++++++++++++++++++ io/ping/README.md | 21 +++++ io/ping/package.json | 23 +++++ io/stomp/18-stomp.html | 20 ++--- io/stomp/LICENSE | 177 +++++++++++++++++++++++++++++++++++++ io/stomp/README.md | 21 +++++ io/stomp/package.json | 24 +++++ io/wol/39-wol.html | 4 +- io/wol/LICENSE | 177 +++++++++++++++++++++++++++++++++++++ io/wol/README.md | 19 ++++ io/wol/package.json | 24 +++++ 16 files changed, 909 insertions(+), 19 deletions(-) create mode 100644 hardware/wemo/LICENSE create mode 100644 hardware/wemo/README.md create mode 100644 hardware/wemo/package.json create mode 100644 io/ping/LICENSE create mode 100644 io/ping/README.md create mode 100644 io/ping/package.json create mode 100644 io/stomp/LICENSE create mode 100644 io/stomp/README.md create mode 100644 io/stomp/package.json create mode 100644 io/wol/LICENSE create mode 100644 io/wol/README.md create mode 100644 io/wol/package.json diff --git a/hardware/wemo/60-wemo.html b/hardware/wemo/60-wemo.html index b282ea73..b75c3ab1 100644 --- a/hardware/wemo/60-wemo.html +++ b/hardware/wemo/60-wemo.html @@ -16,11 +16,11 @@ diff --git a/io/ping/LICENSE b/io/ping/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/io/ping/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/io/ping/README.md b/io/ping/README.md new file mode 100644 index 00000000..e10b690c --- /dev/null +++ b/io/ping/README.md @@ -0,0 +1,21 @@ +node-red-node-ping +================== + +A Node-RED node to ping a remote server, for use as a keep-alive check. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-ping + + +Usage +----- + +Pings a machine and returns the trip time in mS. + +Returns boolean **false** if no response received within 5 seconds, or if the host is unresolveable. + +Default ping is every 20 seconds but can be configured. diff --git a/io/ping/package.json b/io/ping/package.json new file mode 100644 index 00000000..67bb0884 --- /dev/null +++ b/io/ping/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-ping", + "version" : "0.0.1", + "description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/io/ping" + }, + "license": "Apache", + "keywords": [ "node-red", "ping", "keepalive" ], + "node-red" : { + "nodes" : { + "ping": "88-ping.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/io/stomp/18-stomp.html b/io/stomp/18-stomp.html index 86ba6337..8a99a143 100644 --- a/io/stomp/18-stomp.html +++ b/io/stomp/18-stomp.html @@ -16,15 +16,15 @@ @@ -56,15 +56,15 @@ diff --git a/io/stomp/LICENSE b/io/stomp/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/io/stomp/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/io/stomp/README.md b/io/stomp/README.md new file mode 100644 index 00000000..94e4ceb4 --- /dev/null +++ b/io/stomp/README.md @@ -0,0 +1,21 @@ +node-red-node-stomp +=================== + +A Node-RED node to publish and subscribe to and from a Stomp server. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-stomp + + +Usage +----- + +Connects to a Stomp capable server to send and receive messages. + +The **destination** field is optional. If set it overrides the **msg.topic** property of the message. + +This node only uses the simple security version of the stomp-client. diff --git a/io/stomp/package.json b/io/stomp/package.json new file mode 100644 index 00000000..7eec8101 --- /dev/null +++ b/io/stomp/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-stomp", + "version" : "0.0.1", + "description" : "A Node-RED node to publish and subscribe to/from a Stomp server", + "dependencies" : { + "stomp-client" : "0.5.0" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/io/stomp" + }, + "license": "Apache", + "keywords": [ "node-red", "stomp", "stomp-client" ], + "node-red" : { + "nodes" : { + "stomp": "18-stomp.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/io/wol/39-wol.html b/io/wol/39-wol.html index ffcdfb7b..27f3b7fe 100644 --- a/io/wol/39-wol.html +++ b/io/wol/39-wol.html @@ -16,11 +16,11 @@ @@ -73,13 +73,13 @@ (function() { - + var hasGlobal = false; $.getJSON('twilio-api/global',function(data) { hasGlobal = data.hasToken; }); - - + + RED.nodes.registerType('twilio-api',{ category: 'config', defaults: { @@ -98,7 +98,7 @@ } else { $('#node-config-input-token').val(''); } - + }); }, oneditsave: function() { @@ -122,7 +122,7 @@ }); } }); - + RED.nodes.registerType('twilio out',{ category: 'output', defaults: { diff --git a/social/twilio/56-twilio.js b/social/twilio/56-twilio.js index 5db40726..0212fb09 100644 --- a/social/twilio/56-twilio.js +++ b/social/twilio/56-twilio.js @@ -15,100 +15,101 @@ * limitations under the License. **/ -var RED = require(process.env.NODE_RED_HOME+"/red/red"); -var util = require('util'); -var twilio = require('twilio'); +module.exports = function(RED) { + "use strict"; + var twilio = require('twilio'); -try { - var twiliokey = RED.settings.twilio || require(process.env.NODE_RED_HOME+"/../twiliokey.js"); -} -catch(err) { -} - -var querystring = require('querystring'); - -RED.httpAdmin.get('/twilio-api/global',function(req,res) { - res.send(JSON.stringify({hasToken:!(twiliokey && twiliokey.account && twiliokey.authtoken)})); -}); -RED.httpAdmin.get('/twilio-api/:id',function(req,res) { - var credentials = RED.nodes.getCredentials(req.params.id); - if (credentials) { - res.send(JSON.stringify({hasToken:(credentials.token&&credentials.token!="")})); - } else { - res.send(JSON.stringify({})); + try { + var twiliokey = RED.settings.twilio || require(process.env.NODE_RED_HOME+"/../twiliokey.js"); + } + catch(err) { } -}); -RED.httpAdmin.delete('/twilio-api/:id',function(req,res) { - RED.nodes.deleteCredentials(req.params.id); - res.send(200); -}); + var querystring = require('querystring'); -RED.httpAdmin.post('/twilio-api/:id',function(req,res) { - var body = ""; - req.on('data', function(chunk) { - body+=chunk; + RED.httpAdmin.get('/twilio-api/global',function(req,res) { + res.send(JSON.stringify({hasToken:!(twiliokey && twiliokey.account && twiliokey.authtoken)})); }); - req.on('end', function(){ - var newCreds = querystring.parse(body); - var credentials = RED.nodes.getCredentials(req.params.id)||{}; - if (newCreds.token == "") { - delete credentials.token; + RED.httpAdmin.get('/twilio-api/:id',function(req,res) { + var credentials = RED.nodes.getCredentials(req.params.id); + if (credentials) { + res.send(JSON.stringify({hasToken:(credentials.token&&credentials.token!=="")})); } else { - credentials.token = newCreds.token; + res.send(JSON.stringify({})); } - RED.nodes.addCredentials(req.params.id,credentials); + }); + + RED.httpAdmin.delete('/twilio-api/:id',function(req,res) { + RED.nodes.deleteCredentials(req.params.id); res.send(200); }); -}); -function TwilioAPINode(n) { - RED.nodes.createNode(this,n); - this.sid = n.sid; - this.from = n.from; - this.name = n.name; - var credentials = RED.nodes.getCredentials(n.id); - if (credentials) { - this.token = credentials.token; - } -} -RED.nodes.registerType("twilio-api",TwilioAPINode); - - -function TwilioOutNode(n) { - RED.nodes.createNode(this,n); - this.number = n.number; - - this.api = RED.nodes.getNode(n.twilio); - - if (this.api) { - this.twilioClient = twilio(this.api.sid,this.api.token); - this.fromNumber = this.api.from; - } else if (twiliokey) { - this.twilioClient = twilio(twiliokey.account, twiliokey.authtoken); - this.fromNumber = twiliokey.from; - } else { - this.error("missing twilio credentials"); - return; - } - - var node = this; - this.on("input",function(msg) { - if (typeof(msg.payload) == 'object') { - msg.payload = JSON.stringify(msg.payload); - } - try { - // Send SMS - var tonum = node.number || msg.topic; - node.twilioClient.sendMessage( {to: tonum, from: node.fromNumber, body: msg.payload}, function(err, response) { - if (err) { - node.error(err); - } - //console.log(response); - }); - } catch (err) { - node.error(err); - } + RED.httpAdmin.post('/twilio-api/:id',function(req,res) { + var body = ""; + req.on('data', function(chunk) { + body+=chunk; + }); + req.on('end', function(){ + var newCreds = querystring.parse(body); + var credentials = RED.nodes.getCredentials(req.params.id)||{}; + if (newCreds.token == "") { + delete credentials.token; + } else { + credentials.token = newCreds.token; + } + RED.nodes.addCredentials(req.params.id,credentials); + res.send(200); + }); }); + + function TwilioAPINode(n) { + RED.nodes.createNode(this,n); + this.sid = n.sid; + this.from = n.from; + this.name = n.name; + var credentials = RED.nodes.getCredentials(n.id); + if (credentials) { + this.token = credentials.token; + } + } + RED.nodes.registerType("twilio-api",TwilioAPINode); + + + function TwilioOutNode(n) { + RED.nodes.createNode(this,n); + this.number = n.number; + + this.api = RED.nodes.getNode(n.twilio); + + if (this.api) { + this.twilioClient = twilio(this.api.sid,this.api.token); + this.fromNumber = this.api.from; + } else if (twiliokey) { + this.twilioClient = twilio(twiliokey.account, twiliokey.authtoken); + this.fromNumber = twiliokey.from; + } else { + this.error("missing twilio credentials"); + return; + } + + var node = this; + this.on("input",function(msg) { + if (typeof(msg.payload) == 'object') { + msg.payload = JSON.stringify(msg.payload); + } + try { + // Send SMS + var tonum = node.number || msg.topic; + node.twilioClient.sendMessage( {to: tonum, from: node.fromNumber, body: msg.payload}, function(err, response) { + if (err) { + node.error(err); + } + //console.log(response); + }); + } catch (err) { + node.error(err); + } + }); + } + RED.nodes.registerType("twilio out",TwilioOutNode); } -RED.nodes.registerType("twilio out",TwilioOutNode); diff --git a/social/twilio/README.md b/social/twilio/README.md index e0e5b146..83c2db12 100644 --- a/social/twilio/README.md +++ b/social/twilio/README.md @@ -1,5 +1,5 @@ -node-red-node-pushbullet -======================== +node-red-node-twilio +==================== A Node-RED node to send SMS messages via the Twilio service. diff --git a/social/twilio/package.json b/social/twilio/package.json index c9ab8e37..ab4b7bd7 100644 --- a/social/twilio/package.json +++ b/social/twilio/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-twilio", - "version" : "0.0.3", + "version" : "0.0.4", "description" : "A Node-RED node to send SMS messages via the Twilio service.", "dependencies" : { "twilio" : "1.6.0" From 7545515b4d3073d1819ca50b348c0caf6139bd88 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 7 Aug 2014 09:52:16 +0100 Subject: [PATCH 067/134] Update 55-dweetio.js --- social/dweetio/55-dweetio.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/social/dweetio/55-dweetio.js b/social/dweetio/55-dweetio.js index fa450573..4ef8c88b 100644 --- a/social/dweetio/55-dweetio.js +++ b/social/dweetio/55-dweetio.js @@ -29,7 +29,7 @@ module.exports = function(RED) { //if (typeof(msg.payload) === 'object') { var thing = node.thing || msg.thing; try { - dweetio.dweet_for(thing, {some:msg.payload}, function(err, dweet) { + dweetio.dweet_for(thing, {payload:msg.payload}, function(err, dweet) { //console.log(dweet.thing); // "my-thing" //console.log(dweet.content); // The content of the dweet //console.log(dweet.created); // The create date of the dweet @@ -52,7 +52,11 @@ module.exports = function(RED) { dweetio.listen_for(node.thing, function(dweet){ // This will be called anytime there is a new dweet for my-thing - dweet.payload = dweet.content.some; + if (dweet.content.hasOwnProperty("payload")) { + dweet.payload=dweet.content.payload; + } else { + dweet.payload = dweet.content; + } delete dweet.content; node.send(dweet); }); From 3a8e86d96205771c24a8b4b27e29e5b0dd562b44 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 19 Aug 2014 11:41:29 +0100 Subject: [PATCH 068/134] Tweak WOL node to display name correctly if set. Closes PR #63 --- io/wol/39-wol.html | 5 ++--- io/wol/package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/io/wol/39-wol.html b/io/wol/39-wol.html index 27f3b7fe..93ce1e68 100644 --- a/io/wol/39-wol.html +++ b/io/wol/39-wol.html @@ -17,7 +17,7 @@ From f19ae71fb77b085769801de1cad1472eac848fa9 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 3 Sep 2014 16:12:26 +0100 Subject: [PATCH 072/134] Migrate icons. --- 99-sample.html.demo | 4 +-- analysis/swearfilter/74-swearfilter.html | 2 +- analysis/wordpos/72-wordpos.html | 2 +- hardware/BBB/145-BBB-hardware.html | 34 +++++++++++------------ hardware/LEDborg/78-ledborg.html | 2 +- hardware/PiFace/37-rpi-piface.html | 8 +++--- hardware/Pibrella/38-rpi-pibrella.html | 8 +++--- hardware/blink1/77-blink1.html | 4 +-- hardware/blinkstick/76-blinkstick.html | 2 +- hardware/digiRGB/78-digiRGB.html | 2 +- hardware/heatmiser/100-heatmiser-in.html | 6 ++-- hardware/heatmiser/101-heatmiser-out.html | 8 +++--- hardware/hue/103-hue_discover.html | 4 +-- hardware/hue/104-hue_manage.html | 12 ++++---- hardware/scanBLE/101-scanBLE.html | 6 ++-- hardware/sensorTag/79-sensorTag.html | 20 ++++++------- hardware/wemo/60-wemo.html | 8 +++--- io/emoncms/88-emoncms.html | 12 ++++---- io/ping/88-ping.html | 6 ++-- io/stomp/18-stomp.html | 20 ++++++------- io/wol/39-wol.html | 4 +-- social/dweetio/55-dweetio.html | 8 +++--- social/music/69-mpd.html | 4 +-- social/nma/57-nma.html | 6 ++-- social/notify/57-notify.html | 4 +-- social/prowl/57-prowl.html | 8 +++--- social/pushbullet/57-pushbullet.html | 8 +++--- social/pusher/114-pusher.html | 20 ++++++------- social/pushover/57-pushover.html | 10 +++---- social/snapchat/79-snapchat.html | 10 +++---- social/twilio/56-twilio.html | 14 +++++----- social/xmpp/92-xmpp.html | 20 ++++++------- storage/ddb/69-ddbout.html | 8 +++--- storage/ddb/aws.html | 4 +-- storage/leveldb/67-leveldb.html | 12 ++++---- storage/postgres/110-postgres.html | 12 ++++---- storage/sqlite/nodes/sqlite.html | 6 ++-- 37 files changed, 164 insertions(+), 164 deletions(-) diff --git a/99-sample.html.demo b/99-sample.html.demo index c946ad11..fbc733d2 100644 --- a/99-sample.html.demo +++ b/99-sample.html.demo @@ -30,7 +30,7 @@ - +@@ -38,7 +38,7 @@- +diff --git a/analysis/swearfilter/74-swearfilter.html b/analysis/swearfilter/74-swearfilter.html index 34379f9b..e67933eb 100644 --- a/analysis/swearfilter/74-swearfilter.html +++ b/analysis/swearfilter/74-swearfilter.html @@ -16,7 +16,7 @@ diff --git a/analysis/wordpos/72-wordpos.html b/analysis/wordpos/72-wordpos.html index 6b098990..7e940aff 100644 --- a/analysis/wordpos/72-wordpos.html +++ b/analysis/wordpos/72-wordpos.html @@ -16,7 +16,7 @@ @@ -186,7 +186,7 @@ voltage ten times in rapid succession for each input message and output the mean @@ -305,7 +305,7 @@ press. When using buttons or switches, enable debouncing to improve reliability. @@ -416,7 +416,7 @@ any other input message will reset it to zero. @@ -526,7 +526,7 @@ the Inverting property is not applied to this value. diff --git a/hardware/LEDborg/78-ledborg.html b/hardware/LEDborg/78-ledborg.html index 86ce75e4..338e77d5 100644 --- a/hardware/LEDborg/78-ledborg.html +++ b/hardware/LEDborg/78-ledborg.html @@ -16,7 +16,7 @@ @@ -62,7 +62,7 @@ diff --git a/hardware/blinkstick/76-blinkstick.html b/hardware/blinkstick/76-blinkstick.html index 1bef4306..90b941a1 100644 --- a/hardware/blinkstick/76-blinkstick.html +++ b/hardware/blinkstick/76-blinkstick.html @@ -16,7 +16,7 @@ diff --git a/hardware/hue/104-hue_manage.html b/hardware/hue/104-hue_manage.html index d23f3973..99950970 100644 --- a/hardware/hue/104-hue_manage.html +++ b/hardware/hue/104-hue_manage.html @@ -18,17 +18,17 @@ diff --git a/hardware/scanBLE/101-scanBLE.html b/hardware/scanBLE/101-scanBLE.html index 329d142c..8a718460 100644 --- a/hardware/scanBLE/101-scanBLE.html +++ b/hardware/scanBLE/101-scanBLE.html @@ -18,17 +18,17 @@ diff --git a/hardware/sensorTag/79-sensorTag.html b/hardware/sensorTag/79-sensorTag.html index 6e065d94..6f5db727 100644 --- a/hardware/sensorTag/79-sensorTag.html +++ b/hardware/sensorTag/79-sensorTag.html @@ -29,43 +29,43 @@- +- +- +- +- +- +- +- +- +- +diff --git a/hardware/wemo/60-wemo.html b/hardware/wemo/60-wemo.html index b282ea73..b75c3ab1 100644 --- a/hardware/wemo/60-wemo.html +++ b/hardware/wemo/60-wemo.html @@ -16,11 +16,11 @@ @@ -60,15 +60,15 @@ diff --git a/io/stomp/18-stomp.html b/io/stomp/18-stomp.html index 86ba6337..8a99a143 100644 --- a/io/stomp/18-stomp.html +++ b/io/stomp/18-stomp.html @@ -16,15 +16,15 @@ @@ -56,15 +56,15 @@ diff --git a/io/wol/39-wol.html b/io/wol/39-wol.html index ffcdfb7b..27f3b7fe 100644 --- a/io/wol/39-wol.html +++ b/io/wol/39-wol.html @@ -16,11 +16,11 @@ @@ -57,12 +57,12 @@ diff --git a/social/music/69-mpd.html b/social/music/69-mpd.html index b06bd5e7..bfa11854 100644 --- a/social/music/69-mpd.html +++ b/social/music/69-mpd.html @@ -16,7 +16,7 @@ diff --git a/social/notify/57-notify.html b/social/notify/57-notify.html index fa820d31..96859100 100644 --- a/social/notify/57-notify.html +++ b/social/notify/57-notify.html @@ -16,11 +16,11 @@ diff --git a/social/prowl/57-prowl.html b/social/prowl/57-prowl.html index 8c9229ff..8e48d415 100644 --- a/social/prowl/57-prowl.html +++ b/social/prowl/57-prowl.html @@ -16,20 +16,20 @@ @@ -90,32 +90,32 @@ diff --git a/social/pushover/57-pushover.html b/social/pushover/57-pushover.html index aa020122..0f575899 100644 --- a/social/pushover/57-pushover.html +++ b/social/pushover/57-pushover.html @@ -16,24 +16,24 @@ @@ -56,15 +56,15 @@- +- +- +diff --git a/social/xmpp/92-xmpp.html b/social/xmpp/92-xmpp.html index 0c0bb387..5b9b8c9c 100644 --- a/social/xmpp/92-xmpp.html +++ b/social/xmpp/92-xmpp.html @@ -16,11 +16,11 @@ @@ -65,7 +65,7 @@ diff --git a/storage/ddb/aws.html b/storage/ddb/aws.html index 5c26c904..8d6aeb87 100644 --- a/storage/ddb/aws.html +++ b/storage/ddb/aws.html @@ -16,11 +16,11 @@ diff --git a/storage/leveldb/67-leveldb.html b/storage/leveldb/67-leveldb.html index 72ead707..e889a15a 100644 --- a/storage/leveldb/67-leveldb.html +++ b/storage/leveldb/67-leveldb.html @@ -16,7 +16,7 @@ @@ -35,11 +35,11 @@ @@ -75,18 +75,18 @@ diff --git a/storage/postgres/110-postgres.html b/storage/postgres/110-postgres.html index 6fae6ac1..399a574d 100644 --- a/storage/postgres/110-postgres.html +++ b/storage/postgres/110-postgres.html @@ -16,19 +16,19 @@ @@ -86,11 +86,11 @@ @@ -36,11 +36,11 @@ From fdb62b548520519558fb23a7606831ffd06a90d3 Mon Sep 17 00:00:00 2001 From: Mark HindessDate: Wed, 3 Sep 2014 20:52:29 +0100 Subject: [PATCH 073/134] Found fa icon equivalent to icon-resize-full --- hardware/PiFace/37-rpi-piface.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/PiFace/37-rpi-piface.html b/hardware/PiFace/37-rpi-piface.html index 21f6b8e3..126b9c40 100644 --- a/hardware/PiFace/37-rpi-piface.html +++ b/hardware/PiFace/37-rpi-piface.html @@ -38,7 +38,7 @@ - +
- +Tip: This node ONLY works with numbers.diff --git a/analysis/smooth/17-smooth.js b/function/smooth/17-smooth.js similarity index 100% rename from analysis/smooth/17-smooth.js rename to function/smooth/17-smooth.js diff --git a/analysis/smooth/LICENSE b/function/smooth/LICENSE similarity index 100% rename from analysis/smooth/LICENSE rename to function/smooth/LICENSE diff --git a/analysis/smooth/README.md b/function/smooth/README.md similarity index 100% rename from analysis/smooth/README.md rename to function/smooth/README.md diff --git a/analysis/smooth/icons/smooth.png b/function/smooth/icons/smooth.png similarity index 100% rename from analysis/smooth/icons/smooth.png rename to function/smooth/icons/smooth.png diff --git a/function/smooth/npm-debug.log b/function/smooth/npm-debug.log new file mode 100644 index 00000000..d541255d --- /dev/null +++ b/function/smooth/npm-debug.log @@ -0,0 +1,69 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ] +2 info using npm@1.4.28 +3 info using node@v0.10.32 +4 verbose publish [ '.' ] +5 verbose cache add [ '.', null ] +6 verbose cache add name=undefined spec="." args=[".",null] +7 verbose parsed url { protocol: null, +7 verbose parsed url slashes: null, +7 verbose parsed url auth: null, +7 verbose parsed url host: null, +7 verbose parsed url port: null, +7 verbose parsed url hostname: null, +7 verbose parsed url hash: null, +7 verbose parsed url search: null, +7 verbose parsed url query: null, +7 verbose parsed url pathname: '.', +7 verbose parsed url path: '.', +7 verbose parsed url href: '.' } +8 silly lockFile 3a52ce78- . +9 verbose lock . /home/conway/.npm/3a52ce78-.lock +10 verbose tar pack [ '/home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz', +10 verbose tar pack '.' ] +11 verbose tarball /home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz +12 verbose folder . +13 info prepublish node-red-node-smooth@0.0.1 +14 silly lockFile 1f1177db-tar tar://. +15 verbose lock tar://. /home/conway/.npm/1f1177db-tar.lock +16 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz +17 verbose lock tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz /home/conway/.npm/4b60630a-ed-node-smooth-0-0-1-package-tgz.lock +18 silly lockFile 1f1177db-tar tar://. +19 silly lockFile 1f1177db-tar tar://. +20 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz +21 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz +22 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package +23 verbose lock /home/conway/.npm/node-red-node-smooth/0.0.1/package /home/conway/.npm/e098ce82-de-red-node-smooth-0-0-1-package.lock +24 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package +25 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package +26 silly lockFile 3a52ce78- . +27 silly lockFile 3a52ce78- . +28 silly publish { name: 'node-red-node-smooth', +28 silly publish version: '0.0.1', +28 silly publish description: 'A Node-RED node that provides several simple smoothing algorithms for incoming data values.', +28 silly publish dependencies: {}, +28 silly publish repository: +28 silly publish { type: 'git', +28 silly publish url: 'https://github.com/node-red/node-red-nodes/tree/master/analysis/smooth' }, +28 silly publish license: 'Apache', +28 silly publish keywords: [ 'node-red', 'smooth', 'average' ], +28 silly publish 'node-red': { nodes: { smooth: '17-smooth.js' } }, +28 silly publish author: +28 silly publish { name: 'Dave Conway-Jones', +28 silly publish email: 'ceejay@vnet.ibm.com', +28 silly publish url: 'http://nodered.org' }, +28 silly publish readme: 'node-red-node-smooth\n====================\n\nA Node-RED node that provides several simple smoothing algorithms for incoming data values.\n\nInstall\n-------\n\nRun the following command in the root directory of your Node-RED install\n\n npm install node-red-node-smooth\n\n\nUsage\n-----\n\nA simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters.\n\nMax, Min and Mean work over a specified number of previous values.\n\nThe High and Low pass filters use a smoothing factor. The higher the number the more the smoothing. E.g. a value of 10 is similar to an α of 0.1. It is analogous to an RC time constant - but there is no time component to this as the code is based on events arriving.\n\n\n**Note:** This only operates on **numbers**. Anything else will try to be made into a number and rejected if that fails.\n', +28 silly publish readmeFilename: 'README.md', +28 silly publish _id: 'node-red-node-smooth@0.0.1', +28 silly publish scripts: {}, +28 silly publish _shasum: '61d81cdc39b16d5c24c7875fa33fba229d65ec77', +28 silly publish _from: '.' } +29 error need auth auth and email required for publishing +29 error need auth You need to authorize this machine using `npm adduser` +30 error System Linux 3.2.0-68-generic-pae +31 error command "/usr/local/bin/node" "/usr/local/bin/npm" "publish" +32 error cwd /home/conway/node-red/nodes/node-red-nodes/function/smooth +33 error node -v v0.10.32 +34 error npm -v 1.4.28 +35 error code ENEEDAUTH +36 verbose exit [ 1, true ] diff --git a/analysis/smooth/package.json b/function/smooth/package.json similarity index 100% rename from analysis/smooth/package.json rename to function/smooth/package.json From dc7da9680b6cafd84761c262415f092282df95e2 Mon Sep 17 00:00:00 2001 From: Dave C-JDate: Sun, 21 Sep 2014 11:17:49 +0100 Subject: [PATCH 088/134] Update README list to add smooth node to function category. tweak Sample node to be inline with core sample node. --- 99-sample.html.demo | 2 +- 99-sample.js.demo | 9 +++++++++ README.md | 10 ++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/99-sample.html.demo b/99-sample.html.demo index fbc733d2..06092b03 100644 --- a/99-sample.html.demo +++ b/99-sample.html.demo @@ -65,7 +65,7 @@ name: {value:""}, // along with default values. topic: {value:"", required:true} }, - inputs:0, // set the number of inputs - only 0 or 1 + inputs:1, // set the number of inputs - only 0 or 1 outputs:1, // set the number of outputs - 0 to n // set the icon (held in icons dir below where you save the node) icon: "myicon.png", // saved in icons/myicon.png diff --git a/99-sample.js.demo b/99-sample.js.demo index 0bba1818..5147e092 100644 --- a/99-sample.js.demo +++ b/99-sample.js.demo @@ -21,6 +21,8 @@ // Require main module module.exports = function(RED) { "use strict"; + // require any external libraries we may need.... + //var foo = require("foo-library"); // The main node definition - most things happen in here function SampleNode(n) { @@ -41,6 +43,13 @@ module.exports = function(RED) { // send out the message to the rest of the workspace. this.send(msg); + // respond to inputs.... + this.on('input', function (msg) { + node.warn("I saw a payload: "+msg.payload); + // in this example just send it straight on... should process it here really + this.send(msg); + } + this.on("close", function() { // Called when the node is shutdown - eg on redeploy. // Allows ports to be closed, connections dropped etc. diff --git a/README.md b/README.md index afb844fd..d8981285 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ A collection of nodes for [Node-RED](http://nodered.org). See below for a list. ## Installation -Many of these nodes are available as an npm package. See the respective README.md for the npm package name. +Many of these nodes are available as an npm package. See the respective README.md for the npm package name. -To manually install using this repo: +To manually install using this repo: 1. cd into the `nodes` directory of Node-RED 2. Either: @@ -49,12 +49,14 @@ Copyright 2013 IBM Corp. under [the Apache 2.0 license](LICENSE). ### Analysis -**[17-smooth](analysis/smooth)** - A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters. - **[72-wordpos](analysis/wordpos)** - Analyses the payload and classifies the part-of-speech of each word. The resulting message has msg.pos added with the results. A word may appear in multiple categories (eg, 'great' is both a noun and an adjective). **[74-swearfilter](analysis/swearfilter)** - Analyses the payload and tries to filter out any messages containing bad swear words. This only operates on payloads of type string. Everything else is blocked. +### Function + +**[17-smooth](analysis/smooth)** - A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters. + ### Hardware **[37-rpi-piface](hardware/PiFace)** - Adds support for the [PiFace](http://www.piface.org.uk/) interface module for Raspberry Pi. From a36b6b053b520cb9f294917eee7d3db2270b1fef Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 22 Sep 2014 20:00:26 +0100 Subject: [PATCH 089/134] Add npm info to RED.me --- README.md | 127 +++++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index d8981285..db42ddf7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,14 @@ A collection of nodes for [Node-RED](http://nodered.org). See below for a list. ## Installation -Many of these nodes are available as an npm package. See the respective README.md for the npm package name. +Most of these nodes are available as npm packages. See the list below for the npm package names, or [search npm](https://www.npmjs.org/search?q=node-red-node). + +To install + + cd node-red + npm install node-red-node-{*filename*} + +This repository acts as an overall store for these nodes - and is no longer intended as a way to install them - unless you really do want some bloat. To manually install using this repo: @@ -14,136 +21,118 @@ To manually install using this repo: - run `git clone https://github.com/node-red/node-red-nodes.git` 3. npm install in any of the node subfolders to install individual node's dependencies -This is all too manual, so the sooner we npm-enable this stuff the better - ## Contributing -See the [Contributing Guide](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md) of the node-red project. +Now that we support npm installaton of nodes we recommend people post their own via [npm](https://www.npmjs.org/). Please read the [packaging guide notes](http://nodered.org/docs/creating-nodes/packaging.html). -The key points are: - - try to follow the conventions we use (all undocumented at the moment just to make it interesting) - - focus on the UX of the node - make it simple to do simple things and simple to do advanced things. Don't - force a user wanting to do simple things have to wade through the advanced things. - - avoid duplication - -### Contributor License Agreement - -In order for us to accept pull-requests, the contributor must first complete -a Contributor License Agreement (CLA). This clarifies the intellectual -property license granted with any contribution. It is for your protection as a -Contributor as well as the protection of IBM and its customers; it does not -change your rights to use your own Contributions for any other purpose. - -Once you have created a pull-request, we'll provide a link to the appropriate -CLA document. - -If you are an IBMer, please contact us directly as the contribution process is -slightly different. +If you are an IBMer, please contact us directly as the contribution process is slightly different. ## Copyright and license -Copyright 2013 IBM Corp. under [the Apache 2.0 license](LICENSE). +Copyright 2013,2014 IBM Corp. under [the Apache 2.0 license](LICENSE). # Extra Node Information +NPM name - File-link - Description + ### Analysis -**[72-wordpos](analysis/wordpos)** - Analyses the payload and classifies the part-of-speech of each word. The resulting message has msg.pos added with the results. A word may appear in multiple categories (eg, 'great' is both a noun and an adjective). +**node-red-node-wordpos** - *[72-wordpos](analysis/wordpos)* - Analyses the payload and classifies the part-of-speech of each word. The resulting message has msg.pos added with the results. A word may appear in multiple categories (eg, 'great' is both a noun and an adjective). -**[74-swearfilter](analysis/swearfilter)** - Analyses the payload and tries to filter out any messages containing bad swear words. This only operates on payloads of type string. Everything else is blocked. +**node-red-node-wordpos** - *[74-swearfilter](analysis/swearfilter)* - Analyses the payload and tries to filter out any messages containing bad swear words. This only operates on payloads of type string. Everything else is blocked. ### Function -**[17-smooth](analysis/smooth)** - A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters. +**node-red-node-smooth** - *[17-smooth](analysis/smooth)* - A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters. ### Hardware -**[37-rpi-piface](hardware/PiFace)** - Adds support for the [PiFace](http://www.piface.org.uk/) interface module for Raspberry Pi. +**node-red-node-beaglebone** - *[145-BBB-hardware](hardware/BBB)* - A collection of analogue & digital input & output nodes for the [Beaglebone Black](http://beagleboard.org/black). -**[38-rpi-pibrella](hardware/Pibrella)** - Controls a [Pibrella](http://pibrella.com/) add-on board for a Raspberry-Pi. +**node-red-node-piface** - *[37-rpi-piface](hardware/PiFace)* - Adds support for the [PiFace](http://www.piface.org.uk/) interface module for Raspberry Pi. -**[39-rpi-piliter](hardware/PiLiter)** - Controls a Pimorini Pi-LITEr 8 LED add-on board for a Raspberry-Pi. +**node-red-node-pibrella** - *[38-rpi-pibrella](hardware/Pibrella)* - Controls a [Pibrella](http://pibrella.com/) add-on board for a Raspberry-Pi. -**[42-makey](hardware/makey)** - A Node-RED node to read from a [MakeyMakey](http://www.makeymakey.com/) input device. +**node-red-node-piliter** - *[39-rpi-piliter](hardware/PiLiter)* - Controls a Pimorini Pi-LITEr 8 LED add-on board for a Raspberry-Pi. -**[60-wemo](hardware/wemo)** - Basic node to drive a [WeMo](http://www.belkin.com/us/Products/home-automation/c/wemo-home-automation/) socket and switch. Does not use discovery. +**node-red-node-blinkstick** - *[76-blinkstick](hardware/blinkstick)* - Provides support for the [BlinkStick](http://www.blinkstick.com/) USB LED device. -**[76-blinkstick](hardware/blinkstick)** - Provides support for the [BlinkStick](http://www.blinkstick.com/) USB LED device. +**node-red-node-blink1** - *[77-blink1](hardware/blink1)* - Provides support for the [Blink1](http://blink1.thingm.com/) USB LED from ThingM. -**[77-blink1](hardware/blink1)** - Provides support for the [Blink1](http://blink1.thingm.com/) USB LED from ThingM. +**node-red-node-ledborg** - *[78-ledborg](hardware/LEDborg)* - A simple driver for the [LEDborg](https://www.piborg.org/ledborg) plug on module for Raspberry Pi. -**[78-ledborg](hardware/LEDborg)** - A simple driver for the [LEDborg](https://www.piborg.org/ledborg) plug on module for Raspberry Pi. +**node-red-node-digirgb** - *[78-digiRGB](hardware/digiRGB)* - Provides support for the DigiSpark RGB USB LED. -**[78-digiRGB](hardware/digiRGB)** - Provides support for the DigiSpark RGB USB LED. +**node-red-node-wemo** - *[60-wemo](hardware/wemo)* - Basic node to drive a [WeMo](http://www.belkin.com/us/Products/home-automation/c/wemo-home-automation/) socket and switch. Does not use discovery. -**[79-sensorTag](hardware/sensorTag)** - Reads data from the Ti Bluetooh Low Energy (BLE) SensorTag device. +**N/A** - *[42-makey](hardware/makey)* - A Node-RED node to read from a [MakeyMakey](http://www.makeymakey.com/) input device. -**100-heatmiser-in** - Writes settings for temperature and frost protection to Heatmiser thermostats. +**N/A** - *[79-sensorTag](hardware/sensorTag)* - Reads data from the Ti Bluetooh Low Energy (BLE) SensorTag device. -**101-heatmiser-out** - Reads settings from Heatmiser thermostats at a polling interval. +**N/A** - *100-heatmiser-in* - Writes settings for temperature and frost protection to Heatmiser thermostats. -**101-scanBLE** - Scans for a particular Bluetooth Low Energy (BLE) device. +**N/A** - *101-heatmiser-out* - Reads settings from Heatmiser thermostats at a polling interval. -**103-hue_discover** - Looks for a Philips Hue Bridge in the local network. +**N/A** - *101-scanBLE* - Scans for a particular Bluetooth Low Energy (BLE) device. -**104-hue_manag** - Implements some basic functionality for managing a Philips Hue wireless Lamp system. +**N/A** - *103-hue_discover* - Looks for a Philips Hue Bridge in the local network. -**[145-BBB-hardware](hardware/BBB)** - A collection of analogue & digital input & output nodes for the [Beaglebone Black](http://beagleboard.org/black). +**N/A** - *104-hue_manag* - Implements some basic functionality for managing a Philips Hue wireless Lamp system. ### IO -**[18-stomp](io/stomp)** - A Node-RED node to publish and subscribe to and from a [STOMP server](https://stomp.github.io/implementations.html#STOMP_Servers). +**node-red-node-stomp** - *[18-stomp](io/stomp)* - A Node-RED node to publish and subscribe to and from a [STOMP server](https://stomp.github.io/implementations.html#STOMP_Servers). -**26-rawserial** - Only really needed for Windows boxes without serialport npm module installed. +**node-red-node-wol** - *[39-wol](io/wol)* - Sends a Wake-On-LAN magic packet to the mac address specified. You may instead set msg.mac to dynamically set the target device mac to wake up. + +**node-red-node-ping** - *[88-ping](io/ping)* - Pings a machine and returns the trip time in mS. Returns false if no response received within 3 seconds, or if the host is unresolveable. Default ping is every 20 seconds but can be configured. + +**N/A** - *88-emoncms* - Adds node to post to an [Emoncms](http://emoncms.org/) server. + +**N/A** - *26-rawserial* - Only really needed for Windows boxes without serialport npm module installed. Uses a simple read of the serial port as a file to input data. You **must** set the baud rate etc externally *before* starting Node-RED. This node does not implement pooling of connections so only one instance of each port may be used - so in **or** out but **not** both. -**[39-wol](io/wol)** - Sends a Wake-On-LAN magic packet to the mac address specified. You may instead set msg.mac to dynamically set the target device mac to wake up. - -**[88-ping](io/ping)** - Pings a machine and returns the trip time in mS. Returns false if no response received within 3 seconds, or if the host is unresolveable. Default ping is every 20 seconds but can be configured. - -**88-emoncms** - Adds node to post to an [Emoncms](http://emoncms.org/) server. - ### Social -**55-dweetio** - Uses [dweetio](https://dweet.io/) to send/receive messages. +**node-red-node-twilio** - *[56-twilio](social/twilio)* - Uses [Twilio](https://www.twilio.com/) service to send/receive text messages. -**[56-twilio](social/twilio)** - Uses [Twilio](https://www.twilio.com/) service to send/receive text messages. +**node-red-node-dweetio** - *55-dweetio* - Uses [dweetio](https://dweet.io/) to send/receive messages. -**[57-nma](social/nma)** - Sends alerts to Android devices via the [Notify-My-Android](http://www.notifymyandroid.com/) app. +**node-red-node-nma** - *[57-nma](social/nma)* - Sends alerts to Android devices via the [Notify-My-Android](http://www.notifymyandroid.com/) app. -**57-notify** - Uses [Growl](http://growl.info/) to provide a desktop popup containing the payload. Only useful on the local Apple machine. +**node-red-node-notify** - *57-notify* - Uses [Growl](http://growl.info/) to provide a desktop popup containing the payload. Only useful on the local Apple machine. -**[57-prowl](social/prowl)** - Uses [Prowl](http://www.prowlapp.com/) to push the payload to an Apple device that has the Prowl app installed. +**node-red-node-prowl** - *[57-prowl](social/prowl)* - Uses [Prowl](http://www.prowlapp.com/) to push the payload to an Apple device that has the Prowl app installed. -**[57-pushbullet](social/pushbullet)** - Uses [PushBullet](https://www.pushbullet.com/) to push the payload to an Android device that has the [PushBullet](https://www.pushbullet.com/) app installed. +**node-red-node-pushbullet** - *[57-pushbullet](social/pushbullet)* - Uses [PushBullet](https://www.pushbullet.com/) to push the payload to an Android device that has the [PushBullet](https://www.pushbullet.com/) app installed. -**[57-pushover](social/pushover)** - Sends alerts via [Pushover](https://pushover.net/). +**node-red-node-pushover** - *[57-pushover](social/pushover)* - Sends alerts via [Pushover](https://pushover.net/). -**69-mpd** - MPD music control nodes. Output node expects payload to be a valid mpc command. Currently only simple commands that expect no reply are supported. Input node creates a payload object with Artist, Album, Title, Genre and Date. +**node-red-node-xmpp** - *[92-xmpp](social/xmpp)* - Connects to an XMPP server to send and receive messages. -**79-snapchat** - Downloads [SnapChat](https://www.snapchat.com/) images from the account specified. +**N/A** - *69-mpd* - MPD music control nodes. Output node expects payload to be a valid mpc command. Currently only simple commands that expect no reply are supported. Input node creates a payload object with Artist, Album, Title, Genre and Date. -**[92-xmpp](social/xmpp)** - Connects to an XMPP server to send and receive messages. +**N/A** - *79-snapchat* - Downloads [SnapChat](https://www.snapchat.com/) images from the account specified. -**114-pusher** - Publish-Subscribe to a [Pusher](http://pusher.com/) channel/event. +**N/A** - *114-pusher* - Publish-Subscribe to a [Pusher](http://pusher.com/) channel/event. ### Storage -**[67-leveldb](storage/leveldb)** - Uses LevelDB for a simple key value pair database. +**node-red-node-leveldb** - *[67-leveldb](storage/leveldb)* - Uses LevelDB for a simple key value pair database. -**[68-mysql](storage/mysql)** - Allows basic access to a MySQL database. This node uses the **query** operation against the configured database. This does allow both INSERTS and DELETES. By it's very nature it allows SQL injection... *so be careful out there...* +**node-red-node-mysql** - *[68-mysql](storage/mysql)* - Allows basic access to a MySQL database. This node uses the **query** operation against the configured database. This does allow both INSERTS and DELETES. By it's very nature it allows SQL injection... *so be careful out there...* -**69-ddbout** - Support output to Amazon DynamoDB. +**node-red-node-sqlite** - *[sqlite](storage/sqlite)* - Supports read and write to a local sqlite database. -**110-postgres** - PostgreSql I/O node. +**N/A** - *69-ddbout* - Support output to Amazon DynamoDB. -**[sqlite](storage/sqlite)** - Supports read and write to a local sqlite database. +**N/A** - *110-postgres* - PostgreSql I/O node. ### Time -**[79-suncalc](time)** - Uses the suncalc module to generate an output at sunrise and sunset based on a specified location. Several choices of definition of sunrise and sunset are available, +**node-red-node-suncalc** - *[79-suncalc](time)* - Uses the suncalc module to generate an output at sunrise and sunset based on a specified location. Several choices of definition of sunrise and sunset are available, ### Misc -**99-sample** - A sample node with more comments than most to try to help you get started without any other docs... +**N/A** - *99-sample* - A sample node with more comments than most to try to help you get started without any other docs... From a5b3cf09e08a1152cc17d540dc465496f212f760 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 22 Sep 2014 20:47:06 +0100 Subject: [PATCH 090/134] Add extra links to README.md --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index db42ddf7..f02dced5 100644 --- a/README.md +++ b/README.md @@ -70,15 +70,15 @@ NPM name - File-link - Description **N/A** - *[79-sensorTag](hardware/sensorTag)* - Reads data from the Ti Bluetooh Low Energy (BLE) SensorTag device. -**N/A** - *100-heatmiser-in* - Writes settings for temperature and frost protection to Heatmiser thermostats. +**N/A** - *[100-heatmiser-in](hardware/heatmiser)* - Writes settings for temperature and frost protection to Heatmiser thermostats. -**N/A** - *101-heatmiser-out* - Reads settings from Heatmiser thermostats at a polling interval. +**N/A** - *[101-heatmiser-out](hardware/heatmiser)* - Reads settings from Heatmiser thermostats at a polling interval. -**N/A** - *101-scanBLE* - Scans for a particular Bluetooth Low Energy (BLE) device. +**N/A** - *[101-scanBLE](hardware/scanBLE)* - Scans for a particular Bluetooth Low Energy (BLE) device. -**N/A** - *103-hue_discover* - Looks for a Philips Hue Bridge in the local network. +**N/A** - *[103-hue_discover](hardware/hue)* - Looks for a Philips Hue Bridge in the local network. -**N/A** - *104-hue_manag* - Implements some basic functionality for managing a Philips Hue wireless Lamp system. +**N/A** - *[104-hue_manage](hardware/hue)* - Implements some basic functionality for managing a Philips Hue wireless Lamp system. ### IO @@ -88,20 +88,20 @@ NPM name - File-link - Description **node-red-node-ping** - *[88-ping](io/ping)* - Pings a machine and returns the trip time in mS. Returns false if no response received within 3 seconds, or if the host is unresolveable. Default ping is every 20 seconds but can be configured. -**N/A** - *88-emoncms* - Adds node to post to an [Emoncms](http://emoncms.org/) server. +**N/A** - *[88-emoncms](io/emoncms)* - Adds node to post to an [Emoncms](http://emoncms.org/) server. -**N/A** - *26-rawserial* - Only really needed for Windows boxes without serialport npm module installed. +**N/A** - *[26-rawserial](io/rawserial)* - Only really needed for Windows boxes without serialport npm module installed. Uses a simple read of the serial port as a file to input data. You **must** set the baud rate etc externally *before* starting Node-RED. This node does not implement pooling of connections so only one instance of each port may be used - so in **or** out but **not** both. ### Social **node-red-node-twilio** - *[56-twilio](social/twilio)* - Uses [Twilio](https://www.twilio.com/) service to send/receive text messages. -**node-red-node-dweetio** - *55-dweetio* - Uses [dweetio](https://dweet.io/) to send/receive messages. +**node-red-node-dweetio** - *[55-dweetio](social/dweetio)* - Uses [dweetio](https://dweet.io/) to send/receive messages. **node-red-node-nma** - *[57-nma](social/nma)* - Sends alerts to Android devices via the [Notify-My-Android](http://www.notifymyandroid.com/) app. -**node-red-node-notify** - *57-notify* - Uses [Growl](http://growl.info/) to provide a desktop popup containing the payload. Only useful on the local Apple machine. +**node-red-node-notify** - *[57-notify](social/notify)* - Uses [Growl](http://growl.info/) to provide a desktop popup containing the payload. Only useful on the local Apple machine. **node-red-node-prowl** - *[57-prowl](social/prowl)* - Uses [Prowl](http://www.prowlapp.com/) to push the payload to an Apple device that has the Prowl app installed. @@ -111,11 +111,11 @@ Uses a simple read of the serial port as a file to input data. You **must** set **node-red-node-xmpp** - *[92-xmpp](social/xmpp)* - Connects to an XMPP server to send and receive messages. -**N/A** - *69-mpd* - MPD music control nodes. Output node expects payload to be a valid mpc command. Currently only simple commands that expect no reply are supported. Input node creates a payload object with Artist, Album, Title, Genre and Date. +**N/A** - *[69-mpd](social/music)* - MPD music control nodes. Output node expects payload to be a valid mpc command. Currently only simple commands that expect no reply are supported. Input node creates a payload object with Artist, Album, Title, Genre and Date. -**N/A** - *79-snapchat* - Downloads [SnapChat](https://www.snapchat.com/) images from the account specified. +**N/A** - *[79-snapchat](social/snapchat)* - Downloads [SnapChat](https://www.snapchat.com/) images from the account specified. -**N/A** - *114-pusher* - Publish-Subscribe to a [Pusher](http://pusher.com/) channel/event. +**N/A** - *[114-pusher](social/pusher)* - Publish-Subscribe to a [Pusher](http://pusher.com/) channel/event. ### Storage @@ -125,9 +125,9 @@ Uses a simple read of the serial port as a file to input data. You **must** set **node-red-node-sqlite** - *[sqlite](storage/sqlite)* - Supports read and write to a local sqlite database. -**N/A** - *69-ddbout* - Support output to Amazon DynamoDB. +**N/A** - *[69-ddbout](storage/ddb)* - Support output to Amazon DynamoDB. -**N/A** - *110-postgres* - PostgreSql I/O node. +**N/A** - *[110-postgres](storage/postgres)* - PostgreSql I/O node. ### Time @@ -135,4 +135,4 @@ Uses a simple read of the serial port as a file to input data. You **must** set ### Misc -**N/A** - *99-sample* - A sample node with more comments than most to try to help you get started without any other docs... +**N/A** - *[99-sample](./)* - A sample node with more comments than most to try to help you get started without any other docs... From 4baf78e52b3780a90bd3f60d8dab7a3ed3389bff Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 22 Sep 2014 20:50:25 +0100 Subject: [PATCH 091/134] fix sqlite node typos --- storage/sqlite/README.md | 6 +++--- storage/sqlite/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/sqlite/README.md b/storage/sqlite/README.md index 213a857f..bd0e963d 100644 --- a/storage/sqlite/README.md +++ b/storage/sqlite/README.md @@ -1,5 +1,5 @@ -node-red-contrib-sqlite -======================= +node-red-node-sqlite +==================== A Node-Red node to read and write a local sqlite database. @@ -8,7 +8,7 @@ Install Run the following command in the root directory of your Node-RED install - npm install node-red-contrib-sqlite + npm install node-red-node-sqlite Usage diff --git a/storage/sqlite/package.json b/storage/sqlite/package.json index 8b3b78f8..3b9a30a0 100644 --- a/storage/sqlite/package.json +++ b/storage/sqlite/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-sqlite", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A sqlite node for Node-RED", "dependencies" : { "sqlite3" : "2.x" From 71a02ebbce9a9f97e7b38c33e8ed3384e4ddd397 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 26 Sep 2014 21:30:44 +0100 Subject: [PATCH 092/134] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f02dced5..2f7d09cc 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Uses a simple read of the serial port as a file to input data. You **must** set **node-red-node-sqlite** - *[sqlite](storage/sqlite)* - Supports read and write to a local sqlite database. -**N/A** - *[69-ddbout](storage/ddb)* - Support output to Amazon DynamoDB. +**node-red-node-ddb** - *[69-ddbout](storage/ddb)* - Support output to Amazon DynamoDB. (contributed by @wnagele) **N/A** - *[110-postgres](storage/postgres)* - PostgreSql I/O node. From 0d2b89903ddfc0d935011d4bb69abf9f008f7958 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 1 Oct 2014 09:00:26 +0100 Subject: [PATCH 093/134] Remove Dave's npm-debug.log file. --- function/smooth/npm-debug.log | 69 ----------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 function/smooth/npm-debug.log diff --git a/function/smooth/npm-debug.log b/function/smooth/npm-debug.log deleted file mode 100644 index d541255d..00000000 --- a/function/smooth/npm-debug.log +++ /dev/null @@ -1,69 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ] -2 info using npm@1.4.28 -3 info using node@v0.10.32 -4 verbose publish [ '.' ] -5 verbose cache add [ '.', null ] -6 verbose cache add name=undefined spec="." args=[".",null] -7 verbose parsed url { protocol: null, -7 verbose parsed url slashes: null, -7 verbose parsed url auth: null, -7 verbose parsed url host: null, -7 verbose parsed url port: null, -7 verbose parsed url hostname: null, -7 verbose parsed url hash: null, -7 verbose parsed url search: null, -7 verbose parsed url query: null, -7 verbose parsed url pathname: '.', -7 verbose parsed url path: '.', -7 verbose parsed url href: '.' } -8 silly lockFile 3a52ce78- . -9 verbose lock . /home/conway/.npm/3a52ce78-.lock -10 verbose tar pack [ '/home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz', -10 verbose tar pack '.' ] -11 verbose tarball /home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz -12 verbose folder . -13 info prepublish node-red-node-smooth@0.0.1 -14 silly lockFile 1f1177db-tar tar://. -15 verbose lock tar://. /home/conway/.npm/1f1177db-tar.lock -16 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz -17 verbose lock tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz /home/conway/.npm/4b60630a-ed-node-smooth-0-0-1-package-tgz.lock -18 silly lockFile 1f1177db-tar tar://. -19 silly lockFile 1f1177db-tar tar://. -20 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz -21 silly lockFile 4b60630a-ed-node-smooth-0-0-1-package-tgz tar:///home/conway/.npm/node-red-node-smooth/0.0.1/package.tgz -22 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package -23 verbose lock /home/conway/.npm/node-red-node-smooth/0.0.1/package /home/conway/.npm/e098ce82-de-red-node-smooth-0-0-1-package.lock -24 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package -25 silly lockFile e098ce82-de-red-node-smooth-0-0-1-package /home/conway/.npm/node-red-node-smooth/0.0.1/package -26 silly lockFile 3a52ce78- . -27 silly lockFile 3a52ce78- . -28 silly publish { name: 'node-red-node-smooth', -28 silly publish version: '0.0.1', -28 silly publish description: 'A Node-RED node that provides several simple smoothing algorithms for incoming data values.', -28 silly publish dependencies: {}, -28 silly publish repository: -28 silly publish { type: 'git', -28 silly publish url: 'https://github.com/node-red/node-red-nodes/tree/master/analysis/smooth' }, -28 silly publish license: 'Apache', -28 silly publish keywords: [ 'node-red', 'smooth', 'average' ], -28 silly publish 'node-red': { nodes: { smooth: '17-smooth.js' } }, -28 silly publish author: -28 silly publish { name: 'Dave Conway-Jones', -28 silly publish email: 'ceejay@vnet.ibm.com', -28 silly publish url: 'http://nodered.org' }, -28 silly publish readme: 'node-red-node-smooth\n====================\n\nA Node-RED node that provides several simple smoothing algorithms for incoming data values.\n\nInstall\n-------\n\nRun the following command in the root directory of your Node-RED install\n\n npm install node-red-node-smooth\n\n\nUsage\n-----\n\nA simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters.\n\nMax, Min and Mean work over a specified number of previous values.\n\nThe High and Low pass filters use a smoothing factor. The higher the number the more the smoothing. E.g. a value of 10 is similar to an α of 0.1. It is analogous to an RC time constant - but there is no time component to this as the code is based on events arriving.\n\n\n**Note:** This only operates on **numbers**. Anything else will try to be made into a number and rejected if that fails.\n', -28 silly publish readmeFilename: 'README.md', -28 silly publish _id: 'node-red-node-smooth@0.0.1', -28 silly publish scripts: {}, -28 silly publish _shasum: '61d81cdc39b16d5c24c7875fa33fba229d65ec77', -28 silly publish _from: '.' } -29 error need auth auth and email required for publishing -29 error need auth You need to authorize this machine using `npm adduser` -30 error System Linux 3.2.0-68-generic-pae -31 error command "/usr/local/bin/node" "/usr/local/bin/npm" "publish" -32 error cwd /home/conway/node-red/nodes/node-red-nodes/function/smooth -33 error node -v v0.10.32 -34 error npm -v 1.4.28 -35 error code ENEEDAUTH -36 verbose exit [ 1, true ] From 0825ba1dbb43a3d7e90cd972df6ee4c1a3e26695 Mon Sep 17 00:00:00 2001 From: Mark Hindess Date: Wed, 1 Oct 2014 09:04:59 +0100 Subject: [PATCH 094/134] Add ignore file to avoid the problem in future. --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c8f50f7c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +npm-debug.log From 2193eaab24c49b18c67c63814877667b61e5cc4c Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Thu, 2 Oct 2014 19:35:07 +0100 Subject: [PATCH 095/134] Update Smooth node to our more normal html layout.... --- function/smooth/17-smooth.html | 8 +++++--- function/smooth/package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/function/smooth/17-smooth.html b/function/smooth/17-smooth.html index 7e6c7dc7..66b2af90 100644 --- a/function/smooth/17-smooth.html +++ b/function/smooth/17-smooth.html @@ -16,7 +16,8 @@ + + + + diff --git a/parsers/base64/70-base64.js b/parsers/base64/70-base64.js new file mode 100644 index 00000000..d28da040 --- /dev/null +++ b/parsers/base64/70-base64.js @@ -0,0 +1,48 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + + function Base64Node(n) { + RED.nodes.createNode(this,n); + var node = this; + this.on("input", function(msg) { + if (Buffer.isBuffer(msg.payload)) { + // Take binary buffer and make into a base64 string + msg.payload = msg.payload.toString('base64'); + node.send(msg); + } + else if (typeof msg.payload === "string") { + // Take base64 string and make into binary buffer + var regexp = new RegExp('^[A-Za-z0-9+\/=]*$'); + if ( regexp.test(msg.payload) && (msg.payload.length % 4 === 0) ) { + msg.payload = new Buffer(msg.payload,'base64'); + node.send(msg); + } + else { + node.log("Not a Base64 string - maybe we should encode it..."); + msg.payload = (new Buffer(msg.payload,"binary")).toString('base64'); + node.send(msg); + } + } + else { + node.warn("This node only handles strings or buffers."); + } + }); + } + RED.nodes.registerType("base64",Base64Node); +} diff --git a/parsers/base64/LICENSE b/parsers/base64/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/parsers/base64/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/parsers/base64/README.md b/parsers/base64/README.md new file mode 100644 index 00000000..f13fa837 --- /dev/null +++ b/parsers/base64/README.md @@ -0,0 +1,27 @@ +node-red-node-base64 +==================== + +A Node-RED node to endcode and decode base64 format messages. + + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-base64 + +Usage +----- + +A function that converts the **msg.payload** to and from base64 format. + +If the input is a binary buffer it converts it to a Base64 encoded string. + +If the input is a Base64 string it converts it back to a binary buffer. + +Sample Flow +----------- + + diff --git a/parsers/base64/package.json b/parsers/base64/package.json new file mode 100644 index 00000000..ad7dbcdb --- /dev/null +++ b/parsers/base64/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-base64", + "version" : "0.0.1", + "description" : "A Node-RED node to pack and unpack objects to base64 format", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes.git", + "path": "/tree/master/parsers/base64" + }, + "license": "Apache-2.0", + "keywords": [ "node-red", "base64" ], + "node-red" : { + "nodes" : { + "base64": "70-base64.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From a59a7b3d3c28865a858ea15068447af41584ff22 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones[{"id":"d2ccae00.2d335","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":136,"y":99,"z":"385bdf8b.c7a42","wires":[["e03cae10.1fc35"]]},{"id":"b778ef09.48871","type":"base64","name":"","x":411.5,"y":160,"z":"385bdf8b.c7a42","wires":[["6295d1b1.9d6a3","46b597ba.b94a68"]]},{"id":"6295d1b1.9d6a3","type":"debug","name":"","active":true,"console":"false","complete":"false","x":610,"y":160,"z":"385bdf8b.c7a42","wires":[]},{"id":"ead9e7c9.152618","type":"debug","name":"","active":true,"console":"false","complete":"false","x":610,"y":240,"z":"385bdf8b.c7a42","wires":[]},{"id":"46b597ba.b94a68","type":"base64","name":"","x":411.5,"y":240,"z":"385bdf8b.c7a42","wires":[["ead9e7c9.152618"]]},{"id":"1c9124e9.e36edb","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1775,"y":113,"z":"385bdf8b.c7a42","wires":[[]]},{"id":"48a892ea.b7576c","type":"debug","name":"","active":true,"console":"false","complete":"false","x":2171,"y":210,"z":"385bdf8b.c7a42","wires":[]},{"id":"e03cae10.1fc35","type":"function","name":"","func":"msg.payload = new Buffer(\"12345\");\nreturn msg;","outputs":1,"x":250,"y":160,"z":"385bdf8b.c7a42","wires":[["b778ef09.48871"]]}] +
Date: Mon, 13 Oct 2014 23:30:10 +0100 Subject: [PATCH 098/134] Update node-red-node-ddb to point to @wnagele 's version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f7d09cc..d5d1568a 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Uses a simple read of the serial port as a file to input data. You **must** set **node-red-node-sqlite** - *[sqlite](storage/sqlite)* - Supports read and write to a local sqlite database. -**node-red-node-ddb** - *[69-ddbout](storage/ddb)* - Support output to Amazon DynamoDB. (contributed by @wnagele) +**node-red-node-ddb** - *[69-ddbout](https://github.com/wnagele/node-red-node-ddb)* - Support output to Amazon DynamoDB. This version deprecated - now moved to it's own npm. **N/A** - *[110-postgres](storage/postgres)* - PostgreSql I/O node. From c1032f9165949c9eeeb1a7e43e0bb69742d0645a Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 14 Oct 2014 17:49:59 +0100 Subject: [PATCH 099/134] Add Warning to deprecated DDB node Move to @wnagele 's version on npm. --- storage/ddb/69-ddbout.js | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/ddb/69-ddbout.js b/storage/ddb/69-ddbout.js index 09d00124..1d803bb9 100644 --- a/storage/ddb/69-ddbout.js +++ b/storage/ddb/69-ddbout.js @@ -21,6 +21,7 @@ var attrWrapper = require("dynamodb-data-types").AttributeValue; function DDBOutNode(n) { RED.nodes.createNode(this, n); + this.warn("This node has been deprecated and will be deleted in a future release. Please update your flow to use the version from npm. Note: you cannot have both this and the npm version installed at the same time."); this.credentials = RED.nodes.getNode(n.credentials); this.region = n.region || "us-east-1"; this.table = n.table; From 95a01356f5fa3f674f9bb5ae44508c35232fed75 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 14 Oct 2014 17:59:37 +0100 Subject: [PATCH 100/134] Tweak Readme re DDB node point out that you shouldn't have two versions installed. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d5d1568a..1823e4d4 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Uses a simple read of the serial port as a file to input data. You **must** set **node-red-node-sqlite** - *[sqlite](storage/sqlite)* - Supports read and write to a local sqlite database. -**node-red-node-ddb** - *[69-ddbout](https://github.com/wnagele/node-red-node-ddb)* - Support output to Amazon DynamoDB. This version deprecated - now moved to it's own npm. +**node-red-node-ddb** - *[69-ddbout](https://github.com/wnagele/node-red-node-ddb)* - Support output to Amazon DynamoDB. This version deprecated - now moved to it's own npm. **Note:** you cannot have both version installed - if you do install from npm then please manually delete the version from your node-red-nodes/storage/ddb directory. **N/A** - *[110-postgres](storage/postgres)* - PostgreSql I/O node. From 9f900788f82232d10a963bc74786762ad9e043b4 Mon Sep 17 00:00:00 2001 From: Anna Thomas Date: Mon, 20 Oct 2014 10:51:11 +0100 Subject: [PATCH 101/134] Added mqlight nodes with share property --- io/mqlight/mqlight.html | 154 ++++++++++++++++++++++++++++++++++++++++ io/mqlight/mqlight.js | 140 ++++++++++++++++++++++++++++++++++++ 2 files changed, 294 insertions(+) create mode 100644 io/mqlight/mqlight.html create mode 100644 io/mqlight/mqlight.js diff --git a/io/mqlight/mqlight.html b/io/mqlight/mqlight.html new file mode 100644 index 00000000..16ff0d0f --- /dev/null +++ b/io/mqlight/mqlight.html @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + diff --git a/io/mqlight/mqlight.js b/io/mqlight/mqlight.js new file mode 100644 index 00000000..4049a1ed --- /dev/null +++ b/io/mqlight/mqlight.js @@ -0,0 +1,140 @@ +/** + * Copyright 2013,2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var mqlight = require('mqlight'); + var util = require("util"); + + function MQLightServiceNode(n) { + RED.nodes.createNode(this,n); + + var id = "mqlight_" + (n.clientid ? n.clientid : (1+Math.random()*4294967295).toString(16)); + + var opts = { + service: n.service, + id: id + }; + + if (this.credentials) { + opts.user = this.credentials.user; + opts.password = this.credentials.password; + } + + this.client = mqlight.createClient(opts, function(err) { + if (err) { + util.log('[mqlight] ['+id+'] not connected to service '+n.service); + } else { + util.log('[mqlight] ['+id+'] connected to service '+n.service); + } + }); + } + RED.nodes.registerType("mqlight service",MQLightServiceNode,{ + credentials: { + user: {type:"text"}, + password: {type: "password"} + } + }); + + function MQLightIn(n) { + RED.nodes.createNode(this, n); + this.topic = n.topic || ""; + this.share = n.share || null; + this.service = n.service; + this.serviceConfig = RED.nodes.getNode(this.service); + var node = this; + + if (node.serviceConfig) { + if (node.serviceConfig.client) { + var recvClient = node.serviceConfig.client; + recvClient.on("started", function() { + recvClient.on("message", function(data, delivery) { + var msg = { + topic: delivery.message.topic, + payload: data, + _session: { + type: "mqlight", + id: recvClient.id + } + }; + if (delivery.destination.share) { + msg.share = delivery.destination.share; + } + node.send(msg); + }); + var subscribeCallback = function(err) { + if (err) { + node.error("Failed to subscribe: " + err); + } else { + node.log("Subscribed to "+node.topic+(node.share?" ["+node.share+"]":"")); + } + }; + + if (node.share) { + recvClient.subscribe(node.topic, node.share, subscribeCallback); + } else { + recvClient.subscribe(node.topic, subscribeCallback); + } + }); + recvClient.start(); + + node.on("close", function (done) { + recvClient.stop(done); + }); + } + + } + } + RED.nodes.registerType("mqlight in", MQLightIn); + + function MQLightOut(n) { + RED.nodes.createNode(this, n); + this.topic = n.topic || ""; + this.service = n.service; + this.serviceConfig = RED.nodes.getNode(this.service); + var node = this; + + if (node.serviceConfig) { + if (node.serviceConfig.client) { + var sendClient = node.serviceConfig.client; + + sendClient.on("started", function () { + node.on("input", function(msg) { + if (node.topic === "") { + if (msg.topic) { + node.topic = msg.topic; + } else { + node.warn("No topic set in MQ Light out node"); + return; + } + } + sendClient.send(node.topic, msg.payload, function(err) { + if (err) { + node.error(err); + } + }); + }); + }); + sendClient.start(); + + node.on("close", function (done) { + sendClient.stop(done); + }); + } + } + } + RED.nodes.registerType("mqlight out", MQLightOut); +}; From ecbde5d3d597a93462d360762e848e9580e08955 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 27 Oct 2014 20:26:49 +0000 Subject: [PATCH 102/134] Add Random number generator node. --- function/random/LICENSE | 177 +++++++++++++++++++++++++++++++++++ function/random/README.md | 23 +++++ function/random/package.json | 23 +++++ function/random/random.html | 66 +++++++++++++ function/random/random.js | 35 +++++++ 5 files changed, 324 insertions(+) create mode 100644 function/random/LICENSE create mode 100644 function/random/README.md create mode 100644 function/random/package.json create mode 100644 function/random/random.html create mode 100644 function/random/random.js diff --git a/function/random/LICENSE b/function/random/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/function/random/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/function/random/README.md b/function/random/README.md new file mode 100644 index 00000000..2e358d46 --- /dev/null +++ b/function/random/README.md @@ -0,0 +1,23 @@ +node-red-node-random +==================== + +A Node-RED node that when triggered generates a random number between two values. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-random + + +Usage +----- + +A simple node to generate a random number when triggered. + +If integer mode is selected (default) it will return an integer **between and including** the two values given - so selecting 1 to 6 will return values 1,2,3,4,5 or 6. + +If floating point mode is selected then it will return a number **between** the two values given - so selecting 1 to 6 will return values 1 < x < 6 . + +**Note:** This generates **numbers**. diff --git a/function/random/package.json b/function/random/package.json new file mode 100644 index 00000000..eb5b32a0 --- /dev/null +++ b/function/random/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-random", + "version" : "0.0.1", + "description" : "A Node-RED node that that when triggered generates a random number between two values.", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/function/random" + }, + "license": "Apache", + "keywords": [ "node-red", "random" ], + "node-red" : { + "nodes" : { + "random": "random.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} diff --git a/function/random/random.html b/function/random/random.html new file mode 100644 index 00000000..c8200735 --- /dev/null +++ b/function/random/random.html @@ -0,0 +1,66 @@ + + + + + + + diff --git a/function/random/random.js b/function/random/random.js new file mode 100644 index 00000000..ed732058 --- /dev/null +++ b/function/random/random.js @@ -0,0 +1,35 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + function RandomNode(n) { + RED.nodes.createNode(this,n); + this.low = Number(n.low); + this.high = Number(n.high); + this.inte = n.inte; + var node = this; + this.on("input", function(msg) { + if (node.inte === "true") { + msg.payload = Math.round(Number(Math.random()) * (node.high - node.low + 1) + node.low - 0.5); + } else { + msg.payload = Number(Math.random()) * (node.high - node.low) + node.low; + } + node.send(msg); + }); + } + RED.nodes.registerType("random",RandomNode); +} From 48b0c3a68b0c864d74216a814df95b784f2b0c46 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 27 Oct 2014 20:28:05 +0000 Subject: [PATCH 103/134] Update Pi nodes to allow initial read / level set. More consitent use of icons Move to Raspberry Pi category --- hardware/LEDborg/78-ledborg.html | 6 +-- hardware/LEDborg/package.json | 2 +- hardware/PiFace/37-rpi-piface.html | 49 +++++++++++++++++---- hardware/PiFace/37-rpi-piface.js | 9 +++- hardware/PiFace/package.json | 2 +- hardware/PiLiter/39-rpi-piliter.html | 21 ++++----- hardware/PiLiter/39-rpi-piliter.js | 6 +-- hardware/PiLiter/package.json | 2 +- hardware/Pibrella/38-rpi-pibrella.html | 59 ++++++++++++++++++++++---- hardware/Pibrella/38-rpi-pibrella.js | 37 +++++++++------- hardware/Pibrella/package.json | 2 +- 11 files changed, 141 insertions(+), 54 deletions(-) diff --git a/hardware/LEDborg/78-ledborg.html b/hardware/LEDborg/78-ledborg.html index 338e77d5..d7f809b8 100644 --- a/hardware/LEDborg/78-ledborg.html +++ b/hardware/LEDborg/78-ledborg.html @@ -19,13 +19,13 @@ - Expects a msg.payload with PiBorg three digit rgb colour string. 000 -> 222+See info panel for the various input options.diff --git a/hardware/PiFace/37-rpi-piface.js b/hardware/PiFace/37-rpi-piface.js index 6083f259..b206f1cc 100644 --- a/hardware/PiFace/37-rpi-piface.js +++ b/hardware/PiFace/37-rpi-piface.js @@ -1,5 +1,5 @@ /** - * Copyright 2013 IBM Corp. + * Copyright 2013,2014 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,6 +63,8 @@ module.exports = function(RED) { this.npin = n.pin; this.pin = pintable[n.pin]; this.intype = n.intype; + this.read = n.read || false; + if (this.read) { this.buttonState = -2; } var node = this; if (node.pin) { exec("gpio -p mode "+node.pin+" "+node.intype, function(err,stdout,stderr) { @@ -99,6 +101,11 @@ module.exports = function(RED) { this.pin = pintable[n.pin]; var node = this; if (node.pin) { + if (node.set) { + exec("gpio -p write "+node.pin+" "+node.level, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } node.on("input", function(msg) { if (msg.payload === "true") { msg.payload = true; } if (msg.payload === "false") { msg.payload = false; } diff --git a/hardware/PiFace/package.json b/hardware/PiFace/package.json index b98f08ba..784de5c1 100644 --- a/hardware/PiFace/package.json +++ b/hardware/PiFace/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-piface", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "Node-RED nodes to read from and write to a PiFace Digital Raspberry Pi add-on board", "dependencies" : { }, diff --git a/hardware/PiLiter/39-rpi-piliter.html b/hardware/PiLiter/39-rpi-piliter.html index 0fbc3385..c335c379 100644 --- a/hardware/PiLiter/39-rpi-piliter.html +++ b/hardware/PiLiter/39-rpi-piliter.html @@ -16,8 +16,9 @@ diff --git a/hardware/Pibrella/38-rpi-pibrella.js b/hardware/Pibrella/38-rpi-pibrella.js index eaa8c96e..1ee55643 100644 --- a/hardware/Pibrella/38-rpi-pibrella.js +++ b/hardware/Pibrella/38-rpi-pibrella.js @@ -66,6 +66,8 @@ module.exports = function(RED) { RED.nodes.createNode(this,n); this.buttonState = -1; this.pin = pintable[n.pin]; + this.read = n.read || false; + if (this.read) { this.buttonState = -2; } var node = this; if (node.pin) { @@ -102,6 +104,8 @@ module.exports = function(RED) { function PibrellaOut(n) { RED.nodes.createNode(this,n); this.pin = pintable[n.pin]; + this.set = n.set || false; + this.level = n.level || 0; var node = this; if (node.pin == "1") { @@ -123,23 +127,26 @@ module.exports = function(RED) { }); } else if (node.pin) { - process.nextTick(function() { - exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) { - if (err) { node.error(err); } - else { - node.on("input", function(msg) { - if (msg.payload === "true") { msg.payload = true; } - if (msg.payload === "false") { msg.payload = false; } - var out = Number(msg.payload); - if ((out === 0)|(out === 1)) { - exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) { - if (err) { node.error(err); } - }); - } - else { node.warn("Invalid input - not 0 or 1"); } + exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + if (node.set) { + exec("gpio write "+node.pin+" "+node.level, function(err,stdout,stderr) { + if (err) { node.error(err); } }); } - }); + node.on("input", function(msg) { + if (msg.payload === "true") { msg.payload = true; } + if (msg.payload === "false") { msg.payload = false; } + var out = Number(msg.payload); + if ((out === 0)|(out === 1)) { + exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } + else { node.warn("Invalid input - not 0 or 1"); } + }); + } }); } else { diff --git a/hardware/Pibrella/package.json b/hardware/Pibrella/package.json index 69dc32e2..348b5a6b 100644 --- a/hardware/Pibrella/package.json +++ b/hardware/Pibrella/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pibrella", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board", "dependencies" : { }, From 067ece146b3301cf3a5545e111819fc01f7fc2bd Mon Sep 17 00:00:00 2001 From: Dave C-JDate: Thu, 30 Oct 2014 12:57:24 +0000 Subject: [PATCH 104/134] Add comment to Pibrella info about buzzer not sharing PWM (kills 3.5mm audio output). It's a Won'tfix to close #75 --- hardware/Pibrella/38-rpi-pibrella.html | 1 + hardware/Pibrella/README.md | 1 + hardware/Pibrella/package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hardware/Pibrella/38-rpi-pibrella.html b/hardware/Pibrella/38-rpi-pibrella.html index a5e52cdb..c5ea4adf 100644 --- a/hardware/Pibrella/38-rpi-pibrella.html +++ b/hardware/Pibrella/38-rpi-pibrella.html @@ -106,6 +106,7 @@ Raspberry Pi Pibrella output node. The Pibrella board must be fitted.
Will set the selected output high (on) or low (off) depending on the value passed in. Expects a msg.payload with either a 0 or 1 (or true or false).
The Buzzer is a divider so low numbers are high notes. 0 is off, and the sensible lowest note is around 250-300. 2 is the highest note. 1 is just a buzz (so you can use 0/1 type inputs).
+Note: Using the buzzer is known to "kill" audio output via the 3.5mm socket.
Requires the WiringPi gpio command in order to work.
diff --git a/hardware/Pibrella/README.md b/hardware/Pibrella/README.md index b0b303a4..2004ef96 100644 --- a/hardware/Pibrella/README.md +++ b/hardware/Pibrella/README.md @@ -27,6 +27,7 @@ The output node will set the selected output high (on) or low (off) depending on The Buzzer is a divider so low numbers are high notes. 0 is off, and the sensible lowest note is around 250-300. 2 is the highest note. 1 is just a buzz - so you can use 0/1 type inputs. +**Note:** Using the buzzer is known to "kill" audio output via the 3.5mm socket. ###Input diff --git a/hardware/Pibrella/package.json b/hardware/Pibrella/package.json index 348b5a6b..0345e00f 100644 --- a/hardware/Pibrella/package.json +++ b/hardware/Pibrella/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pibrella", - "version" : "0.0.3", + "version" : "0.0.4", "description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board", "dependencies" : { }, From f7c7c52578ef41c0a708a2c64f6f431bc1636933 Mon Sep 17 00:00:00 2001 From: Dave C-JDate: Fri, 7 Nov 2014 08:25:53 +0000 Subject: [PATCH 105/134] Hide PiLiter node from non-Pi users --- hardware/PiLiter/39-rpi-piliter.js | 6 +++--- hardware/PiLiter/package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hardware/PiLiter/39-rpi-piliter.js b/hardware/PiLiter/39-rpi-piliter.js index ba3673c5..22e94f5c 100644 --- a/hardware/PiLiter/39-rpi-piliter.js +++ b/hardware/PiLiter/39-rpi-piliter.js @@ -19,9 +19,9 @@ module.exports = function(RED) { var exec = require('child_process').exec; var fs = require('fs'); - //if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - //throw "Info : Ignoring Raspberry Pi specific node."; - //} + if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi + throw "Info : Ignoring Raspberry Pi specific node."; + } if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed throw "Info : Can't find Raspberry Pi wiringPi gpio command."; diff --git a/hardware/PiLiter/package.json b/hardware/PiLiter/package.json index 5c9eef86..d30df82d 100644 --- a/hardware/PiLiter/package.json +++ b/hardware/PiLiter/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-piliter", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node to drive a Raspberry Pi Pi-LITEr 8 LED board.", "dependencies" : { }, From ebbd9f44944c764dbf55a3efa071e9f19a5a9308 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 7 Nov 2014 08:27:24 +0000 Subject: [PATCH 106/134] Change regex for Ping node to work across languages... (hopefully) Addresses Issue #80 --- io/ping/88-ping.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/io/ping/88-ping.js b/io/ping/88-ping.js index 2d25d7a3..e178e3c8 100644 --- a/io/ping/88-ping.js +++ b/io/ping/88-ping.js @@ -34,9 +34,13 @@ module.exports = function(RED) { var res = false; ex.stdout.on('data', function (data) { //console.log('[ping] stdout: ' + data.toString()); - var regex = /from.*time.(.*)ms/; + var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9]*)/; + //var regex = /from.*time.(.*)ms/; var m = regex.exec(data.toString())||""; - if (m !== '') { res = Number(m[1]); } + if (m !== '') { + if (m[1]) { res = Number(m[1]); } + if (m[2]) { res = Number(m[2]); } + } }); ex.stderr.on('data', function (data) { //console.log('[ping] stderr: ' + data); From d47b7f57a2fda72949dcbdabafdd85b224516c3e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 7 Nov 2014 11:44:04 +0000 Subject: [PATCH 107/134] re-re-fix Ping node to assemble full result before parsing.... --- io/ping/88-ping.js | 18 +++++++++--------- io/ping/package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/io/ping/88-ping.js b/io/ping/88-ping.js index e178e3c8..c7496cf8 100644 --- a/io/ping/88-ping.js +++ b/io/ping/88-ping.js @@ -32,21 +32,21 @@ module.exports = function(RED) { else if (plat == "darwin") { ex = spawn('ping', ['-n', '-t', '5', '-c', '1', node.host]); } else { node.error("Sorry - your platform - "+plat+" - is not recognised."); } var res = false; + var line = ""; + //var regex = /from.*time.(.*)ms/; + var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9\.]*)/; ex.stdout.on('data', function (data) { - //console.log('[ping] stdout: ' + data.toString()); - var regex = /=.*[<|=]([0-9]*).*TTL|ttl..*=([0-9]*)/; - //var regex = /from.*time.(.*)ms/; - var m = regex.exec(data.toString())||""; - if (m !== '') { - if (m[1]) { res = Number(m[1]); } - if (m[2]) { res = Number(m[2]); } - } + line += data.toString(); }); ex.stderr.on('data', function (data) { //console.log('[ping] stderr: ' + data); }); ex.on('close', function (code) { - //console.log('[ping] result: ' + code); + var m = regex.exec(line)||""; + if (m !== '') { + if (m[1]) { res = Number(m[1]); } + if (m[2]) { res = Number(m[2]); } + } var msg = { payload:false, topic:node.host }; if (code === 0) { msg = { payload:res, topic:node.host }; } node.send(msg); diff --git a/io/ping/package.json b/io/ping/package.json index 67bb0884..ca5b23a0 100644 --- a/io/ping/package.json +++ b/io/ping/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-ping", - "version" : "0.0.1", + "version" : "0.0.3", "description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.", "dependencies" : { }, From ce62e23cf23d28d19b09794172beaf045d636b4d Mon Sep 17 00:00:00 2001 From: zobalogh Date: Tue, 4 Nov 2014 15:07:32 +0000 Subject: [PATCH 108/134] Adding Exif node. --- utility/exif/94-exif.html | 49 +++++++++++++++ utility/exif/94-exif.js | 124 ++++++++++++++++++++++++++++++++++++++ utility/exif/package.json | 23 +++++++ 3 files changed, 196 insertions(+) create mode 100644 utility/exif/94-exif.html create mode 100644 utility/exif/94-exif.js create mode 100644 utility/exif/package.json diff --git a/utility/exif/94-exif.html b/utility/exif/94-exif.html new file mode 100644 index 00000000..689c290c --- /dev/null +++ b/utility/exif/94-exif.html @@ -0,0 +1,49 @@ + + + + + + + diff --git a/utility/exif/94-exif.js b/utility/exif/94-exif.js new file mode 100644 index 00000000..eb7140c7 --- /dev/null +++ b/utility/exif/94-exif.js @@ -0,0 +1,124 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var ExifImage = require('exif').ExifImage; + + function convertDegreesMinutesSecondsToDecimals(degrees, minutes, seconds) { + var result; + result = degrees + (minutes / 60) + (seconds / 3600); + return result; + } + + /*** + * Extracts GPS location information from Exif data. If enough information is + * provided, convert the Exif data into a pair of single floating point number + * latitude/longitude data pairs. Populates msg.location with these. + * Assumes that the msg object will always have exifData available as msg.exif. + * Assume that the GPS data saved into Exif provides a valid value + */ + function addMsgLocationDataFromExifGPSData(msg) { + if(msg.exif.gps) { + var gpsData = msg.exif.gps; // declaring variable purely to make checks more readable + if(gpsData.GPSAltitude) { + if(!msg.location) { + msg.location = {}; + } + msg.location.alt = gpsData.GPSAltitude; + } + if(gpsData.GPSLatitudeRef && gpsData.GPSLatitude && gpsData.GPSLongitudeRef && gpsData.GPSLongitude) { // location can be determined, OK + // The data provided in Exif is in degrees, minutes, seconds, this is to be converted into a single floating point degree + if(gpsData.GPSLatitude.length === 3) { // OK to convert latitude + if(gpsData.GPSLongitude.length === 3) { // OK to convert longitude + var latitude = convertDegreesMinutesSecondsToDecimals(gpsData.GPSLatitude[0], gpsData.GPSLatitude[1], gpsData.GPSLatitude[2]); + latitude = Math.round(latitude * 100000)/100000; + + // (N)orth means positive latitude + // (S)outh means negative latitude + // (E)ast means positive longitude + // (W)est means negative longitude + if(gpsData.GPSLatitudeRef.toString() === 'S' || gpsData.GPSLatitudeRef.toString() === 's') { + latitude = latitude * -1; + } + + var longitude = convertDegreesMinutesSecondsToDecimals(gpsData.GPSLongitude[0], gpsData.GPSLongitude[1], gpsData.GPSLongitude[2]); + longitude = Math.round(longitude * 100000)/100000; + + if(gpsData.GPSLongitudeRef.toString() === 'W' || gpsData.GPSLongitudeRef.toString() === 'w') { + longitude = longitude * -1; + } + if(!msg.location) { + msg.location = {}; + } + msg.location.lat = latitude; + msg.location.lon = longitude; + return; + } else { + node.log("Invalid longitude data, no location information has been added to the message."); + } + } else { + node.log("Invalid latitude data, no location information has been added to the message."); + } + } else { + node.log("The location of this image cannot be determined safely so no location information has been added to the message."); + } + } else { + node.log("No location info found in this image."); + } + } + + function ExifNode(n) { + RED.nodes.createNode(this,n); + var node = this; + this.on("input", function(msg) { + try { + + if(msg.payload) { + var isBuffer = Buffer.isBuffer(msg.payload); + if(isBuffer === true) { + new ExifImage({ image : msg.payload }, function (error, exifData) { + if (error) { + node.error('Failed to extract Exif data from image.'); + node.log('Failed to extract Exif data from image. '+ error); + } else { + //msg.payload remains the same buffer + if(exifData) { + msg.exif = exifData; + addMsgLocationDataFromExifGPSData(msg); + } else { + node.warn("The incoming buffer did not contain Exif data, nothing to do. "); + } + } + node.send(msg); + }); + } else { + node.error("Invalid payload received, the Exif node cannot proceed, no messages sent."); + return; + } + } else { + node.error("No payload received, the Exif node cannot proceed, no messages sent."); + return; + } + } catch (error) { + node.error("An error occurred while extracting Exif information. Please check the log for details."); + node.log('Error: '+error.message); + return; + } + }); + } + RED.nodes.registerType("exif",ExifNode); +} diff --git a/utility/exif/package.json b/utility/exif/package.json new file mode 100644 index 00000000..ba12c7d0 --- /dev/null +++ b/utility/exif/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-exif", + "version" : "0.0.1", + "description" : "A Node-RED node that extracts Exif information from JPEG image buffers.", + "dependencies" : { + "exif": "0.4.0" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/utility/exif" + }, + "license": "Apache-v2.0", + "keywords": [ "node-red", "exif"], + "node-red" : { + "nodes" : { + "exif": "94-exif.js" + } + }, + "contributors": [ + {"name": "Dave Conway-Jones"}, + {"name": "Zoltan Balogh"} + ] +} From 8b689ca09b909803e2df655740373c9141c4c62e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sat, 8 Nov 2014 14:11:02 +0000 Subject: [PATCH 109/134] Add License and Readme to Exif node --- utility/exif/LICENSE | 177 +++++++++++++++++++++++++++++++++++++++++ utility/exif/README.md | 23 ++++++ 2 files changed, 200 insertions(+) create mode 100644 utility/exif/LICENSE create mode 100644 utility/exif/README.md diff --git a/utility/exif/LICENSE b/utility/exif/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/utility/exif/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/utility/exif/README.md b/utility/exif/README.md new file mode 100644 index 00000000..47d14f7a --- /dev/null +++ b/utility/exif/README.md @@ -0,0 +1,23 @@ +node-red-node-exif +================== + +A Node-RED node to extract Exif information from JPEG images. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-exif + + +Usage +----- + +Extracts Exif information from JPEG images. + +This node expects an incoming JPEG image as a buffer. If Exif data is present, it extracts the data into a **msg.exif** object. + +If the Exif data also contains location information this is extracted as **msg.location**. + +**msg.payload** retains the original, unmodified image buffer. From 7474905b08d590a9092db3f6f51744fd61345334 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Sun, 9 Nov 2014 14:28:09 +0000 Subject: [PATCH 110/134] Fix msgpack node to handle more than just objects... Fix to close Issue #482 and #483 --- parsers/msgpack/70-msgpack.html | 5 ++--- parsers/msgpack/70-msgpack.js | 14 +++++--------- parsers/msgpack/package.json | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/parsers/msgpack/70-msgpack.html b/parsers/msgpack/70-msgpack.html index 0bc935c4..7a754d14 100644 --- a/parsers/msgpack/70-msgpack.html +++ b/parsers/msgpack/70-msgpack.html @@ -24,9 +24,8 @@ diff --git a/hardware/blinkstick/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js index ceaefef5..f5f6202b 100644 --- a/hardware/blinkstick/76-blinkstick.js +++ b/hardware/blinkstick/76-blinkstick.js @@ -1,5 +1,6 @@ /** - * Copyright 2013 IBM Corp. + * Copyright 2013-2014 Agile Innovative Ltd. + * Based on code written by Dave Conway-Jones, IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,45 +19,232 @@ module.exports = function(RED) { "use strict"; var blinkstick = require("blinkstick"); + var availableTasks = ["set_color", "blink", "pulse", "morph"]; + Object.size = function(obj) { var size = 0; for (var key in obj) { if (obj.hasOwnProperty(key)) { size++; } } return size; }; - function BlinkStick(n) { - RED.nodes.createNode(this,n); - var p1 = /^\#[A-Fa-f0-9]{6}$/ - var p2 = /[0-9]+,[0-9]+,[0-9]+/ - this.led = blinkstick.findFirst(); // maybe try findAll() (one day) - var node = this; + //Helper function to convert decimal number to hex with padding + function decimalToHex(d, padding) { + var hex = Number(d).toString(16); + padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding; - this.on("input", function(msg) { - if (Object.size(node.led) !== 0) { - try { - if (p2.test(msg.payload)) { - var rgb = msg.payload.split(","); - node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255); - } - else { - node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,'')); - } - } - catch (err) { - node.warn("BlinkStick missing ?"); - node.led = blinkstick.findFirst(); - } - } - else { - //node.warn("No BlinkStick found"); - node.led = blinkstick.findFirst(); - } - }); - if (Object.size(node.led) === 0) { - node.error("No BlinkStick found"); + while (hex.length < padding) { + hex = "0" + hex; } + return hex; + } + + function validateInt(value, defaultValue) { + return typeof (value) === "undefined" || value === null ? value = defaultValue : parseInt(value); + } + + function validate(value, defaultValue) { + return typeof (value) === "undefined" || value === null ? value = defaultValue : value; + } + + function validatePayloadObject (obj) { + var + task = validate(obj.task), + delay = validateInt(obj.delay), + repeats = validateInt(obj.repeats), + duration = validateInt(obj.duration), + steps = validateInt(obj.steps), + repeat = validate(obj.repeat), + color = validate(obj.color); + + if (typeof(task) !== 'undefined' && availableTasks.indexOf(task) === -1) { + return "Task is invalid"; + } + + if (typeof(color) === 'undefined') { + return "Color parameter is not set"; + } + + return { 'task': task, 'delay': delay, 'repeats': repeats, 'duration': duration, 'steps': steps, + 'repeat': repeat, 'color': color }; + } + + function BlinkStick(n) { + RED.nodes.createNode(this,n); + + this.name = n.name; + this.serial = n.serial; + this.task = n.task || "set_color"; + this.delay = n.delay || 500; + this.repeats = n.repeats || 1; + this.duration = n.duration || 1000; + this.steps = n.steps || 50; + this.repeat = n.repeat; + this.closing = false; + this.color = ''; + this.previousColor = ''; + + var p1 = /[0-9]+,[0-9]+,[0-9]+/; + var node = this; + //Keeps track for active animations + var animationComplete = true; + + //Find BlinkStick based on serial number if supplied, otherwise look for first + //Blinkstick in the USB device list + var findBlinkStick = function (callback) { + if (typeof(node.serial) == 'string' && node.serial.replace(/\s+/g,'') !== '') { + blinkstick.findBySerial(node.serial, function (device) { + node.led = device; + + if (Object.size(node.led) === 0) { + node.status({fill:"red",shape:"ring",text:"disconnected"}); + node.error("BlinkStick with serial number " + node.serial + " not found"); + } else { + node.status({fill:"green",shape:"dot",text:"connected"}); + if (callback) callback(); + } + }); + } else { + node.led = blinkstick.findFirst(); + + if (Object.size(node.led) === 0) { + node.status({fill:"red",shape:"ring",text:"disconnected"}); + node.error("No BlinkStick found"); + } else { + node.status({fill:"green",shape:"dot",text:"connected"}); + if (callback) callback(); + } + } + }; + + //Check if repeat is enabled. Works only for pulse and blink tasks + var canRepeat = function () { + return node.task == "pulse" || node.task == "blink"; + }; + + //Event handler for all animation complete events + var blinkstickAnimationComplete = function (err) { + if (typeof(err) !== 'undefined') { + node.warn(err); + + if (typeof(err.name) === 'undefined' || err.name !== 'ReferenceError') { + //USB error occurred when BlinkStick was animating + node.led.close(function (err) { + node.led = undefined; + findBlinkStick(); + }); + } + } + + animationComplete = true; + + //Apply queued color animation + if (!node.closing && node.color !== '') { + //Apply new color only if there was no error or queued color is different from the previous color + if (typeof(err) === 'undefined' || typeof(err) !== 'undefined' && node.color != node.previousColor) { + applyColor(); + } + } + }; + + var applyColor = function () { + animationComplete = false; + + //Store the value of color to check if it has changed + node.previousColor = node.color; + + try { + //Select animation to perform + if (node.task == "pulse") { + node.led.pulse(node.color, {'duration': node.duration, 'steps': node.steps }, blinkstickAnimationComplete); + } else if (node.task == "morph") { + node.led.morph(node.color, {'duration': node.duration, 'steps': node.steps }, blinkstickAnimationComplete); + } else if (node.task == "blink") { + node.led.blink(node.color,{'repeats': node.repeats, 'delay': node.delay }, blinkstickAnimationComplete); + } else { + node.led.setColor(node.color, blinkstickAnimationComplete); + } + } catch (err) { + node.warn("BlinkStick missing ? " + err); + //Reset animation + animationComplete = true; + //Clear color + node.color = ''; + //Look for a BlinkStick + findBlinkStick(); + return; + } + + //Clear color value until next one is received, unless repeat option is set to true + if (!node.repeat || !canRepeat()) { + node.color = ''; + } + }; + + findBlinkStick(); + + this.on("input", function(msg) { + if (typeof(msg.payload) === 'object' ) { + var data = validatePayloadObject(msg.payload); + + if (typeof(data) === 'object') { + node.task = data.task ? data.task : node.task; + node.delay = data.delay ? data.delay : node.delay; + node.repeats = data.repeats ? data.repeats : node.repeats; + node.duration = data.duration ? data.duration : node.duration; + node.steps = data.steps ? data.steps : node.steps; + node.repeat = data.repeat ? data.repeat : node.repeat; + node.color = data.color ? data.color : node.color; + } else { + node.error(data); + return; + } + + } else if (p1.test(msg.payload)) { + //Color value is represented as "red,green,blue" string of bytes + var rgb = msg.payload.split(","); + + //Convert color value back to HEX string for easier implementation + node.color = "#" + decimalToHex(parseInt(rgb[0])&255) + + decimalToHex(parseInt(rgb[1])&255) + decimalToHex(parseInt(rgb[2])&255); + } else { + //Sanitize color value + node.color = msg.payload.toLowerCase().replace(/\s+/g,''); + } + + if (Object.size(node.led) !== 0) { + //Start color animation, otherwise the color is queued until current animation completes + if (animationComplete) { + applyColor(); + } + } else { + //Attempt to find BlinkStick and start animation if it's found + findBlinkStick(function() { + if (animationComplete) { + applyColor(); + } + }); + } + }); + + this.on("close", function() { + //Set the flag to finish all animations + this.closing = true; + + if (Object.size(node.led) !== 0) { + //Close device and stop animations + this.led.close(); + } + }); } RED.nodes.registerType("blinkstick",BlinkStick); -} + + RED.httpAdmin.get("/blinksticklist",function(req,res) { + blinkstick.findAllSerials(function(serials) { + res.writeHead(200, {'Content-Type': 'application/json'}); + res.write(JSON.stringify(serials)); + res.end(); + }); + }); +}; diff --git a/hardware/blinkstick/README.md b/hardware/blinkstick/README.md index 4bc440d6..e47fd168 100644 --- a/hardware/blinkstick/README.md +++ b/hardware/blinkstick/README.md @@ -1,11 +1,12 @@ node-red-node-blinkstick ======================== -A Node-RED node to control a Blinkstick. + +A Node-RED node to control a BlinkStick. Install ------- -Run the following command in the root directory of your Node-RED install +Run the following command in the root directory of your Node-RED install: npm install node-red-node-blinkstick @@ -13,11 +14,19 @@ Run the following command in the root directory of your Node-RED install Usage ----- -The BlinkStick output node expects a msg.payload with either a hex string #rrggbb triple or red,green,blue as three 0-255 values. +BlinkStick output node. Expects a msg.payload with one of: +* A hex string "#rrggbb" triple +* "red,green,blue" three 0-255 values as a string +* "random" will generate a random color +* Standard HTML color name +* object can override any of the parameters -It can also accept standard HTML colour names. +An object payload can override any of the settings on the node. Omitted parameters are left intact. For example: -NOTE: currently only works with a single BlinkStick. (As it uses the findFirst() function to attach). + { 'color': 'blue' } + { 'task': 'blink', 'color': 'red' } + { 'task': 'pulse', 'color': 'gree', 'duration': 500 } + { 'task': 'morph', 'color': 'orange', 'duration': 500, 'steps': 20 } -For more info see the BlinkStick website or the blinkstick npm documentation. +For more information see BlinkStick tutorials or the node module documentation. diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json index dd957728..11f08f66 100644 --- a/hardware/blinkstick/package.json +++ b/hardware/blinkstick/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-blinkstick", - "version" : "0.0.3", + "version" : "0.1.0", "description" : "A Node-RED node to control a Blinkstick", "dependencies" : { - "blinkstick" : "0.1.*" + "blinkstick" : "1.1.*" }, "repository" : { "type":"git", @@ -17,8 +17,15 @@ } }, "author": { - "name": "Dave Conway-Jones", - "email": "ceejay@vnet.ibm.com", - "url": "http://nodered.org" - } + "name": "Arvydas Juskevicius", + "email": "arvydas@agileinnovative.co.uk", + "url": "http://www.blinkstick.com" + }, + "contributors": [ + { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } + ] } From 661a50b1233d4dcd15d8f2c8b604b50a625047cd Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 19 Nov 2014 20:36:04 +0000 Subject: [PATCH 114/134] Add try/catch to WOL node to try to grab socket error. (Upstream fix requested). --- io/wol/39-wol.js | 11 ++++++++--- io/wol/package.json | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/io/wol/39-wol.js b/io/wol/39-wol.js index be475369..b455f282 100644 --- a/io/wol/39-wol.js +++ b/io/wol/39-wol.js @@ -28,9 +28,14 @@ module.exports = function(RED) { var mac = this.mac || msg.mac || null; if (mac != null) { if (chk.test(mac)) { - wol.wake(mac, function(error) { - if (error) { node.warn(error); } - }); + try { + wol.wake(mac, function(error) { + if (error) { node.warn(error); } + else if (RED.settings.verbose) { + node.log("sent WOL magic packet"); + } + }); + } catch(e) { if (RED.settings.verbose) { node.log("WOL: socket error"); } } else { node.warn('WOL: bad mac address "'+mac+'"'); } } diff --git a/io/wol/package.json b/io/wol/package.json index f3a325d1..3dd47cd7 100644 --- a/io/wol/package.json +++ b/io/wol/package.json @@ -3,7 +3,7 @@ "version" : "0.0.2", "description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets", "dependencies" : { - "wake_on_lan" : "0.0.3" + "wake_on_lan" : "0.0.4" }, "repository" : { "type":"git", From c646596a5d6ae5b7500327bb9748e0ef006554f5 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 19 Nov 2014 20:52:10 +0000 Subject: [PATCH 115/134] WOL fix again - this time with correct number of braces... --- io/wol/39-wol.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/io/wol/39-wol.js b/io/wol/39-wol.js index b455f282..1813c0b7 100644 --- a/io/wol/39-wol.js +++ b/io/wol/39-wol.js @@ -35,7 +35,9 @@ module.exports = function(RED) { node.log("sent WOL magic packet"); } }); - } catch(e) { if (RED.settings.verbose) { node.log("WOL: socket error"); } + } catch(e) { + if (RED.settings.verbose) { node.log("WOL: socket error"); } + } } else { node.warn('WOL: bad mac address "'+mac+'"'); } } From 74a470c22e351ff67724a7961e86eba578ccc2e2 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 19 Nov 2014 21:44:29 +0000 Subject: [PATCH 116/134] Bump WOL package version number in anticipation of pub to npm --- io/wol/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/wol/package.json b/io/wol/package.json index 3dd47cd7..32ee4b19 100644 --- a/io/wol/package.json +++ b/io/wol/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-wol", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets", "dependencies" : { "wake_on_lan" : "0.0.4" From 317aaa1b64cb8e2117919c77b41a722d8cc60202 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Thu, 20 Nov 2014 08:44:05 +0000 Subject: [PATCH 117/134] Handle users of old Blinkstick npm a bit more nicely. Don't barf (quite so badly) on new API calls if they don't exist yet. --- hardware/blinkstick/76-blinkstick.html | 6 ++---- hardware/blinkstick/76-blinkstick.js | 12 ++++++++++-- hardware/blinkstick/package.json | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hardware/blinkstick/76-blinkstick.html b/hardware/blinkstick/76-blinkstick.html index de84b05d..959bfb75 100644 --- a/hardware/blinkstick/76-blinkstick.html +++ b/hardware/blinkstick/76-blinkstick.html @@ -60,9 +60,7 @@ - Expects a msg.payload with either hex "#rrggbb" or decimal "red,green,blue" string.- - +Expects a msg.payload with either hex "#rrggbb" or decimal "red,green,blue" string, or HTML color name.diff --git a/hardware/blinkstick/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js index f5f6202b..54c1485e 100644 --- a/hardware/blinkstick/76-blinkstick.js +++ b/hardware/blinkstick/76-blinkstick.js @@ -165,7 +165,14 @@ module.exports = function(RED) { node.led.setColor(node.color, blinkstickAnimationComplete); } } catch (err) { - node.warn("BlinkStick missing ? " + err); + if (err.toString().indexOf("setColor") !== -1) { + node.led.setColour(node.color, blinkstickAnimationComplete); + node.warn("Old version - please upgrade Blinkstick npm"); + } + else { + node.warn("BlinkStick missing ? " + err); + } + console.log(err); //Reset animation animationComplete = true; //Clear color @@ -233,7 +240,8 @@ module.exports = function(RED) { if (Object.size(node.led) !== 0) { //Close device and stop animations - this.led.close(); + if (typeof this.led.close === "function") { this.led.close(); } + else { node.warn("Please upgrade blinkstick npm"); } } }); } diff --git a/hardware/blinkstick/package.json b/hardware/blinkstick/package.json index 11f08f66..7bc2b1ad 100644 --- a/hardware/blinkstick/package.json +++ b/hardware/blinkstick/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-blinkstick", - "version" : "0.1.0", + "version" : "0.1.1", "description" : "A Node-RED node to control a Blinkstick", "dependencies" : { "blinkstick" : "1.1.*" From d7cee30787fe5b1a76f1c71da360358cfb90a314 Mon Sep 17 00:00:00 2001 From: Andrew LindsayDate: Wed, 26 Nov 2014 20:37:54 +0000 Subject: [PATCH 118/134] Updated to make calls --- social/twilio/56-twilio.html | 50 ++++++++++++++++++++++++++++++++---- social/twilio/56-twilio.js | 34 ++++++++++++++++++------ social/twilio/README.md | 6 +++-- 3 files changed, 75 insertions(+), 15 deletions(-) diff --git a/social/twilio/56-twilio.html b/social/twilio/56-twilio.html index b7863dfd..08ec91f8 100644 --- a/social/twilio/56-twilio.html +++ b/social/twilio/56-twilio.html @@ -1,5 +1,5 @@ + + + + + + + + + + + + + diff --git a/hardware/HummingboardGPIO/hb-gpio.js b/hardware/HummingboardGPIO/hb-gpio.js new file mode 100644 index 00000000..da8993af --- /dev/null +++ b/hardware/HummingboardGPIO/hb-gpio.js @@ -0,0 +1,188 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var exec = require('child_process').exec; + var fs = require('fs'); + + var gpioCommand = '/usr/local/bin/gpiohb'; + + //if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi + //throw "Info : Ignoring Raspberry Pi specific node."; + //} + + if (!fs.existsSync(gpioCommand)) { // gpio command not installed + throw "Info : Can't find "+gpioCommand+" command."; + } + + // Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) + var pintable = { + // Physical : WiringPi + "11":"0", + "12":"1", + "13":"2", + "15":"3", + "16":"4", + "18":"5", + "22":"6", + "7":"7", + "3":"8", + "5":"9", + "24":"10", + "26":"11", + "19":"12", + "21":"13", + "23":"14", + "8":"15", + "10":"16", + "27":"30", + "28":"31", + "29":"21", + "31":"22", + "32":"26", + "33":"23", + "35":"24", + "36":"27", + "37":"25", + "38":"28", + "40":"29" + } + var tablepin = { + // WiringPi : Physical + "0":"11", + "1":"12", + "2":"13", + "3":"15", + "4":"16", + "5":"18", + "6":"22", + "7":"7", + "8":"3", + "9":"5", + "10":"24", + "11":"26", + "12":"19", + "13":"21", + "14":"23", + "15":"8", + "16":"10", + "30":"27", + "31":"28", + "21":"29", + "22":"31", + "26":"32", + "23":"33", + "24":"35", + "27":"36", + "25":"37", + "28":"38", + "29":"40" + } + + function GPIOHBInNode(n) { + RED.nodes.createNode(this,n); + this.buttonState = -1; + this.pin = pintable[n.pin]; + this.intype = n.intype; + this.read = n.read || false; + if (this.read) { this.buttonState = -2; } + var node = this; + + var readit = function() { + exec(gpioCommand+" read "+node.pin, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + exec(gpioCommand+" wfi "+node.pin + " both", function(err,stdo,stde) { + if (err) { node.error(err); } + else { readit(); } + }); + if (node.buttonState !== Number(stdout)) { + var previousState = node.buttonState; + node.buttonState = Number(stdout); + if (previousState !== -1) { + var msg = {topic:"pi/"+tablepin[node.pin], payload:(node.buttonState === 0 ? 0 : 1)}; + node.send(msg); + } + } + } + }); + } + + if (node.pin !== undefined) { + exec(gpioCommand+" mode "+node.pin+" "+node.intype, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + readit(); + } + }); + } + else { + node.error("Invalid GPIO pin: "+node.pin); + } + + node.on("close", function() { + clearInterval(node._interval); + exec(gpioCommand+" close "+node.pin); + }); + } + + function GPIOHBOutNode(n) { + RED.nodes.createNode(this,n); + this.pin = pintable[n.pin]; + this.set = n.set || false; + this.level = n.level || 0; + this.out = n.out || "out"; + var node = this; + (node.out === "pwm") ? (node.op = "pwm") : (node.op = "write"); + + if (node.pin !== undefined) { + exec(gpioCommand+" mode "+node.pin+" "+node.out, function(err,stdout,stderr) { + if (err) { node.error(err); } + else { + if (node.set && (node.out === "out")) { + exec(gpioCommand+" write "+node.pin+" "+node.level, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } + node.on("input", function(msg) { + if (msg.payload === "true") { msg.payload = true; } + if (msg.payload === "false") { msg.payload = false; } + var out = Number(msg.payload); + var limit = 1; + if (node.out === "pwm") { limit = 1023; } + if ((out >= 0) && (out <= limit)) { + exec(gpioCommand+" "+node.op+" "+node.pin+" "+out, function(err,stdout,stderr) { + if (err) { node.error(err); } + }); + } + else { node.warn("Invalid input: "+out); } + }); + } + }); + } + else { + node.error("Invalid GPIO pin: "+node.pin); + } + + node.on("close", function() { + exec(gpioCommand+" close "+node.pin); + }); + } + + RED.nodes.registerType("hb-gpio in",GPIOHBInNode); + RED.nodes.registerType("hb-gpio out",GPIOHBOutNode); +} diff --git a/hardware/HummingboardGPIO/package.json b/hardware/HummingboardGPIO/package.json new file mode 100644 index 00000000..af3e9b2e --- /dev/null +++ b/hardware/HummingboardGPIO/package.json @@ -0,0 +1,26 @@ +{ + "name" : "node-red-node-hbgpio", + "version" : "0.0.1", + "description" : "A Node-RED node for the GPIO of the Hummingboard", + "dependencies": { + }, + "repository" : { + "type":"tgz", + "url":"http://dcj.dtdns.net/npms/hbgpio.tgz" + }, + "license": "Apache-2.0", + "keywords": [ "node-red", "hummingboard", "gpio" ], + "node-red" : { + "nodes": { + "hb-gpio": "hb-gpio.js" + } + }, + "scripts": { + "postinstall": "./fixup.sh" + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 785f2dde1699e0777d65b64029d2e9a3b47cfc15 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 10 Dec 2014 09:30:20 +0000 Subject: [PATCH 122/134] Add initial GeoHash node --- parsers/geohash/70-geohash.html | 52 ++++++++++ parsers/geohash/70-geohash.js | 93 +++++++++++++++++ parsers/geohash/LICENSE | 177 ++++++++++++++++++++++++++++++++ parsers/geohash/README.md | 35 +++++++ parsers/geohash/package.json | 24 +++++ 5 files changed, 381 insertions(+) create mode 100644 parsers/geohash/70-geohash.html create mode 100644 parsers/geohash/70-geohash.js create mode 100644 parsers/geohash/LICENSE create mode 100644 parsers/geohash/README.md create mode 100644 parsers/geohash/package.json diff --git a/parsers/geohash/70-geohash.html b/parsers/geohash/70-geohash.html new file mode 100644 index 00000000..1a43fcea --- /dev/null +++ b/parsers/geohash/70-geohash.html @@ -0,0 +1,52 @@ + + + + + + + diff --git a/parsers/geohash/70-geohash.js b/parsers/geohash/70-geohash.js new file mode 100644 index 00000000..24fd95da --- /dev/null +++ b/parsers/geohash/70-geohash.js @@ -0,0 +1,93 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var geohash = require('ngeohash'); + + function GeohashNode(n) { + RED.nodes.createNode(this,n); + var node = this; + + var round = function(value, decimals) { + return Number(Math.round(value+'e'+decimals)+'e-'+decimals); + } + + this.on("input", function(msg) { + if (msg.hasOwnProperty("location")) { + if (msg.location.hasOwnProperty("geohash")) { + var pos = geohash.decode(msg.location.geohash); + msg.location.lat = round(pos.latitude,5); + msg.location.lon = round(pos.longitude,5); + msg.location.error = { lat:round(pos.error.latitude,5), lon:round(pos.error.longitude,5) }; + node.send(msg); + } + else { + var lat = msg.location.lat; + var lon = msg.location.lon; + var len = parseInt(msg.location.precision || msg.location.payload || 9); + if (len < 1) { len = 1; } + if (len > 9) { len = 9; } + if (lat && lon) { + msg.location.geohash = geohash.encode(lat, lon, len); + node.send(msg); + } + } + } + else if (typeof msg.payload === "string") { + // try to decode it... + var regexp = new RegExp('^[a-z0-9]{1,9}$'); // can only contain a-z or 0-9 and length 1-9 + if (regexp.test(msg.payload)) { + var pos = geohash.decode(msg.payload); + msg.payload = { lat:round(pos.latitude,5), lon:round(pos.longitude,5) }; + msg.payload.error = { lat:round(pos.error.latitude,5), lon:round(pos.error.longitude,5) }; + node.send(msg); + } + else if (msg.payload.indexOf(",") !== -1) { + // has a comma so assume it's lat,lon(,precision) + var bits = msg.payload.split(","); + if (bits.length === 2) { + var la = Number(bits[0]); + if (la < -90) { la = -90; } + if (la > 90) { la = 90; } + var lo = Number(bits[1]); + if (lo < -180) { lo = -180; } + if (lo > 180) { la = 180; } + msg.payload = geohash.encode(la, lo); + node.send(msg); + } + else { node.warn("Unexpected string format - should be lat,lon"); } + } + else { node.warn("Unexpected string format - should either be lat,lon or geohash"); } + } + else if (typeof msg.payload === "object") { + var lat = msg.payload.lat || msg.payload.latitude; + var lon = msg.payload.lon || msg.payload.longitude; + var len = parseInt(msg.payload.precision || 9); + if (len < 1) { len = 1; } + if (len > 9) { len = 9; } + if (lat && lon) { + msg.payload.geohash = geohash.encode(lat, lon, len); + node.send(msg); + } + } + else { + node.warn("This node only expects strings or objects."); + } + }); + } + RED.nodes.registerType("geohash",GeohashNode); +} diff --git a/parsers/geohash/LICENSE b/parsers/geohash/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/parsers/geohash/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/parsers/geohash/README.md b/parsers/geohash/README.md new file mode 100644 index 00000000..76fc67f2 --- /dev/null +++ b/parsers/geohash/README.md @@ -0,0 +1,35 @@ +node-red-node-geohash +===================== + +A Node-RED node to encode and decode lat,lon pairs to a geohash diff --git a/parsers/geohash/package.json b/parsers/geohash/package.json new file mode 100644 index 00000000..071ee339 --- /dev/null +++ b/parsers/geohash/package.json @@ -0,0 +1,24 @@ +{ + "name" : "node-red-node-geohash", + "version" : "0.0.1", + "description" : "A Node-RED node to encode and decode lat,lon pairs to a geohash.", + "dependencies" : { + "ngeohash" : "0.6.0" + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/parsers/geohash" + }, + "license": "Apache-2.0", + "keywords": [ "node-red", "geohash" ], + "node-red" : { + "nodes" : { + "geohash": "70-geohash.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 5f78aa10ad74c4210c111e1953345b8e3764afd3 Mon Sep 17 00:00:00 2001 From: Dave C-J[{"id":"60ebfc45.9f1404","type":"function","name":"","func":"msg.payload = {lat:51,lon:-1,precision:5};\nreturn msg;","outputs":1,"x":281,"y":485,"z":"385bdf8b.c7a42","wires":[["6f1c5357.90e3ac"]]},{"id":"6f1c5357.90e3ac","type":"geohash","name":"","x":415.5,"y":420,"z":"385bdf8b.c7a42","wires":[["71a94378.8e56bc"]]},{"id":"52763c46.ad89c4","type":"inject","name":"","topic":"","payload":"51.05,-1.05","payloadType":"string","repeat":"","crontab":"","once":false,"x":165.5,"y":337,"z":"385bdf8b.c7a42","wires":[["7b08247.f84f7dc"]]},{"id":"7b08247.f84f7dc","type":"geohash","name":"","x":360.5,"y":337,"z":"385bdf8b.c7a42","wires":[["6f1c5357.90e3ac","893e37b7.76c1c8"]]},{"id":"6fec77c4.901388","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":155,"y":397,"z":"385bdf8b.c7a42","wires":[["60ebfc45.9f1404"]]},{"id":"893e37b7.76c1c8","type":"debug","name":"","active":true,"console":"false","complete":"false","x":535,"y":337,"z":"385bdf8b.c7a42","wires":[]},{"id":"71a94378.8e56bc","type":"debug","name":"","active":true,"console":"false","complete":"false","x":590,"y":420,"z":"385bdf8b.c7a42","wires":[]}]
Date: Wed, 10 Dec 2014 17:52:33 +0000 Subject: [PATCH 123/134] niggles in new Hummingboard GPIO node --- hardware/HummingboardGPIO/README.md | 2 ++ hardware/HummingboardGPIO/hb-gpio.js | 6 +++--- hardware/HummingboardGPIO/package.json | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hardware/HummingboardGPIO/README.md b/hardware/HummingboardGPIO/README.md index 74600e94..b4b0ccab 100644 --- a/hardware/HummingboardGPIO/README.md +++ b/hardware/HummingboardGPIO/README.md @@ -6,6 +6,8 @@ A Node-RED node to read and write Install ------- +**This install is for Debian based OS on Hummingboard.** + Run the following command in the root directory of your Node-RED install: npm install node-red-node-hpgpio diff --git a/hardware/HummingboardGPIO/hb-gpio.js b/hardware/HummingboardGPIO/hb-gpio.js index da8993af..b4c07c82 100644 --- a/hardware/HummingboardGPIO/hb-gpio.js +++ b/hardware/HummingboardGPIO/hb-gpio.js @@ -21,12 +21,12 @@ module.exports = function(RED) { var gpioCommand = '/usr/local/bin/gpiohb'; - //if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - //throw "Info : Ignoring Raspberry Pi specific node."; + //if (!fs.existsSync("/etc/init.d/armhwinfo")) { // unlikely if not on a Hummingboard + //throw "Info : Ignoring Hummingboard specific node."; //} if (!fs.existsSync(gpioCommand)) { // gpio command not installed - throw "Info : Can't find "+gpioCommand+" command."; + throw "Error : Can't find "+gpioCommand+" command for Hummingboard."; } // Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant) diff --git a/hardware/HummingboardGPIO/package.json b/hardware/HummingboardGPIO/package.json index af3e9b2e..93471010 100644 --- a/hardware/HummingboardGPIO/package.json +++ b/hardware/HummingboardGPIO/package.json @@ -1,12 +1,12 @@ { "name" : "node-red-node-hbgpio", - "version" : "0.0.1", + "version" : "0.0.3", "description" : "A Node-RED node for the GPIO of the Hummingboard", "dependencies": { }, "repository" : { "type":"tgz", - "url":"http://dcj.dtdns.net/npms/hbgpio.tgz" + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/HummingboardGPIO" }, "license": "Apache-2.0", "keywords": [ "node-red", "hummingboard", "gpio" ], From e5d75fbd9b58be748e093a0365131e8541c02d58 Mon Sep 17 00:00:00 2001 From: Edwin Hermans Date: Fri, 12 Dec 2014 00:57:01 +0100 Subject: [PATCH 124/134] Update package.json --- social/nma/package.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/social/nma/package.json b/social/nma/package.json index 7004dd69..c8ccd65e 100644 --- a/social/nma/package.json +++ b/social/nma/package.json @@ -1,9 +1,9 @@ { "name" : "node-red-node-nma", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "A Node-RED node to send alerts via Notify-My-Android", "dependencies" : { - "nma" : "0.1.8" + "nma" : ">=0.2.2" }, "repository" : { "type":"git", @@ -20,5 +20,9 @@ "name": "Dave Conway-Jones", "email": "ceejay@vnet.ibm.com", "url": "http://nodered.org" - } + }, + "contributors": [{ + "name": "Edwin Hermans", + "email": "edwin@madtech.cx" + }] } From 24282291f455fcdc4a1a4451602a477a58b002fb Mon Sep 17 00:00:00 2001 From: Edwin Hermans Date: Fri, 12 Dec 2014 01:01:18 +0100 Subject: [PATCH 125/134] updates for new version of nma package --- social/nma/57-nma.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/social/nma/57-nma.js b/social/nma/57-nma.js index 017345b1..3870a05b 100644 --- a/social/nma/57-nma.js +++ b/social/nma/57-nma.js @@ -32,11 +32,17 @@ module.exports = function(RED) { } else { msg.payload = msg.payload.toString(); } if (node.pushkey) { - try { - nma(node.pushkey, "Node-RED", titl, msg.payload, 0 ); - } catch (e) { - node.warn("NMA error: "+ e); - } + nma({ + "apikey": node.pushkey, + "application": "Node-RED", + "event": titl, + "description": msg.payload, + "priority": 0 + }, function (error) { + if (error) { + node.warn("NMA error: " + error); + } + }); } else { node.warn("NMA credentials not set."); From 3b6f0ae2223559fcddf171bd87162c923b2e4d22 Mon Sep 17 00:00:00 2001 From: Edwin Hermans Date: Fri, 12 Dec 2014 10:36:15 +0100 Subject: [PATCH 126/134] pinned version of nma dependency --- social/nma/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/social/nma/package.json b/social/nma/package.json index c8ccd65e..07932d16 100644 --- a/social/nma/package.json +++ b/social/nma/package.json @@ -3,7 +3,7 @@ "version" : "0.0.2", "description" : "A Node-RED node to send alerts via Notify-My-Android", "dependencies" : { - "nma" : ">=0.2.2" + "nma" : "0.2.2" }, "repository" : { "type":"git", From c128184d6a44a1ec85799d9efcc426008ef3e7ae Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Fri, 12 Dec 2014 23:15:09 +0000 Subject: [PATCH 127/134] re-categorise Geohash node as location --- parsers/geohash/70-geohash.html | 2 +- parsers/geohash/package.json | 2 +- social/nma/57-nma.js | 16 +++++++++++----- social/nma/package.json | 10 +++++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/parsers/geohash/70-geohash.html b/parsers/geohash/70-geohash.html index 1a43fcea..a1e483cc 100644 --- a/parsers/geohash/70-geohash.html +++ b/parsers/geohash/70-geohash.html @@ -34,7 +34,7 @@ diff --git a/storage/mysql/package.json b/storage/mysql/package.json index 724f1336..3bd6818e 100644 --- a/storage/mysql/package.json +++ b/storage/mysql/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-mysql", - "version" : "0.0.3", + "version" : "0.0.4", "description" : "A Node-RED node to read and write to a MySQL database", "dependencies" : { "mysql" : "2.3.*" From c45c625872b14829cd4304e1367708d4bed520b9 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Mon, 22 Dec 2014 13:12:34 +0000 Subject: [PATCH 130/134] Updated doc and added package.json --- hardware/sensorTag/README | 5 ----- hardware/sensorTag/README.md | 26 ++++++++++++++++++++++++++ hardware/sensorTag/package.json | 24 ++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-) delete mode 100644 hardware/sensorTag/README create mode 100644 hardware/sensorTag/README.md create mode 100644 hardware/sensorTag/package.json diff --git a/hardware/sensorTag/README b/hardware/sensorTag/README deleted file mode 100644 index 2d6657ab..00000000 --- a/hardware/sensorTag/README +++ /dev/null @@ -1,5 +0,0 @@ -This currently requires the sensortag library - -To install use the following command in the Node-Red directory - -npm install sensortag diff --git a/hardware/sensorTag/README.md b/hardware/sensorTag/README.md new file mode 100644 index 00000000..f443f893 --- /dev/null +++ b/hardware/sensorTag/README.md @@ -0,0 +1,26 @@ +node-red-node-sensortag +======================= + +This node adds support to Node-RED to read from the Texas Instruments SensorTag. + +The SensorTag is a Bluetooth LE device hosting the following sensors: +* Ambient & ir Temperature +* Barometric Pressure +* Humidity +* 3 axis Accelerometer +* 3 axis Magnetometer +* 3 axis Gyroscope +* 2 push Buttons + +The config node allows the user to enable/disable any of the sensors listed above. The readings from +these sensors will be sent as a JSON object payload with the sensor name appended to the topic provided: + +* Temperature - { topic: [topic_prefix]/temperature, payload: { ambient: 21.2, object: 33.0 } } +* Barometric Pressure - { topic: [topic_prefix]/pressure, payload: { pres: 1000.1 } } +* Humidity - { topic: [topic_prefix]/humidity , payload: { temp: 21.2, humidity: 88} } +* Accelerometer - { topic: [topic_prefix]/ , payload: { x:0.0, y:9.8, z:0.0 } } +* Magnetometer - { topic: [topic_prefix]/ , payload: { x:0.0, y:0.0, z:0.0 } } +* Gyroscope - { topic: [topic_prefix]/ , payload: { x:0.0, y:0.0, z:0.0 } } +* Buttons - { topic: [topic_prefix]/ , payload: { left: "down", right: "up"} } + +**NOTE:** Node-RED needs to be run as root inorder or access the Linux Bluetooth 4.0 system calls \ No newline at end of file diff --git a/hardware/sensorTag/package.json b/hardware/sensorTag/package.json new file mode 100644 index 00000000..97091be1 --- /dev/null +++ b/hardware/sensorTag/package.json @@ -0,0 +1,24 @@ +{ + "name": "node-red-node-sensortag", + "description": "A Node-RED node to read data from a TI SensorTag", + "version": "0.0.1", + "keywords" : ["node-red","sensortag"], + "dependencies": { + "sensortag" : "0.1.9" + }, + "license": "Apache", + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/sensorTag" + }, + "node-red" : { + "nodes" : { + "sensortTag": "79-sensorTag.js" + } + }, + "autor": { + "name": "Ben Hardill", + "email":"hardillb@gmail.com", + "url": "http://www.hardill.me.uk/wordpress" + } +} \ No newline at end of file From 4a0608d2e962bed6d802a928ddc79060b2fe6a8e Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Mon, 22 Dec 2014 14:26:17 +0000 Subject: [PATCH 131/134] slight speelling correction to sensortag package.json --- hardware/sensorTag/LICENSE | 177 ++++++++++++++++++++++++++++++++ hardware/sensorTag/package.json | 40 ++++---- 2 files changed, 197 insertions(+), 20 deletions(-) create mode 100644 hardware/sensorTag/LICENSE diff --git a/hardware/sensorTag/LICENSE b/hardware/sensorTag/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/hardware/sensorTag/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/hardware/sensorTag/package.json b/hardware/sensorTag/package.json index 97091be1..a1ab6961 100644 --- a/hardware/sensorTag/package.json +++ b/hardware/sensorTag/package.json @@ -1,24 +1,24 @@ { - "name": "node-red-node-sensortag", - "description": "A Node-RED node to read data from a TI SensorTag", - "version": "0.0.1", - "keywords" : ["node-red","sensortag"], - "dependencies": { - "sensortag" : "0.1.9" - }, - "license": "Apache", - "repository" : { + "name": "node-red-node-sensortag", + "description": "A Node-RED node to read data from a TI SensorTag", + "version": "0.0.1", + "keywords" : ["node-red","sensortag"], + "dependencies": { + "sensortag" : "0.1.9" + }, + "license": "Apache", + "repository" : { "type":"git", "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/sensorTag" }, - "node-red" : { - "nodes" : { - "sensortTag": "79-sensorTag.js" - } - }, - "autor": { - "name": "Ben Hardill", - "email":"hardillb@gmail.com", - "url": "http://www.hardill.me.uk/wordpress" - } -} \ No newline at end of file + "node-red" : { + "nodes" : { + "sensortTag": "79-sensorTag.js" + } + }, + "author": { + "name": "Ben Hardill", + "email":"hardillb@gmail.com", + "url": "http://www.hardill.me.uk/wordpress" + } +} From 1ef562edbd4fd15d39594848756aae5eb89b27a8 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Mon, 22 Dec 2014 15:45:51 +0000 Subject: [PATCH 132/134] Removed "use strict" as it breaks this node. I'm investigating why. Also updated the package.json to reflect autors and bumped version number --- hardware/digiRGB/78-digiRGB.js | 2 +- hardware/digiRGB/package.json | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hardware/digiRGB/78-digiRGB.js b/hardware/digiRGB/78-digiRGB.js index 735652b6..e8fc247c 100644 --- a/hardware/digiRGB/78-digiRGB.js +++ b/hardware/digiRGB/78-digiRGB.js @@ -15,7 +15,7 @@ **/ module.exports = function(RED) { - "use strict"; + //"use strict"; var HID = require('node-hid'); var device; var node; diff --git a/hardware/digiRGB/package.json b/hardware/digiRGB/package.json index 340cb6bf..6b4502e5 100644 --- a/hardware/digiRGB/package.json +++ b/hardware/digiRGB/package.json @@ -1,10 +1,11 @@ { "name" : "node-red-node-digirgb", - "version" : "0.0.1", + "version" : "0.0.2", "description" : "A Node-RED node to control a Digispark RGB LED", "dependencies" : { "node-hid" : "0.3.1" }, + "homepage": "http://www.hardill.me.uk/wordpress/2013/02/06/budget-blink1/", "repository" : { "type":"git", "url":"https://github.com/node-red/node-red-nodes/tree/master/hardware/digiRGB" @@ -16,9 +17,16 @@ "digiRGB": "78-digiRGB.js" } }, - "author": { - "name": "Dave Conway-Jones", - "email": "ceejay@vnet.ibm.com", - "url": "http://nodered.org" - } + "contributors": [ + { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + }, + { + "name": "Ben Hardill", + "email": "hardillb@gmail.com", + "url": "http://www.hardill.me.uk/wordpress/" + } + ] } From 3e21d7d730a256afa37e98186b53ffff9cef1ed6 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 24 Dec 2014 21:51:17 +0000 Subject: [PATCH 133/134] New Daemon node to call and monitor long running external commands --- utility/daemon/LICENSE | 177 ++++++++++++++++++++++++++++++++++++ utility/daemon/README.md | 29 ++++++ utility/daemon/daemon.html | 80 ++++++++++++++++ utility/daemon/daemon.js | 106 +++++++++++++++++++++ utility/daemon/package.json | 23 +++++ 5 files changed, 415 insertions(+) create mode 100644 utility/daemon/LICENSE create mode 100644 utility/daemon/README.md create mode 100644 utility/daemon/daemon.html create mode 100644 utility/daemon/daemon.js create mode 100644 utility/daemon/package.json diff --git a/utility/daemon/LICENSE b/utility/daemon/LICENSE new file mode 100644 index 00000000..f433b1a5 --- /dev/null +++ b/utility/daemon/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/utility/daemon/README.md b/utility/daemon/README.md new file mode 100644 index 00000000..32bba0c4 --- /dev/null +++ b/utility/daemon/README.md @@ -0,0 +1,29 @@ +node-red-node-daemon +==================== + +A Node-RED node that runs and monitors a long running system command. + +Similar to the **exec** node - but this calls the command at start time and then pipes any input to the node to the STDIN of the running command, and feeds any STDOUT to the first output. + +Useful for monitoring command line based processes. + +Install +------- + +Run the following command in the root directory of your Node-RED install + + npm install node-red-node-daemon + + +Usage +----- + +Calls out to a long running system command. Sends msg.payload to stdin of the process. + +Provides 3 outputs... stdout, stderr, and return code, from the running command. + +If the called program stops (i.e. a return code is produced), this node can attempt to restart the command. + +**Note :** when you stop Node-RED running we may not get a chance to kill the called program so it may remain running. You may have to kill it manually. + +For example I have used it to run and then monitor the dump1090 plane spotter, and also to interact with various python apps that everyone seem to write these days :-) diff --git a/utility/daemon/daemon.html b/utility/daemon/daemon.html new file mode 100644 index 00000000..dc32f07d --- /dev/null +++ b/utility/daemon/daemon.html @@ -0,0 +1,80 @@ + + + + + + + diff --git a/utility/daemon/daemon.js b/utility/daemon/daemon.js new file mode 100644 index 00000000..704d7f5e --- /dev/null +++ b/utility/daemon/daemon.js @@ -0,0 +1,106 @@ +/** + * Copyright 2014 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ + +module.exports = function(RED) { + "use strict"; + var spawn = require('child_process').spawn; + + function DaemonNode(n) { + RED.nodes.createNode(this,n); + this.cmd = n.command; + this.args = n.args.split(" ") || []; + this.cr = n.cr; + this.op = n.op; + this.redo = n.redo; + this.running = false; + var node = this; + + function inputlistener(msg) { + if (msg != null) { + if (!Buffer.isBuffer(msg.payload)) { + if (typeof msg.payload === "object") { msg.payload = JSON.stringify(msg.payload); } + if (typeof msg.payload !== "string") { msg.payload = msg.payload.toString(); } + if (node.cr === true) { msg.payload += "\n"; } + } + if (RED.settings.verbose) { node.log("inp: "+msg.payload); } + if (node.child !== null) { node.child.stdin.write(msg.payload); } + else { node.warn("Command not running"); } + } + } + + function runit() { + node.child = spawn(node.cmd, node.args); + if (RED.settings.verbose) { node.log(node.cmd+" "+JSON.stringify(node.args)); } + node.status({fill:"green",shape:"dot",text:"running"}); + node.running = true; + + node.on("input", inputlistener); + + node.child.stdout.on('data', function (data) { + if (node.op == "string") { data = data.toString(); } + if (node.op == "number") { data = Number(data); } + if (RED.settings.verbose) { node.log("out: "+data); } + if (data && data.trim() !== "") { + var msg = {payload:data}; + node.send([msg,null,null]); + } + }); + + node.child.stderr.on('data', function (data) { + if (node.op == "string") { data = data.toString(); } + if (node.op == "number") { data = Number(data); } + if (RED.settings.verbose) { node.log("err: "+data); } + var msg = {payload:data}; + node.send([null,msg,null]); + }); + + node.child.on('close', function (code) { + if (RED.settings.verbose) { node.log("ret: "+code); } + var msg = {payload:code}; + node.send([null,null,msg]); + node.child = null; + node.running = false; + node.status({fill:"red",shape:"ring",text:"stopped"}); + }); + + node.child.on('error', function (err) { + if (err.errno === "ENOENT") { node.warn('Command not found'); } + else if (err.errno === "EACCES") { node.warn('Command not executable'); } + else { node.log('error: ' + err); } + node.status({fill:"grey",shape:"dot",text:"error"}); + }); + } + + if (node.redo === true) { + var loop = setInterval( function() { + if (!node.running) { + node.removeListener('input', inputlistener); + node.warn("Restarting : " + node.cmd); + runit(); + } + }, 10000); // Restart after 10 secs if required + } + + node.on("close", function() { + if (node.child != null) { node.child.kill('SIGKILL'); } + if (RED.settings.verbose) { node.log(node.cmd+" stopped"); } + clearInterval(loop); + }); + + runit(); + } + RED.nodes.registerType("daemon",DaemonNode); +} diff --git a/utility/daemon/package.json b/utility/daemon/package.json new file mode 100644 index 00000000..8c5dbc84 --- /dev/null +++ b/utility/daemon/package.json @@ -0,0 +1,23 @@ +{ + "name" : "node-red-node-daemon", + "version" : "0.0.1", + "description" : "A Node-RED node that runs and monitors a long running system command.", + "dependencies" : { + }, + "repository" : { + "type":"git", + "url":"https://github.com/node-red/node-red-nodes/tree/master/utility/daemon" + }, + "license": "Apache-v2.0", + "keywords": [ "node-red", "daemon", "shell", "exec" ], + "node-red" : { + "nodes" : { + "daemon": "daemon.js" + } + }, + "author": { + "name": "Dave Conway-Jones", + "email": "ceejay@vnet.ibm.com", + "url": "http://nodered.org" + } +} From 98a029bfd71ee6fb1855f28a58e8a80a0de788a9 Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Wed, 24 Dec 2014 21:53:00 +0000 Subject: [PATCH 134/134] Slightly better hardware discrimination for Hummingboard Node --- hardware/HummingboardGPIO/hb-gpio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/HummingboardGPIO/hb-gpio.js b/hardware/HummingboardGPIO/hb-gpio.js index b4c07c82..88cc61db 100644 --- a/hardware/HummingboardGPIO/hb-gpio.js +++ b/hardware/HummingboardGPIO/hb-gpio.js @@ -21,7 +21,7 @@ module.exports = function(RED) { var gpioCommand = '/usr/local/bin/gpiohb'; - //if (!fs.existsSync("/etc/init.d/armhwinfo")) { // unlikely if not on a Hummingboard + //if (!fs.existsSync("/sys/devices/soc0/machine")) { // unlikely if not on a Hummingboard //throw "Info : Ignoring Hummingboard specific node."; //}