As an electrical engineer, I often tell homeowners that installing solar panels and buying an electric vehicle are only the first two steps in a three-step process. The third step—and frankly, the most technically interesting one—is bridging the gap between generation and consumption. Without intelligent control, you are likely feeding clean solar energy back to the grid for pennies while paying a premium to charge your car at night. That is an efficiency loss we simply don't accept here.
Automating EV charging is not just about convenience; it is a fundamental exercise in load balancing and energy optimization. By leveraging powerful hardware like the Fronius Primo Gen 24 Plus inverter and orchestrating it through Home Assistant, we can create a closed-loop system that reacts to the sun in real-time. In this guide, I will walk you through the engineering principles behind smart energy management, the specific capabilities of the Fronius ecosystem, and how to configure logic that prioritizes self-consumption over grid imports.
The Engineering Case for Smart Charging Automation
Before we start splicing wires or writing YAML code, we need to understand the load profile we are dealing with. An EV is likely the single largest electrical load in your home. A typical Level 2 charger draws roughly 7kW to 11kW. To put that in perspective, that is equivalent to running three or four central air conditioning units simultaneously.
If you plug in your vehicle indiscriminately, you create massive demand spikes. Automating EV charging allows us to flatten this curve. The goal is to modulate the charging rate (amperage) dynamically based on the available excess solar power.
The Self-Consumption Equation
From an efficiency standpoint, self-consumption is the golden metric. Every kilowatt-hour (kWh) you generate and use immediately is a kWh you don't have to buy from the utility.
-
Generation: Your PV array produces DC power.
-
Conversion: The Fronius Primo Gen 24 Plus converts this to AC.
-
Baseload Subtraction: Your home uses a portion for lights, fridges, and standby devices.
-
The Surplus: This is our variable.
Solar Output - House Load = Available Charging Power.
Our automation goal is to keep the grid export as close to zero as possible by dumping that exact surplus into the EV's battery.
Hardware Spotlight: Fronius Primo Gen 24 Plus

In the world of solar inverters, I have a particular fondness for the Fronius Primo Gen 24 Plus. It isn't just an inverter; it is a sophisticated energy manager. For our automation purposes, it shines for a few specific reasons:
-
Open API and Modbus TCP: Unlike some locked-down ecosystems, Fronius provides excellent access to local data. We can pull real-time production numbers via JSON or Modbus without relying on a cloud server. This reduces latency—critical when you are trying to match charging speeds to passing clouds.
-
Integrated Energy Management: The Gen 24 Plus has built-in features for controlling external loads via digital I/O pins, though we will be superseding this with Home Assistant for more granular control.
-
Hybrid Capability: If you are also running a stationary home battery, this inverter manages the DC-coupling. This adds a layer of complexity to our automation logic (priority: House > Battery > EV > Grid), which we will discuss later.
To make this work, you absolutely need the Fronius Smart Meter installed at your feed-in point. Without it, the inverter knows what it is producing, but it doesn't know what the house is consuming, making smart home energy management impossible.
The Brain: Home Assistant Integration
Home Assistant (HA) is the industry standard for open-source home automation. It allows us to bypass the limitations of proprietary apps and create custom logic.
Integrating Fronius with Home Assistant
Getting your inverter data into HA is usually the first step.
-
Enable the API: Log into your Fronius web interface and ensure 'Solar API' is enabled.
-
HA Integration: In Home Assistant, navigate to Settings > Devices & Services > Add Integration > Fronius.
-
Data Points: Once connected, you will see entities for
ac_power(what you are generating) andpower_flow_channel_p_grid(what is moving to/from the grid).
Integrating the EV Charger
To automate the charging, HA also needs to talk to your wallbox. Whether you use an OCPP-compliant charger, a Tesla Wall Connector, or a go-eCharger, you need an integration that supports:
-
Switching Charging On/Off
-
Dynamic Current Adjustment: The ability to change the amperage from 6A to 32A via software command.
Without dynamic current adjustment, we can't do true solar tracking; we can only turn the charger on when solar is high, which is a blunt instrument compared to the scalpel we want to use.
Building the Automation Logic

