Met dit Home Assistant-pakket bepaalt Home Assistant elke 15 seconden met welke stroom je Alfen-laadpaal laadt, en op hoeveel fasen. De auto laadt op zonne-overschot, laadt maximaal bij een negatieve stroomprijs en volgt de planning van DAO (Day Ahead Optimizer) als je die gebruikt.
Het hart is een pyscript dat alle regels in een vaste volgorde afloopt: direct laden, negatieve prijs, laaddoel, DAO en tot slot zon. Heb je een thuisbatterij, dan houdt het script daar rekening mee: de auto gebruikt bij laden op zon nooit stroom uit de batterij.
Wat het pakket doet:
- Laden op zon op 1 fase vanaf 6 A, met startdrempel, stopvertraging en een pauze na een stop, zodat het laden niet flappert bij wisselende bewolking
- Maximaal laden (16 A, 3 fasen) zolang de stroomprijs negatief is
- Direct laden met één schakelaar, tot een laaddoel dat je zelf kiest
- DAO-planning volgen, met drie laadmodi: dao, min_solar en solar
- Rekening houden met een thuisbatterij op “0 op de meter”
- Bij inpluggen een melding met vraag wanneer de auto klaar moet zijn (07:00, maandag 8 uur of “direct”)
Onderaan dit artikel kun je de complete, kant-en-klare YAML downloaden, met een uitgebreide PDF-handleiding. Getest met Home Assistant 2026.10.
Het pakket bestaat uit: een pyscript voor de laadsturing, een package met helpers en een melding, en een package voor de koppeling met DAO. Zonder DAO gebruik je alleen de eerste twee.
⚙️ Wat heb je nodig?
Hardware:
- Een Alfen-laadpaal (bijvoorbeeld Eve Single Pro-line) met Modbus TCP aan; bij Alfen heb je daarvoor meestal de licentie Active Load Balancing nodig
- Een laadpaal die tussen 1 en 3 fasen kan wisselen (anders laadt het script op zon op het aantal fasen dat de paal heeft)
- Een P1-meter in Home Assistant, bijvoorbeeld van HomeWizard, met het netvermogen in W
- Zonnepanelen met een vermogenssensor in Home Assistant
- Een auto waarvan het accupercentage in Home Assistant staat (via de integratie van je automerk)
- Optioneel: een thuisbatterij en DAO (Day Ahead Optimizer)
- Een dynamisch energiecontract, bijvoorbeeld bij Zonneplan
In Home Assistant:
- Pyscript via HACS
- Een Alfen Modbus-integratie uit HACS (laadstroom, fasekeuze, aangesloten-status)
- De integratie Zonneplan ONE voor de kwartierprijs (of een andere prijssensor in EUR/kWh)
- De Home Assistant Companion-app voor de meldingen
- Ondersteuning voor packages in
configuration.yaml
Zelf aan te maken helpers:
input_boolean.laadpaal_override— direct laden, maximaal tot het laaddoelinput_number.ev_min_soc— laaddoel van de auto in %input_number.ev_min_solar_amp— minimale laadstroom bij laden op zon (meestal 6 A)input_select.ev_charge_mode— laadmodus bij een DAO-planning: dao, min_solar of solar
🧩 De 5 onderdelen
Pyscript: Instellingen bovenaan
Wat doet dit: koppelt het script aan jouw entiteiten.
Hoe maak je dit:
ENT = {
"soc": "sensor.auto_accupercentage", # SoC van de auto (%)
"car_connected": "sensor.alfen_car_connected",
"ev_power": "sensor.alfen_active_power_total", # W
"phase_select": "select.alfen_usable_phases1",
"grid_w": "sensor.p1_meter_vermogen", # W, + = afname
"pv": ["sensor.omvormer_vermogen"], # lijst met PV-vermogens (W)
"batt_net": None, # thuisbatterij (optioneel)
"dao_amp": None, # DAO (optioneel)
# ...
}
TARGET_NUMBER = "number.alfen_max_current_limit_s1"
Bovenaan in ENT staan alle entiteiten die het script leest. Wat je niet hebt, zet je op None: zonder thuisbatterij laat het script die berekening weg, zonder DAO laadt de auto alleen op zon, bij een negatieve prijs of met direct laden. Daaronder staan constanten zoals de maximale stroom (16 A) en de stopvertraging (60 s).
Pyscript: Beslisvolgorde
Wat doet dit: bepaalt elke 15 seconden de laadstroom en het aantal fasen.
Hoe maak je dit:
if override_active: # 1. direct laden
target_a, desired_phases = MAX_A, PH3
elif price_now is not None and price_now < 0: # 2. negatieve prijs
target_a, desired_phases = MAX_A, PH3
elif soc_reached: # 3. laaddoel bereikt
target_a = 0
elif dao_planned: # 4. planning van DAO
...
else: # 5. alleen zon
target_a, kort = pv_besluit(avg_kw, last_a, ...)
Het script loopt de regels van boven naar beneden af; de eerste die geldt, wint. Bij laden op zon telt het script het zonne-overschot op als teruglevering plus het laadvermogen van de thuisbatterij, min wat de batterij ontlaadt, en kapt dat af op wat de panelen werkelijk leveren. Omhoog gaat de stroom met maximaal 1 A per stap, omlaag direct. Zakt het overschot onder de 6 A, dan laadt de auto nog even door en stopt hij na 60 seconden (of na 30 seconden als het tekort uit de batterij komt).
Package: Helpers en melding
Wat doet dit: maakt de helpers voor direct laden, laaddoel, minimale stroom en laadmodus, en een melding bij start en klaar.
Hoe maak je dit:
input_select:
ev_charge_mode:
name: Auto laadmodus
options:
- dao
- min_solar
- solar
De melding luistert naar het event ev_laadpaal_update dat het script afvuurt. Je krijgt een bericht als het laden start (met de reden) en als het laaddoel bereikt is. Met dezelfde tag vervangt een nieuwe melding de vorige.
Package: Koppeling met DAO
Wat doet dit: de helpers die DAO vult, en automatiseringen voor de stoptijd en het einde van direct laden.
Hoe maak je dit:
triggers:
- trigger: time
at: input_datetime.dao_ev_stop_time
DAO zet dao_ev_laadstroom en dao_ev_laadpaal_actief als er laden gepland staat. Wil DAO binnen een kwartier stoppen, dan zet het een stoptijd; de automatisering zet op dat moment de laadopdracht uit. Zet je direct laden uit, dan stopt het laden meteen en wacht Home Assistant op de volgende reguliere DAO-run.
Automatisering: Vraag laadtijd bij inpluggen
Wat doet dit: vraagt bij inpluggen via een melding wanneer de auto klaar moet zijn.
Hoe maak je dit:
actions:
- action: EV_KLAAR_ANTWOORD
title: Antwoord geven
behavior: textInput
Je antwoordt in de melding zelf: een tijd (07:00), een dag (maandag), een dag met tijd (maandag 8 uur) of “direct”. De automatisering zet de klaartijd voor DAO en meldt de auto pas daarna bij DAO aan. Geen antwoord binnen 30 minuten? Dan blijft de vorige tijd staan.
📝 Gebruikte templates
- Zonne-overschot — teruglevering + laadvermogen thuisbatterij (bij 0 op de meter en SoC vanaf 20%) – ontlaadvermogen thuisbatterij, maximaal de gemeten PV-productie.
- Laadstroom op zon — (overschot – 0,25 kW marge + wat de auto nu trekt) / 230 V, omhoog maximaal 1 A per stap.
- Tijd uit het antwoord — de inplug-melding herkent een datum met tijd, een tijd, een dagnaam of een dagnaam met “8 uur”.
❓ Veelgestelde vragen
Werkt dit zonder DAO? Ja. Zet in het script de DAO-entiteiten op None en gebruik alleen laadpaal_helpers.yaml. De auto laadt dan op zon, maximaal bij een negatieve prijs en met direct laden.
Werkt dit met andere laadpalen dan Alfen? Het script stuurt een number-entiteit voor de laadstroom en een select voor het aantal fasen. Heeft jouw laadpaal-integratie die ook, dan pas je alleen de entiteiten aan. Zonder fasekeuze zet je phase_select op None.
Gebruikt de auto stroom uit mijn thuisbatterij? Niet bij laden op zon: komt het tekort uit de batterij, dan stopt het laden binnen 30 seconden. Bij direct laden en een negatieve prijs laadt de auto wel maximaal, ook uit net of batterij.
Wat zijn de laadmodi dao, min_solar en solar? Ze gelden als DAO een planning heeft en de strategie minimize consumption is. dao volgt DAO, min_solar laadt altijd minimaal de bodemstroom plus wat er aan zon is, solar laadt alleen op zon.
Gebruik je DAO nog niet? Lees Day Ahead Optimizer (DAO) met Home Assistant. Een thuisbatterij erbij sturen? Lees Thuisbatterij sturen met DAO.
Hieronder kun je bovenstaande automatiseringen downloaden incl. de genoemde helpers en templates, de volledige YAML en een uitgebreide PDF-handleiding.
De genoemde helpers kun je zelf aanmaken in Home Assistant onder apparaten en diensten -> helpers -> Helper toevoegen.
Let op gebruik is op eigen risico!!
Home Assistant: smart EV charging on solar, negative prices and DAO (Alfen)
With this Home Assistant package, Home Assistant decides every 15 seconds at which current your Alfen charger charges, and on how many phases. The car charges on solar surplus, charges at maximum power when the price is negative and follows the DAO schedule (Day Ahead Optimizer) if you use it.
At its heart is a pyscript that goes through all rules in a fixed order: charge now, negative price, target level, DAO and finally solar. If you have a home battery, the script takes it into account: when charging on solar the car never uses power from the battery.
What the package does:
- Solar charging on 1 phase from 6 A, with a start threshold, stop delay and a pause after a stop, so charging doesn’t flap on and off with passing clouds
- Maximum charging (16 A, 3 phases) while the electricity price is negative
- Charge now with one switch, up to a target level you choose
- Follow the DAO schedule, with three charge modes: dao, min_solar and solar
- Takes a home battery on “zero on the meter” into account
- When you plug in, a notification asking when the car must be ready (07:00, monday 8 uur or “direct”)
At the bottom of this article you can download the complete, ready-to-use YAML with an extensive PDF guide. Tested with Home Assistant 2026.10.
The package consists of: a pyscript for charge control, a package with helpers and a notification, and a package for the DAO link. Without DAO you only use the first two.
⚙️ What do you need?
Hardware:
- An Alfen charger (for example Eve Single Pro-line) with Modbus TCP enabled; with Alfen this usually needs the Active Load Balancing license
- A charger that can switch between 1 and 3 phases (otherwise solar charging uses the charger’s fixed number of phases)
- A P1 meter in Home Assistant, for example from HomeWizard, with grid power in W
- Solar panels with a power sensor in Home Assistant
- A car whose battery level is in Home Assistant (via your car brand’s integration)
- Optional: a home battery and DAO (Day Ahead Optimizer)
- A dynamic energy contract, for example with Zonneplan
In Home Assistant:
- Pyscript via HACS
- An Alfen Modbus integration from HACS (charge current, phase selection, connected status)
- The Zonneplan ONE integration for the quarter-hourly price (or another price sensor in EUR/kWh)
- The Home Assistant Companion app for notifications
- Support for packages in
configuration.yaml
Helpers to create yourself:
input_boolean.laadpaal_override— charge now, at maximum power up to the target levelinput_number.ev_min_soc— target level of the car in %input_number.ev_min_solar_amp— minimum charge current for solar charging (usually 6 A)input_select.ev_charge_mode— charge mode with a DAO schedule: dao, min_solar or solar
🧩 The 5 parts
Pyscript: Settings at the top
What it does: links the script to your entities.
How to build it:
ENT = {
"soc": "sensor.auto_accupercentage", # SoC van de auto (%)
"car_connected": "sensor.alfen_car_connected",
"ev_power": "sensor.alfen_active_power_total", # W
"phase_select": "select.alfen_usable_phases1",
"grid_w": "sensor.p1_meter_vermogen", # W, + = afname
"pv": ["sensor.omvormer_vermogen"], # lijst met PV-vermogens (W)
"batt_net": None, # thuisbatterij (optioneel)
"dao_amp": None, # DAO (optioneel)
# ...
}
TARGET_NUMBER = "number.alfen_max_current_limit_s1"
At the top, ENT lists all entities the script reads. Set what you don’t have to None: without a home battery the script skips that calculation, without DAO the car only charges on solar, at a negative price or with charge now. Below that are constants such as the maximum current (16 A) and the stop delay (60 s).
Pyscript: Decision order
What it does: sets the charge current and number of phases every 15 seconds.
How to build it:
if override_active: # 1. direct laden
target_a, desired_phases = MAX_A, PH3
elif price_now is not None and price_now < 0: # 2. negatieve prijs
target_a, desired_phases = MAX_A, PH3
elif soc_reached: # 3. laaddoel bereikt
target_a = 0
elif dao_planned: # 4. planning van DAO
...
else: # 5. alleen zon
target_a, kort = pv_besluit(avg_kw, last_a, ...)
The script goes through the rules from top to bottom; the first one that applies wins. For solar charging the script calculates the surplus as export plus home battery charging power, minus what the battery discharges, capped at what the panels actually produce. The current goes up by at most 1 A per step and down immediately. If the surplus drops below 6 A, the car keeps charging for a while and stops after 60 seconds (or after 30 seconds if the shortage comes from the battery).
Package: Helpers and notification
What it does: creates the helpers for charge now, target level, minimum current and charge mode, plus a notification at start and finish.
How to build it:
input_select:
ev_charge_mode:
name: Auto laadmodus
options:
- dao
- min_solar
- solar
The notification listens to the ev_laadpaal_update event the script fires. You get a message when charging starts (with the reason) and when the target level is reached. With the same tag a new notification replaces the previous one. The message texts are Dutch; change them to your own language.
Package: DAO link
What it does: the helpers DAO fills in, and automations for the stop time and the end of charge now.
How to build it:
triggers:
- trigger: time
at: input_datetime.dao_ev_stop_time
DAO sets dao_ev_laadstroom and dao_ev_laadpaal_actief when charging is scheduled. If DAO wants to stop within a quarter hour, it sets a stop time; the automation switches the charge command off at that moment. When you switch charge now off, charging stops immediately and Home Assistant waits for the next regular DAO run.
Automation: Ask ready time when plugging in
What it does: asks via a notification when the car must be ready when you plug in.
How to build it:
actions:
- action: EV_KLAAR_ANTWOORD
title: Antwoord geven
behavior: textInput
You reply in the notification itself: a time (07:00), a day (maandag), a day with time (maandag 8 uur) or “direct”. The automation sets the ready time for DAO and only then registers the car with DAO. No reply within 30 minutes? The previous time stays. The day names are Dutch; translate them in the template if you like.
📝 Templates used
- Solar surplus — export + home battery charging power (at zero on the meter and SoC from 20%) – home battery discharging power, at most the measured PV production.
- Solar charge current — (surplus – 0.25 kW margin + what the car draws now) / 230 V, up by at most 1 A per step.
- Time from the reply — the plug-in notification recognises a date with time, a time, a day name or a day name with “8 uur”.
❓ Frequently asked questions
Does this work without DAO? Yes. Set the DAO entities in the script to None and only use laadpaal_helpers.yaml. The car then charges on solar, at maximum power at a negative price and with charge now.
Does this work with chargers other than Alfen? The script controls a number entity for the charge current and a select for the number of phases. If your charger integration has those too, you only change the entities. Without phase selection, set phase_select to None.
Does the car use power from my home battery? Not when charging on solar: if the shortage comes from the battery, charging stops within 30 seconds. With charge now and at a negative price the car does charge at maximum power, also from grid or battery.
What are the charge modes dao, min_solar and solar? They apply when DAO has a schedule and the strategy is minimize consumption. dao follows DAO, min_solar always charges at least the minimum current plus any solar, solar only charges on solar.
Not using DAO yet? Read Day Ahead Optimizer (DAO) with Home Assistant. Want to control a home battery too? Read Control a home battery with DAO.
Below you can download the automations above including the helpers and templates mentioned, the complete YAML and an extensive PDF guide.
You can create the helpers yourself in Home Assistant under Devices & services -> Helpers -> Create helper.
Use at your own risk!!


Geef een reactie