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.
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. Created 3x helpers for the levels -
- input_number.max_soc_eco
- input_number.max_soc_day
- input_number.max_soc_peak
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