bassmaster187 / TeslaLogger

TeslaLogger is a self hosted data logger for your Tesla Model S/3/X/Y. Actually it supports RaspberryPi 3B, 3B+, 4B, Docker and Synology NAS.
https://www.teslalogger.de
GNU General Public License v3.0
517 stars 170 forks source link

TeslaLogger WallBox (tlwb) API #1014

Open Adminius opened 1 year ago

Adminius commented 1 year ago

Tesla API allows to start/stop charging and also set amps. But is relatively complex. In addion the car shoul be online and not asleep.

The Idea is: provide API in Wallbox style: check status start/stop charging

TeslaLogger will handle the complexty like: send wake up, wait, start charging and so. This implementaion should also be used vor PV guided charging. In this case wallbox api should provide information if PV charging is possible (e.g. the car is at "PV location". on other charging locations it will doen't make sense ;) ) The PV location will be set via geofence new special tag

Suggestions for API endpoints:

GET: http://raspberry:5000/tlwb/carID/status Answer in JSON:

{
"status": 3,
"soc": 67,
"targetsoc": 90,
"targetamp": 13,
"maxamp": 16,
"amps": 13, 
"volts": 233,
"power": 3029,
"phases": 1,
"energy": 65.4
}

"status": 0 = not ready 1 = ready (pluged in) 2 = ready for PV (pluged in and at home) 3 = charging 4 = charging stopped 5 = charging interrupted

Some fields are already provided by TeslaAPI

"soc": current car soc [%](0-100)       "battery_level"
"targetsoc": target soc [%](1-100)      "charge_limit_soc" (in case 1-49 directly from TL)
"targetamp": target current [A] (3-32)      "charge_current_request"
"maxamp": available max current [A]     "charger_pilot_current"
"amps": actual charging current [A]     "charger_actual_current"
"volts": actual charging voltage [V]        "charger_voltage"
"power": actual charging power [W]      internally calculated: phases_internal * charger_voltage * charger_actual_current
"phases": actual phases             internally calculated phases_internal = trunc(charger_power*1000+500/charger_voltage/charger_actual_current)
"energy": added anergy [kWh]            "charge_energy_added"

Start=1/Stop=0 charging GET: http://raspberry:5000/tlwb/carID/control?1

Set current GET: http://raspberry:5000/tlwb/carID/set_amps?16 Direcly set to TeslaAPI: set_charging_amps

Set target SoC GET: http://raspberry:5000/tlwb/carID/set_soc?55 SoC 50-100 is directly set to TeslaAPI: set_charge_limit SoC 1-49 is set as 50 to TeslaAPI set_charge_limit, but TL will check if target soc 1-49 is already achieved, if so it stops charging by it self and not the car. TeslaAPIs 50% is a backup, if TL gets unavailble or crashes or ...

Alternatively only one end point: GET: http://raspberry:5000/tlwb/carID?control=1&set_amps=16&set_soc=55 And as answer the whole status JSON

bassmaster187 commented 1 year ago

Feature branch: https://github.com/bassmaster187/TeslaLogger/tree/SolarChargingTeslaAPI