Manual / Charging
Charging history & cost
Because BavarianData streams data in real time, it records every completed charging session and can put a price on it — all from the stream, spending no REST quota. The charge level while it charges has a page of its own: state of charge while charging.
Charged-energy sensors
BMW never sends a kWh counter, so the integration integrates the live charging power over time into two sensors per vehicle:
- Charged Energy (Total) — a monotonic kWh counter
(
device_class: energy/state_class: total_increasing). It counts every charge, at home or not. For the Energy dashboard, use the charging energy at home series instead. - Charged Energy (Session) — resets at the start of every session. While
a charge runs it also carries what that charge has done so far, which the
dashboard card shows:
soc_start(the charge it began at),cost_so_farandcurrency(at your tariff, at home only),cost_partial(some energy went in while the price was unknown) andsolar_percent(the share from your roof, with energy sources set). A figure that can’t be told is empty, never 0; away from home cost and solar stay empty. Between charges these attributes are gone.
Both work on any vehicle that streams charging power.
How accurate is it?
The figure is battery-side — it’s what reached the pack, not what left the
wall, so it sits below your meter by the charging losses. (A true grid figure
only appears as grid_kwh, from BMW’s charging-history import or a wallbox
entity you bind.)
BMW does not sample charging power evenly. It arrives in bursts, sometimes with more than an hour between them, and the integration has to assume the last reported power held until the next one. When the readings are dense that is accurate to within a percent; when the stream goes quiet mid-charge, one unrepresentative sample can dominate a long stretch.
So the running total is bounded by what the battery can have absorbed — the SoC rise times the pack capacity, plus a small margin for the fact that SoC arrives a whole percent at a time. It is a ceiling, never a correction: a session that under-read is left alone, because nothing can tell an under-read from a genuinely slow charge. The bound applies to the total rather than to each step, so a charge held back while a SoC reading is pending recovers in full the moment it lands. A session with no SoC reading of its own is still held to what fills the battery from the level it started at (from empty, if even that is unknown). Only without a capacity does no bound apply.
That includes a car that sleeps through its charge and sends the new level only with the end of it: the charge is settled against that reading once more when it closes. The energy held back keeps the solar, home-battery and grid split and the price of the moment it was charged, so a night charge released at sunrise is still counted as grid.
With a wallbox meter bound, the meter is the bound instead (at home, where it counts the charge). The figure is then what the car reported, but never more than the meter counted. That lifts a charge the car sent no new SoC for, which the SoC bound would have held at the margin, and trims power the car last reported but the wallbox no longer delivered, for example through a power cut. The SoC bound comes back while the meter hasn’t counted anything yet, and when it counted less than the SoC rise proves: then it is stuck or measures something else. Since 0.9.22; charges stored before keep their figure.
The bound needs a SoC reading taken during the session. Not every car streams one: where the only state of charge available comes from the REST snapshot it never changes between charges, and a rise of zero would bound every session at the margin alone rather than at what the car took. Such a session is left unbounded and recorded with no SoC — see no start/end SoC on a session below.
Recorded history
Every completed session is recorded and kept in the integration’s own store rather than the recorder (which purges after ten days). It captures start/end SoC, energy, duration, peak power, the charging power curve, and cost.
A charge that stops and starts again stays one session as long as the
pause is short: up to five minutes while the cable stays in (some cars pause
by themselves mid-charge), or up to two minutes if your car doesn’t report
whether it is plugged in. A charge that waits for a start time set in the
car stays one session however long it waits: plugged in at 18:20 with charging
set to start at 01:00, the car often charges for a minute first, then reports
itself as paused until 01:00. As long as the car says paused and the cable
is in (up to a day), that minute and the night’s charge are one session, and the
wait doesn’t count as charging time: the duration and the average power leave
it out. Any other longer pause ends the session while it happens, even if the
cable stays in (solar charging that waits out a long cloud, say), and the runs
become one session when you unplug (one plug-in, one session).
Pulling the cable ends the session right away. The session ends when charging stopped. When the car reports the charge
as ended, its end events (bavariandata_charging_stopped and the triggers
built on it) fire at once. A stop short of the target first fires
Charging paused after two minutes; the end events follow once the wait is
over, up to five minutes later with the cable in
(when a charge counts as ended).
Retention is set by history_retain_months under
Configure → Charging costs & history (0 = keep everything).
One plug-in, one session
BMW keeps one record from plug-in to unplug, and so does BavarianData once the cable is out. A car on a schedule often charges several times on one plug-in: a short charge right after plugging in, the night’s charge, and preconditioning before you leave. Live, each of these runs is recorded and announced as it happens, so charging finished still arrives when the charge ends, not when you unplug the next morning. When you pull the cable, the runs since you plugged in become one session: the meter’s figures, the energy, the cost and the energy mix are added up, and the gaps count as paused time.
The session keeps each run (runs in get_charging_sessions). That way the
Energy dashboard puts the energy in the hours it actually flowed, not across the
night’s wait, and battery health leaves preconditioning out. The session_id
each run’s bavariandata_charging_stopped carried still finds the session, for
set_charge_cost too.
If the unplug never reaches Home Assistant, the next drive ends the plug-in instead. The runs stay separate when your car doesn’t report whether it is plugged in, when you entered a cost for one of them, or when your wallbox meter measured only some of them. BMW’s charging history then brings them together (importing past charges). Plug-ins before v0.9.35-beta.3 stay as they were recorded.
Preconditioning on the cable
Some cars report charging while they only heat or cool themselves on the
cable, for a departure time set in the car: the battery is already full and the
power goes into the cabin and the battery’s temperature. Such a run is still
recorded as a session, with its energy and cost, and counts in the month’s
totals, since the house paid for it. It is labelled preconditioning in the
card, and its record says preconditioning_only: true. A session gets the
label when the car reported preconditioning as active while it was open and the
battery level didn’t rise. A charge that also heats, with the battery gaining,
stays a normal charge. When you unplug, a warm-up after a charge becomes part of
that plug-in’s session (one plug-in, one session),
which is then a normal charge with the warm-up as one of its runs.
Restarting while the car is charging
A charge that is still running is written to the store as it goes, so restarting Home Assistant, updating it, or reloading the integration in the middle of one no longer loses it. When Home Assistant comes back:
- still charging — the same session simply carries on, and the energy the pack gained while nothing was watching is credited back from the state of charge that measured it;
- charging already over — the session is recorded ending at the last reading actually seen, not at the moment the integration noticed. Whatever flowed after that reading is not in the figure, so the record is a floor.
A stop the car reports just after the restart waits two minutes before the session ends, as a stop seen while Home Assistant runs does. If charging comes back within them, say a wallbox that pauses for a few seconds while Home Assistant starts, it is still the same session. A car that calls the charge finished ends it at once.
Either way the session is flagged interrupted, which is visible in
get_charging_sessions and in an export. Battery health skips such a session
(see Battery health); energy and cost still count
everywhere else.
Which of the two it was is only known once the car says so, and a car charging at steady power can stay silent for hours. So if the car has not reported within two minutes of the restart, the integration asks BMW — BMW’s servers keep the last status the car sent, including a stop that happened while Home Assistant was down. That is the automatic data refresh after every start, and a running charge is checked even when the rest is skipped as recent. With it switched off the charge waits for the car, and is filed as ended by the restart if the car stays quiet for 15 minutes. The same goes when BMW can’t answer. The exception is a bound wallbox meter that is still counting: that shows the charge is running, so it continues. Meanwhile the estimated state of charge keeps climbing at the rate the charge was running at.
Before v0.9.9 an in-progress charge was dropped outright on a restart, which is why the odd charge could be missing from the ledger and monthly totals could read low.
No start/end SoC on a session
A session shows no SoC when no state-of-charge reading arrived while it ran. That is the honest answer rather than a missing feature: the last value held may be days old and belong to a different charge, and reporting it as this one’s start and end would show a flat “38 → 38%” for every charge the car ever makes.
It means your car isn’t streaming
vehicle.drivetrain.batteryManagement.header, which is BMW’s (confusingly named)
high-voltage state of charge.
If you set up before v0.9.6, re-run Configure → Choose streamed data. That descriptor was missing from the old setup snippet, so it was never switched on in the portal and never reached the stream. The coverage repair names it once it has been missing long enough.
If it is ticked and the value still never updates, your car doesn’t send it and there is nothing the integration can do about that. Energy, duration, peak power, the power curve and cost are all unaffected either way, and importing BMW’s own charging history (Importing past charges from BMW) fills the SoC back in where BMW recorded it.
Charges recorded before v0.9.6 show the opposite symptom — a flat “38 → 38%” and about 1.4 kWh — and can be repaired from BMW’s history too: Repairing charges from before v0.9.6.
Where the energy came from
With Configure → Solar & energy sources set up, every charge also records how much of its energy came off your roof, out of your house battery, and off the grid — in grid-side kWh, the side your house meters measure.
This only applies to charges at home. At a public charger, at work or at any other place the car reports outside your Home zone, your house sensors say nothing about what went into the car, so such a charge records no mix. The same goes for the cost: your tariff is your home price, so a charge elsewhere gets no cost from it. Its energy still counts everywhere. If BMW billed the charge itself, importing BMW’s history adds that cost. A car that reports no position at all is treated as at home, as before. A smaller zone drawn at the house, such as a carport or the drive, counts as home too: a charge inside your Home zone and within 150 m of its center is filed under Home, whatever smaller zone Home Assistant puts the car in. A zone further out, inside a Home zone you widened for presence (a supermarket down the road), stays a place of its own. Charges recorded before v0.9.18 that got your home mix or tariff away from home are cleared the next time Home Assistant starts.
The card shows a ☀ 62 % solar tag on the session row and the full breakdown
when you expand it; the month’s share rides as attributes (solar_percent,
energy_mix) on the Charging energy this month sensor, and the export and
the printed month report both carry the numbers. A charge with no solar in it
gets no tag. The share is of the energy that could be measured: charges from
before the sensors were set up count toward the month’s energy but not toward
its mix, so the month report says it outright, e.g. 76 % — 75 of 99 kWh
measured.
How the split is decided
Energy is attributed as it is delivered, from the site’s supply mix at that instant — the same way the price is sampled. A charge that starts in sunshine and finishes after dark is split between the two, rather than filed under whichever came last.
The car is treated as just another load: it gets the same mix the rest of the house got at that moment. No convention that gives the car the sunshine first (which flatters the roof), and none that makes it the marginal load carrying the grid import (which flatters the grid). Concretely, at an instant with 4 kW of PV reaching loads, 2 kW out of the battery and 2 kW imported, the car’s energy is booked 50 % PV, 25 % battery, 25 % grid.
Two consequences worth knowing:
- Exported PV doesn’t count, and PV going into the house battery doesn’t count yet — it is attributed later, as battery, when it comes back out. So the same kilowatt-hour is never counted twice.
- A missing or unavailable sensor means “unattributed”, not “grid”. Such energy lands in its own bucket, and a session where nothing could be attributed records no mix at all — because “we couldn’t tell” and “none of it was solar” are different statements. The solar percentage is always a share of what could be attributed. One exception: a PV sensor that reads unknown while the sun is down (many inverters go offline at night) counts as 0 W, so a night charge is still split between grid and house battery.
- A restart during a charge leaves a gap. The charge carries on, and the energy it took while Home Assistant was restarting still counts in its total, but no sensor was read for it, so it has no source and no price. The card counts it as unattributed, so a charge’s breakdown always adds up to the charge, and the charge’s detail says Home Assistant restarted during it. Saving a Configure screen restarts the integration too.
What it costs
Set Value of own solar — usually your feed-in tariff, the money you give up by not exporting — and a charge’s cost becomes what it really cost you: a fixed value, or a price entity for a dynamic feed-in price, read while the car charges. Left at Import price, solar is billed like grid energy, so existing totals keep their old meaning and only the mix is new information.
House-battery energy is always billed at the import price in force at the time. Its contents could have come from the roof at noon or from a cheap-hour grid charge at three in the morning, and this integration cannot tell which — so it takes the conservative figure rather than claim a saving that may never have existed. The raw kWh per source are stored, so you can always do that arithmetic differently yourself.
Setting up cost
Set this up under Configure → Charging costs & history (Settings reference). Pick a price source:
- Fixed price per kWh — a flat rate you know.
- Price entity — point it at Tibber, Nordpool, aWATTar, … That entity is sampled while the car charges, so a session spanning a price change is billed correctly rather than at whatever the price happened to be at the end.
Until you choose a price source, no cost entities are created at all — a wrong number would be worse than none. A price filled in while the price source is still None is refused when you save, so it can’t go unused.
You then get, per vehicle:
- Charging Energy (This Month) — always available.
- Charging Cost (This Month) and Charging Cost (Last Session) — once a price source is set.
- Charging Cost per 100 km — additionally needs the odometer (Vehicle status cluster) and two sessions to measure a distance between. Every charge in the month must have a cost: the distance covers every kilometer, so a charge away from home, which has no cost, leaves the month without one. Not on a plug-in hybrid, whose odometer also counts the kilometers driven on fuel (why).
Entering what a charge cost
A charge away from home has no cost unless BMW billed it, and a figure from BMW or the tariff may not match what you paid. Tap the charge on the charging view, type the total from the receipt into Paid and press Save. The amount is in the currency set under Configure → Charging costs & history, and the card marks it entered.
An entered amount replaces BMW’s figure and the tariff’s, and counts wherever a
cost does: the month’s total, Charging Cost (This Month), cost per 100 km and
the export. The figure it replaced is kept: Remove brings it back, and a
later import of BMW’s history updates that kept figure without touching yours.
The long-term statistics take the new amount on the next import_statistics.
A public charger often bills time or parking on top of the energy. Type that part
into of which fees next to the amount: the amount stays the charge’s total
(it is what you paid), and the charge’s details and the
export’s cost_fees column show the fees apart, so the energy
cost can be told from them.
Automations can do the same with
bavariandata.set_charge_cost; the
session_id of the bavariandata_charging_stopped event names the charge.
Grid energy vs. battery energy
Energy is measured at the battery, so it’s slightly below what the grid delivered. Two ways to reconcile:
- Wallbox sensor — select your wallbox’s cumulative energy sensor
(
grid_energy_entity) and that exact grid figure is used instead: it lands on the session as a measuredgrid_kwh, feeds the monthly totals, the statistics and the export, and is billed as the charge proceeds, so a dynamic tariff still prices each kilowatt-hour at the rate in force when it arrived. A reading that can’t be right — a meter that reset, or one reporting far less than the pack absorbed or nearly twice it — is refused rather than believed, and the session keeps its battery-side figure. Details and the failure cases: MQTT bridge (evcc & more). - Loss percentage — otherwise gross the battery figure up by your charging
losses (
charging_loss_percent). It stays at 0 % by default, because an invented correction would look like a measurement. With a wallbox meter bound you don’t need it: the loss becomes measured.
A session charged while the price was briefly unknown is flagged partial
rather than silently understated. The month’s cost is flagged partial too
when it leaves out a charge with no cost at all, such as one away from home.
Metered home charges stored before v0.9.22 can carry the flag as well: an
older version left part of their energy out of the split and the cost, and
since its price was never recorded, the missing kWh are listed as unpriced
(unpriced_kwh) instead of guessed.
Importing past charges from BMW
The bavariandata.fetch_charging_history service pulls BMW’s own recorded
sessions and imports them into the local history, so charges from before you
installed the integration appear on the card and in the monthly summaries.
Overlapping live-recorded sessions are enriched in place with BMW’s measured
grid energy, unless your wallbox meter already measured the charge: its figure,
and the cost billed from it, are kept. BMW’s own billed cost still replaces it.
If BMW’s record also takes in short pieces of the same charge that the meter
didn’t measure, BMW’s figure is used for the whole charge. This one does spend API quota (one or more of your 50 a day).
Without From and To it fetches the last 30 days.
BMW keeps one record from plug-in to unplug, as BavarianData does once you unplug (one plug-in, one session). Runs that were still separate (because your car doesn’t report the cable, say) become one session when BMW’s history arrives, in the same way. BMW’s preconditioned flag then describes that whole session, as BMW means it.
Repairing charges from before v0.9.6
Until v0.9.6 the state of charge never reached the stream, so every charge from then was stored with the same stale level at both ends (“38 → 38%”). The energy was held to what a flat level allows: about 2 % of the pack, roughly 1.4 kWh.
Run Fetch charging history once with From set before your first affected charge. For each charge that BMW recorded with a rise of at least 2 percentage points but that is stored as flat, the import:
- takes BMW’s start and end level,
- adds BMW’s measured grid energy, which the card, monthly totals, statistics and export then count,
- removes the battery-side kWh and the solar share, since both came from the capped figure,
- works the cost out again on a fixed price, or keeps it marked partial with a live price entity, whose past prices can’t be rebuilt.
A charge BMW also recorded as flat — a car pre-heating while full, say — is left exactly as it is, as is a charge BMW doesn’t list. Running the import again changes nothing further.
Two things stay different from a charge recorded on a fixed build. Those charges never count toward battery health, which needs battery-side energy. And real range needs the battery-side kWh of every charge it covers, so it shows nothing rather than a wrong figure until the repaired charges are older than 30 days.
Charging places
The card’s Places tab lists every place the car has charged at, most visited first, built from the recorded sessions. Nothing extra is stored: delete history and the places go with it. For each place:
- visits, the typical stop (the median length of a charge there), and the energy charged there in total;
- AC or DC. The car says so when it streams its plug type; otherwise a peak above 22 kW counts as DC, since no BMW charges faster than that on AC. AC and DC visits are never averaged together;
- the average power you actually got, and from two visits on the best visit;
- minutes per 10 %, counted only from visits that added at least 20 % and ended at or below 80 %. Above 80 % a fast charger slows down a lot, which would make a good charger look slow;
- preconditioned vs. not, when visits of both kinds exist. Only BMW’s charging history says whether the battery was preconditioned, so this needs an import;
- the power curves of the latest five visits, drawn on top of each other.
A place with one visit shows that visit’s figures, never an “average” of one. Late-started charges and charges a restart cut into count as visits, but not toward speed: their energy is only a lower bound.
How charges become places. A charge in a Home Assistant zone belongs to that zone. Away from your zones, BMW’s address and charge point operator name the place; the operator is shown only when every charge point BMW matched belongs to the same one. A charge with no position at all counts as Home, the same rule the tariff follows, and is marked assumed. Charges away from home that have neither a position nor an address share one Other places row, with no speeds, since it mixes chargers.
Remember charging locations
Configure → Charging costs & history → Remember charging locations (off by default) keeps the coordinates of each charge. With it on, charges within 75 m of each other are one place, and the Places tab shows them on a map. It writes raw coordinates to disk, which is why it is off until you turn it on. Turning it off again deletes every stored coordinate; zones, addresses and operators stay, and so does the list.
It works from the next charge on. For older charges, Fetch charging history once: BMW’s records carry the position, and the import adds it to the charges you already have.
The places come from get_charging_places (below), which costs no quota.
DC charging and BMW’s operator names have not been seen on a real car’s data yet.
If yours shows something odd, a
diagnostics report helps.
Reading it back
- The
view: chargingcard, with its Sessions and Places tabs. bavariandata.get_charging_placesreturns the places as service response data (optionalvin,from,to) — no quota.bavariandata.get_charging_sessionsreturns the full history as service response data (optionalvin,from,to,limit) — no quota.- Export to CSV or a printable report.
- Long-term statistics on the Energy dashboard.