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