Now for the fun part: the logic. We want to construct an automation that continuously monitors the grid export value. Here is the pseudo-code logic I use for reducing power consumption from the grid:
The Calculation Loop
Trigger: Every 30 seconds (or when grid power changes).
Condition: Is the car plugged in? Is the battery below the target limit?
Action:
-
Calculate Spare Amps: Take the Grid Power (negative value usually indicates export).
- Formula:
Available Power (W) / Voltage (230V) = Available Amps.
- Formula:
-
Hysteresis (Buffering): We don't want the charger toggling on and off with every cloud. We apply a buffer. For example, only increase charge rate if the surplus is > 2 Amps for more than 1 minute.
-
Minimum Threshold: The J1772 and Type 2 charging standards typically require a minimum of 6 Amps (~1.4kW) to start charging. If your surplus is only 500W, the automation must wait or pull a small amount from the grid/battery to meet the 6A minimum.
Handling Multi-Phase Charging
If you are on a three-phase connection (common with the Fronius Symo, but possible with some setups involving the Primo), switching between 1-phase and 3-phase charging is the holy grail. 1-phase allows granular control from 1.4kW to 7.4kW. 3-phase starts at ~4.1kW.
Warning: Not all EVs or chargers support dynamic phase switching while charging. Attempting this on unsupported hardware can damage the vehicle's onboard charger (OBC). Always verify your specific EV's OBC capabilities before automating phase switching.
Optimizing for Time-of-Use (TOU) and Battery Interaction
If you have a home battery attached to your Fronius Primo Gen 24 Plus, the logic gets trickier. Usually, the default priority is to charge the home battery first. However, EV charging requires high power.
Scenario: It is 10:00 AM. Solar is peaking.
-
Standard Logic: Home battery charges at maximum rate. EV gets nothing until home battery is full.
-
Optimized Logic: If you know you need the car at 2:00 PM, you might want to throttle the home battery charging via Home Assistant to divert power to the EV immediately.
TOU Arbitrage
Automating EV charging isn't just about solar. If you have a Time-of-Use tariff with cheap overnight rates, your Home Assistant automation should include a 'Night Boost' mode.
- Logic: If
Timeis between 12:00 AM and 4:00 AM ANDSolar Forecastfor tomorrow is low -> Charge to 80% from grid.
This ensures you never wake up with an empty battery on a cloudy day, while still paying the lowest possible rate.
Reducing Phantom Drain and System Latency
A common issue I see in DIY automation setups is 'phantom drain' caused by aggressive polling. If your automation wakes the car up every minute to check the state of charge (SoC), the car's computers never sleep. This can drain the 12V battery and waste energy.
Best Practices:
-
Passive Monitoring: Rely on the charger's data (is the cable plugged in?) rather than waking the car via its API.
-
Polling Intervals: If using the car's API, set polling to 15-30 minutes when idle.
Furthermore, keep your automation loops local. By using the Fronius Modbus TCP local integration rather than the cloud API, you keep control latency under 1 second. This prevents the system from pulling grid power for 30 seconds while the cloud server processes that a cloud has blocked the sun.
Integrating the Fronius Primo Gen 24 Plus with Home Assistant transforms your EV charging from a passive drain on your wallet into an active asset for smart home energy management. While it requires some initial configuration and a solid understanding of how amperage, voltage, and power interrelate, the result is an engineering marvel: a car that runs almost entirely on sunshine.
Remember, the goal is balance. Don't chase every single watt of efficiency if it compromises the usability of your vehicle. Start with simple excess solar charging logic, test it thoroughly to ensure safety, and then layer in complexities like battery prioritization and TOU arbitration. Drive safe, and charge smart.







