Git Product home page Git Product logo

agile-octopus-tools's Introduction

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.

agile-octopus-tools's People

Contributors

beararmy avatar

Stargazers

Andy Edwards avatar Chris B avatar Ian Hampton avatar  avatar

Watchers

James Cloos avatar Andy Edwards avatar  avatar

agile-octopus-tools's Issues

New table for summaries

I notice that when we're looking for more daily summaries (bottom left) the page takes some considerable time to load. Consider generating these as a background process, or at least on First load rather than every time.

config

I'm hungry for user config. I think a simple way to do this is to have a box of user configurable items. probably dropped as a cookie.

timezones still not 100% somewhere

To me this implies that either data going in, or during retreival is incorrect. Please ensure that everything is UTC (given there's currently no browser modification to local time).

2020-06-17 - 0.27 using 0.892 kWh

Too lazy to scroll

I am too lazy to scroll. It's a repeated and wasted action. When I load the page after about midday (browser size dependant) I have to scroll in the SE corner to see the current price and adjacent prices. It would be better if the page would automatically load that div at the current time.

inconsistent values

I have just checked the index2.php page and can see that;

13:30 - 14:00 is £0.08 GBp per kWh

Current rate (right now!) £0.07 per kWh

This may be a rouding issue somewhere or an adjacent value although '13:30 - 14:00' both directly adjacent values are 0.08 so this seems unlikely.

| 2520 | 2020-01-17 13:00:00 | 2020-01-17 13:30:00 | 7.1800 | 7.5390 |
| 2519 | 2020-01-17 13:30:00 | 2020-01-17 14:00:00 | 7.1800 | 7.5390 |
| 2518 | 2020-01-17 14:00:00 | 2020-01-17 14:30:00 | 7.1800 | 7.5390 |

All values should be displayed from the including VAT number. Maybe this is our issue and we're rounding up / down respectively?

efficiency

When running the automated=yes flag we're still sending the first 13 lines of html to display which are then getting thrown on the floor (or much more likely into a /var/mail box. This should probably only output basic diag (or nothing) to the user.

Get-OctopusUpcomingRates no worky on linux

Looks like I'm assuming the date will always return as yyyy-MM-dd, which on my windows build it does, not on fedora though, suspect $result contains a system formatted date. Get-Date with that in mind.

Correct line highlighting

Around 23:50 last night I checked electric prices and the correct line was not highlighted in red as happens throughout the rest of the day.

post time-zone change, summaries are collecting two days data

I've noticed that now we're in summertime (gmt+1) data would appear to be gathering the hour from the day before. My guess would be that SQL statements are not using GMT/0. Data is being put into the DB in GMT/0 but is being pulled out in Local, now GMT+1.

2020-03-31 - £0.36 using 2.785 kWh
2020-03-30 - £2.54 using 30.165 kWh

cronjob is mental.

* 5,11,17,23 * * *

Seriously, go home and think about what you've done.

tidy up api calls

According to documentation;

Page size of returned results. Default is 100

Assuming this we're returning 100 results every time and really only ever looking for the last 48 segments.

not displaying local time

I see from your wonderful code that everything internal now talks in UTC/0, currently I'm UTC/+1 and would like to see things in my local time.

recent mariadb updates have broken data being inserted into the DB

recent mariadb updates have broken data being inserted into the DB. Went up a few major versions. Looks like the older version of mariadb was happy to INSERT the js formatted date that comes from the Octopus API. munged this so it will always be in an acceptable format and will convert via strtotime so also roll in the timezone modifier.

Washing Window

I'd like to be able to see a (user defined) length window of the cheapest electric for the day.

Just a simple "Today's cheapest 4 hour window is 1800-2200" kind of thing.

Consider using LEAD and LAG for this.

duplicate lines highlighted

The time is now 14:00, in the SE corner, two lines are highlighted as current.

13:30 - 14:00 is £0.075390 GBp per kWh
14:00 - 14:30 is £0.075390 GBp per kWh

some forward planning please

When I am trying to schedule things like heating and washing it'd be nice to be able to see into the next day's prices. Please either add another SE column to show tomorrow, or simply append them to the bottom of the list.

reconcile

Please reconcile data against a bill as numbers don't line up 100%

error in logs

I think there's still an issue, seeing the below errors in logs and also data is not updating.

2020-06-26T07:51:30.615827285Z: [ERROR] [Fri Jun 26 07:51:30.615723 2020] [php7:warn] [pid 122] [client 172.16.0.1:27344] PHP Warning: Invalid argument supplied for foreach() in /home/site/wwwroot/index.php on line 170

currentrate highlights twice

After 1600 when we pickup tomorrows numbers, currentrate now has two matches because it's only based on time.

Only applies when $allfuture is true

Split out API based information and DB held information

There is currently no obvious difference where a function will get information from (ie database or directly from the octopus API). This should be made more clear and give the possibility of people being able to use the functions without having to have a database configured.

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.