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

I tested it with the Tesla API back in the day, but I changed it to control the charger because of this reason. I didn’t want to depend on changes to the API (like they happened) and I wanted it to be universal (what if I was charging a different car, and not a Tesla?).

That’s why I recommend to go the charger way. If you can control it through Home Assistant, you are future proof.

Ok, checking this right now, it’s an issue

I’ve been working on an update. I’ve modified the logic, stopped the charging when below threshold and making it more robust in general.

I’ll give it a test and will post the update to the github soon.

1 Like

:red_car::zap: Dynamic EV Charging Automation Blueprint v2.0 - Major Update Released!

I’m excited to announce version 2.0 of my Dynamic EV Charging Automation blueprint with significant improvements and new features that make it more reliable and robust than ever!

:new: What’s New in v2.0

:star: Smart Start/Stop Control

The biggest addition is automatic charger control. Instead of trying to set charging current to 0A (which many chargers can’t handle), the automation now:

  • Stops charging when available power drops below minimum threshold
  • Restarts charging when sufficient power becomes available again
  • Prevents charger errors caused by invalid amperage values

:wrench: Fixed Power Calculation Logic

Resolved a critical issue in the power calculation formula that could cause:

  • :x: Incorrect available power calculations
  • :x: Oscillating start/stop behavior
  • :x: Charging stopping when it should continue

The new logic correctly calculates actual available power for the charger.

:shield: Enhanced Stability

  • Gradual amperage adjustment prevents rapid changes that cause charger errors
  • Improved oscillation prevention through better state management
  • More reliable operation during power fluctuations

:wrench: Installation & Upgrade Instructions

:clipboard: New Users:

Import Blueprint

:arrows_counterclockwise: Existing Users - IMPORTANT:

You MUST recreate your automation as new configuration options have been added:

  1. Import the updated blueprint using the button above
  2. Delete your existing automation (or disable it)
  3. Create a new automation with the updated blueprint
  4. Configure the new required entity (see below)

:gear: New Required Configuration

:electric_plug: EV Charging Toggle (Start/Stop)

New required input: You must select a select entity that controls your charger’s start/stop state.

Supported options should include:

  • "Start charging"
  • "Stop charging"
  • "Waiting for command"

Examples of compatible entities:

  • select.ev_charger_toggle_charging
  • select.wallbox_charging_state
  • select.charger_control

How to find yours:

  1. Go to Developer Tools → States
  2. Search for entities with domain select related to your charger
  3. Look for one with charging control options

:dart: How It Works Now

Intelligent Power Management:

  1. Monitors total household power consumption every 1-3 minutes
  2. Calculates available power for EV charging
  3. Adjusts charging current gradually (1A steps with delays)
  4. Stops charging when insufficient power (instead of setting 0A)
  5. Restarts automatically when power becomes available

Dual Time Period Support:

  • Day mode: Lower power limit (e.g., 4.7kW)
  • Night mode: Higher power limit (e.g., 6.2kW)
  • Configurable days and hours for each mode

Safety Features:

  • Maximum/minimum amperage limits
  • Gradual adjustments to prevent charger errors
  • Only operates when car is home and plugged in
  • Respects charger capabilities

:bar_chart: Example Scenarios

Scenario 1: High House Consumption

  • House using 4.5kW, charger using 3kW
  • Available power drops below minimum
  • Action: Stops charging until house consumption decreases

Scenario 2: Low House Consumption

  • House using 1.5kW, plenty of power available
  • Action: Starts/continues charging at maximum safe rate

Scenario 3: Power Fluctuation

  • Appliances turn on/off throughout the day
  • Action: Gradually adjusts charging rate in 1A increments

:mag: Compatibility

Works with any EV charger that has:

  • :white_check_mark: Amperage control via Home Assistant (number entity)
  • :white_check_mark: Start/stop control via Home Assistant (select entity)
  • :white_check_mark: Charging state sensor (sensor entity)

:bug: Bug Fixes

  • Fixed power calculation causing incorrect stop/start decisions
  • Resolved oscillation issues during marginal power conditions
  • Improved handling of edge cases when charger consumption varies
  • Better error handling for invalid amperage values

:bulb: Tips for Best Results

  1. Set realistic min/max amperage based on your electrical system
  2. Monitor for the first few days to ensure stable operation
  3. Adjust time periods to match your electricity tariff
  4. Use shorter intervals (1 min) for faster response to power changes

:pray: Feedback & Support

This blueprint has been tested extensively, but every setup is different. Please:

  • :star: Star the repository if you find it useful
  • :bug: Report issues via forum
  • :speech_balloon: Share your experience in the comments
  • :arrows_counterclockwise: Suggest improvements for future versions

