From dc3c1b7cc4e7a2bb28ecc8a0b661b7eda0c0fcb7 Mon Sep 17 00:00:00 2001 From: Glyn Hudson Date: Mon, 26 Oct 2015 00:47:55 +0000 Subject: [PATCH] Don't log when all is good, parse JSON retun --- io/emoncms/88-emoncms.js | 10 +++------- io/emoncms/README.md | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/io/emoncms/88-emoncms.js b/io/emoncms/88-emoncms.js index 56abad0f..fd8eecbe 100644 --- a/io/emoncms/88-emoncms.js +++ b/io/emoncms/88-emoncms.js @@ -58,7 +58,6 @@ module.exports = function(RED) { } node.log("[emoncms] "+this.url); http.get(this.url, function(res) { - node.log("Http response: " + res.statusCode); msg.rc = res.statusCode; msg.payload = ""; if ((msg.rc != 200) && (msg.rc != 404)) { @@ -75,7 +74,6 @@ module.exports = function(RED) { // node.error(e); msg.rc = 503; msg.payload = e; - node.send(msg); }); }); } @@ -101,16 +99,15 @@ module.exports = function(RED) { if (feedid !== "") { this.url += '&id=' + feedid; } - if (typeof msg.time !== 'undefined') { - this.url += '&time=' + msg.time; + if (typeof msg.payload !== 'undefined') { + this.url += '&time=' + msg.payload; } node.log("[emoncms] "+this.url); http.get(this.url, function(res) { - node.log("Http response: " + res.statusCode); msg.rc = res.statusCode; msg.payload = ""; if ((msg.rc != 200) && (msg.rc != 404)) { - node.send(msg); + node.send(JSON.parse(msg)); } res.setEncoding('utf8'); res.on('data', function(chunk) { @@ -123,7 +120,6 @@ module.exports = function(RED) { // node.error(e); msg.rc = 503; msg.payload = e; - node.send(msg); }); }); } diff --git a/io/emoncms/README.md b/io/emoncms/README.md index 0968d8d0..48c15ef2 100644 --- a/io/emoncms/README.md +++ b/io/emoncms/README.md @@ -32,4 +32,4 @@ Insertion time can be manipulated by setting **msg.time**. ### Emoncms In: -Fetches last emoncms feed value in JSON format, use JSON processor node to convert to number. \ No newline at end of file +Fetches last emoncms feed value, returns numberical value. \ No newline at end of file