node-red-contrib-dashboard-bar-chart-data
Advanced tools
Comparing version 0.9.8 to 0.9.9
@@ -18,2 +18,4 @@ module.exports = function(RED) { | ||
clearNode(msg,this,store); | ||
else if (msg.payload.toString().split(' ')[0] === 'set_meter_value') | ||
setMeterValue(msg,this,store); | ||
else if (msg.hasOwnProperty("bar_keys")) //restore | ||
@@ -30,2 +32,19 @@ restoreNode(msg,this,store); | ||
function setMeterValue(msg, myNode, store) { | ||
if(msg.topic == '') { | ||
myNode.error('topic is missing, cannot set the new meter value'); | ||
return; | ||
} | ||
let newValue = Number(msg.payload.split(' ')[1]); | ||
if(isNaN(newValue)) { | ||
myNode.error('new meter value is missing, use for example "set_meter_value 123.45"'); | ||
return; | ||
} | ||
store.set(msg.topic + '_last', newValue); | ||
msg.payload = {}; | ||
msg.info = 'new meter value is ' + newValue + ' for ' + msg.topic; | ||
} | ||
function clearNode(msg, myNode, store) { | ||
@@ -32,0 +51,0 @@ var topics = store.get('topics')||[]; |
{ | ||
"name": "node-red-contrib-dashboard-bar-chart-data", | ||
"version": "0.9.8", | ||
"version": "0.9.9", | ||
"description": "Transforms sensor measurements or meter readings to be displayed in dashboard-chart as bar-chart", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/arneman/node-red-contrib-dashboard-bar-chart-data", |
@@ -69,2 +69,10 @@ # node-red-contrib-dashboard-bar-chart-data | ||
<h3>Set (start) meter value</h3> | ||
<dl> | ||
<dd>A message with the payload "set_meter_value 123.45" will set the (start) value for the topic to <code>123.45</code>. | ||
The calculation of the difference between the new and the previous meter reading value will be skipped. You can use | ||
this when your old meter is replaced with a new one and the values begins from 0 (again). | ||
</dd> | ||
</dl> | ||
<h3>Restore</h3> | ||
@@ -71,0 +79,0 @@ <dl> |
70483
319
113