Octopus Energy Intergration & Agile Charging

15 comments started 2024-02-26 last 2024-02-26
APIsHome AutomationHome Assistant
C
#1 Chaz

I've just downloaded and installed the Octopus Energy Integration from https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/ this is working well and has a great feature that will set an Entity within Home Assistant as On or Off when it picks the predetermined best slots either individually or as a block.

I've got this working with a Smart Plug and an automation to turn the Switch On when the Entity is On and Off accordingly. This will be great for the Dishwasher etc in the middle of the night.

I can't though work out how to use the Giv/TCP integration to get it to charge the battery.

I was going to make an automation to look for the Entity to go from Off to On and then send a command to charge the battery. Then when the Entity went to Off it stopped charging. I also wanted to throw into the mix a SOC percentage. Then I could say pick 4 charge slots in the night and get the battery to 80%.

Any ideas?

G
#2 geoffreycoan

Chaz The GivTCP add on is great that it gives you unfettered access to the inverter controls, but it does work very much at a raw-inverter level.

That means you need to set the right controls in the right sequence to get charging to start and stop. I worked out what the required controls were by manually using the quick-controls in the GivEnergy app and then seeing what GivTCP controls changed.

The key bit you are missing is probably the charge start and end time. These have to be set to the time period before you turn the inverter into charge mode. You could for instance just set these to 00:01:00 and 23:59:00 and then only need to change the mode, but this is dangerous as if you inadvertently changed a setting your automation wouldn’t work as you expected.

I now use Predbat to predict my battery levels, charging and discharging, but before I moved, and I was on Flux, I used scripts to manage my battery, and the scripts always set the battery to a known state before they started.

G
#3 geoffreycoan

geoffreycoan
here's my start charging script (replace the x's with your inverter id):

alias: G395 Inv 2 Force Charge
description: Force a full rate battery charge
sequence:
  - service: select.select_option
    data:
      option: Normal
    target:
      entity_id:
        - select.givtcp_xxxx_temp_pause_charge
  - service: select.select_option
    data:
      option: Eco
    target:
      entity_id: select.givtcp_xxxx_mode
  - service: number.set_value
    data:
      value: "100"
    target:
      entity_id: number.givtcp_xxxx_target_soc
  - service: select.select_option
    target:
      entity_id:
        - select.givtcp_xxxx_charge_start_time_slot_1
    data:
      option: "00:00:00"
  - service: select.select_option
    target:
      entity_id: select.givtcp_xxxxx_charge_end_time_slot_1
    data:
      option: "23:59:00"
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.givtcp_xxxx_enable_charge_schedule
    enabled: false
  - delay:
      seconds: 20
  - service: number.set_value
    data:
      value: "2600"
    target:
      entity_id: number.givtcp_xxx_battery_charge_rate
  - service: select.select_option
    data:
      option: Running
    target:
      entity_id:
        - select.givtcp_xxx_force_charge
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.givtcp_xxx_enable_discharge
mode: single
icon: mdi:battery-charging-30

And the stop charge:

alias: G395 Inv2 Stop Charge
sequence:
  - service: select.select_option
    data:
      option: Normal
    target:
      entity_id:
        - select.givtcp_xxxx_force_charge
  - delay:
      hours: 0
      minutes: 0
      seconds: 20
      milliseconds: 0
  - service: select.select_option
    data:
      option: Eco
    target:
      entity_id: select.givtcp_xxxx_mode
  - service: select.select_option
    data:
      option: "00:00:00"
    target:
      entity_id:
        - select.givtcp_xxxx_charge_start_time_slot_1
        - select.givtcp_xxxx_charge_end_time_slot_1
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.givtcp_xxxx_enable_discharge
  - service: number.set_value
    data:
      value: "4"
    target:
      entity_id: number.givtcp_xxxx_battery_power_reserve
mode: single
icon: mdi:timer-cancel

There are other ways of doing this, you can set force_charge to a duration such as 30 to start the charging for 30 minutes, but what this does is start a timer process in GivTCP that then cancels the charge after the time period. I prefer to do all the controls in my scripts.

You also don't need to be as exhaustive as I am in setting the inverter to a known state. But belt and braces.

