A simple Node-RED flow and Python script to display the current Octopus Energy half hourly dynamic electricity Agile tariff on a RaspberryPi equipped with a Pimoroni Micro Dot pHAT display:
It also provides a web interface using the Node-RED dashboard:
The main functionality is provided by the Node-RED flow, with the Python script just used to drive the LED display.
The Node-RED flow queries the Octopus Agile tariff API to fetch the half hourly rates once per day and caches the prices in a simple SQLite file based database.
The following hardware was used in this project:
- RaspberryPi Zero W comfortably handles this project. I'd strongly recommend using the
W
version for WiFi connectivity. - LED dot-matrix style display, the Pimoroni Micro Dot pHAT. I found this is quite a nice readable display that looks clearer in real life than my photo above.
Create the data basefile file and enter SQLite command prompt:
sqlite3 agile_rates.sqlite
Create the table:
sqlite> create table rates(start_time unsigned integer primary key, cost unsigned smallint);
I recommend installing the latest Node-RED directly from the Node-RED website: Node-RED Raspberry Pi install guide
Run Node-RED as a service:
node-red-start
Open the Node-RED editor in a browser at http://<your pi address>:1880
.
Install the following optional Node-RED nodes from its editor using Menu->Manage palette:
- node-red-node-sqlite
- node-red-dashboard
Load the agile_flows.json
into Node-RED from its editor using Menu->Import.
The current version of the flows has some hardcoded parameters which you may wish to change:
- Path to the SQLite database is by default
/home/pi/agile_rates.sqlite
- Path to the Python script is by default
/home/pi/display_driver.py
The energy tariffs are regional, by default the Get rates subflow function Prepare API has its region variable set to region A, which the Eastern Region. The region code is known as the GSP Group ID and can be looked up either via the Octopus API or using the Wikipedia MPAN Distributor ID table
The Node-RED flow updates the LED display by calling the Python script display_driver.py
, so this could be easily adapted to drive whatever external display you like.
- improve the documentation!
- make the key configuration parameters more easily accessible