I’ve got solar PV, battery storage, an ASHP and an EV. Finding the right energy tariff to get the most electricity for my use isn’t straightforward. I’m with Octopus Energy, and they have a whole load of different tariffs.
Fortunately, Octopus being the modern sort of a company, they have an API which customers can query and, fortunately, there’s an R package OctopusR which interfaces with that API to make my life easy. I’m going to use that package to look at my electricty usage over the last year and hopefully optimise my tariff choices and battery settings.
Methods
The OctopusR package is available on CRAN, the code is on GitHub and there are nice github pages on the package here.
To access the API, you need the API key for your account, the MPAN numbers for your meters and the meter serial number. There’s documentation on the API on the Octopus developer pages and Guy Lipman has a nice write-up on his blog.
If you have PV, then you have two MPAN numbers, one for import from the grid and one for export. Octopus don’t tell you which is which, but the data make it obvious.
I’m going to use the get_consumption() function to pull my consumption and export data for the calendar year 2024 into R and do some basic calculations with dplyr. With that data, and some transcribed data about tariff costs for my local area I should be able to find the best tariff for me.
Code
library(octopusR)library(dplyr)library(ggplot2)library(viridis)library(lubridate)# I've got my api key and mpan numbers stored in text files so that they're not exposed here.set_api_key(readLines(con ="../api_key.txt"))set_meter_details(meter_type ="electricity",mpan_mprn =readLines("../elec_mtr_mpan.txt"),serial_number =readLines("../elec_mtr_srl_num.txt"))exp_mpan <-readLines("../elec_mtr_mpan_exprt.txt")# consumption dataelec_use <-get_consumption(meter_type ="elec", tz ="GMT", period_from =dmy("01-01-2024"),period_to =dmy("31-12-2024"), group_by ="hour") %>%mutate(mnth =month(interval_start), hr =hour(interval_start))head(elec_use)
There is an API endpoint that gives prices for the Agile and Go tariffs, but there isn’t an R function for that yet, so I haven’t used it here. I have checked the Octopus website for the current (late February) prices for my local area (East England).
So, with the Intelligent Go tariff, I could have saved myself £206.5 (15.1%), which is rather less that I had hoped for.
However, I haven’t factored in the daily standing charge, but these are the same for both tariffs at 48.70p / day.
Savings by altering my battery plan
I’ve got a 10 kWh battery system. If I set that to charge on a cheap overnight tariff and then discharge it when that cheap overnight tariff runs out, how much will I save?
I’m not quite sure how to calculate this, but if, per day, my kWh is > 10, I can shift that 10 kWh to the night time load.
So, below I’ve generated an altered consumption column where the load is 10 kWh lower if it’s in the peak period for Intelligent Go and 10 kWh higher in the off-peak period and then used these values to calculate the cost in £.
Over the year, this would sum to £920.88 on the Intelligent Go tariff. A further saving of £242.79.
Discussion
I can save myself £449.29, assuming that my energy use is similar in 2025 to my use in 2024. I did buy an EV in May 2024, so that may alter the total consumption, but it is only likely to tip it further in favour of Intelligent Go since I can schedule the EV charging for the cheap overnight rate. Scheduling consumption to early in the morning has the added advantage of less carbon-intensive too.1
One thing that I haven’t modelled here is the effect of charging the batteries at the off-peak rate in the summer. In those periods, I’m probably not going to exhaust the batteries before charging starts (unless the ashp is on a Legionella cycle or a hot-water cycle) and thus a, it won’t take the full 10 kWh from the grid to reach max charge and b, I’ll start exporting to the grid a lot earlier. This is beyond what I want to spend my spare time on but means that the savings presented here are likely to be slightly underestimate the actual savings.
I love the fact that Octopus Energy have an API where I can check this sort of thing. I also love the fact that someone has been nerdy enough to write an R package to make it easy to interact with the API.
I think my analyses here are accurate, but if you spot any errors please create an issue on the github repo.