Smart charging
A home-made charging assistant for our Tesla Model Y. With a dynamic energy contract the price of power changes every quarter hour. The app charges the car when power is cheap, charges on surplus solar power and sets the charge limit in the car itself. Built with Claude Code, on the home server.
Try the demo (in Dutch) →- Prices per day
- 96
- Connections
- 5
- Charge limit
- 80 · 90%
- Cost per month
- € 0
Prices, sun and car together
The app on the home server fetches the power prices every day and hears from the car, the inverter and the smart meter how things stand. Every quarter hour it decides whether the car charges, and up to which percentage. It sends that to the car as a command. On my phone I can see what it does.
From plan to a car that charges itself
Claude wrote the plan, the code and the explanations in the app. I chose what the app is allowed to do, the percentages and when it leaves the car alone. Every change went into the repository as a pull request, and I tested with the real car in the driveway.
-
1
A plan first
ClaudeOff-the-shelf services can do a lot, but they don't know my contract, panels and meter. Claude wrote a plan in phases: first the connections, then watching along, and only then taking control. The calendar link and fast charging on the road were dropped; they added too little.
-
2
Our own link with the car
Tesla Fleet APIThe app is registered with Tesla on scher.nl and has its own digital key in the car. The car streams live data to our own Fleet Telemetry server. At home on wifi that doesn't always work; then the app asks the car itself, without waking it.
-
3
Working per quarter hour
EnergyZeroThe hourly prices come from EnergyZero, for today and from 13:00 also for tomorrow. The app converts them into the ANWB price: market price plus VAT, purchase costs and energy tax. Target charging charges to 80% in the cheapest hours. Opportunity charging raises the limit to 90% when the price drops below a threshold.
-
4
Charging on our own sun
HomeWizardThe P1 meter measures every second what the house draws or feeds back. If there is enough surplus for five minutes, the app starts charging and matches the charging current to the surplus. To spare the car it changes the current at most once every 4 minutes, and only for a difference of more than 250 W.
-
5
Watching along first
Shadow modeBefore the app was allowed to control the car, it only calculated along: what would each charging method have cost for my own charging sessions? Now the history shows for every session what charging right after plugging in would have cost, and how much the app saved.
-
6
What's next
In progressNotifications via ntfy and a weather strategy with Open-Meteo have been built, but are not switched on yet. When it freezes, the app charges the last hour just before departure, so the battery is warm. When tomorrow will be sunny, it leaves 20 to 30% room overnight for our own solar power.
Ground rules for the app
- One button switches smart charging off. The car then gets its own charge limit back and charges as set in the Tesla app again.
- Below 30% the car always charges right away, whatever power costs.
- If I start charging myself, the app leaves the car alone until the plug comes out. And it starts or stops at most once every 10 minutes.
- The app never wakes the car. That costs battery and weighs heavily on the Tesla bill; this way it stays within the free credit of $10 per month.
- Keys and tokens live only on the server, never in git or in a chat. The app itself can only be opened via Tailscale.
What's inside
| Part | Choice |
|---|---|
| App | Python with FastAPI in Docker on the home server |
| Car | Tesla Fleet API and Fleet Telemetry, own virtual key, commands via the tesla-http-proxy |
| Prices | EnergyZero (public, per hour), with ANWB surcharges set by me; calculated per quarter hour |
| Solar | GoodWe GW3600T-DS, 3.8 kWp, read locally |
| Grid | HomeWizard P1 meter, local API |
| Weather | Open-Meteo, free and without a key |
| Storage | SQLite: prices per quarter hour and the car every minute |
| Web app | Current, History and API, own SVG charts, scher.nl house style, only via Tailscale |
Click through the demo
The demo is the same app as on the server, with a made-up year of prices, trips and charging sessions. Pick another method under Settings and see which quarters turn green, browse the days under History or see under API which data a Tesla can pass on. Nothing goes to a car or server. The app itself is in Dutch.
Open the demo (in Dutch) →Updated 21 November 2026.