mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
let emoncms node accept simple objects
This commit is contained in:
parent
d8f1ecc629
commit
396173525b
@ -32,7 +32,8 @@
|
|||||||
<script type="text/x-red" data-help-name="emoncms">
|
<script type="text/x-red" data-help-name="emoncms">
|
||||||
<p>Posts data to Emoncms.</p>
|
<p>Posts data to Emoncms.</p>
|
||||||
<p>The <b>msg.payload</b> can contain either a comma separated list of name
|
<p>The <b>msg.payload</b> can contain either a comma separated list of name
|
||||||
value pairs ex. name:value,... or a comma separated list of values ex. 1,2,.. .
|
value pairs e.g. <pre>name:value,...</pre> or a comma separated list of values e.g. <pre>1,2,...</pre>
|
||||||
|
or a simple javascript object e.g. <pre>msg.payload = {temp:12}</pre>
|
||||||
<p>If Node is left blank <b>msg.nodegroup</b> will used.</p>
|
<p>If Node is left blank <b>msg.nodegroup</b> will used.</p>
|
||||||
<p>Insertion time can be manipulated by setting <b>msg.time</b>.</p>
|
<p>Insertion time can be manipulated by setting <b>msg.time</b>.</p>
|
||||||
</script>
|
</script>
|
||||||
|
@ -43,10 +43,15 @@ module.exports = function(RED) {
|
|||||||
else { http = require("http"); }
|
else { http = require("http"); }
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
this.url = this.baseurl + '/input/post.json?';
|
this.url = this.baseurl + '/input/post.json?';
|
||||||
if (msg.payload.indexOf(':') > -1) {
|
if (typeof(msg.payload) !== "string") {
|
||||||
this.url += 'json={' + msg.payload + '}';
|
this.url += 'json=' + JSON.stringify(msg.payload);
|
||||||
} else {
|
}
|
||||||
this.url += 'csv='+msg.payload;
|
else {
|
||||||
|
if (msg.payload.indexOf(':') > -1) {
|
||||||
|
this.url += 'json={' + msg.payload + '}';
|
||||||
|
} else {
|
||||||
|
this.url += 'csv='+msg.payload;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.url += '&apikey='+this.apikey;
|
this.url += '&apikey='+this.apikey;
|
||||||
var nodegroup = this.nodegroup || msg.nodegroup;
|
var nodegroup = this.nodegroup || msg.nodegroup;
|
||||||
|
Loading…
Reference in New Issue
Block a user