Start Car Charging Automatically When Solar Panels Produce Excess Energy
- Andrea Leandri
- Jun 29
- 5 min read
Skill level: Intermediate | Time to complete: 30-45 minutes
What you'll build: A Home Assistant automation that watches your solar inverter and P1 (Home wizard) smart meter, then automatically starts your EV charger when you have been exporting more than 2000W for 5 consecutive minutes. Charge on sunshine, not grid electricity.
The Idea
When your solar panels produce more power than your home uses, the excess flows back to the grid. If you have an electric car on the driveway, that is wasted potential - you are selling energy back at a low rate while your car stays uncharged, only to buy it back at night at a higher rate.
This automation closes that loop. It watches both your solar inverter output and your P1 smart meter, and the moment you have sustained a genuine surplus for 5 minutes, it starts the car charger, sends a push notification to your phone, and announces it through your Alexa speakers.
Why Two Sensors, Not One
The automation checks both the solar inverter output AND the P1 meter. Your inverter might produce 2500W, but if your home is simultaneously using 1500W, you are only exporting 1000W - not enough to meaningfully charge a car. The P1 meter at the grid connection confirms the net surplus. In the Dutch DSMR convention, a negative P1 reading means export - the more negative, the more you are sending to the grid.
The trigger also requires the inverter to stay above 2000W for 5 consecutive minutes before firing. This filters out cloud shadow spikes and general fluctuation. You want sustained surplus, not a momentary peak.
What You'll Need
Home Assistant - any recent version (2024.x or later)
Solar inverter integration - providing AC output power in watts (Solis, SolarEdge, Fronius, Huawei, etc.)
P1 smart meter integration - the Dutch DSMR P1 meter, negative values = export
EV charger switch - your car charger controllable from HA via a switch entity.
Car integration (optional) - charge flap sensor, charge program, and state of charge sensors. Look for your car brand in HACS.
Step 1: Verify Your Sensors
Before creating the automation, go to Developer Tools -> States and confirm: your inverter sensor shows watts (e.g. 2847 on a sunny afternoon); your P1 sensor shows a negative value when exporting (e.g. -1823 on a sunny afternoon); and you can manually toggle your EV charger switch from Developer Tools -> Services.
Step 2: Create the Start Automation
Settings -> Automations & Scenes -> Create Automation -> Edit in YAML. Paste the automation below and replace each entity ID marked with a comment.
alias: "Solar EV charging - start when surplus above 2000W"
description: >
Starts the EV charger when the solar inverter has been above 2000W
for 5 consecutive minutes, confirmed by P1 meter showing net export.
triggers:
- trigger: numeric_state
entity_id: sensor.YOUR_INVERTER_ac_output_total_power # your inverter sensor
for:
minutes: 5
above: 2000
conditions:
# P1 confirms actual grid export (negative = export in Dutch DSMR)
- condition: numeric_state
entity_id: sensor.p1_meter_power # your P1 meter sensor
below: -2000
# Car charge flap is open - ensures the car is cabled up
- condition: state
entity_id: sensor.YOUR_CAR_charge_flap_dc_status
state:
- Open
# Car is in Home charging program - ensuring the car is at home
- condition: state
entity_id: sensor.YOUR_CAR_selected_charge_program
state:
- Home
# Car battery below its target maximum - no point charging a full battery
- condition: template
value_template: >
{{ states('sensor.YOUR_CAR_state_of_charge') | float
< states('sensor.YOUR_CAR_max_state_of_charge') | float }}
actions:
# Push notification
- action: notify.mobile_app_iphone_XXXXXX
# your notify service
data:
title: "Solar charging started"
message: Solar export above 2000W for 5 minutes - car charging started!
# Toggle charger off then on to reset into active charging state
- action: switch.turn_off
target:
entity_id: switch.YOUR_EV_CHARGER # your charger switch
- delay:
seconds: 5
- action: switch.turn_on
target:
entity_id: switch.YOUR_EV_CHARGER
# Announce through all Alexa speakers
- action: notify.alexa_media_everywhere_announce # your announce service
data:
message: The solar panels are producing enough energy to charge your car.
mode: singleStep 3: Add a Matching Stop Automation
When clouds roll in or household demand increases, you need to stop charging. The stop threshold (1500W) is intentionally lower than the start threshold (2000W) - this hysteresis gap prevents rapid toggling as production hovers around the boundary, which is bad for both the charger and the car battery management system.
Settings -> Automations & Scenes -> Create Automation -> Edit in YAML.
alias: "Solar EV charging - stop when surplus drops"
triggers:
- trigger: numeric_state
entity_id: sensor.p1_meter_power
for:
minutes: 10
above: -1500 # less than 1500W export for 10 minutes
conditions:
- condition: state
entity_id: switch.YOUR_EV_CHARGER
state: "on"
actions:
- action: switch.turn_off
target:
entity_id: switch.YOUR_EV_CHARGER
- action: notify.mobile_app_iphone_XXXXXX
data:
title: "Solar charging paused"
message: Solar export dropped - car charging paused.
mode: singleHandling the Home Battery
If you have a Marstek Venus home battery (or any other brand), you need to decide: should the battery charge first, or the car? Two strategies:
Battery first, then car (default): The Marstek charges to full on solar, then surplus flows to the car. Best for maximum battery storage for evening use.
Car and battery simultaneously: Add an action to switch the Marstek to Manual mode first, stopping it from absorbing all the surplus. Best if your battery is already well charged by midday.
# Add as first action to prioritise car charging over battery:
- action: select.select_option
target:
entity_id: select.marstek_venuse_3_0_operating_mode
data:
option: ManualWhen wanting to switch it back to absorb whatever excess of energy or to offer back energy automatically then have the same piece of code but with option: Auto.
# Add as first action to prioritise car charging over battery:
- action: select.select_option
target:
entity_id: select.marstek_venuse_3_0_operating_mode
data:
option: AutoIn all honesty i stopped handling the battery in this automation because charging my home battery is faster and more flexible than charging my car. The home battery charges up even with a minimum excess of solar energy and it automatically detects whether it is convenient to charge or discharge based on the P1 meter readings.
Threshold Guide
Set your start threshold close to your charger minimum draw so the surplus actually covers the charging. 2.3 kW charger (10A / 1 phase): use 2000W threshold. 3.7 kW charger (16A / 1 phase): use 3000W. 7.4 kW charger (32A / 1 phase): use 6000W. 11 kW charger (16A / 3 phase): use 9000W.
Troubleshooting
Automation never triggers: Verify the inverter sensor name matches exactly what is in the automation. Check it shows values above 2000W on a sunny day.
Triggers but conditions fail: Open Traces to see which condition blocked it. Usually the P1 condition or the charge flap condition.
Charger does not respond: Test the switch manually in Developer Tools first. Some chargers need a specific integration rather than a generic switch.
Triggers on a cloudy day: Check the P1 condition - it requires confirmed export, not just inverter output. Verify your P1 sensor reads negative when exporting.
Guide written by a Home Assistant enthusiast in Utrecht. Built with Home Assistant, a Solis inverter, a P1 meter, and the satisfaction of never paying to charge the car on a sunny day.



Comments