Git Product home page Git Product logo

agile-blinkt-indicator's Introduction

agile-blinkt-indicator

Display upcoming Octopus Agile prices on the Pimoroni Blinkt! display for Raspberry Pi.

Display in action

Read it from left to right. Each pixel represents a half hour slot, so you get 3.5 to 4 hours of data depending on when you look at it! The leftmost pixel represents the current price. On the half hour, every half hour, everything shifts one pixel to the left.

Magenta is the most expensive, then red if it's under 28p, orange if it's under 17p, yellow if it's under 13.5p, green if it's under 10p, cyan if it's under 5p, and blue if it's a plunge. You can change these quite easily by editing the code.

Hardware needed

Software needed

  • This has been tested on Raspberry Pi OS Buster only.
  • You will need the Pimoroni Blinkt! Python library, https://github.com/pimoroni/blinkt
  • Install the Blinkt! library like so:
curl https://get.pimoroni.com/blinkt | bash

How to use this code

This code runs unprivileged - no sudo required. Copy it to your home directory in a folder of your choice. It will drop a SQLite database file in there when it runs.

Make the files executable:

chmod +x *.py

(https://en.wikipedia.org/wiki/Distribution_network_operator):
A = East England
B = East Midlands
C = London
D = North Wales, Merseyside and Cheshire
E = West Midlands
F = North East England
G = North West England
P = North Scotland
N = South and Central Scotland
J = South East England
H = Southern England
K = South Wales
L = South West England
M = Yorkshire

You should initially run manually to check everything works, replacing X with your DNO region:

./store_prices.py --region X

The code will tell you what it's doing and whether it worked. You can run this as many times as you like without causing too many problems.

Then, a separate command to update the display:

./update_blinkt.py

This will also tell you what it's doing, as well as showing you the colours it is setting. If you want to see all the colours available, you can run

./update_blinkt.py --demo

If it's all a bit much, you can blank the display:

./clear_blinkt.py

Running automatically

I really can't be bothered to make a systemd timer/service for this. cron is so much easier! Run crontab -e and do something like this (don't forget to update your region code:)

@reboot /bin/sleep 30; cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 store_prices.py --region X > ./blinkt.log 2>&1
@reboot /bin/sleep 40; cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 update_blinkt.py > ./blinkt.log 2>&1
*/30 * * * * /bin/sleep 5; cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 update_blinkt.py > ./blinkt.log 2>&1
30 16 * * * cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 store_prices.py > ./blinkt.log 2>&1
30 18 * * * cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 store_prices.py > ./blinkt.log 2>&1
30 20 * * * cd /home/pi/agile-blinkt-indicator && /usr/bin/python3 store_prices.py > ./blinkt.log 2>&1
  • line 1: wait 30 seconds at startup, get new prices
  • line 2: wait a further 10 seconds at startup and update the display
  • line 3: wait till 5 seconds past every half hour and update the display
  • lines 4, 5, and 6: update the price database at 4.30pm, 6.30pm, and 8.30pm to cover late arrival of data

If it stops working, log in and run it manually and see what it moans about!

To Do:

  • better retry if data is late, 3 cron jobs is hacky
  • colours could depend on daily average rather than fixed values
  • configuration options?
  • logging of issues

Thanks to:

Garry Hayne on the Octopus Agile forums (https://forum.octopus.energy) for the original idea
pufferfish-tech's octopus-agile-pi-prices for inspiration (https://github.com/pufferfish-tech/octopus-agile-pi-prices)

agile-blinkt-indicator's People

Contributors

jerbzz avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.