Emoncms - drop time if not a number

and update docs.
This commit is contained in:
Dave Conway-Jones 2015-12-09 13:21:42 +00:00
parent 596736be75
commit bbed4bab9a
4 changed files with 17 additions and 11 deletions

View File

@ -20,8 +20,8 @@
<input type="text" id="node-input-emonServer">
</div>
<div class="form-row">
<label for="node-input-nodegroup"><i class="fa fa-tag"></i> Node</label>
<input type="text" id="node-input-nodegroup" placeholder="">
<label for="node-input-nodegroup"><i class="fa fa-object-group"></i> Nodegroup</label>
<input type="text" id="node-input-nodegroup" placeholder="number eg: 3">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@ -34,8 +34,9 @@
<p>The <b>msg.payload</b> can contain either a comma separated list of name
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>Insertion time can be manipulated by setting <b>msg.time</b>.</p>
<p>If <i>Nodegroup</i> is left blank <b>msg.nodegroup</b> will used.</p>
<p>Insertion time can be manipulated by setting <b>msg.time</b>.
This must be in epoch format - seconds since 1970.</p>
</script>
<script type="text/javascript">
@ -45,7 +46,7 @@
defaults: {
name: {value:"Emoncms"},
emonServer: {type:"emoncms-server", required:true},
nodegroup: {value:""}
nodegroup: {value:"", validate:function(v) {return ((v === undefined)||(/^\d+$/).test(v)); }}
},
inputs:1,
outputs:0,

View File

@ -59,7 +59,7 @@ module.exports = function(RED) {
this.url += '&node=' + nodegroup;
}
if (typeof msg.time !== 'undefined') {
this.url += '&time=' + msg.time;
if (!isNaN(parseInt(msg.time))) { this.url += '&time=' + msg.time; }
}
http.get(this.url, function(res) {
msg.rc = res.statusCode;

View File

@ -16,7 +16,7 @@ Usage
### Emoncms post.
The **msg.payload** can contain either a comma separated list of name
The `msg.payload` can contain either a comma separated list of name
value pairs, e.g.
name:value,...
@ -25,11 +25,16 @@ or a comma separated list of values, e.g.
1,2,..
or a simple javascript object e.g.
If Node is left blank **msg.nodegroup** will used.
msg.payload = {temp:12, humidity:56};
Insertion time can be manipulated by setting **msg.time**.
If *Nodegroup* is left blank `msg.nodegroup` will used (if set).
This should be a numeric value.
Insertion time can be manipulated by setting `msg.time`. This **must** be in
epoch format - i.e. seconds since 1970.
### Emoncms In:
Fetches last emoncms feed value, returns numberical value.
Fetches last emoncms feed value, returns a numerical value.

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-emoncms",
"version" : "0.0.6",
"version" : "0.0.8",
"description" : "A Node-RED node to fetch/post data to/from emoncms",
"dependencies" : {
},