Octopus Energy Agile Tariff

@baz123 at the moment it doesn’t, as I haven’t run in to that. I could add a timeout to the requests.get command and put it in a try: except: block to handle any exception, then maybe either retry after 60 seconds or skip the update until the next time callback, in ~30 mins I guess.

@badguy any way to make it only show todays cheapest price (even if its in the past). Want to use the start time to set my automation to charge my solar battery out of hours at the cheapest time possible?

@james_hiscott
Changing the d= and r= lines to be as follows should show it even if it is in the past:

d = datetime.date.today().isoformat()
r = requests.get('https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-H/standard-unit-rates/?period_from=' + d + 'T00:00:00')

However if you are running this after 4pm it will show tomorrow if it is cheaper than today, if you don’t want that, set r= to the following instead:

r = requests.get('https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-H/standard-unit-rates/?period_from=' + d + 'T00:00:00&period_to=' + d + 'T23:59:59')
1 Like

@badguy

Am i reading it right, the sensor created will be the best “x” minutes of the day (whatever i set in the apps.yaml) up to 4pm on that day, then after 4pm with be the best up to 4pm the next day?

I think it was mentioned before and am looking for the same. I need to find the best time slot(s) to charge my batteries connected to solar panels/inverter, which I guess will be at night but could be good to top up during the day if the price drops

Also looking at automating the time on my immersion heater when the price is low during the day

@matthewjporter yes basically, it is in hours rather than minutes, just because they use half hour blocks. Octopus publish the next days tariff between 4 and 7pm, though it is usually around 4pm. So just before 4pm their website was showing the following for me:


so I’m currently looking at the right hand tab, and the sensors I’ve written were giving me the following:

The data goes up to 23:00 so for example, the latest the 3 hour time period could start with data ending at 11pm is 8pm, which is what it was showing for the best price.

Now it has gone past 4pm, and the data has been updated, the website is showing the following:


i.e. now looking at the left tab for today and the right tab is tomorrow. The data their API provides, is also updated, so now my sensors are showing:

So based on the new data, the best 3 hour price is now 12:30 tomorrow. Though it could be any time up to 23:00 tomorrow.
Hope that helps.

I’ve been fiddling with a Node-Red node to do something similar.

It is still rather rough round the edges, but it seems to work though (and perhaps as it may be a different region), I’m getting different answers. It could be my maths is wrong of course :grinning:. I have though pulled it into Excel to check.

Personally I also wanted the current price and the next price to display. I’ll probably use a template to pull it in from MQTT for now as I will use it elsewhere as well.

{
	"current_price": 6.174,
	"next_price": 7.7175,
	"min_price_inc_vat": 4.1895,
	"max_price_inc_vat": 24.8745,
	"min_blocks": [{
		"min Block Price": 4.19,
		"min Block valid From": "2020-03-17T04:00:00Z",
		"min_block_size_mins": 60
	}, {
		"min Block Price": 4.47,
		"min Block valid From": "2020-03-17T03:30:00Z",
		"min_block_size_mins": 120
	}]
}
2 Likes

@badguy
Got it, Cheers

I am test driving it at the mo to see as I have not switched yet

One question, how would you do an automation based on the best price per time

I haven’t really played around with this yet, but maybe something along the lines of the following trigger for the automation:

trigger:
  platform: template
  value_template: >
  {% if (states("sensor.date_time_iso") + "Z") == (states("sensor.octopus_1hour_time")) %}
    true
  {% endif %}

This would need Time & Date - Home Assistant configured too.

1 Like

I’ve updated the code again and put it here:

I’ve also created this:

The README.md files in the repos are up-to-date, the region letter can be set in the apps.yaml now as well, and they are also integrated with https://hacs.xyz/ so can be installed into Appdaemon through HACS. The repositories are now part of the HACS default repositories.

2 Likes

Just got them from HACS thanks @badguy do you just use the REST API to get the current price or not bother with that? was wondering if it was a logical extension to your octoblock sensors?

The octocost one is independent of the octoblock one - it calls:
https://api.octopus.energy/v1/electricity-meter-points/(MPAN)/meters/(SERIAL)/consumption/
and
https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-(region)/standard-unit-rates/

The octoblock one just calls the tariff api.

1 Like

Sorry, i was meaning, maybe the octoblock could pull the current tariff price for this current 30mins (as an extension to what it already does.

Oh I see :slight_smile: I didn’t include that as I’d used the bit @dmgreen had added at the top of this thread. That works nicely for me.

@badguy

Awesome. Now using HACS

Thanks for the great work. Any chance you might be working to make this a component?

I’ll take a look into it. I wasn’t planning it when I wrote the code initially, I just wanted to get something working. But I guess I’ll have plenty of spare time with everything going on now :mask: :woozy_face:

Hi Dave,

I’m just to use your Curl command in terminal but getting a syntax error.

I’m trying to adapt this for Webcore so I can pull the current result and (for the sake of SmartThings and Homekit) make it apply to a virtual dimmer switch.

Could anyone help?

I’m about to change supplier, considering this. Aside from the ‘leading edge’ automation interest how happy are you with this tariff and approach , and I guess supplier but Octopus seem ‘OK’

Also, and you may not have this information, if you hadn’t, or couldn’t change your usage pattern how do you feel the tariff would have fared ?

I have about 1.5KWHr constant usage 24hrs and then the usual household additions during an offset daytime of noon to midnight. £2500 annually - too much tech ! I’m thinking if going without management that might benefit me as a disproportionate offpeak usage. But I don’t have Economy 7 (gas here)

@xAPPO I’ve been impressed with them so far, and the Agile Octopus tariff itself. There is a tool near the bottom of this page - https://octopus.energy/agile/ - which shows general usage patterns and shows that you should still save.

I would say we’ve managed to move when we use the dishwasher and washing machine, but haven’t made many other changes and it is still working out a good amount cheaper than what our previous supplier would have charged. I’ve definitely enjoyed writing the octoblock and octocost apps to work in Home Assistant and then use them to trigger certain things to turn on, like charging the cordless hoover, plus having information on running costs. We are also on gas heating.

Also their referral is pretty good, if you use my link - https://share.octopus.energy/dense-ape-125 - we’d each get £50 credit.

If I do of course I will as I appreciate people who contribute such code.

Looking at the home based battery storage solutions , not specifically Tesla PowerWall , do you think they have any commercial merit here ? Even on near break even as it satisfies a tech rush for me.

Covering that 24hr 1.5KWHr at lowest possible rate I guess is the best approach. I know … turn things off but I like flashing LED’s.

Being a listed building solar has not been an option, nor double glazing… but rates come in abundance.

I definitely think a battery storage solution would be interesting. It is something I’m likely to look at in the future, I just haven’t had the time (or finance) to do it at the moment. Either to charge up when the price is low, and then use for the house when the price is high, or possibly sell back to the grid when the price is high, as there is also an Outgoing Agile tariff to make the most of selling back to the grid when the price is high.
I had a very quick look at https://www.powervault.co.uk/ but I need to do more research.