diff --git a/io/emoncms/88-emoncms.html b/io/emoncms/88-emoncms.html index d210d22d9..de9234d59 100644 --- a/io/emoncms/88-emoncms.html +++ b/io/emoncms/88-emoncms.html @@ -20,37 +20,31 @@
- - -
-
- +
-
If Payload is set to csv, msg.payload can be a comma separated values and the key will - be automatically generated by Emoncms, if Payload is set to json, msg.payload can only be a single value and - the key value can be manually or programmatically set.

- Key is not mandatory, if Key is left blank msg.topic will used. Key overrides msg.topic

+
If msg.payload holds comma separated values (csv), Key and msg.topic is ignored and the key will + be automatically generated by Emoncms. If msg.payload holds a single value and Key and msg.topic is not specified, msg.payload + will be treated as a csv otherwise it will be treated as a json payload and the key value can be manually or programmatically set.

+ Key is not mandatory, if Key is left blank msg.topic will used. Key overrides msg.topic, it will be ignored if msg.payload is holding csv

Node (numeric) is not mandatory, if Node is left blank msg.nodegrpup will used. Node over rides msg.nodegroup.
@@ -75,18 +69,6 @@ }, labelStyle: function() { return this.name?"node_label_italic":""; - }, - oneditprepare: function() { - $("#node-input-payloadType").change(function() { - var id = $("#node-input-payloadType option:selected").val(); - if (id == "json") { - $("#node-input-row-topic").show(); - } else { - $("#node-input-row-topic").hide(); - } - }); - $("#node-input-payloadType").val(this.payloadType); - $("#node-input-payloadType").change(); } }); diff --git a/io/emoncms/88-emoncms.js b/io/emoncms/88-emoncms.js index 7635cb349..938cdad57 100644 --- a/io/emoncms/88-emoncms.js +++ b/io/emoncms/88-emoncms.js @@ -20,7 +20,6 @@ function EmoncmsServerNode(n) { RED.nodes.createNode(this,n); this.server = n.server; this.name = n.name; - this.payloadType = n.payloadType; var credentials = RED.nodes.getCredentials(n.id); if (credentials) { this.apikey = credentials.apikey; @@ -72,7 +71,6 @@ function Emoncms(n) { this.baseurl = sc.server; this.apikey = sc.apikey; - this.payloadType = n.payloadType; this.topic = n.topic ||""; this.nodegroup = n.nodegroup || ""; var node = this; @@ -80,11 +78,11 @@ function Emoncms(n) { else { var http = require("http"); } this.on("input", function(msg) { this.url = this.baseurl + '/input/post.json?'; - if(this.payloadType == 'json'){ - var topic = this.topic || msg.topic; - this.url += 'json={' + topic + ':' + msg.payload+'}'; - } else { + var topic = this.topic || msg.topic; + if(msg.payload.indexOf(',') > -1 || topic.trim() == ''){ this.url += 'csv='+msg.payload; + } else { + this.url += 'json={' + topic + ':' + msg.payload+'}'; } this.url += '&apikey='+this.apikey; var nodegroup = this.nodegroup || msg.nodegroup;