pufferfish-tech / octopus-agile-pi-prices

Display the upcoming prices on the Octopus Energy "Agile" tariff.
Apache License 2.0
85 stars 27 forks source link
agile octopus octopusagile pimoroni prices raspberry-pi

octopus-agile-pi-prices

Display the upcoming prices on the Octopus Energy "Agile" tariff.

What does it do?

Octopus is an energy provider in the uk. Agile is a package they provide with half hourly energy prices. https://octopus.energy/agile/ Amazingly they offer an API to allow us nerds to code things.

Yeah but...what does it do?

It's for displaying current prices. It runs in python on a raspberry pi. This is great because it means you don't need to install anything*. The current version of Raspbian has the two things it needs: python and SQLite.

image of it working here -> https://imgur.com/hymxfbq

There's 2 versions right now. The first one I wrote was for the pimoroni "display-o-tron" hat, which is a three line LCD with RGB frontlighting. It's good, but it's not graphical, and it made a whine noise (a fault in my unit).

So I wrote a second version for the pimoroni inkyphat https://shop.pimoroni.com/?q=inkyphat. This is silent, doesn't self light, consumes no extra power, and oh, it looks awesome!

(* other than the libraries for whatever display device you want...)

What do I need?

currently:

Preparing the pi

This is actually more of a tutorial on what I've found to be the best way to just set up a pi to run arbitrary code without the hassle of a mouse keyboard and monitor. It's the path of least resistance!

Once imaged, put the SD card in your Pi and wait a while for it to boot (it can take 5-10 minutes). It should connect to your wifi, then you can ssh to it using ssh <username>@<hostname>.local replacing the username and hostname for those entered when imaging

Once you have an ssh terminal, you can get started with setting up our project

Installing

You'll need to obtain some information from Octopus for the next step. Go to the octopus developer page and scroll to "Unit rates". There you will see a URL, for example "https://api.octopus.energy/v1/products/AGILE-FLEX-22-11-25/electricity-tariffs/E-1R-AGILE-FLEX-22-11-25-M/standard-unit-rates/". Look at this part: "E-1R-AGILE-FLEX-22-11-25-M". This is in the format E-1R-AGILE-<tariff>-<region>. The tariff is the part following "AGILE-", e.g. "FLEX-22-11-25". The region is the letter at the end, e.g. "M".

Now its time to test our scripts:

You should see your display update with the current price!

Set up cron to update regularly

NOTE: If you are using the DOThat, you need to edit the above to use octoprice_main_dot.py instead of octoprice_main_inky.py. You will also need to run pimoroni's one line curl install script for the DOThat instead of inkyphat. You can go find that yourself, it exists :)

Another NOTE: I tried to make this code simple and readable. If you see any issues let me know.

Considerations

Future Work

Final note

If you do appreciate this code and are thinking about joining octopus, I'll leave my referral link here https://share.octopus.energy/rust-heron-863 - We both get £50 which is pretty spectacular.

Also if you're into home automation or random tinkering then subscribe to my youtube stuff here -> https://www.youtube.com/channel/UCl_uGYJe9KW9fJWBMq1A9kw