Octopus Energy Agile Tariff

Hi. I managed a little while ago to get a dashboard set, I also found the powerwall api percentage not matching with the app.

Apparently there is around a 5% reserve (additional to the reserve we can set in the app) so to get a better match you need to do 95/100 of the api reported percentage (though this still drifts when below 30% soc).

Have you found a way to switch your PW to backup mode based on the agile pricing, either current or future?

I can pull stuff from the tesla api, but does it accept post to change the mode?

Yep using the Tesla powerwall custom component I can set it backup only (pulls from the grid) when ever it is less than £0.05 and less then 80% full or negative (I get paid £0.05 outgoing so even if we overfilled the battery it’s still free)

Hi, would you mind sharing how you did this to an absolute beginner?

I’ve got a dashboard showing the stuff I can pull, like powerwall charge, solar incoming and octopus current price.

Can you advise how you took the octopus price and used this to change the powerwall?

As a beginner with HA I’m just about confident in pulling stuff from an api to a sensor, but sending commands based on other sensors and getting it to do this every half hour, or building a schedule for the next 24 hours etc is my next step of learning.

@Hodor I can’t give you and example with power wall, but I’ve put an example with managing gas vs electric heating of hot water, which should give you an idea of how it can hang together. Setting up automations is definitely the next step with Home Assistant, once you’ve got sensors and a dash board showing you information.

- id: '1586467604242'
  alias: 'Hot Water: Turn on electric heating when price is zero or lower'
  description: When Octopus Energy Electricity is 0p or below turn on the immersion
    heater
  trigger:
  - below: '0.01'
    entity_id: sensor.octopus_current_price
    platform: numeric_state
  condition:
  - condition: device
    device_id: ec8b195c0eaa48f68894f852130bdbe5
    domain: light
    entity_id: light.water_heater_controller
    type: is_off
  action:
  - device_id: ec8b195c0eaa48f68894f852130bdbe5
    domain: light
    entity_id: light.water_heater_controller
    type: turn_on
  - data:
      data:
        subtitle: Water Heater Controller
      message: Water Heater switched on! Electricity Free!
      title: Smart Home Alerts
    service: notify.mobile_app_phone
- id: '1590948945751'
  alias: 'Hot Water: Turn off gas schedule hot water if electric is going below zero
    within 12 hrs'
  description: ''
  trigger:
  - entity_id: sensor.hw_via_electric_not_gas
    from: 'False'
    platform: state
    to: 'True'
  condition: []
  action:
  - data:
      entity_id: water_heater.downstairs_thermostat_hot_water
      operation_mode: 'off'
    service: water_heater.set_operation_mode

So these two automations are used together.
The 2nd one uses a lookahead sensor created from https://github.com/badguy99/octoblock/ This sensor returns true or false, depending upon if the Agile Octopus price will go below zero at any point in the next 12 hours. If it will it turns off the gas fired hot water, so that that doesn’t fire up when following its normal schedule and heat the water.

The 1st automation then switches on the immersion heater (via a smart socket controlling a contactor) when the current Agile Octopus price is 0 or below.

I also have another 2 automations that work the other way around, to turn off the immersion heater and turn the gas scheduled hot water back on.
Hopefully this at least gives you a starting point in to automations.

Dont know what Im doing wrong but I cannot get this rates card to work at all. I cant get it to create the octopusagile.rates entity.

copied the repo into custom components, renamed as per instructions, copied the config into apps.yaml, restarted both appdaemon and the HA server, still no joy.

My mistake, altered the config yaml and waited for the refresh on the half hour, prices now pulling through just fine.

1 Like

Hi, I see the octopusagile.rates entity updates every half hour. Is there a way to get this to populate after a restart without having to wait until the half hour - Im a beginner and as I keep adding/removing/learning things I find myself restarting the server quite frequently.

Many thanks, an appreciate this is not a strictly octopus agile related question.

You can run the octopusagile.half_hour service and it will populate. I will put an issue in github too as it would be better if it just ran itself on first run or stored the info and reloads after a restart as it does for some of the other data it generates.

Appreciate it. Thank you.

As a beginner, Ive just managed to set up an automation to start my car charging when prices go negative - Ive tested it and it works! negative prices tonight too so brilliant timing.

As a beginner Im really pleased Ive managed to get something like this working!

3 Likes

Could you let me know how exactly this can be done? I looked at the powerwall integration but cannot see anywhere to change the mode.

