raindarr / wattdepot

Automatically exported from code.google.com/p/wattdepot
0 stars 0 forks source link

Handle energyConsumedToDate counters that decrease #127

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When retrieving data from an eGauge meter, it is possible to have an energy 
odometer value that is positive but decreasing. This violates WattDepot's 
assumption that odometers increase monotonically, and prevents all energy 
calculations from succeeding.

To handle this unusual case, the eGauge sensor could have a configuration 
parameter that causes the received meter data to be modified before storing in 
WattDepot. The sensor would retrieve the latest SensorData from WattDepot, 
extract the (positive) energyConsumedToDate value to use as a starting point. 
Then the odometer value from the meter would be subtracted from the starting 
point to determine how much energy has been used since the last sample, and 
that difference would be added to the starting point and stored as 
energyConsumedToDate in a new SensorData to be sent to the WattDepot server. 
This will preserve the monotenacity of the energyConsumedToDate counter, but 
will mean that the energyConsumedToDate will not match the actual odometer 
value from the meter, which is something that we have tried to preserve in the 
past. The sensor will need to remember the last energyConsumedToDate value to 
difference with each new incoming value.

Note that when the Source has no SensorData (first meter data), the starting 
odometer value can be whatever the meter value is.

Original issue reported on code.google.com by rbre...@gmail.com on 15 Sep 2012 at 10:40