Repository: GitHub - EDV11/electric-vehicle-ev-dynamic-charging-home-assistant-

Happy charging! :red_car::zap:

1 Like

I’m using both an Easee charger and a Tesla. But neither have a select sensor for charging. Have got tons of other sensors, but the blueprint requires select.

Would your advice be to just create a helper for this? Or are there other possibilities?

With Tesla Fleet integration you have a charging switch, you may try that option. Before making any modifications just try and start charging the car and enable and disable the switch to see how it behaves and if the charger resumes.

If it does work fine, you would have to do some changes to the blueprint

  1. Search and replace in charger_toggle
    Old
charger_toggle:
  name: EV Charging Toggle (Start/Stop)
  selector:
    entity:
      domain: select

New

charger_toggle:
  name: EV Charging Switch (On/Off)
  selector:
    entity:
      domain: switch

2 Search and replace in Service Call
Old

- service: select.select_option
  target:
    entity_id: !input charger_toggle
  data:
    option: |-
      {% if actual_free_power / voltage >= min_amps %}
        Start charging
      {% else %}
        Stop charging
      {% endif %}

New

- choose:
    - conditions:
        - condition: template
          value_template: "{{ actual_free_power / voltage >= min_amps }}"
      sequence:
        - service: switch.turn_on
          target:
            entity_id: !input charger_toggle
    - conditions:
        - condition: template
          value_template: "{{ actual_free_power / voltage < min_amps }}"
      sequence:
        - service: switch.turn_off
          target:
            entity_id: !input charger_toggle

Try that and see if the car can replace that feature of the charger.

2 Likes

One question, is it possible to analyze each of the phases, because in my case I can spend a maximum of 18 amps per phase, which means that depending on the type of consumption I have at home I can have, for example, one phase spending 8 amps and the other 2 1 amp if I am charging at 16 amps per phase the electrical panel will trip

I guess it would be possible if you add one Shelly per phase.

my wall box see amp per phase and i have a shelly 3em

Did this modifification work? I have the same issue and would like to know if anyone tested it?

Not tested by me. ā€œOfficiallyā€ the blueprint operates over the charger because it’s a universal approach and it doesn’t matter if you are charging a Tesla or any other car.

Great work!. How was the experience with feyree portable charger when adjusting current? Stable with local Tuya?

Yes, 100% stable with Tuya, I just reserve the IP in the router and it never disconnects

Thanks for the quick response. I am going to order the feyfee portable type2 7kw. Let see how it goes.

Hi Team, I have an EV5 that only allows you to set charge rate to 60, 90 or 100%. Is there a way to modify this blueprint so that it still works? Or can anyone recommend an alt blueprint?

It doesn’t matter the maximum charge level you select the car to, that doesn’t affect how the blueprint works.

Hi.
I’m using your automation with an AFYEE that can’t change amps if it is charging.
To avoid this I’m using car’s charge control (Tesla) with an ESP32 connected to car’s bluetooth (ESPHome Tesla BLE | esphome-tesla-ble)
My smartmeter is the huawei PV meter but it measures inverted values,
-1000W means that I’m using 1000W from grid and +1000W means that I’m exporting 1000W to grid.

I’ve solved this adding a helper template sensor that inverts value of the meter.
So, for the people that have a inverted value of grid export /import
add a new helper - template - sensor that inverts the value:

{{ states('sensor.power_meter_active_power') | float * -1 }}

Thanks for your blueprint, that helped me a lot.

Just released v2.1 with improved charging status detection. Now supports case variations like ā€œChargingā€ (capital C) which is what ESPHome Tesla BLE returns. This should work better with your ESP32 setup.

Update available on GitHub: GitHub - EDV11/electric-vehicle-ev-dynamic-charging-home-assistant-

Happy charging! :zap:

Hi.
I’ve modified the blueprint to allow charging only from solar excess.

You’ll need to create a helper that enable or disable solar excess mode.
In solar excess mode it will only use the excess of your solar production.
Normal modes doesn’t change, and it will use the maximum grid available.

I hope you consider this useful.

Thanks.

Hi! Thank you so much for taking the time to implement this feature and share it with everyone! :raised_hands:

I’ve reviewed your code and the solar excess charging logic looks solid. The approach of calculating available power based on (total_consumption - charger_consumption) when grid power is negative makes perfect sense for those with solar installations.

A few thoughts: I noticed the calculation uses (total_consumption - charger_consumption) | abs when in solar mode. While this works well, there might be edge cases where the absolute value could create slight oscillations. Have you tested this extensively? I’m curious about your real-world experience with it. Any issues so far?

I can’t test it myself as I don’t have solar panels.