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

Post Reply
marcus
Posts: 8
Joined: Thu Aug 10, 2023 8:19 am

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.
Marcus

House
H1 Series H1-3.7-E Inverter | RS485 Modbus->HA
8x Jinko 300W Mono (3x East facing; 5x South facing - 2400W)
Workshop
H1 Series H1-5.0-E Inverter | RS485 Modbus->HA
7x HV2600 2.6 kWh (5x V2; 2x V1 (Version C)) BMS V2 using this fix
12x Canadian 430W (2 strings South facing - 5160W)
Post Reply