This is a simple home project that enables me to charge my Tesla at maximum speed without overloading my home power circuit.
It uses the mqtt messages published by DSMR-reader and calculates the current headroom for charging the Tesla. Using the charging_amps command the Tesla charging speed is scaled up and down as needed. This requires Tesla software 2021.36 or higher to be installed in the car.
Communication with the Tesla API is done using TeslaPy.
In this example the charge is started at 24A but midway L3 is being used for other purposes as well. The load balancer scaled the Tesla back so the maximum current of L3 stays at 25A which is the maximum for this power circuit. As the consumption on L3 decreases the Tesla is scaled back up until it is charging at 24A again.
To be able to use this software you need to do a few things first
- Install DSMR-reader as explained in the documentation
- Install an mqtt broker. On Raspbian:
apt install mosquitto mosquitto-clients
- Configure DSMR-reader to publish telegrams on the dsmr/mqtt channel. Make sure
phase_power_current_l1
(and l2+l3) are included in the mapping. - Install the latest (bleeding edge) TeslaPy version:
git clone https://github.com/tdorssers/TeslaPy.git
cd TeslaPy
python3 setup.py --prefix=~/.local
- Use
cli.py
to get a Tesla API token. This is explained in the README, I used the selenium method. - Copy the
cache.json
to the tesla-loadbalancer directory - Edit
config.py
to match your settings - Start
tesla-mqtt-loadbalancer.py