1 Like

Sounds awesome, would you mind sharing what you did to achieve it? Like you and as a beginner this is all a bit confusing!! I want to be able to do what you have for the car charging and powerwall. Thanks

So managed to work out how to get the powerwall switching mode on an automation, very powerful stuff this integration!

@im85288 glad you worked out it, sorry busy weekend. FYI its always worth posting how you solve the problems so others looks at this know how. For anyone interested the component is in post 6 on this thread: Add support for Tesla Powerwall

Once you have that setup you can add an automation to run the following:

image

and the reverse (backup) to get it to pull from the grid. If you mix and match this with @badguy example you should be able to get something working.

Mine is currently a mess, and not active as i still need my smart meter installed (seems to be taken forever, even if you dont take Covid into account). Once done and working i will post the full setup. Any questions on the above, happy to help.

Hi, Im having an issue using the octocost module and displaying the monthly usage and cost. An error appears to occur in the cost calculations when octopus have missing periods of data.

Ive tried following the code, but cant see what happens if the usage data from API has missing periods.

Further info below:

It pulls and shows the figures as expected, however it seemed a little off, so I pulled the data myself from the octopus api, and laid it out in exel - I can see that the usage shown by octocost is exactly right.

This tells me that octocost is fetching the usage from the correct start date and adding usage up correctly.

The cost however is quite a way out. It is showing as £17.23 - however when I put the agile rates alongside my usage in excel and do the relevant usage * price = cost, and sum up all the cells, the actual cost is £7.72.

I think, having tried differing start dates in the octocost settings and comparing results with that from my spreadsheet I can see that octopus has a day of missing data (16th June). If I put my start date as 17th june, everything shows correctly.

If I put the start date as 16th June (so it includes the day that octopus has missing according to the API), then octocost adds a random £9.50 for that day or about 19p per time period.

If I set the start date correctly to 6th June, this error persists and it appears to be adding a large amount of 19p per time period for any periods that the octopus API has no data.

It doesn’t cope with missing data, it’s a bit rough and ready. I probably need to give it a bit of time, but if you’ve got any pull requests for fixes, feel free to submit them.
I think (I haven’t looked at this for quite a while), that it just tries to line up the start point, allowing for daylight saving, then rattles through the data line by line, multiplying use by cost, so may get out of sync if lines are missing completely rather than being zero.
I’ll try and take a look next weekend. I want to work on https://github.com/badguy99/octocost/issues/4 anyway, as the gas tracker info isn’t in the normal API, so I have to get that from elsewhere.

Ah right - Im not very goog at coding, in fact pretty useless if Im honest. That much of a beginner I dont know what you mean by “pull requests for fixes”.

Yes - if it shuffles up data to fill lines that would explain it as Ive hammered my usage during negative price periods, as these periods wouldnt be negative if moved by 24 hours that would explain the large shift.

Id like to be able to write a simple script to pull my usage data into a csv, and similarly prics for the same period, but as above coding skills arent anywhere at that level yet.

Cool, no worries, I’ll hopefully look at it on the weekend, and come on with a solution.

@Markg - are the rates one hour behind for you? Looks to me like the timezone is GMT but not adjusted for summer time (GMT+1)

Hi @im85288, is the the rates card that is one hour behind for you? For me it’s good, everything else is shown as GMT rather than BST, I need to revisit to get all the sensors to either query the octopus API for BST or convert times before storing them. The javascript in the rates card should convert to local time for you though…

@Markg - It was the data shown in the developer section where I noticed it being an hour behind rather than visually (as I have not tried the rated card yet). What I was attempting to do was trigger a timer on a custom switch…but never see it having its value changed to “on”. This lead me to think maybe it was because the timings were out. I re-installed everything but now there’s no rates data at all. I’ll give it another try tomorrow when hopefully the rates data is there. Am I correct in thinking the timer should trigger a custom toggle switch (Helpers-> Toggle)?

Ah yes that makes sense that they would show as GMT then, they should get triggered based on GMT times too though. I haven’t checked, can the toggle switch be managed with the home assistant.turn_on/turn_off service? That’s what it’s making use of.

In terms of the missing data, it should catch up over time, the timers get updated at 1900 each day, and keep trying every hour if they fail (like yesterday when the rates didn’t come in until late) and the rates and timer management runs on every half hour. If you don’t want to wait after a restart you can manually call the octopusagile.update_timers and octopusagile.half_hour service to update everything.