As promised, here's the automation to pre-fill your GivEnergy battery before a saving session. The thinking is you are left back at square one at the end of the session, obviously you don't
need to do this but it makes sense to me + it ensures you don't run out of juice before the session ends.
First off you'll need to create two new helpers;
- a date time entity called "Saving Session Date" (input_datetime.saving_session_date)
- an input number entity called "Saving Session Duration" (input_number.saving_session_duration). The unit of measurement should be minutes.
Now add this automation. You will need to replace wherever it says
givtcp_xxxxxxxxxx to what your inverter is called.
YAML:
alias: Saving Session force charge
description: ""
trigger:
- platform: template
value_template: >-
{{ now() >= states('input_datetime.saving_session_date') | as_datetime |
as_local -
timedelta(minutes=states('input_number.saving_session_duration') | int(0))
}}
id: start
alias: Before the start of Saving Session
- platform: time
at: input_datetime.saving_session_date
id: end
alias: At the start of Saving Session
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- start
sequence:
- service: select.select_option
data:
option: >-
{{ (now() + timedelta(minutes=1)).time().replace(microsecond=0,
second=0) }}
target:
entity_id: select.givtcp_xxxxxxxxxx_charge_start_time_slot_1
- service: select.select_option
data:
option: >-
{{ (states('input_datetime.saving_session_date') | as_datetime |
as_local - timedelta(minutes= 5)).time().replace(microsecond=0,
second=0) }}
target:
entity_id: select.givtcp_xxxxxxxxxx_charge_end_time_slot_1
- conditions:
- condition: trigger
id:
- end
sequence:
- service: select.select_option
data:
option: "23:30:00"
target:
entity_id: select.givtcp_xxxxxxxxxx_charge_start_time_slot_1
- service: select.select_option
data:
option: "05:29:00"
target:
entity_id: select.givtcp_xxxxxxxxxx_charge_end_time_slot_1
mode: single
What this does is it will force charge your battery from the length of duration of the session before the session starts (so if it's an hour, it'll start an hour before, if it's an hour and a half then it'll start an hour and a half before) until 5 minutes before to make sure you're not accidentally still charging once it starts as the inverter can be a bit slow to react if you've got a gen 1.
Once the session session starts, the automation will set your charging slot to between 23:00 - 05:29 (IO cheap rates). If you have a different time you'd like to use, just update the automation.
If you want to force discharge your battery during the session, here's an automation I made earlier
YAML:
alias: Saving Session force export
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.octopus_energy_x_xxxxxxxx_octoplus_saving_sessions
from: "off"
to: "on"
for:
hours: 0
minutes: 0
seconds: 10
id: start
- platform: state
entity_id:
- binary_sensor.octopus_energy_x_xxxxxxxx_octoplus_saving_sessions
from: "on"
to: "off"
for:
hours: 0
minutes: 0
seconds: 10
id: end
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- start
sequence:
- repeat:
sequence:
- service: select.select_option
data:
option: 180
target:
entity_id: select.givtcp_xxxxxxxxxx_force_export
- delay: "00:00:20"
until:
- or:
- and:
- condition: template
value_template: >-
{{ (states('select.givtcp_xxxxxxxxxx_mode')) ==
"Timed Export" }}
- condition: template
value_template: >-
{{
(states('select.givtcp_xxxxxxxxxx_discharge_start_time_slot_2'))
!= "00:00:00" }}
- condition: template
value_template: >-
{{
(states('select.givtcp_xxxxxxxxxx_discharge_end_time_slot_2'))
!= "00:00:00" }}
- condition: template
value_template: "{{ repeat.index >= 6 }}"
- conditions:
- condition: trigger
id:
- end
sequence:
- if:
- condition: template
value_template: >-
{{( states('select.givtcp_xxxxxxxxxx_force_export')) !=
"Normal" }}
then:
- repeat:
sequence:
- service: select.select_option
data:
option: Cancel
target:
entity_id: select.givtcp_xxxxxxxxxx_force_export
- delay: "00:00:10"
until:
- or:
- condition: template
value_template: >-
{{ (states('select.givtcp_xxxxxxxxxx_force_export'))
== "Normal" }}
- condition: template
value_template: "{{ repeat.index >= 6 }}"
mode: single
Now in order to update those two helper entities to populate the date and duration of the session, you can use the automation below. Make sure you replace
octopus_energy_x_xxxxxxxx with your own Octopus account entity name.
YAML:
alias: Octopus Saving Session join
description: Automatically join Octopus Saving Session Events
trigger:
- platform: event
event_type: octopus_energy_new_octoplus_saving_session
condition: []
action:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.saving_session_date
data:
datetime: |-
{{
state_attr('binary_sensor.octopus_energy_x_xxxxxxxx_octoplus_saving_sessions', 'next_joined_event_start')
}}
alias: Set start date and time
- service: input_number.set_value
target:
entity_id: input_number.saving_session_duration
data:
value: |-
{{
state_attr('binary_sensor.octopus_energy_x_xxxxxxxx_octoplus_saving_sessions', 'next_joined_event_duration_in_minutes')
}}
alias: Set duration
mode: single