šŸš— Tesla Dynamic Charging (Ford, Mercedes… any EV) Automation

Dynamic EV Charging Automation for Home Assistant

This project automates the charging current of an electric vehicle based on household power consumption.
It works with any EV (Tesla, Mercedes, Ford, BYD, etc.) or any EV charger as long as it is integrated and can be controlled within Home Assistant.

This blueprint dynamically adjusts the charging rate, ensuring that the vehicle uses the maximum available power without exceeding the contracted limit.
It also supports different power limits for day and night to optimize charging based on electricity tariffs.

If you found this project helpful, please consider buying me a coffee!

Buy Me a Coffee at ko-fi

Versions

Version 2.1 - Added case-insensitive charging status support (Compatible with ESPhome Tesla BLE and other integrations)

Version 2.0 - Added start/stop control and fixed power calculation
Version 1.1 - Adjustments are made in 1A increments every 8 seconds to avoid charger errors.

:inbox_tray: Installation

This blueprint can be installed in two ways:

:link: Direct Import via Home Assistant

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

:open_file_folder: Manual Installation

  1. Open the blueprint file in this repository:
    https://github.com/EDV11/electric-vehicle-ev-dynamic-charging-home-assistant-/blob/main/Dynamic-EV-Charging-Automation.yaml
  2. Copy the URL from your browser’s address bar.
  3. In Home Assistant, go to Settings → Automations & Scenes → Blueprints.
  4. Click ā€œImport Blueprintā€ in the bottom right corner.
  5. Paste the URL and click ā€œPreview Blueprintā€.
  6. Click ā€œImport Blueprintā€ to finalize.

:electric_plug: :red_car: :battery: Tested Hardware

This is some of the hardware I’ve used and tested with this automation:

Just to be clear, if you can control your car from Home Assistant and have access to its sensors, you can use this automation without a connected charger.


:wrench: Requirements

Before using this blueprint, you need the following:

  • Total Power Consumption Sensor
    (e.g., Shelly EM Gen3 is recommended if you don’t have one; you can get it from that link).
  • Your EV or Charger integrated into Home Assistant, exposing the necessary sensors.
    (For example, Feyree portable charger.)
  • Basic information about your electricity contract, including:
    • Grid voltage (e.g., 230V for EU, 120V for the US).
    • Maximum grid power limits (contracted power).
    • Day and night tariff periods (if applicable).

:gear: Configuration

The following parameters need to be configured:

  • Charging interval (1, 3, or 5 minutes).
  • A device tracker (preferably the car) to ensure that the automation runs only when the EV is at home.
  • A charging status sensor to ensure changes are only made when the EV is actively charging.
  • Total power consumption sensor (measured in watts).
  • Maximum Grid Power (Day) – Set to 0 if you only want to charge at night.
  • Maximum Grid Power (Night).
  • Charging current control entity – The EV or charger must support dynamic amperage control.
  • Grid voltage.
  • Maximum charging amperage – The system will never exceed this limit, even if extra power is available.
  • Minimum charging amperage – The system will stop charging if power availability drops below this threshold.
  • Day-time period settings (Define when ā€œdayā€ mode applies, typically when electricity is more expensive or power is limited).

:rocket: How It Works

The automation runs every 1, 3, or 5 minutes, depending on the selected interval.
It only adjusts the charging rate if the EV is charging and at home.

Dynamic Load Adjustment

The automation continuously monitors household power usage and dynamically adjusts the charging current to avoid exceeding the contracted power limit.
If a high-power appliance (e.g., oven, stove, heating) is turned on, the charging rate will automatically decrease to prevent overloading.
Once power consumption drops, the EV will resume charging at the maximum allowed rate.

Day & Night Power Limits

Many electricity contracts offer cheaper power at night, along with higher power limits.
This blueprint allows setting different power limits for day and night, ensuring that charging is optimized based on your tariff structure.


:question: Reporting Issues & Community Discussion

If you encounter issues or have suggestions for improvements, please post them below

4 Likes

New update after @Deporpeps reported errors with the charger.

