mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Don't log when all is good, parse JSON retun
This commit is contained in:
parent
1467575f6c
commit
dc3c1b7cc4
@ -58,7 +58,6 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
node.log("[emoncms] "+this.url);
|
node.log("[emoncms] "+this.url);
|
||||||
http.get(this.url, function(res) {
|
http.get(this.url, function(res) {
|
||||||
node.log("Http response: " + res.statusCode);
|
|
||||||
msg.rc = res.statusCode;
|
msg.rc = res.statusCode;
|
||||||
msg.payload = "";
|
msg.payload = "";
|
||||||
if ((msg.rc != 200) && (msg.rc != 404)) {
|
if ((msg.rc != 200) && (msg.rc != 404)) {
|
||||||
@ -75,7 +74,6 @@ module.exports = function(RED) {
|
|||||||
// node.error(e);
|
// node.error(e);
|
||||||
msg.rc = 503;
|
msg.rc = 503;
|
||||||
msg.payload = e;
|
msg.payload = e;
|
||||||
node.send(msg);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -101,16 +99,15 @@ module.exports = function(RED) {
|
|||||||
if (feedid !== "") {
|
if (feedid !== "") {
|
||||||
this.url += '&id=' + feedid;
|
this.url += '&id=' + feedid;
|
||||||
}
|
}
|
||||||
if (typeof msg.time !== 'undefined') {
|
if (typeof msg.payload !== 'undefined') {
|
||||||
this.url += '&time=' + msg.time;
|
this.url += '&time=' + msg.payload;
|
||||||
}
|
}
|
||||||
node.log("[emoncms] "+this.url);
|
node.log("[emoncms] "+this.url);
|
||||||
http.get(this.url, function(res) {
|
http.get(this.url, function(res) {
|
||||||
node.log("Http response: " + res.statusCode);
|
|
||||||
msg.rc = res.statusCode;
|
msg.rc = res.statusCode;
|
||||||
msg.payload = "";
|
msg.payload = "";
|
||||||
if ((msg.rc != 200) && (msg.rc != 404)) {
|
if ((msg.rc != 200) && (msg.rc != 404)) {
|
||||||
node.send(msg);
|
node.send(JSON.parse(msg));
|
||||||
}
|
}
|
||||||
res.setEncoding('utf8');
|
res.setEncoding('utf8');
|
||||||
res.on('data', function(chunk) {
|
res.on('data', function(chunk) {
|
||||||
@ -123,7 +120,6 @@ module.exports = function(RED) {
|
|||||||
// node.error(e);
|
// node.error(e);
|
||||||
msg.rc = 503;
|
msg.rc = 503;
|
||||||
msg.payload = e;
|
msg.payload = e;
|
||||||
node.send(msg);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,4 @@ Insertion time can be manipulated by setting **msg.time**.
|
|||||||
|
|
||||||
### Emoncms In:
|
### Emoncms In:
|
||||||
|
|
||||||
Fetches last emoncms feed value in JSON format, use JSON processor node to convert to number.
|
Fetches last emoncms feed value, returns numberical value.
|
Loading…
x
Reference in New Issue
Block a user