Let me see if I can explain it better.
Option A
agile.py
populates a feed called consumption, which is kWh used per half-hour. A virtual feed that multiplies this by 2000
would give you average power in Watts. This is the “use” feed that “My Electric” app is asking for.
total.py
populates a feed called consumption_total which is the cumulative energy that starts at zero and keeps on going up [great for daily/weekly graphs]. This is the “use_kwh” feed to give to “My Electric”.
So, running both scripts and creating a virtual feed will get you want you need.
Here’s a chart showing consumption_total (from total.py) (aka use_kwh) on the left axis and consumption_watts (virtual feed) (aka use) on the right.
(Plotting the delta of the total on 1800 second interval should perfectly match up with watts)
Option B
Instead of running two python scripts and needing a virtual feed, total.py
could do the conversion and populate both feeds at the same time. I can write this up if you think it would be useful, however…
Option C
Had agile.py
used the input api to upload the data instead of the feed api, then you could created the two feeds with a standard process list:
x 2000, Log to feed → ‘consumption_watts’, Power to kwh → ‘consumption_total’.
Something like this in place of Step 4
and Step 5
in agile.py:
# Step 4: Process history into data array for emoncms
for dp in data['results']:
time = int(datetime.timestamp(datetime.strptime(dp['interval_end'],"%Y-%m-%dT%H:%M:%S%z")))
value = dp['consumption']
result = requests.post(settings['emoncms']['server']+"/input/post",
params={'node':'agile','time':time,
'fulljson':json.dumps({'consumption':value}),
'apikey':settings['emoncms']['apikey']})
You’ll need to change the hard-coded node and input names, making sure the feed has the same name as the input. Once you have it working, empty the feed and run it again so it will download the maximum number of records from Octopus API.
Option C is probably the more typical way of doing things in emoncms, though option B is better for working out-of-the-box. I’ll probably rewrite total.py at some point, and fix the other issues. Hopefully there’s something useful in my ramblings to help you get what you need to get My Electricity app working.