michaelmcgoldrick sure no problem
Here is a script that I call from an automation to force a discharge. It’s in a script just so I can run it any time I want or trigger it from an automation:
alias: G395 Inv2 Force Discharge
sequence:
- service: select.select_option
data:
option: "00:00:00"
target:
entity_id: select.h_sd2237g395_discharge_start_time_slot_1
- service: select.select_option
target:
entity_id:
- select.h_sd2237g395_discharge_end_time_slot_1
data:
option: "23:59:00"
- service: number.set_value
data:
value: "2600"
target:
entity_id: number.h_sd2237g395_battery_discharge_rate
- service: number.set_value
data:
value: "4"
target:
entity_id: number.h_sd2237g395_battery_power_reserve
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: select.select_option
target:
entity_id:
- select.h_sd2237g395_mode
data:
option: Timed Export
mode: single
icon: mdi:battery-minus-outline
I don’t have an automation that precisely matches what you want, but here’s one I use for Octopus power up events, it holds the battery from charging up in the morning (you won’t need that bit), at 1pm it checks if the battery has a charge and if it has it runs the above script to discharge it, and then at 2pm it starts a force charge, and finally 4pm it stops the charge and puts the inverter back to Eco mode
Should be enough to reuse
alias: G395 Inv2 Octopus Power Up
description: Don't let the battery charge in the morning, then force charge 2-4pm
trigger:
- platform: time
at:
- "06:00"
- "08:00"
- "10:00"
- "12:00"
id: 2-hourly-stop-charging
- platform: time
at: "13:15:00"
id: 1pm-check-if-discharge-required
enabled: true
- platform: time
at:
- "14:00"
- "14:06"
id: power-up-start
- platform: time
at: input_datetime.octopus_power_up_end_time
id: power-up-end
condition:
- condition: template
value_template: >-
{{ (now().date()) | string ==
states('input_datetime.octopus_power_up_date') }}
action:
- choose:
- conditions:
- condition: trigger
id:
- 2-hourly-stop-charging
sequence:
- service: number.set_value
data:
value: "0"
target:
entity_id: number.h_sd2237g395_battery_charge_rate
- conditions:
- condition: trigger
id:
- 1pm-check-if-discharge-required
sequence:
- if:
- condition: numeric_state
entity_id: sensor.h_sd2237g395_soc
above: 5
then:
- service: script.g395_inv2_force_discharge
data: {}
- conditions:
- condition: trigger
id:
- power-up-start
sequence:
- service: select.select_option
data:
option: Normal
target:
entity_id:
- select.h_sd2237g395_temp_pause_charge
- service: select.select_option
data:
option: Eco
target:
entity_id: select.h_sd2237g395_mode
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: number.set_value
data:
value: "2600"
target:
entity_id: number.h_sd2237g395_battery_charge_rate
- service: select.select_option
data:
option: "120"
target:
entity_id:
- select.h_sd2237g395_force_charge
- service: homeassistant.turn_off
data: {}
target:
entity_id:
- switch.h_sd2237g395_enable_discharge
- conditions:
- condition: trigger
id:
- power-up-end
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: select.select_option
data:
option: Normal
target:
entity_id:
- select.h_sd2237g395_force_charge
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- service: select.select_option
data:
option: Eco
target:
entity_id: select.h_sd2237g395_mode
- service: select.select_option
data:
option: "00:00:00"
target:
entity_id:
- select.h_sd2237g395_charge_end_time_slot_1
- select.h_sd2237g395_charge_start_time_slot_1
- select.h_sd2237g395_discharge_start_time_slot_1
- select.h_sd2237g395_discharge_end_time_slot_1
- service: number.set_value
data:
value: "2000"
target:
entity_id: number.h_sd2237g395_battery_charge_rate
- service: homeassistant.turn_on
data: {}
target:
entity_id:
- switch.h_sd2237g395_enable_discharge
mode: single