changeset 5:b42baa411817

Display battery_power (which seems to be in milliwatts..?)
author Daniel O'Connor <darius@dons.net.au>
date Mon, 11 Sep 2017 12:39:08 +0930
parents deb3adc4e086
children 2e50426c946f
files agl.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/agl.py	Mon Sep 11 12:32:05 2017 +0930
+++ b/agl.py	Mon Sep 11 12:39:08 2017 +0930
@@ -91,7 +91,7 @@
             date += datetime.timedelta(days = 1)
 
     if args.graph:
-        graph(args.filename, cur, ['battery_charge', 'power_imported', 'power_exported', 'power_consumed', 'power_generated'], start, end)
+        graph(args.filename, cur, ['battery_charge', 'battery_power', 'power_imported', 'power_exported', 'power_consumed', 'power_generated'], start, end)
 
 def mkdb(cur):
     cur.execute('''
@@ -132,6 +132,10 @@
     'site_cons_pv' : 'Watt'
 }
 
+convs = {
+    'battery_power' : lambda a: a / 1000.0
+}
+
 names = {
     'battery_charge' : 'Battery Charge',
     'battery_power' : 'Battery Power',
@@ -199,10 +203,13 @@
     # Convert naive UTC to proper UTC then adjust to local time
     xdata = map(lambda f: f.replace(tzinfo = utc).astimezone(lt), ary[:,0])
     for idx in range(len(cols)):
+        ydata = ary[:,idx + 1]
+        if cols[idx] in convs:
+            ydata = convs[cols[idx]](ydata)
         if units[cols[idx]] == yaxisunits1:
-            ax1lines.append([xdata, ary[:,idx + 1], names[cols[idx]], colourlist[colouridx]])
+            ax1lines.append([xdata, ydata, names[cols[idx]], colourlist[colouridx]])
         else:
-            ax2lines.append([xdata, ary[:,idx + 1], names[cols[idx]], colourlist[colouridx]])
+            ax2lines.append([xdata, ydata, names[cols[idx]], colourlist[colouridx]])
         colouridx += 1
 
     if fname == None: