Home Battery Protection during EV Night Charging (V2C + Huawei Solar)

Hello everyone,

I’d like to share a small automation I created to solve a common issue when charging an Electric Vehicle (EV) during cheap night hours while using a residential battery system.

The Problem: When my EV charger (V2C) starts charging at night, the car often draws power from my home battery (Huawei) instead of solely using the cheap grid energy, defeating the purpose of storing power for daytime use.

The Solution: I’ve implemented a simple automation that “freezes” the minimum discharge level (SOC) of the home battery to its current level the moment the car starts charging. This forces the EV to draw power directly from the grid and ensures the valuable stored energy is preserved.

:gear: My Setup:

  • EV Charger: V2C Charger (using the HACS integration for its status sensor).
  • Home Battery: Huawei LUNA2000 (using the Huawei Solar integration in Administrator Mode to control the minimum SOC setting).
  • EV: Any electric vehicle. This automation is universal as it only controls the home battery, not the car.

:brain: The Automation Logic

The automation has two parts:

  1. Freeze Automation (Night): When the car starts charging between 00:00 and 08:00, it sets the battery reserve level (number.baterias_carga_de_reserva_soc) to the battery’s current SOC (State of Charge). Crucially, it includes a safety check to ensure the reserve never drops below 10%, even if the sensor fails or the battery is already low.
  2. Unfreeze Automation (Morning): (Required but not shown here) A second automation must reset the reserve back to your normal level (e.g., 10%) when charging is complete or after 08:00.

:memo: Automation Code (Freeze Battery Level)

This is the YAML code for the first part (the freezing action):

alias: EV Charging - Freeze Home Battery SOC
description: >-
  Sets the home battery reserve to its current SOC (min 10%) when the EV starts
  charging during cheap hours (00:00 - 08:00).
triggers:
  - platform: state
    entity_id: sensor.v2c_hacs_estado_de_carga
    to: "Manguera conectada (CARGANDO)"
conditions:
  - condition: time
    after: "00:00:00"
    before: "08:00:00"
actions:
  - service: number.set_value
    target:
      entity_id: number.baterias_carga_de_reserva_soc
    data:
      # This template sets the reserve to the current SOC, 
      # but ensures it is at least 10% (safety feature).
      value: >
        {{ [states('sensor.baterias_estado_de_la_capacidad') | int(default=10), 10] | max }}
mode: single

I hope this helps anyone trying to optimize their EV charging and home battery usage! Let me know if you have any questions or suggestions for improvements.

1 Like