scher.nl
← All projects Personal project · November 2026

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 →
Prices per day
96
Connections
4
Charge limit
80 · 90%
Cost per month
€ 0
The Current screen of Smart charging in the demo: the status of the car, the battery and charge limit, and a bar chart with the power price per quarter hour for today and tomorrow. The cheapest quarters at night and around noon are coloured green.
The Current screen in the demo, with made-up data. Green marks the quarters in which the app lets the car charge.
At a glance

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.

How Smart charging works Four sources feed data to the app on the home server: the Tesla via Fleet Telemetry, the power prices from EnergyZero, the GoodWe inverter and the HomeWizard P1 meter. The app works per quarter hour and stores everything in a database. It sends commands to the car, can be opened on the phone via Tailscale and sends notifications with ntfy. HOME SERVER Teslalive telemetry EnergyZeroprice per hour GoodWeevery 30-60 s P1 meterevery second Smart chargingdecides per quarter DatabaseSQLite Carlimit, start, stop Phonevia Tailscale ntfynotification
The approach

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. 1

    A plan first

    Claude

    Off-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. 2

    Our own link with the car

    Tesla Fleet API

    The 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. 3

    Working per quarter hour

    EnergyZero

    The 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. 4

    Charging on our own sun

    HomeWizard

    The 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. 5

    Watching along first

    Shadow mode

    Before 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. 6

    Notifications

    ntfy

    Via ntfy I get messages on my phone. On the Notifications page I switch each type on or off: cheap charging (the car is at home without the plug in and a cheap moment is coming within the hour), charging started or paused, preconditioning switched on, and errors. Below that are all sent notifications with a date filter, including those held back by quiet hours or the maximum per day.

Challenges

Where the Tesla has a mind of its own

A Tesla has habits of its own that get in the way of smart charging. The app can't switch them off, so it has to work around them. Each of these three only came to light with the real car in the driveway.

Plugging in means charging right away

What happens. As soon as the plug goes in, the car starts charging, even when power is expensive at that moment. On top of that, at home on wifi the car sends no live data, so at first the app only noticed the charging at its next check, up to 30 minutes later.

How the app solves it. The P1 meter notices when the house suddenly draws 4 kW or more. The app then asks the car right away. If it is not a cheap moment and the battery is above 30%, the app pauses charging: it temporarily sets the charge limit to the current battery level, and sets it back in the next cheap quarter hour. If I then start charging myself in the Tesla app, the app leaves the car alone until the plug comes out.

Preconditioning runs on grid power

What happens. With the plug in, the car takes the power for preconditioning from the grid, even when it isn't charging. On a cold morning that is easily a few kW at the most expensive time of day. A stop command doesn't help: the car isn't charging at that moment.

How the app solves it. The app recognises preconditioning on the P1 meter (more than 2 kW while the car is plugged in and not charging) and asks the car. If it is an expensive moment, it temporarily sets the charging current as low as possible. Whatever extra the heating needs then comes from the battery, which the app tops up later in a cheap quarter hour. Time and temperature stay as set in the Tesla app; the app never cancels preconditioning. The charging current goes back as soon as preconditioning ends, the car starts charging, the plug comes out, a cheap moment arrives or after 2 hours at most.

Starting charging switched off the departure schedule

What happens. On 23 November the car wasn't preconditioned in the morning, although it was scheduled in the Tesla app. Most likely the app's start command switched off the Tesla's scheduled departure programme.

How the app solves it. The app now pauses and resumes charging through the charge limit instead of stop and start commands; only below 50% (Tesla's minimum) does it still send a stop. In the 45 minutes before a scheduled departure with preconditioning it leaves the Tesla's charging alone. And if the climate control is still off a quarter of an hour before departure, the app switches it on, once per departure, and I get a notification. If the car refuses with a fault, the app doesn't try again and reports it once.

Charger

Dumb charger, smart charger or this app

At home there is a dumb charger: it delivers power as soon as the plug goes in, nothing more. A smart charger can do more, but it only controls the power going through the cable. This app controls the car itself. That's why it knows more than a charger does, and no new charger is needed.

WhatDumb chargerSmart chargerDumb charger + this app
Charging in the cheapest quartersNo, charges as soon as it's plugged inOften, via the maker's app or an energy serviceYes, on the ANWB price per quarter hour with my own surcharges
Knows how full the battery isNoUsually not; the charger only sees how much current flowsYes, the app asks the car
Setting the charge limit in the carNoNoYes, 80% normally and 90% when power is very cheap
Charging on surplus solar powerNoYes, usually with an extra meter in the fuse boxYes, with the P1 meter that was already there
Departure time and preconditioningNoSometimes a departure time, nothing moreYes: looks at the scheduled departure in the Tesla and watches over preconditioning
Overload protection (load balancing)NoYesNo, on purpose (see below)
Works withAny carAny carOnly a Tesla
Extra costNoneA new charger, sometimes a subscriptionNone; runs on the home server that was already there
Deliberately not built

What a smart charger does have

Not everything a smart charger can do adds something here. So these things are deliberately left out.

Agreements

Ground rules for the app

Why a demo with made-up data The real app shows where the car is and when nobody is home. That doesn't belong on a public website. The demo is the same app, but the prices, trips and meter readings are made up.
Under the hood

What's inside

PartChoice
AppPython with FastAPI in Docker on the home server
CarTesla Fleet API and Fleet Telemetry, own virtual key, commands via the tesla-http-proxy
PricesEnergyZero (public, per hour), with ANWB surcharges set by me; calculated per quarter hour
SolarGoodWe GW3600T-DS, 3.8 kWp, read locally
GridHomeWizard P1 meter, local API
Notificationsntfy, each type on or off, with a history of everything sent
StorageSQLite: prices per quarter hour and the car every minute
Web appCurrent, History, Notifications and API, own SVG charts, scher.nl house style, only via Tailscale
Try it yourself

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, see under Notifications which messages the app sent, or see under API which data a Tesla can pass on. Nothing goes to a car or server.

Open the demo →

Updated 24 November 2026.