Skip to content

Octopus Agile

Octopus Agile is an Octopus tariff which allows you to plan your usage for your current day, the pricings are following wholesale prices so you can take advantage of the fluctuations during the day and night while prices drop.

Configuration

  • prices_to_include is the number of the cheapest half hourly periods that you want to include
    • this can be a function (as defined in custom prices to include)
    • or simply just an integer value between 0 and 46 ( a full day 0:00-23:00)
  • action_when_cheap is your function that is called when the half hourly period is among the cheapest
  • action_when_expensive is your function that is called when the half hourly period is more expensive than the cheapest
  • pricing_strategy is a custom class you can pass in to act on prices in a more complex way (this is covered in custom pricing strategies)
  • api_key a secret key that gives the script access to fetch your most recent tariff (do not push this to git or share with anyone)
  • account_number your account number for a supported supplier and tariff
How do I get my account number & API key?

Go to octopus.energy and sign in, then follow these steps after clicking the menu button on the home page.

clicking the menu navigation in the top left, then navigating to my account image showing that you should copy the account number from the field under your name, and then selecting personal details under it to get to next step after clicking personal details, you should scroll down to developer settings and then click API access then copy the API key that is in the field, this should read like some nonsense characters

A best practice is to place these in a .env file, and bring them in with python-dotenv, be sure to put .env in a .gitignore file.

How often are my actions called

The actions happen every 30 minutes, if the price is cheap then action_when_cheap is called, if it is expensive then action_when_expensive is called.

There is a 10 minute grace period on an action missing your current time from when you begin the schedule initially.

Usage

# main.py
from energy_tariff_scheduler import runner, Price

def action_when_cheap(price: Price):
    print("cheap", price.value)

def action_when_expensive(price: Price)
    print("expensive", price.value)

runner.run_octopus_agile_tariff_schedule(
  prices_to_include=12,
  action_when_cheap=action_when_cheap,
  action_when_expensive=action_when_expensive,
  api_key="YOUR-API-KEY",
  account_number="YOUR-ACCOUNT-NUMBER"
)