Friday, 12 May 2023

Very happy with the on-grid electricity being generated

So I'm now generating between 2.5 and 4 units per day depending on how sunny the day is around noon. And to date I've generated around 62 units of electricity most of which is being used by the house.




If I download my 30 minute usage values form Community Power and just looked at the daily and weekly totals for the last year using the Python program listed below:


That was daily for the last year. And this is weekly


Sadly no massive decrease yest even though I'm generating a few units each day. Maybe it's being exported?




# Program to read 30 min energy usage figures downloaded
# in a .CSV fril from Community Power web portal and
# display energy (KWh) used per day

import csv

with open('usage.csv') as csv_file:
    with open('dailyUsage.csv', 'w') as outFile:
        with open('weeklyUsage.csv', 'w') as weekOutFile:

            csv_reader = csv.reader(csv_file, delimiter=',')
            line_count = 0
            out_count = 0
            dailyUsage = 0
            mprnNumber = 0
            serialNumber = 0
            lastDate = ""
            weekCounter = 0
            weeklyUsage = 0

            for row in csv_reader:
                if line_count == 0:
                    if row[0] != "MPRN":
                        print( "ERROR: First colum of first row not 'MPRN'")
                        break
                    if row[1] != "Serial No":
                        print( "ERROR: Second colum of first row not 'Serial No'")
                        break
                    if row[2] != "Date":
                        print( "ERROR: Third colum of first row not 'Date'")
                        break
                    if row[3] != "Time":
                        print( "ERROR: Fourth colum of first row not 'Time'")
                        break          
                    if row[4] != "Usage kWh":
                        print( "ERROR: Fifth colum of first row not 'Usage kWh'")
                        break                              
                    print(f'Column names are {", ".join(row)}')
                    line_count += 1
                else:
                    # We want to accumulate the usage until the day changes
                    # then print it out.
                    # We will also ensure the MPRN and Serial No. does change
                    if mprnNumber == 0:
                        mprnNumber = row[0]
                    if serialNumber == 0:
                        serialNumber = row[1]
                    date = row[2]
                    time = row[3]
                    usage = row[4]

                    dailyUsage = dailyUsage + float(usage);
                    if lastDate == "":
                        lastDate = date

                    if date != lastDate:
                        lastDate = date
                        weeklyUsage = weeklyUsage + dailyUsage
                        # Let's print out our dailyUsage..
                        dailyUsagex10 = int(dailyUsage * 10.0)
                        dailyUsage = float(dailyUsagex10/10.0)

                        dateDay = date.split(' ')[0] # Just get the date part of "30/04/2023 00:00:00"
                        print( dateDay, ",", dailyUsage )
                        lines = [dateDay, ",", str(dailyUsage), "\n" ]
                        outFile.writelines(lines)  
                        out_count = out_count + 1
                        # ..and then reset it to zero
                        # .. write it to a new .CSV file dailyUsage.csv

                        weekCounter = weekCounter + 1
                        if weekCounter == 7:
                            weekCounter = 0
                            weeklyUsagex10 = int(weeklyUsage * 10.0)
                            weeklyUsage = float(weeklyUsagex10/10.0)                            
                            lines = [dateDay, ",", str(weeklyUsage), "\n" ]
                            weekOutFile.writelines(lines)                              
                            weeklyUsage = 0

                        dailyUsage = 0

                    line_count += 1
                    #if line_count > 10:
                    #    break
            print(f'{line_count} lines read and {out_count} line written.')

#f = open("usage.csv", "r")
#lineNumber = 0
#for x in f:
  #lineNumber = lineNumber + 1
  # Expect datas in the format: 18385 10009732581,32467430,02/05/2023 00:00:00,23:30:00,0.06500
  #print(lineNumber, x)
  # So if seperatured by a comma can w

#print(f.readline())
#f.close()
outFile.close()
weekOutFile.close()
csv_file.close()