Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Python script to import Octopus Agile consumption data into emoncms

Reasonable, but did try to connect via SSH but it came back with connection refused so not sure what I was doing wrong or what I should do if it did let me in

John

@borpin

Per yr request in another thread – here’s my variant on Trystan’s great Python script to download historic Octopus Agile 30 mins consumption data. It now includes CUM consumption.

octopus_consumption_TL+JB.zip (1.8 KB)

I’ve removed personal info.

And you’ll probably want to prune my verbose comments – just memory joggers for me.

If you’ve already downloaded historic data, running this new script will not re-download it. So temporarily change the 0 on line 37 to 10000 to work around this problem.

Setting up FEEDs is a bit of a hassle – but you don’t need to do that just to try out this script – just run it under Python3 in an SSH terminal.

These screenshots illustrate the end result …

1 Like

If to the emonbase, what user/password combo did you use?

@borpin

OOPS!
My revised script resets the CUM each day as the previous day’s history is added.
And that kinda defeats the object
I’m on the case …

I’d had a look and was wondering. You need the last data value out of the feed as your starting point!

https://YOURIP/feed/value.json?id=1

@borpin

I fixed the problem with the cum starting point yesterday - both for first run and subsequent runs.
And yesterday with two fresh empty feeds, it ran OK.
And the daily cronjob ran successfully this AM - the previous cum advanced - so good to go …

octopus_consumption_TL+JB_v2.zip (1.8 KB)

Recommendation - if you’ve previously run Trystan’s original script and only have daily data, it’s best to create two fresh empty feeds before running this modified script.

1 Like

managed to get in to SSH now (was not enabled) Any help with what to do now. I suspect I need to copy the script somewhere first (onto the EmonPi), not a clue how to do this I can then see that you run the command to set it to run at the prompt. Sorry for being so daft :frowning:

John

@TrystanLea, can you drop this into UsefulScripts please?

Done: usefulscripts/octopus at master · emoncms/usefulscripts · GitHub

I’ve added this in

I havent added this in yet.

I use the Octopus Agile emoncms app to do this.

Yes

I’ve added the script to the usefulscripts repository as @borpin suggested.

Here are the steps to use the new location:

1. Run Emoncms update to pull in the latest version of the usefulscripts repository

2. SSH onto the Pi and navigate to the agile script directory:

cd /opt/emoncms/modules/usefulscripts/octopus

3. Create config file from default:

cp default.agile.conf agile.conf

4. Enter configuration including emoncms apikey and authentication and meter details from Octopus

nano agile.conf

5. Run script for the first time to pull in data:

python3 agile.py

6. Run script from crontab every morning to pull in latest data:

30 9 * * * /usr/bin/python3 /opt/emoncms/modules/usefulscripts/octopus/agile.py > /dev/null 2>&1

This example runs the script at 9:30am every morning, consider changing the exact timing to reduce simultaneous load on the octopus servers from lots of pi’s calling this script at the same time (Probably not an issue but hey…)

1 Like

But it doesn’t ‘compare’ it just uses it instead? I was hoping for a means to check the accuracy of the measured figures. I couldn’t work out how to do it on the Graphs.

I have worked out that the easiest way to check between 2 accumulating feeds, is to graph one on the left scale, one on right and compare the diff figure in statistics. Once I have that I can then apply a scaling multiplier in the Input Process. Has been quite successful.

Perhaps this could be done as an app where you can select 2 (or more) different feeds for comparison (e.g. Agile, Pulse, CT)?

1 Like

If you open the browser console window on the emoncms app, it prints this information out:

1 Like

Good idea as well!

I seem to be getting quite a few data outages on my half hourly data from the smart meter, i often have full days missing, but then clearing the feed and re-running the script from the start seems to pull the missing historic data in again… do octopus query for this missing data at the end of the month/week?

At the moment Im missing new data since the September 24th and am missing both 21nd and 22nd of September but older missing days have now appeared after I cleared the feed and re-imported from the start…

Processing a cumulative feed from this would require going back and reprocessing when the missing days become available… will have to think how best to do this…

I haven’t tried the script yet but FYI my Octopus (Go) data has frozen
on the website since the 24th September too so there may be a wider issue.

1 Like

Oh that is obvious… :rofl:.

1 Like

I think Octopus are having issues. I have an open ticket re missing data and they say it isn’t just me.

1 Like

I did mention it in the other thread on the agile app Octopus Agile emoncms app - #111 by TrystanLea but I dont blame you for not seeing it. This and the comparison feature needs to be added to the guide documentation…

1 Like

Should probably just include the info below the tickbox selector…

1 Like

I’m noticing a few gaps too - it’s at the Octopus end, usually. They sometimes need a chase, but they will have to re-fetch it before a bill is issued. It is the subject of some debate on the Octopus Agile forum atm.

FWIW I wrote a Node-RED flow that will backfill data for the missing slots, if that’s useful to anyone. It uses the same method as the editrealtime visualisation (ie. pokes it in via the update url, rather than the input one). Works well for me so far. Needs moderately careful handling insofar as you need to put the period from/to in correctly, and I’m longing for a decent ‘calendar style date-picker’ to refine the Node-Red flow somewhat - but it works…

Shout if wanted. Not sure whether to just post it here or whether that’s a breach of local etiquette.

1 Like