Skip to content

beararmy/Agile-Octopus-Tools

Repository files navigation

Agile-Octopus-Tools

Simple set of tools to aid management / user-friendliness for the agile octopus energy supplier. Focussed on Electric only.

If anyone is going to sign up, please use my referral link and we split £100. https://share.octopus.energy/dusk-wave-115

Features

The bulk of this code is written as functions which can be called in either an automated fashion (ie to periodically check in and get prices, then drop into a DB) or more point in time data (ie what is the current price).

  • Actively Validate mysql and octopus api connections
  • Centralised config in json or php
  • A way to nicely view data on kindle or ipad or an e-ink pi screen
  • Display Current price
  • Display most expensive few hours today
  • Display all of todays prices
  • Display Cheapest few hours today
  • Drop prices into mysql db for later analysis
  • Drop past consumption into mysql db
  • Make it an Azure Function to update DB rather than curl against a webpage
  • Email alerts for following day 'avoid at x, use lots at y'
  • Make data visible to Home Assistant to allow device scheduling
  • Some form of integration with hue, high prices = red light kinda thing.

Prerequisites

What things you need to install the software and how to install them

Working MySQL installation
PHP and your httpd of choice  (Personally, Apache)

Installing

Clone the repo

Configure your DB using DB-setup.sql helper

Update your secrets.php file with your chosen settings as per local comments

Add a cronjob to curl the automated version of the webpage as example in example.cron

visit index2.php for nicely visible data once enough has been pulled in to database.

Built With

Function call examples

// Test: function TestOctopusLogin
$call_url = $base . $emeter . $elec_mpan . "/";
$status_octopus = TestOctopusLogin($api_key, $call_url);
// Test: function TestMySQLLogin
$status_octopus = TestMySQLLogin();
// Test: function GetUsage
print("<pre>" . print_r(GetUsage(), true) . "</pre>");
// Test: function GetUpcomingPrices
print("<pre>" . print_r(GetUpcomingPrices($api_key), true) . "</pre>");
// Test: function InsertUpcomingPrices
$pricesArray = GetUpcomingPrices($api_key);
InsertUpcomingPrices($pricesArray);
// Test: function InsertRecentUsage
$pricesArray = GetUsage($api_key);
InsertRecentUsage($pricesArray);
// Test: function GetTotalCost
$start_date = "2020-01-03";
$end_date = "2020-01-05";
print("<pre>" . print_r(GetTotalCost($start_date, $end_date), true) . "</pre>");
// Test: function GetCurrentRate
print("<pre>" . print_r(GetCurrentRate(), true) . "</pre>");
echo GetCurrentRate()['current_rate_per_kWh'];
// Test: function GetHighestRate
print("<pre>" . print_r(GetHighestRate('10'), true) . "</pre>");
// Test: function GetUpcomingPrices
print("<pre>" . print_r(GetUpcomingPrices($api_key)['results'], true) . "</pre>");
// Test: function GetDaysRatesFromDB
print("<pre>" . print_r(GetDaysRatesFromDB(), true) . "</pre>");

Contributing

Pull requests and issues welcome to guide development!

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Stefan Harrington-Palmer

See also the list of contributors who participated in this project.

Acknowledgments

  • Octopus, who's devs have been great at answering questions I have.