Page 1 of 1

Setting Max SoC at different levels during the day to get the best from Octopus Flux tariff

Posted: Tue Jan 02, 2024 6:20 pm
by marcus
Hi,

This is my first automation after finally setting up my HA (on old laptop using docker) and the Modbus integration (using a 304), so I'm sure it can be improved on and very welcome to hear your comments!

The idea for this comes from wanting to maximise the savings by charging on Octopus Flux while solar generation is low over winter. There's a lot of similarity here with Nathan Marlor's Octopus Energy Flux Tariff Automation which I started with to automate switching the Work Mode.
Dashboard-SoC.png
During 2am - 5am I want to top up to 100% at the cheapest rate.
If there's not been much generation through the day and the battery is low, I want to top up at the day rate before the more expensive peak rate cuts in between 4pm and 7pm, not to 100%, but enough to avoid grid consumption at the highest rate.

Before automation & Modbus I played with different "charge 2" settings on the Cloud/App, experimenting with different durations around a window before 4pm, but obviously this was all in an attempt to get to a level which is what I've now done. i.e.
Dashboard-ChargePeriods.png
Created 3x helpers for the levels -
  • input_number.max_soc_eco
  • input_number.max_soc_day
  • input_number.max_soc_peak
Helpers.png
Added them to a card on the dash so they can be set easily, (I can imagine during summer you'd reduce even ECO right down depending on needs)
Dashboard-Card.png
And then the automation, this is very similar to Octopus Energy Flux Tariff Automation, (time variable naming may differ) this gets triggered by the time helpers, sets as a value (cast as a float, that had me scratching my head for a while!) onto the Modbus's entity_id: number.max_soc, again this is different, using service: number.set_value with the data['value'], it didn't feel as straight forward as the option strings in the one I based it on.

Code: Select all

alias: Battery Max SoC setting
description: "Sets the Max SoC according to the time of day based on tariffs using the input number values on dashboard"
trigger:
  - platform: time
    at: input_datetime.off_peak_energy_start
    variables:
      maxSoC: >-
        {{ states('input_number.max_soc_eco') | float(states('number.min_soc'))
        }}
  - platform: time
    at: input_datetime.off_peak_energy_end
    variables:
      maxSoC: >-
        {{ states('input_number.max_soc_day') | float(states('number.min_soc'))
        }}
  - platform: time
    at: input_datetime.peak_energy_start
    variables:
      maxSoC: >-
        {{ states('input_number.max_soc_peak') | float(states('number.min_soc'))
        }}
  - platform: time
    at: input_datetime.peak_energy_end
    variables:
      maxSoC: >-
        {{ states('input_number.max_soc_day') | float(states('number.min_soc'))
        }}
condition: []
action:
  - service: number.set_value
    target:
      entity_id: number.max_soc
    data:
      value: "{{ maxSoC }}"
mode: single
So now I can sit back and know that I'll get a full charge at cheapest rate, and if needed a top up before the peak rate, easily configured and automated. Thanks for reading, look forward to hearing what you think.