node-red-contrib-energymeterplus 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/energyMeterPlus.js +13 -11
  2. package/package.json +1 -1
@@ -7,7 +7,7 @@ module.exports = function(RED) {
7
7
 
8
8
  let unitCost = Number(config.unitCost) || 0;
9
9
  let filePath = config.filePath || "/addon_configs/a0d7b954_nodered/node_red/solarGen_data.json";
10
- let inputUnit = config.inputUnit || "W"; // default to Watts since your stream is in W
10
+ let inputUnit = config.inputUnit || "W"; // default to Watts
11
11
 
12
12
  // Numeric baseline corrections
13
13
  let baselineDaily = Number(config.baselineDaily) || 0;
@@ -58,16 +58,18 @@ module.exports = function(RED) {
58
58
  let monthly_cost = baseline.monthly * unitCost;
59
59
  let yearly_cost = baseline.yearly * unitCost;
60
60
 
61
- // Build Output
61
+ // Round all outputs to 2 decimal places
62
+ function round2(val) { return Number(val.toFixed(2)); }
63
+
62
64
  msg.payload = {
63
- daily_kWh: baseline.daily,
64
- weekly_kWh: baseline.weekly,
65
- monthly_kWh: baseline.monthly,
66
- yearly_kWh: baseline.yearly,
67
- daily_cost,
68
- weekly_cost,
69
- monthly_cost,
70
- yearly_cost
65
+ daily_kWh: round2(baseline.daily),
66
+ weekly_kWh: round2(baseline.weekly),
67
+ monthly_kWh: round2(baseline.monthly),
68
+ yearly_kWh: round2(baseline.yearly),
69
+ daily_cost: round2(daily_cost),
70
+ weekly_cost: round2(weekly_cost),
71
+ monthly_cost: round2(monthly_cost),
72
+ yearly_cost: round2(yearly_cost)
71
73
  };
72
74
 
73
75
  // Save snapshot
@@ -79,6 +81,6 @@ module.exports = function(RED) {
79
81
  }
80
82
 
81
83
  RED.nodes.registerType("energyMeterPlus", EnergyMeterPlus, {
82
- color: "#228B22" // Forest Green
84
+ color: "#d9910cfe" // Dutch Orange
83
85
  });
84
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-energymeterplus",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
4
4
  "description": "A node-red energy meter node with editable baseline data, milestone summary, and cost calculation",
5
5
  "author": "Arcfrankye",
6
6
  "license": "MIT",