Aldaviva / DadsEnergyReporter

Send monthly electricity usage reports from SolarCity, aligned to Orange & Rockland utility billing cycles.
GNU Affero General Public License v3.0
0 stars 0 forks source link

Determine how much surplus generated electricity is sent from solar panels to utility company #1

Closed Aldaviva closed 6 years ago

Aldaviva commented 6 years ago

If the solar panels are generating more electricity than the house is using, the surplus power will be sent to the power company. If you do this enough in one month, you might end up producing more net electricity than you buy from the utility, so they owe you money and your used meter kWh are negative.

It's useful to report these negative meter readings because it more accurately shows how much of an impact the solar panels have on your power purchased.

Unfortunately, because Orange and Rockland's My Account application is not as good as it could be, the negative meter readings are not reported in the HTML, CSV, or XML billing history interfaces. They all report 0 kWh for negative months. The only place to find the negative readings is the bill PDF, which is significantly harder to deal with than the other formats.

Aldaviva commented 6 years ago

It's possible to read text from a PDF using iTextSharp and a regular expression. The bill PDF could probably be automatically downloaded from Orange & Rockland and parsed with this library.

Unfortunately, this library uses the poisonous AGPLv3 license, which would force this program to change its license from Apache to AGPLv3.

Aldaviva commented 6 years ago

Proof of concept:

var reader = new PdfReader(@"c:\users\ben\desktop\bill 9-18.pdf");

string page1 = PdfTextExtractor.GetTextFromPage(reader, 1, new SimpleTextExtractionStrategy());

Match match = Regex.Match(page1, @"Total Usage KWH \d+ Days (-?\d+)", RegexOptions.IgnoreCase);

if (match.Success)
{
    int consumedPower = int.Parse(match.Groups[1].Value);
    Console.WriteLine($"Consumed Electricity: {consumedPower:N0} kWh");
}
else
{
    Console.WriteLine("No match found.");
}
Aldaviva commented 6 years ago

Done, needs tests.

Aldaviva commented 6 years ago

Added tests.