Save these to an automation script and you can then call the script from your own automation. I'll leave that as an exercise for the reader, as is understanding what the different controls do ...

C
#4 Chaz

geoffreycoan

Brilliant reply. Looks very complex for my standard at the moment.

Predbat. Need to look at that I think. Would that charge in the best Agile slots?

G
#5 geoffreycoan

Chaz Yes, Predbat identifies the best charging slots for your tariff, battery charge level and predicted solar and house load and manages your battery charging and discharging for you.

It is very comprehensive, very configurable, but it is a learning curve to understand how it operates. Predbat will deliver a better result than you can do manually, but is an investment of time to understand it. Plenty of other people recently been on that journey - see the ‘first night live on predbat’ conversation for one person’s experiences that now seems to be a general predbat support group !

Nothing wrong with you continuing to learn how Home Assistant works because it is a good grounding for whatever you want to do next, whether that is predbat or not. Simply create a new script in HA (script tab under Automations), click ‘edit in YAML’ and copy paste the above scripts in. Add your inverter serial number, save, then click to run the script and it’ll do everything for you.

C
#6 Chaz

So I have an automation that says when my Entity (Octopus Energy Generated) is on run the script for charge and then when it's off run the script for stop?

C
#7 Chaz

I've just created some scripts as you say and change the inverter number. I ran them direct from the script and all seems to work. Opening the Charge one though just to see how it's done the editor open sin visual and half way down it says disabled!!

Is this anything to worry about?

G
#8 geoffreycoan

Chaz Yes you’ve got the idea of using the scripts.

The disabled, that’s because I used to have the scripts working a different way and hadn’t tidied it up before I shared it with you, you can delete that command from the script, it’s now not needed. As I said there are different ways of achieving what you want.

The 20 second delay in the middle is to allow GivTCP time to send the commands to the inverter rather than send a very long sequence and risk something getting missed out, it sets the target soc, start and end times, pauses, then the charge rate and starts the charge. It also turns off discharging as the last command.

C
#9 Chaz

geoffreycoan What a man thanks for that.

I've just watched a couple of hours of the Predbat setup video and have it now on my system running!!! How well I don't know but it's working. Just going through the various setup screens.

Is it possible for a seasoned pro like yourself to share the code for a nice Dash Layout?

Back to the Utility it's looks absolutely awesome. That bloke is a genius.

C
#10 Chaz

I think I've just broke Predbat!!!!

It was all working OK and then a Home Assistant update has stopped it working! Keeps saying that nothing is available.

Is it possible to go back a version?

G
#11 geoffreycoan

Chaz yes you can restore a previous version of home assistant.

Go to Settings/System/Backups and all the backups before you upgraded should be there.

I also strongly recommend you add the Google Drive Backup add-on to Home Assistant. Automates taking backups every day and copies them to a google drive account for safe keeping. I just created an additional google account for HA and so have 15Gb of free storage, and keeps it separate from my own Google account (that’s full of photos anyway)

C
#12 Chaz

Fixed!!!

When editing a yaml file I put an extra space at the start of a line. Obviously didn’t matter whilst it was running but after the update and a reboot it wouldn’t work. Obviously I’m blaming the update when it was my fat fingers an hour beforehand!!

G
#13 geoffreycoan

Chaz yaml is very critical of the file layout.

I’ve added a few intro video links to the predbat install guide - there’s one on yaml worth watching

C
#14 Chaz

geoffreycoan I’m going through them bit by bit.

Got to be said this is some utility. Amazing to watch it work.

Do you use this all year? Are you on Agile etc etc.

G
#15 geoffreycoan

Chaz I had my givenergy inverters and batteries installed last January.

I was originally on a fixed rate tariff and only moved to Octopus Flux (for the export income) in June last year. The export MPAN took a couple of months to arrive and we only got export setup in mid August.

I quickly realised I wanted a way to automate the Flux peak period discharging, initially with my own hand written scripts before I moved to Predbat in September. Took a while to get used to it with Flux, but was happy with what it was doing so felt confident to move to Agile in October as my energy use ramps up considerably for the winter as we have an ASHP.
I will move back to Flux at some point but at the moment am very happy with what Predbat is doing for me. A far better optimisation than I could do myself.