I’ve modified the current increase/decrease logic. Now, adjustments are made in 1A increments to avoid charger errors. Changes occur every 8 seconds until the selected power limit is stabilized.

Hi @Eduardo any chance you could help me out?
I’m trying to use your Blueprint with a Wallbox Copper SB.

The charging status is set by default to ā€œChargeā€.
While in your blueprint it is checking on ā€œchargeā€.

The uppercase C is resulting in a false result while my car is charing. I’d like to keep the blueprint as user-friendly as possible and not transform it in an editable automation.

Any chance this can be configured somewhere that I could have missed?
Thanks

Open the installed blueprint and change, on line 173, adding the uppercase C

        state: Charging

It’s the easiest way to move forward with your issue.

1 Like

Thanks a lot @Eduardo worked like a charm. I’m new with Blueprints so I didn’t know these could be edited through the File manager.
It’s working fine now!
Thanks a lot for your help and super useful blueprint.

hello Eduardo, i“ve read the blueprint, and my question is: is it complicated to use a blueprint like yours to absorbe all the power from solar pannels,

Sorry but until I install some panels I will not be able to hive any details on solar power, as it’s something I haven’t tested myself

1 Like

Can it be used without location/tracking?

Location tracking is there in case you adjust charging rate to the car (ie your charger doesn’t have WiFi) and you charge at home as well as elsewhere.

If you adjust the charger, or only charge at home, you can disregard location. Just delete the lines in the blueprint

OK. thank you very much,

can you change the ā€œnumberā€ to also include ā€œinput_numberā€?

Im thinking of deploying this blueprint towards my charger (and not specify the actual car) and my charger changes ampere thorugh service-calls which i have set up a separate automation for, hence i need input_number …

Hi! Great Work!
Do You plan to support multiple chargers in a household?
I mean if i have two chargers at home, they could share the rest energy fairly. Or would be possible to give prio for one.

Thanks

You can change it on the local blueprint downloaded and see if it works using the service calls

No, I don’t plan to. That could be a big rabbit hole I don’t want to go into… it’s going to be hard to sync two chargers in the same household.

@Eduardo
Sorry to bother, i testing yout blueprint but i have one question,
actual_free_power_day: ā€˜{{ max_grid_power_day - (total_consumption - charger_consumption) }}’
actual_free_power_night: ā€˜{{ max_grid_power_night - (total_consumption - charger_consumption) }}’

if you had this, the result will always be the same or not??
the total consumption integrates the charger consumption .
or im seeing something wrong,

Sorry if im just not seeing

No bother at all

It’s been a while since I created it and you are right, it seems inconsistent as total_consumption comes from the sensor. I can’t recall right now why I did it like that, I guess I should test with

  actual_free_power_day: "{{ max_grid_power_day - total_consumption }}"
  actual_free_power_night: "{{ max_grid_power_night - total_consumption }}"

I will try to simplify those lines.

Another thing I should check is when there is less than 6A available it throws an error because it can’t go to 0, so instead charging should stop. I have to see how to implement it

Thanks, i think i manage and adjust your blueprint, to correspond to my solar power available, i will then share my blueprint

I think it’s a great idea, what happens is that with the new Tesla API I can’t control the power, just read it, but with Tessie I can.

Hello, I’ve been testing your system these days and it didn’t work for me completely and I don’t know why, I’ve done several tests and ultimately doing tests with automations I can read the consumption I spend at home both in W and in Amp, and then I can control the charging speed of the vehicle in Amp in real time, with Tessie, with which it could work, but it doesn’t go as expected, since when I start charging. and marking as Charging, it changes the number of charging power up to 16 Amp which is how I have limited it to test, but then I turn on anything that consumes 8amp, and instead of lowering it to 8Amp the car’s charge keeps it at 16, but if I manually lower it to 10, it goes up again

target:
entity_id: number.drakharys_corriente_de_carga
data:
value: |-
{% if actual_free_power / voltage > max_amps %}
{{ max_amps | float }}
{% elif actual_free_power / voltage < min_amps %}
0.0
{% else %}
{{ (actual_free_power / voltage) | round(1) | float }}
{% endif %}
action: number.set_value

This is the part that I think he doesn’t execute