Page 1 of 1

Pre-release version with consumption API Support

PostPosted: Mon Jun 08, 2020 3:57 pm
by neilk

This version is the initial release that should only be used if you are prepared to be part of the QA process. It adds to the previous version :-

- Device states for each 30 minute tariff period for the current day (so you can plan usage and track the rates changes for the whole day)

API Features

A new consumption/cost device that retrieves consumption data from Octopus for the previous day and populates it in the same 30 minute period states as the tariff for Gas and Electricity. It can also be configured to calculate the cost for each 30 minute period by associating it with a Tariff device, which you can then also graph etc.


I need to tidy up and restructure the update code, and optimise the API calls for consumption as they only need to be done once a day. Also needs testing over a period as they availability of the data to the API can vary on a daily basis.

Re: Pre-release version with consumption API Support

PostPosted: Thu Jun 18, 2020 2:36 pm
by neilk

This version is now ready for final testing. From the version in the plugin store this now :-

- Publishes 48 states for the tariff device so you can determine future rates, not just the current device state
- Connects to the Octopus API to pull down consumption from your gas and electricity smart meter for the previous days
- Calculates the actual cost by combining the stored rates from yesterday with your actual electricity usage
- Publishes CSV using the timestamp that is compatible with the MatplotLib Plugin (previous version used ISO format)
- Reverses the order in the CSV file (the API default was reversed, this corrects it)
- Places a agile_today.csv in the CSV engine folder to allow Matplot lib plugin to publish a rate chart

As well as better error checking and general updates, If I get any testing feedback I will move this to the plugin store, or when I complete my own testing

Re: Pre-release version with consumption API Support

PostPosted: Tue Jun 30, 2020 4:31 pm
by petematheson
Getting errors at the moment:
Octopus Energy Error exception in deviceStartComm(Electricity Price): local variable 'current_tariff' referenced before assignment

Also strangely the plugin is reporting the current price as 6.615p when it should be 6.97p.
Looks like it's got stuck - Current From Period: 2020-06-30 21:30

Have restarted the plugin and just upgraded to 0.2.10 to try and resolve but no luck so far. Perhaps it'll sort itself out tomorrow?

Re: Pre-release version with consumption API Support

PostPosted: Wed Jul 01, 2020 5:22 am
by neilk
Ocotopus had an issue publishing their next day rates yesterday, and I try and give some headroom by waiting 2 hours after they time they should be published. At the moment this is the first time it has happened and my rather crude "leave a long enough gap and all will be well". I Iast checked at around 8:30 and they were still not available.

You can manually force a refresh on the next update cycle from the plugin menu and that will force a new API call during the next device refresh cycle for all devices and that would sort it in the interim.

I am close to a new version that will add states that essentially say "Best time to run a load for 30 mins/1Hr/2Hr/3Hr/4Hr" and I will look to are slightly more sophisticated retry mechanism in that release as well.

I will also better trap that error, it shouldn't fail like that anyway.


Re: Pre-release version with consumption API Support

PostPosted: Wed Jul 01, 2020 2:53 pm
by neilk

This version should correct the error Pete experienced (I checked my logs and I did not get the error, so had already trapped it) to more elegantly handle a failure of the Octopus API. This version also correct the state and trigger labelling so that the 48 half hourly states can be displayed on a control page or triggered from

I have also added a function to calculate the "cheapest" period to run a specific load for either 30m, lhr, 2hrs, 3hrs or 4hrs and it also has a corresponding cost for that period.

I need to consider the best way to render the time, at present it is a little ugly due to BST and shows with the offset from UTC but this part is work in progress.

Future version will correct to BST/GMT depending on if daylight savings applies.


Re: Pre-release version with consumption API Support

PostPosted: Sun Jul 05, 2020 3:17 pm
by neilk

This version corrects the time rendering issue (The UI value for this state is simply a HH:MM) but the state has the actual time if you wish to manipulate it in a script.

When combined with the Glowmarkt plugin and a hardware CAD you can generate data like this (excuse the crude control page) which updates through the day with rates, consumption and cost as well as showing the best times to run a load.

Screenshot 2020-07-05 at 22.09.42.png
Screenshot 2020-07-05 at 22.09.42.png (216.97 KiB) Viewed 395 times

You can see today had a good spell of "plunge pricing" where I was paid 14p to charge my car, would have been more if the battery was a little lower.

Some final testing and this will be pushed to the plugin store