When the Zappi charger is on it will draw power from the batteries as well as the grid, unless the batteries are themselves being protected from discharge by a force charge window.
This automation ensures that if the Zappi charger starts up during the eco tariff hours and starts to draw power from the batteries (i.e. no charge window exists) that a force charge window is set in 'Period 2' for the entire duration of the Eco period, and once the eco period is over it will clear the charge period in Period 2.
It needs a home assistant and the RS485 Foxess Modbus integration to operate.
There are 2 datetime helpers creating for Eco Start Period and Eco End Period.
The helpers are created under Settings, Devices & Services, Helpers (at the top), click on + Create Helpers, then choose 'Date and/or Time' and set them as follows -
Once created, click on the Helpers and set them to your Eco tariff i.e. for Economy 7 it would be 1:30am for start and 08:30am for the end.
The Automation works by monitoring the Zappi charger and the battery discharge and if both are above 3kW then it will set a Force Charge in Period 2 (but Grid charge turned off) for the Eco tariff period which will protect the batteries from any further discharge.
Once the Eco tariff period is over it will clear Period 2 - Note: this will not affect whatever has been set in Period 1.
It will log all it's actions in Logbook.
The Automation code is as follows, please note that you will have to enter some information that is unique to your system, they are detailed below the code.
Code: Select all
alias: Zappi Home Battery Protect with EM
description: >-
IF Zappi starts charging at high power and no charge windows are set then auto
set a force charge window for eco tariff period and reset when eco tariff has
ended
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: or
conditions:
- condition: template
value_template: >-
{{ now().strftime('%H:%M') ==
states('input_datetime.eco_end_period')[:5] }}
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.myenergi_lymm_6_greenacres_power_charging
above: 4000
- condition: numeric_state
entity_id: sensor.battery_discharge
above: 3
action:
- if:
- condition: time
before: input_datetime.eco_end_period
after: input_datetime.eco_start_period
then:
- service: foxess_modbus.update_charge_period
data:
inverter: 84609677d0bc2a5f9fb29beba3f27565
enable_force_charge: true
enable_charge_from_grid: false
start: "{{ states('input_datetime.eco_start_period') }}"
end: "{{ states('input_datetime.eco_end_period') }}"
charge_period: "2"
enabled: true
- service: logbook.log
data:
name: Battery Protect
message: >-
EV Charging and no charge period set, Protecting batteries - Start
{{states('input_datetime.eco_start_period')}}, End
{{states('input_datetime.eco_end_period')}}
else:
- if:
- condition: template
value_template: >-
{{ now().strftime('%H:%M') ==
states('input_datetime.eco_end_period')[:5] }}
then:
- delay:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- if:
- condition: state
entity_id: binary_sensor.time_period_2_enable_force_charge
state: "on"
then:
- service: foxess_modbus.update_charge_period
data:
inverter: 84609677d0bc2a5f9fb29beba3f27565
enable_force_charge: false
enable_charge_from_grid: false
start: "00:00:00"
end: "00:00:00"
charge_period: "2"
enabled: true
- service: logbook.log
data:
name: Battery Protect
message: Removing period 2 settings
else:
- service: logbook.log
data:
name: Battery Protect
message: Period 2 was already reset
mode: single
max_exceeded: silent
As the Inverter 'device' is also unique to your installation you will need to update the device name in the code with your inverter device - you can find your inverter device_ID by creating a new blank automation, click '+Add Action', and choose 'Call Service', in the 'Service' box start to type 'Foxess - modbus' and choose the item in the list 'FoxESS - Modbus: Update Charge Period'
In the box below for 'Inverter' click in the 'Device' box and choose your inverter (there will usually only be one unless you have multiple inverters), now click on the three dots in the right corner of this action and select 'Edit in Yaml'.
You will see your inverter device ID (see the image below), this is your unique inverter device ID and must be copy and pasted into the automation code above in the 2 places that you see 'inverter: xxxxxxxxxxxxxxxxxxxxxxxxxx'
You can exit this screen by clicking the <- Arrow in the top left corner of the New Automation screen and choose 'Leave' to exit without saving.
And that's that, the automation will check each minute to see if the Zappi is charging and the Home Battery being discharged and if it is during the Eco Tariff period, it will set Period 2 for the duration of the Eco Tariff and clear it when finished.