Energy export management on a solar PV system with batteries by using home assistant automations, electric heaters and smart switches


In a photovoltaic system with batteries, the inverter tries to keep the energy balance at zero, as long as there is charge in the batteries and / or sufficient solar radiation.

Instant power as indicated by the smart meter sensor

When the battery reaches a charge level above 80%, if the solar energy is higherr than the loads in the house, the inverter begins to export energy to the grid because the speed of charge can’t be as quick as when the SOC (state of charge) is lower.

At this specific instant, at 82% SOC, battery charge power is lower than production
And lower indeed at 95% SOC a little bit later

The idea here is to start / stop various resistive loads (mainly heaters) to use the energy in the house and not give it away to the power company.

The use of resistive loads facilitates the response of the automations because if, for example, other loads such an oven or the climate system are started, because these resistive loads are stopped immediately by the smart switches with no delay. On the contrary, other kind of loads such ovens, microwaves or climate systems have a load curve more irregular as shown in the figure above, hence more difficult to control.

For that purpose we need several heaters and smart switches and create a couple of automations for each heater, one for start and the other for stop.

One automation to switch the heater on and other for the contrary

All the automations run every 15 seconds. The trigger conditions to switch heaters on/off are as follows:

Heater number/priorityConditions for switching onConditions for switching off
1Inverter state is exporting and Exported power > 100 Watts during 10 secondsswitch1 is on and
Battery soc < 90 and
Battery state is discharging
2switch1 is on and inverter state is exporting during 5 secondsswitch2 on and
Battery soc < 90 and
Battery state is discharging
nswitch (n-1) is on and inverter state is exporting during 5 secondsswitchn is on and
Battery soc < 90 and
Battery state is discharging
Day 1: A low generation December day, battery SOC reaches low level
Day 2: A good winter day. Loads doesn’t start until system starts exporting energy
Day 3: Agaiin a good day. Loads start early because batteries discharged less on day 2, hence the system starts to export early

Day 4: A quite good winter day. Notice how the loads are regulated depending on solar power

Automation configuration YAML’s

-----
alias: 1 - ASEO ON
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: state
    entity_id: sensor.goodwe_grid_in_out_label
    state: Exporting
    for:
      hours: 0
      minutes: 0
      seconds: 10
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: numeric_state
    entity_id: sensor.goodwe_pgrid
    above: '100'
action:
  - type: turn_on
    device_id: 89d61bd5efd1f26648f999a63ac4a99c
    entity_id: switch.aseo
    domain: switch
mode: single
-----
alias: 1 - ASEO OFF
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: numeric_state
    entity_id: sensor.goodwe_battery_soc
    below: '90'
  - condition: state
    entity_id: sensor.goodwe_battery_mode_label
    state: Discharge
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: state
    entity_id: switch.aseo
    state: 'on'
action:
  - type: turn_off
    device_id: 89d61bd5efd1f26648f999a63ac4a99c
    entity_id: switch.aseo
    domain: switch
mode: single
-----
alias: 2 - RED ON
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: state
    entity_id: sensor.goodwe_grid_in_out_label
    state: Exporting
    for:
      hours: 0
      minutes: 0
      seconds: 5
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: state
    entity_id: switch.aseo
    state: 'on'
action:
  - type: turn_on
    device_id: 5e5d152c353ced8e64c238621be02e75
    entity_id: switch.red_heater
    domain: switch
mode: single
-----
alias: 2 -RED OFF
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: state
    entity_id: switch.red_heater
    state: 'on'
  - condition: state
    entity_id: sensor.goodwe_battery_mode_label
    state: Discharge
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: numeric_state
    entity_id: sensor.goodwe_battery_soc
    below: '90'
action:
  - type: turn_off
    device_id: 5e5d152c353ced8e64c238621be02e75
    entity_id: switch.red_heater
    domain: switch
mode: single
-----
alias: 3 - BAÑO AZUL ON
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: state
    entity_id: sensor.goodwe_grid_in_out_label
    state: Exporting
    for:
      hours: 0
      minutes: 0
      seconds: 5
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: state
    entity_id: switch.aseo
    state: 'on'
  - condition: state
    entity_id: switch.red_heater
    state: 'on'
action:
  - type: turn_on
    device_id: 04596c16707b6df848988fe285cadba0
    entity_id: switch.estufa_bano_azul
    domain: switch
mode: single
-----
alias: 3 - BAÑO AZUL OFF
description: ''
trigger:
  - platform: time_pattern
    seconds: /15
condition:
  - condition: state
    entity_id: sensor.goodwe_battery_mode_label
    state: Discharge
    for:
      hours: 0
      minutes: 0
      seconds: 0
  - condition: state
    entity_id: switch.estufa_bano_azul
    state: 'on'
  - condition: time
    after: '23:00'
    before: '21:00'
  - condition: numeric_state
    entity_id: sensor.goodwe_battery_soc
    below: '90'
action:
  - type: turn_off
    device_id: 04596c16707b6df848988fe285cadba0
    entity_id: switch.estufa_bano_azul
    domain: switch
mode: single

Note: In my own setting, I have an ‘special’ condition, because between 21oo ans 23oo I have free energy from the grid:

    after: '23:00'
    before: '21:00'

SOME OTHER PICTURES

First heater is switched on
3 heaters on
The heaters I use
Shelly plug S

You can find my production/utilisation curves here

Hope it helps!! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.