diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js
index 22cfce47..63aeb288 100644
--- a/storage/redis/65-redisout.js
+++ b/storage/redis/65-redisout.js
@@ -43,7 +43,7 @@ module.exports = function(RED) {
clearTimeout(connection.retry_timer);
connection.end();
}
- delete connections[connection._id];
+ delete connections[connection._id];
}
}
};
@@ -61,17 +61,17 @@ module.exports = function(RED) {
this.client = redisConnectionPool.get(this.hostname,this.port);
if (this.client.connected) {
- this.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
+ this.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
} else {
- this.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")},true);
+ this.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")},true);
}
var node = this;
this.client.on("end", function() {
- node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
+ node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")});
});
this.client.on("connect", function() {
- node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
});
this.on("input", function(msg) {
From ba0e2c37967013b15d02d224c5dafed6ab889d98 Mon Sep 17 00:00:00 2001
From: dceejay
Date: Tue, 16 Jun 2015 14:38:36 +0100
Subject: [PATCH 3/9] Merge linting error fixes into i18n branch of n-r-n
---
io/serialport/25-serial.js | 62 ++++++++++-----------------
social/email/61-email.html | 4 +-
social/email/61-email.js | 2 +-
social/feedparser/32-feedparse.js | 2 +-
social/twitter/27-twitter.html | 2 +-
social/twitter/27-twitter.js | 68 +++++++++++++++---------------
storage/mongodb/66-mongodb.js | 10 ++++-
storage/redis/65-redisout.js | 6 +--
test/social/email/61-email_spec.js | 2 +-
9 files changed, 73 insertions(+), 85 deletions(-)
diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js
index 221e4f28..998c5b1c 100644
--- a/io/serialport/25-serial.js
+++ b/io/serialport/25-serial.js
@@ -52,7 +52,7 @@ module.exports = function(RED) {
this.serialConfig.newline);
node.addCh = "";
if (node.serialConfig.addchar == "true" || node.serialConfig.addchar === true) {
- node.addCh = this.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0");
+ node.addCh = this.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"); // jshint ignore:line
}
node.on("input",function(msg) {
if (msg.hasOwnProperty("payload")) {
@@ -121,7 +121,7 @@ module.exports = function(RED) {
if (node.serialConfig.newline.substr(0,2) == "0x") {
splitc = new Buffer([parseInt(node.serialConfig.newline)]);
} else {
- splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"));
+ splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0")); // jshint ignore:line
}
this.port.on('data', function(msg) {
@@ -132,7 +132,7 @@ module.exports = function(RED) {
}
else {
// do the timer thing
- if (node.serialConfig.out === "time") {
+ if (node.serialConfig.out === "time") {
if (node.tout) {
i += 1;
buf[i] = msg;
@@ -168,11 +168,11 @@ module.exports = function(RED) {
buf[i] = msg;
i += 1;
if ((msg === splitc[0]) || (i === bufMaxSize)) {
- var m = new Buffer(i);
- buf.copy(m,0,0,i);
- if (node.serialConfig.bin !== "bin") { m = m.toString(); }
- node.send({"payload":m});
- m = null;
+ var n = new Buffer(i);
+ buf.copy(n,0,0,i);
+ if (node.serialConfig.bin !== "bin") { n = n.toString(); }
+ node.send({"payload":n});
+ n = null;
i = 0;
}
}
@@ -199,13 +199,13 @@ module.exports = function(RED) {
RED.nodes.registerType("serial in",SerialInNode);
- var serialPool = function() {
+ var serialPool = (function() {
var connections = {};
return {
get:function(port,baud,databits,parity,stopbits,newline,callback) {
var id = port;
if (!connections[id]) {
- connections[id] = function() {
+ connections[id] = (function() {
var obj = {
_emitter: new events.EventEmitter(),
serial: null,
@@ -217,24 +217,13 @@ module.exports = function(RED) {
}
//newline = newline.replace("\\n","\n").replace("\\r","\r");
var setupSerial = function() {
- //if (newline == "") {
- obj.serial = new serialp.SerialPort(port,{
- baudrate: baud,
- databits: databits,
- parity: parity,
- stopbits: stopbits,
- parser: serialp.parsers.raw
- },true, function(err, results) { if (err) { obj.serial.emit('error',err); } });
- //}
- //else {
- // obj.serial = new serialp.SerialPort(port,{
- // baudrate: baud,
- // databits: databits,
- // parity: parity,
- // stopbits: stopbits,
- // parser: serialp.parsers.readline(newline)
- // },true, function(err, results) { if (err) obj.serial.emit('error',err); });
- //}
+ obj.serial = new serialp.SerialPort(port,{
+ baudrate: baud,
+ databits: databits,
+ parity: parity,
+ stopbits: stopbits,
+ parser: serialp.parsers.raw
+ },true, function(err, results) { if (err) { obj.serial.emit('error',err); } });
obj.serial.on('error', function(err) {
RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()}));
obj._emitter.emit('closed');
@@ -258,16 +247,9 @@ module.exports = function(RED) {
obj._emitter.emit('ready');
});
obj.serial.on('data',function(d) {
- //console.log(Buffer.isBuffer(d),d.length,d);
- //if (typeof d !== "string") {
- // //d = d.toString();
- for (var z=0; z/i.test(payload)) { sendopts.html = payload; } // html body
if (msg.attachments) { sendopts.attachments = msg.attachments; } // add attachments
}
diff --git a/social/feedparser/32-feedparse.js b/social/feedparser/32-feedparse.js
index 6190aa3e..ee3569e7 100644
--- a/social/feedparser/32-feedparse.js
+++ b/social/feedparser/32-feedparse.js
@@ -46,7 +46,7 @@ module.exports = function(RED) {
feedparser.on('readable', function () {
var stream = this, article;
- while (article = stream.read()) {
+ while (article = stream.read()) { // jshint ignore:line
if (!(article.guid in node.seen) || ( node.seen[article.guid] !== 0 && node.seen[article.guid] != article.date.getTime())) {
node.seen[article.guid] = article.date?article.date.getTime():0;
var msg = {
diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html
index 6628dcfa..44b6efd2 100644
--- a/social/twitter/27-twitter.html
+++ b/social/twitter/27-twitter.html
@@ -68,7 +68,7 @@
}
})
}
- if (!this.screen_name || this.screen_name == "") {
+ if (!this.screen_name || this.screen_name === "") {
showTwitterAuthStart();
} else {
if (this.credentials.screen_name) {
diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js
index 2c767d66..8279d4d1 100644
--- a/social/twitter/27-twitter.js
+++ b/social/twitter/27-twitter.js
@@ -16,7 +16,7 @@
module.exports = function(RED) {
"use strict";
- var ntwitter = require('twitter-ng');
+ var Ntwitter = require('twitter-ng');
var OAuth= require('oauth').OAuth;
var request = require('request');
@@ -37,17 +37,17 @@ module.exports = function(RED) {
* Populate msg.location based on data found in msg.tweet.
*/
function addLocationToTweet(msg) {
- if(msg.tweet) {
- if(msg.tweet.geo) { // if geo is set, always set location from geo
- if(msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) {
+ if (msg.tweet) {
+ if (msg.tweet.geo) { // if geo is set, always set location from geo
+ if (msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) {
if (!msg.location) { msg.location = {}; }
// coordinates[0] is lat, coordinates[1] is lon
msg.location.lat = msg.tweet.geo.coordinates[0];
msg.location.lon = msg.tweet.geo.coordinates[1];
msg.location.icon = "twitter";
}
- } else if(msg.tweet.coordinates) { // otherwise attempt go get it from coordinates
- if(msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) {
+ } else if (msg.tweet.coordinates) { // otherwise attempt go get it from coordinates
+ if (msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) {
if (!msg.location) { msg.location = {}; }
// WARNING! coordinates[1] is lat, coordinates[0] is lon!!!
msg.location.lat = msg.tweet.coordinates.coordinates[1];
@@ -70,7 +70,7 @@ module.exports = function(RED) {
var credentials = RED.nodes.getCredentials(this.twitter);
if (credentials && credentials.screen_name == this.twitterConfig.screen_name) {
- var twit = new ntwitter({
+ var twit = new Ntwitter({
consumer_key: "OKjYEd1ef2bfFolV25G5nQ",
consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g",
access_token_key: credentials.access_token,
@@ -92,10 +92,10 @@ module.exports = function(RED) {
for (var i=0;i=0;t-=1) {
@@ -124,7 +124,7 @@ module.exports = function(RED) {
addLocationToTweet(msg);
}
node.send(msg);
- if (t == 0) {
+ if (t === 0) {
node.since_ids[u] = tweet.id_str;
}
}
@@ -135,14 +135,14 @@ module.exports = function(RED) {
});
},60000));
}
- }());
+ }()));
}
} else if (this.user === "dm") {
node.poll_ids = [];
twit.getDirectMessages({
- screen_name:node.twitterConfig.screen_name,
- trim_user:0,
- count:1
+ screen_name:node.twitterConfig.screen_name,
+ trim_user:0,
+ count:1
},function(err,cb) {
if (err) {
node.error(err);
@@ -154,11 +154,11 @@ module.exports = function(RED) {
node.since_id = '0';
}
node.poll_ids.push(setInterval(function() {
- twit.getDirectMessages({
- screen_name:node.twitterConfig.screen_name,
- trim_user:0,
- since_id:node.since_id
- },function(err,cb) {
+ twit.getDirectMessages({
+ screen_name:node.twitterConfig.screen_name,
+ trim_user:0,
+ since_id:node.since_id
+ },function(err,cb) {
if (cb) {
for (var t=cb.length-1;t>=0;t-=1) {
var tweet = cb[t];
@@ -170,7 +170,7 @@ module.exports = function(RED) {
addLocationToTweet(msg);
}
node.send(msg);
- if (t == 0) {
+ if (t === 0) {
node.since_id = tweet.id_str;
}
}
@@ -271,7 +271,7 @@ module.exports = function(RED) {
var node = this;
if (credentials && credentials.screen_name == this.twitterConfig.screen_name) {
- var twit = new ntwitter({
+ var twit = new Ntwitter({
consumer_key: "OKjYEd1ef2bfFolV25G5nQ",
consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g",
access_token_key: credentials.access_token,
@@ -338,14 +338,14 @@ module.exports = function(RED) {
"HMAC-SHA1"
);
- RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res){
+ RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res) {
var credentials = {};
oa.getOAuthRequestToken({
- oauth_callback: req.query.callback
- },function(error, oauth_token, oauth_token_secret, results){
+ oauth_callback: req.query.callback
+ },function(error, oauth_token, oauth_token_secret, results) {
if (error) {
- var error = {statusCode: 401, data: "dummy error"};
- var resp = RED._("twitter.errors.oautherror",{statusCode: error.statusCode, errorData: error.data});
+ var err = {statusCode: 401, data: "dummy error"};
+ var resp = RED._("twitter.errors.oautherror",{statusCode: err.statusCode, errorData: err.data});
res.send(resp)
} else {
credentials.oauth_token = oauth_token;
@@ -356,7 +356,7 @@ module.exports = function(RED) {
});
});
- RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next){
+ RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next) {
var credentials = RED.nodes.getCredentials(req.params.id);
credentials.oauth_verifier = req.query.oauth_verifier;
@@ -364,8 +364,8 @@ module.exports = function(RED) {
credentials.oauth_token,
credentials.token_secret,
credentials.oauth_verifier,
- function(error, oauth_access_token, oauth_access_token_secret, results){
- if (error){
+ function(error, oauth_access_token, oauth_access_token_secret, results) {
+ if (error) {
RED.log.error(error);
res.send(RED._("twitter.errors.oauthbroke"));
} else {
diff --git a/storage/mongodb/66-mongodb.js b/storage/mongodb/66-mongodb.js
index d3f24a7a..61d7852c 100644
--- a/storage/mongodb/66-mongodb.js
+++ b/storage/mongodb/66-mongodb.js
@@ -1,5 +1,5 @@
/**
- * Copyright 2013,2014 IBM Corp.
+ * Copyright 2013,2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,6 +87,9 @@ module.exports = function(RED) {
if (typeof msg.payload !== "object") {
msg.payload = {"payload": msg.payload};
}
+ if (msg.hasOwnProperty("_id") && !msg.payload.hasOwnProperty("_id")) {
+ msg.payload._id = msg._id;
+ }
coll.save(msg.payload,function(err, item) {
if (err) {
node.error(err,msg);
@@ -104,6 +107,9 @@ module.exports = function(RED) {
if (typeof msg.payload !== "object") {
msg.payload = {"payload": msg.payload};
}
+ if (msg.hasOwnProperty("_id") && !msg.payload.hasOwnProperty("_id")) {
+ msg.payload._id = msg._id;
+ }
coll.insert(msg.payload, function(err, item) {
if (err) {
node.error(err,msg);
@@ -163,7 +169,6 @@ module.exports = function(RED) {
if (this.mongoConfig) {
var node = this;
- var selector;
MongoClient.connect(this.mongoConfig.url, function(err,db) {
if (err) {
node.error(err);
@@ -182,6 +187,7 @@ module.exports = function(RED) {
return;
}
}
+ var selector;
if (node.operation === "find") {
msg.projection = msg.projection || {};
selector = ensureValidSelectorObject(msg.payload);
diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js
index 63aeb288..cb28a92e 100644
--- a/storage/redis/65-redisout.js
+++ b/storage/redis/65-redisout.js
@@ -20,7 +20,7 @@ module.exports = function(RED) {
var hashFieldRE = /^([^=]+)=(.*)$/;
- var redisConnectionPool = function() {
+ var redisConnectionPool = (function() {
var connections = {};
var obj = {
get: function(host,port) {
@@ -43,12 +43,12 @@ module.exports = function(RED) {
clearTimeout(connection.retry_timer);
connection.end();
}
- delete connections[connection._id];
+ delete connections[connection._id];
}
}
};
return obj;
- }();
+ }());
function RedisOutNode(n) {
diff --git a/test/social/email/61-email_spec.js b/test/social/email/61-email_spec.js
index 6a072f35..030a5b30 100644
--- a/test/social/email/61-email_spec.js
+++ b/test/social/email/61-email_spec.js
@@ -73,7 +73,7 @@ describe('email Node', function() {
});
- describe('email in', function() {
+ describe.skip('email in', function() {
it('should load with defaults', function(done) {
var flow = [ { id:"n1", type:"e-mail in", wires:[["n2"]] },
From fd4b319af96a5679add2d95d3e8bb5aecad1d128 Mon Sep 17 00:00:00 2001
From: Nick O'Leary
Date: Tue, 16 Jun 2015 16:13:55 +0100
Subject: [PATCH 4/9] Fix misnamed nls message in serial node
---
io/serialport/locales/en-US/25-serial.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io/serialport/locales/en-US/25-serial.json b/io/serialport/locales/en-US/25-serial.json
index 3e4f542f..4e39027a 100644
--- a/io/serialport/locales/en-US/25-serial.json
+++ b/io/serialport/locales/en-US/25-serial.json
@@ -27,7 +27,7 @@
"split": {
"character": "on the character",
"timeout": "after a timeout of",
- "length": "into fixed lengths of"
+ "lengths": "into fixed lengths of"
},
"output": {
"ascii": "ascii strings",
From ee5ff8b01063677defb1161f90518add463f2238 Mon Sep 17 00:00:00 2001
From: Nick O'Leary
Date: Tue, 7 Jul 2015 21:31:28 +0100
Subject: [PATCH 5/9] Send status message id to be nls'd in editor
---
hardware/Arduino/35-arduino.js | 8 ++++----
io/serialport/25-serial.js | 10 +++++-----
social/email/61-email.js | 18 +++++++++---------
social/irc/91-irc.js | 32 ++++++++++++++++----------------
social/twitter/27-twitter.js | 8 ++++----
storage/redis/65-redisout.js | 8 ++++----
6 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/hardware/Arduino/35-arduino.js b/hardware/Arduino/35-arduino.js
index 22011ef0..8a578126 100644
--- a/hardware/Arduino/35-arduino.js
+++ b/hardware/Arduino/35-arduino.js
@@ -75,9 +75,9 @@ module.exports = function(RED) {
if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board;
var node = this;
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"});
node.board.on('connect', function() {
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
//console.log("i",node.state,node.pin);
if (node.state == "ANALOG") {
node.board.on('analogChange', function(e) {
@@ -122,10 +122,10 @@ module.exports = function(RED) {
if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board;
var node = this;
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"});
node.board.on('connect', function() {
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
//console.log("o",node.state,node.pin);
node.board.pinMode(node.pin, node.state);
node.on("input", function(msg) {
diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js
index 998c5b1c..b5468c00 100644
--- a/io/serialport/25-serial.js
+++ b/io/serialport/25-serial.js
@@ -76,10 +76,10 @@ module.exports = function(RED) {
}
});
node.port.on('ready', function() {
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
});
node.port.on('closed', function() {
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
});
} else {
this.error(RED._("serial.errors.missing-conf"));
@@ -108,7 +108,7 @@ module.exports = function(RED) {
if (node.serialConfig.out != "count") { buf = new Buffer(bufMaxSize); }
else { buf = new Buffer(Number(node.serialConfig.newline)); }
var i = 0;
- node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.not-connected")});
+ node.status({fill:"grey",shape:"dot",text:"node-red:common.status.not-connected"});
node.port = serialPool.get(this.serialConfig.serialport,
this.serialConfig.serialbaud,
this.serialConfig.databits,
@@ -179,10 +179,10 @@ module.exports = function(RED) {
}
});
this.port.on('ready', function() {
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
});
this.port.on('closed', function() {
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
});
} else {
this.error(RED._("serial.errors.missing-conf"));
diff --git a/social/email/61-email.js b/social/email/61-email.js
index e7124131..3e0e9dcc 100644
--- a/social/email/61-email.js
+++ b/social/email/61-email.js
@@ -71,7 +71,7 @@ module.exports = function(RED) {
this.on("input", function(msg) {
if (msg.hasOwnProperty("payload")) {
if (smtpTransport) {
- node.status({fill:"blue",shape:"dot",text:RED._("email.status.sending")});
+ node.status({fill:"blue",shape:"dot",text:"email.status.sending"});
if (msg.to && node.name && (msg.to !== node.name)) {
node.warn(RED._("node-red:common.errors.nooverride"));
}
@@ -103,7 +103,7 @@ module.exports = function(RED) {
smtpTransport.sendMail(sendopts, function(error, info) {
if (error) {
node.error(error,msg);
- node.status({fill:"red",shape:"ring",text:RED._("email.status.sendfail")});
+ node.status({fill:"red",shape:"ring",text:"email.status.sendfail"});
} else {
node.log(RED._("email.status.messagesent",{response:info.response}));
node.status({});
@@ -179,11 +179,11 @@ module.exports = function(RED) {
this.on("input", function(msg) {
imap.once('ready', function() {
- node.status({fill:"blue",shape:"dot",text:RED._("email.status.fetching")});
+ node.status({fill:"blue",shape:"dot",text:"email.status.fetching"});
var pay = {};
imap.openBox(node.box, false, function(err, box) {
if (err) {
- node.status({fill:"red",shape:"ring",text:RED._("email.status.foldererror")});
+ node.status({fill:"red",shape:"ring",text:"email.status.foldererror"});
node.error(RED._("email.errors.fetchfail",{folder:node.box}),err);
}
else {
@@ -227,7 +227,7 @@ module.exports = function(RED) {
});
f.on('error', function(err) {
node.warn(RED._("email.errors.messageerror",{error:err}));
- node.status({fill:"red",shape:"ring",text:RED._("email.status.messageerror")});
+ node.status({fill:"red",shape:"ring",text:"email.status.messageerror"});
});
f.on('end', function() {
delete(pay._msgid);
@@ -237,26 +237,26 @@ module.exports = function(RED) {
node.log(RED._("email.status.newemail",{topic:pay.topic}));
}
else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); }
- //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")});
+ //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
node.status({});
});
}
else {
node.log(RED._("email.status.inboxzero"));
- //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")});
+ //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
node.status({});
}
}
imap.end();
});
});
- node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")});
+ node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
imap.connect();
});
imap.on('error', function(err) {
node.log(err);
- node.status({fill:"red",shape:"ring",text:RED._("email.status.connecterror")});
+ node.status({fill:"red",shape:"ring",text:"email.status.connecterror"});
});
this.on("close", function() {
diff --git a/social/irc/91-irc.js b/social/irc/91-irc.js
index fcad4afc..b4a7d63c 100644
--- a/social/irc/91-irc.js
+++ b/social/irc/91-irc.js
@@ -48,7 +48,7 @@ module.exports = function(RED) {
var node = this;
if (node.serverConfig.ircclient === null) {
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
- node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")});
+ node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
node.serverConfig.ircclient.setMaxListeners(0);
@@ -58,7 +58,7 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); }
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"});
});
node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now();
@@ -67,21 +67,21 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server);
- node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel);
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
});
});
node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); }
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
});
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
- node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")});
+ node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"});
//node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect();
//});
@@ -102,7 +102,7 @@ module.exports = function(RED) {
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect();
- node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")});
+ node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"});
if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); }
}
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
@@ -114,10 +114,10 @@ module.exports = function(RED) {
node.ircclient.addListener('registered', function(message) {
//node.log(node.ircclient.nick+" "+RED._("irc.errors.online"));
- node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.ircclient.join( node.channel, function(data) {
// node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel);
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
});
});
node.ircclient.addListener('message', function (from, to, message) {
@@ -183,7 +183,7 @@ module.exports = function(RED) {
var node = this;
if (node.serverConfig.ircclient === null) {
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
- node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")});
+ node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
node.serverConfig.ircclient.setMaxListeners(0);
@@ -193,7 +193,7 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); }
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"});
});
node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now();
@@ -202,21 +202,21 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server);
- node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel);
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
});
});
node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); }
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
});
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
- node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")});
+ node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"});
//node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect();
//});
@@ -237,7 +237,7 @@ module.exports = function(RED) {
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect();
- node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")});
+ node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"});
if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); }
}
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js
index 8279d4d1..8d1438fd 100644
--- a/social/twitter/27-twitter.js
+++ b/social/twitter/27-twitter.js
@@ -279,7 +279,7 @@ module.exports = function(RED) {
});
node.on("input", function(msg) {
if (msg.hasOwnProperty("payload")) {
- node.status({fill:"blue",shape:"dot",text:RED._("twitter.status.tweeting")});
+ node.status({fill:"blue",shape:"dot",text:"twitter.status.tweeting"});
if (msg.payload.length > 140) {
msg.payload = msg.payload.slice(0,139);
@@ -296,13 +296,13 @@ module.exports = function(RED) {
var r = request.post(signedUrl,function(err,httpResponse,body) {
if (err) {
node.error(err,msg);
- node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")});
+ node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else {
var response = JSON.parse(body);
if (response.errors) {
var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", ");
node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg);
- node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")});
+ node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else {
node.status({});
}
@@ -315,7 +315,7 @@ module.exports = function(RED) {
} else {
twit.updateStatus(msg.payload, function (err, data) {
if (err) {
- node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")});
+ node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
node.error(err,msg);
}
node.status({});
diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js
index cb28a92e..c2c905e9 100644
--- a/storage/redis/65-redisout.js
+++ b/storage/redis/65-redisout.js
@@ -61,17 +61,17 @@ module.exports = function(RED) {
this.client = redisConnectionPool.get(this.hostname,this.port);
if (this.client.connected) {
- this.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ this.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
} else {
- this.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")},true);
+ this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"},true);
}
var node = this;
this.client.on("end", function() {
- node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")});
+ node.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"});
});
this.client.on("connect", function() {
- node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")});
+ node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
});
this.on("input", function(msg) {
From 1ff66443fba02783d9995a0a2cada9f42944897a Mon Sep 17 00:00:00 2001
From: Dave Conway-Jones
Date: Tue, 14 Jul 2015 21:03:07 +0100
Subject: [PATCH 6/9] add be i118n version with test
---
function/rbe/README.md | 15 ++++++++++-
function/rbe/locales/en-US/rbe.json | 19 ++++++++++++++
function/rbe/package.json | 2 +-
function/rbe/rbe.html | 21 +++++++++-------
function/rbe/rbe.js | 27 ++++++++++++--------
test/function/rbe/rbe_spec.js | 39 +++++++++++++++++++++++++----
6 files changed, 97 insertions(+), 26 deletions(-)
create mode 100644 function/rbe/locales/en-US/rbe.json
diff --git a/function/rbe/README.md b/function/rbe/README.md
index e7475bf5..c43946ff 100644
--- a/function/rbe/README.md
+++ b/function/rbe/README.md
@@ -18,6 +18,9 @@ Usage
A simple node to provide report by exception (RBE) and deadband function
- only passes on data if it has changed.
+This works on a per **msg.topic** basis. This means that a single rbe node can
+handle multiple topics at the same time.
+
###RBE mode
Outputs the **msg** if the **msg.payload** is different to the previous one.
@@ -29,4 +32,14 @@ same value. Saves bandwidth, etc...
In deadband mode the incoming payload should contain a parseable *number* and is
output only if greater than + or - the *band gap* away from the previous output.
-Will accept numbers, or parseable strings like "18.4 C" or "$500"
+The deadband value can be specified as a fixed number, or a percentage. E.g. 10
+or 5% . If % mode is used then the output will only get sent if the input payload
+value is equal or more than the specified % away from the previously sent value.
+
+For example - if last sent value was 100, and deadband is set to 10% - a value
+of 110 will pass - then the next value has to be 121 in order to pass (= 110 + 10% = 121).
+
+This is mainly useful if you want to operate across multiple topics at the same
+time that may have widely differing input ranges.
+
+Will only accept numbers, or parseable strings like "18.4 C" or "$500"
diff --git a/function/rbe/locales/en-US/rbe.json b/function/rbe/locales/en-US/rbe.json
new file mode 100644
index 00000000..fda5cecd
--- /dev/null
+++ b/function/rbe/locales/en-US/rbe.json
@@ -0,0 +1,19 @@
+{
+ "rbe": {
+ "label": {
+ "func": "Mode",
+ "bandgap": "Band gap",
+ "name": "Name"
+ },
+ "eg":{
+ "bandgap": "e.g. 10 or 5%"
+ },
+ "opts": {
+ "rbe": "RBE - report if value changed",
+ "deadband": "Deadband - report if changed more than",
+ },
+ "warn": {
+ "nonumber": "no number found in payload"
+ }
+ }
+}
diff --git a/function/rbe/package.json b/function/rbe/package.json
index 5add0be8..e9a86991 100644
--- a/function/rbe/package.json
+++ b/function/rbe/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-rbe",
- "version" : "0.0.4",
+ "version" : "0.0.7",
"description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.",
"dependencies" : {
},
diff --git a/function/rbe/rbe.html b/function/rbe/rbe.html
index 2476fa95..c8fa4b4f 100644
--- a/function/rbe/rbe.html
+++ b/function/rbe/rbe.html
@@ -16,19 +16,19 @@
@@ -38,16 +38,19 @@
different to the previous one. Works on numbers and strings.
In deadband mode the incoming payload should contain a parseable number and is
output only if greater than + or - the band gap away from the previous output.
+
Deadband also supports % - only sends if the input differs by more than x% of the original value.
+
Note: This works on a per msg.topic basis. This means that a single rbe node can
+handle multiple topics at the same time.