BavarianData

Manual / Driving

Trips / driving journal

Every drive is reconstructed from the stream and kept: distance, duration, start/end places, SoC used, and BMW’s own per-trip consumption, recuperation and driving-style figures. No REST quota.

Not a tax-office-compliant logbook (kein Finanzamt-konformes Fahrtenbuch). This is a trip journal and expense helper; it has no legal tamper-resistance.

How trips are detected

Trips are reconstructed from live GPS in the stream (the integration tracks distance along the GPS track), so no configuration is needed. Make sure the Electric vehicle and location descriptors are enabled in step 4.

The times on a trip

A drive is noticed later than it starts and closed later than it ends — BMW’s position stream can go quiet for minutes at a time, and a trip only closes once the car has sat still for five. The recorded start and end are corrected for that, so they read as driving times rather than detection times:

  • Start — when the car was last seen parked, if your car streams its driver door (the door closing means the driver just got in) and it closed within the last five minutes. Otherwise the first position fix that showed movement.
  • End — the last position fix that showed movement, not the moment the five-minute stop timer expired. If the driver door opening ends the drive instead, that is the arrival.

The distance and the starting charge always count from the parked car. Some cars, such as the i4, report only every few minutes while driving, so their first report on the move comes a few kilometers into the drive. Those kilometers still belong to the trip. The last kilometer, or a final drop in the charge, can also arrive a minute after the trip has ended. If it comes within five minutes and the car hasn’t moved since, it is added to that trip.

Both are still estimates bounded by how often your car reports its position: a long gap in the stream is a long gap in what can be known.

When the position stream goes quiet

“No movement seen for five minutes” has two very different causes: the car stopped, or the stream did. Only the first ends a drive — closing on the second used to split one drive through a tunnel or a coverage hole into two trips.

So a stop is only acted on once something confirms it: a position report that arrived showing the car standing still, an explicit “not moving” from cars that send one, or the driver door opening on arrival with no movement after it. With none of these, the drive is held open until the reports come back and settle it — if the car has moved on, it was one drive all along; if it reappears where it vanished, it really was parked and the trip ends back at the last movement. A stream that never comes back closes the trip after half an hour, and because the end is backdated either way, a late close costs no accuracy.

A position far away

Now and then BMW sends one position far from where the car really is, and the next one back where it stood. Counted as movement, that made a parked car “drive” there and back in no time: a 170 km trip for a car moved 10 m to its wallbox.

A move between two positions faster than any car drives (over 250 km/h, judged by BMW’s own time on each position) is therefore ignored: it neither starts a trip nor adds to one. A position that comes without BMW’s time is always believed.

Trips recorded before this could be ignored may still be in your history. When BavarianData finds one, Settings → Repairs shows Trips that can’t be real: a list of each such trip, all ticked. Submit removes the ticked trips for good, from the trip list, the statistics and the export; untick one to keep it, and it isn’t offered again. Only trips of 10 km or more that would need over 250 km/h on average are offered: a short hop can be stored with a start that came late, and those are real drives.

Older cars that report only at the end of a trip

The detection above needs the car to stream its position while it drives. Owners report that some older cars do not: a G31 530d with iDrive 6, for example, sends mileage, fuel level and position in one burst when a trip ends, and nothing while driving. Read live, that burst looks like a jump of many kilometres in one step, so the live detection can’t make a trip journal out of it.

For these cars, set Configure → Trips → Trip detection to End-of-trip reports. The live detection is then off. On an account with more than one car, pick that car first: the setting is per car, so a car that streams while driving keeps Live. Instead, every vehicle report (a new odometer reading that has held for 5 minutes) becomes one trip:

The Trip detection setting under Configure, Trips, with its two choices: Live (car streams while driving) and End-of-trip reports (car reports once parked)
  • From where to where: from the place the car stood at the previous report to the place it stands now (zone name, or an address with Resolve addresses on).
  • Distance: the odometer difference, in whole kilometres, as the car reports it.
  • Fuel: the trip’s stats carry fuel_start_l, fuel_end_l and, unless the car was refuelled on the way, fuel_used_l. Short trips often show 0 L, because these cars report the tank in whole litres.
  • Charge (electric cars and plug-in hybrids): the trip runs from the battery level the car had when it set off (including any charging since the previous report) to the level in its report, and the energy is worked out from that, as on any other trip.
  • Start time: the burst says when the car parked, never when it set off. So a trip only gets a real start time if something tells BavarianData when the drive began: call bavariandata.mark_trip_start at that moment, for example from an automation that runs when your phone connects to the car’s Bluetooth. If several marks arrive for one drive (a phone that reconnects), the earliest counts. A mark that arrives after the car’s report belongs to the next trip, and a mark more than 12 hours before the report is ignored.
  • Without a mark the trip is stored at its arrival time with no duration: the card shows no minutes for it, and the export leaves the duration empty. This is deliberate. The previous report is when the car last parked, maybe days earlier, so using it as the start would give a duration that is not true.

The first report after you switch the mode only sets the starting point, so the first trip comes with the second drive. Classification, commute chains and the arrived in zone trigger work as for any other trip. There is no trip in progress on these cars, because nothing arrives during the drive, and no route unless a phone supplies one (below).

The route from a phone

An i3 sends no position while it drives, but your phone does: the Home Assistant companion app reports its location as a device_tracker. With Trip detection on End-of-trip reports and Record route on, Configure → Trips shows a second screen, Route from a phone, for that car:

The Route from a phone screen with its four fields, Phone, Phone is in the car, Second phone and Second phone is in the car, all empty
  • Phone: the phone’s device_tracker. Its positions during the drive become the trip’s route.
  • Phone is in the car (optional): a binary sensor that is on while the phone is connected to the car, such as an Android Auto or Bluetooth sensor from the companion app, or a template sensor built from the CarPlay Wi-Fi name. When it turns on, that counts as bavariandata.mark_trip_start, so the trip gets its start time without an automation. Only positions taken while it is on are kept. Without it, positions are held from the trip’s start mark to its arrival.
  • Second phone / Second phone is in the car (both optional): the same pair for a second driver, say a partner. Each phone keeps its own positions. If both phones rode along, the first phone draws the route; the second one’s is used when the first stayed home or ended somewhere else. Either phone turning on its in-car sensor marks the start, and the earliest mark counts. Leave the second pair empty and nothing changes.

What the car says still wins:

  • Distance, duration and charge come from the car. The phone only draws the line. A GPS track reads short on a winding road, the odometer doesn’t.
  • The phone has to end where the car parked. If the phone’s last position is more than 500 m from where the car reported it parked, the phone was not in that car (someone else drove it). The trip then keeps its straight line.
  • No start, no route. Without a start mark, nothing says which of the phone’s positions belong to the drive.
  • Positions closer than 50 m to the previous one (a queue) and fixes less accurate than 100 m are left out. Positions are held in memory only and reach the disk only as part of a trip’s route. A restart during the drive loses the positions held so far.

A trip whose route came from a phone has track_source: phone in get_trips. How often the phone reports is up to the companion app’s location settings. More frequent updates make a finer route and drain the phone’s battery faster.

One owner of an iDrive 6 car built a driving logbook on top of BavarianData before this mode existed. It takes the trip end from the car and the trip start from the phone’s Bluetooth connection, and writes one row per trip to Google Sheets: BMW logbook for iDrive 6 by @ursubey. It is an independent community project, not maintained or tested by BavarianData.

Seeing the drive that’s happening now

A drive in progress is not in the journal yet — it has no end, no final distance and nothing to classify — so it is surfaced separately, live:

  • A Trip in Progress binary sensor per vehicle: on while a drive is under way, with the trip so far as attributes — started, start_location, distance_km, duration_s, soc_start, soc_now, energy_kwh, last_movement and held.
  • On the card: a badge on the overview (distance and minutes so far, tap it for the attributes) and a live row at the top of the trips view — where you came from, the distance and time so far, and the route so far on a map when route recording is on.
  • In bavariandata.get_trips: an open_trips list alongside the recorded ones.

Two things to know before you automate on it:

  • It is not a “car is moving” sensor, which is why it isn’t named one. It tells you a trip is open. A trip opens on the first position report that shows movement and closes five minutes after the last one — longer while the stream is quiet (see above), which is what parking underground looks like. So it stays on for some minutes after you arrive, and up to half an hour if the car parked somewhere with no reception. The recorded trip’s end is backdated correctly regardless; it is only the live flag that lingers. Use the last_movement attribute if you need the finer question.
  • The figures are provisional. Distance comes from the odometer, which only ticks in whole kilometers, so it reads unknown for the first minute or so of a drive and then falls behind the GPS track a little. The final record is computed at close from the better of the available sources.
  • A restart mid-drive doesn’t split the trip. When Home Assistant stops during a drive, the trip is saved as far as it got and the flag goes off. If the car is still driving when Home Assistant is back (within 10 minutes), the trip carries on from its original start and is saved as one drive when you arrive. If the car had already stopped, or the driver’s door had opened, the next drive is a trip of its own. The weather along the drive covers the part before the restart from the recorded route, or, without route recording, from the zone it started in.

Privacy by default

Endpoints are stored as place names, never coordinates:

  • A point inside a Home Assistant zone shows that zone’s name. A smaller zone at the house (a carport, the drive) shows as Home, the same rule as charging: inside your Home zone and within 150 m of its center. The arrived in zone trigger still names the smaller zone.
  • A point outside any zone is stored as an address only if you enable reverse geocoding under Configure → Trips (trip_geocode). That sends the endpoint coordinates to OpenStreetMap’s Nominatim; the resulting address string is stored, and the coordinates themselves are never persisted.
  • Otherwise the endpoint reads Unknown, and the trip carries location_assumed: true. That happens when there was no position at all, or when the position lay outside every zone and has no address: either Resolve addresses is off, or OpenStreetMap gave no answer. A lookup that fails (a timeout or a busy server) is tried once more a few seconds later. Because coordinates are never stored, an Unknown endpoint can’t be resolved afterwards.

Recording the route (opt-in)

By default a trip keeps only its named endpoints — enough for the journal, but not enough to draw a map. Turn on Record route under Configure → Trips (trip_track) and each new trip additionally stores its GPS track: the polyline of coordinates along the drive, each stamped with its time, so a map can show where the car went and replay the drive.

  • This is the only setting that writes raw coordinates to disk — including your exact start and end points — which is why it is off by default and independent of address resolution.
  • It takes effect on the next trip that starts; trips already recorded keep whatever they were captured with, and an in-progress drive keeps the setting it began with.
  • The track rides the trip record and is returned by bavariandata.get_trips (as a track list of points). Each point is [lat, lon, t], where t is whole seconds since the trip started — so a map can animate the route in real time and color it by pace. Routes recorded before this was added store two-element [lat, lon] points and read back without timing; there is no way to backfill their times. The track is never included in the CSV / printable export, which stays place-names-only.
  • The track is bounded and lightly downsampled, so even a long multi-hour drive stays a compact route rather than an unbounded stream of fixes. A stop shows up as a single point whose gap to the next stamp records how long the car sat.

Once routes are recorded, the dashboard card’s Trip map view (view: map) draws them on a map, colored by classification and filterable by time window (see the card).

Weather along the route (opt-in)

CarData has no outside temperature, so how much more the car uses in the cold can only be judged against the weather from outside. Turn on Weather along the route under Configure → Trips (trip_weather, one switch for every car) and each trip gets the weather the car actually drove through, from Open-Meteo (free, no key, no BMW quota).

  • During the drive, the integration keeps a waypoint every 5 minutes or 5 km, rounded to about 1 km, in memory only. Route recording doesn’t have to be on.
  • After the trip, one request sends those waypoints to Open-Meteo, which answers with the 15-minute weather at each one, corrected to the ground height there. A mountain pass reads colder than the valley it started in.
  • What is stored on the trip: per waypoint, the time into the trip, the temperature, rain, wind speed and direction, the ground height and the car’s heading, plus a time-weighted temperature for the whole drive with its lowest and highest value. No coordinates. The waypoints are dropped once asked.
  • Trips stored before you turned it on are filled in too, a few at a time: along their recorded route if they have one, else at their two ends where those are zones, else at your home location. Each record says which (source: route, track, ends or home).
  • A failed lookup is tried once more 15 minutes later.
  • Once a day, it also asks for the day’s lowest and highest temperature where each car is parked (at home, for a car that never sent a position), so the efficiency card can mark today’s band on its chart by temperature. Only the date and the temperatures are kept, never the position, as the Real Range sensor’s outside_temp_c and outside_temp_date. They are stored with the history, so a restart keeps them and doesn’t ask again.

What leaves your house is each trip’s route at about 1 km precision, once, and where each car is parked, at the same precision, once a day, to Open-Meteo. That is why it is off by default.

The trip’s detail on the card shows the temperature (with its range when it varied on the way), get_trips returns the whole record as weather, and the CSV export carries it in four columns. What the figures add up to is in Efficiency & range.

Classification

Drives auto-classify as business, private or commute:

  • Set a work zone under Configure → Trips (trip_work_zone) so home↔work drives are recognized as commutes. Home is Home Assistant’s Home zone, or the Home zone picked on the same screen (home_zone) when Home Assistant runs somewhere else.
  • Everything else is filed as your Default type (trip_default_class) — Private out of the box. Choose Business if that is the honest default for your driving, or Leave unclassified to sort every trip by hand.
  • Correct any guess with bavariandata.set_trip_class or the tap-to-edit control on the trips card.

Automatic classification is only ever a starting point: a trip you classified yourself is never overwritten, and changing these settings does not touch trips that are already recorded.

A commute with a stop on the way

Buying groceries between home and work parks the car long enough that the detector records two drives, neither of which is home→work on its own. The Commute stop tolerance (trip_commute_gap, default 30 minutes) covers that: if the car stands no longer than this between one drive ending and the next beginning, the drives form a chain, and a chain that runs from one commute zone to the other counts as commuting — all of its legs, retroactively. The stops stay visible as separate trips in the journal; they are just all badged commute.

Home ──12 min──▶ Supermarket ──[22 min stop]──▶ Work     both legs = commute
Home ──8 min───▶ Bakery ──────[15 min stop]───▶ Home     both legs = private
Work ──5 min───▶ Lunch ───────[40 min stop]───▶ Work     both legs = private

Details worth knowing:

  • A chain ends when it reaches home or work, so a lunch run out of the office and back doesn’t get pulled into the morning commute.
  • Both ends of the chain are checked, not any endpoint — a round trip that starts and finishes at home stays private, however many stops it had.
  • Up to five drives may form one chain. A longer string of short hops is a day of running around, so it keeps the default type.
  • Stops shorter than about five minutes never split a drive in the first place, so this setting governs the band above that. Set it to 0 to switch chaining off entirely.

How consumption is measured

BMW streams the state of charge as a whole percent. On a 78 kWh pack that makes one step worth about 0.8 kWh — a rounding error over a 30 km commute, and the entire measurement over a 1 km hop. There is nothing finer to reach for: the only other energy value in the stream (smeEnergyDeltaFullyCharged) is the same quantity rounded to whole kWh, and BMW’s own per-trip consumption field (energyConsumptionComfort) is not sent by every car — the i5, for one, never sends it. So BavarianData shows two figures, and refuses a third.

The headline: an energy balance. Measured from the charging ledger alone — two charging sessions bracket a window, each carrying an odometer reading and an SoC taken when it ended, so the distance covered and the energy delivered between them are both known without any drive having to have been detected.

used     = energy charged between the two readings
           − (SoC at the close − SoC at the open) × capacity
distance = odometer at the close − odometer at the open

Charged energy is integrated from streamed charging power, not read off a quantised SoC, so this figure isn’t limited by the one-percent resolution. And because it never reads the trip record, it stays right in a month where a drive was missed (a dead stream, an upgrade, an underground garage). It covers first charge to last charge, which is usually a little shorter than the calendar month.

Which side of the charger it describes depends on your setup, and the card says which:

  • At the battery — the default. BMW streams battery charging power, so the energy that goes into this sum is what reached the pack, not what left the wall. This is directly comparable with the car’s own consumption display.
  • At the plug — only once every charge in the window carries a measured grid figure, from a wallbox energy entity you’ve bound or from BMW’s own charging-history import. This one includes charging losses, so it reads above the car’s display and is what the electricity actually cost. Only then does the card also show the battery-side figure beneath it, with the gap between them labeled as the charging loss — because only then are the two measuring genuinely different things.

The battery-side trip figure. Total trip energy over total trip distance, also comparable with the car’s display. It is a distance-weighted total, not an average of the per-trip figures: averaging ratios lets a 2 km hop outvote a 200 km run, which inflates the result badly. It is the same quantity the battery-side balance measures, only measured through trip detection and SoC deltas — which is why the balance leads and this appears alongside it only when the balance is grid-side.

Per-trip consumption is withheld below a 3 % SoC drop. Under that, the quantisation is the measurement — a 1 km drive that happens to tick one percent would read as ~78 kWh/100 km. Such trips show their distance, duration and energy as usual but no consumption figure, and they can be neither the “best” nor the “worst” trip of the month. On a typical month of short errands and long commutes this means only the longer drives carry a rate; that is the honest outcome, not a gap.

Plug-in hybrids get no per-trip consumption rate. A trip’s energy is the drop in battery charge, but a hybrid may have driven part of the distance on fuel, and the stream carries no electric-only distance to divide by. A 40 km run that used 4 kWh and a liter of petrol would read 10 kWh/100 km — a figure no part of the car achieved. So hybrid trips keep their energy and leave the rate blank, and they don’t count toward the battery-side average. The month’s consumption measured at the plug is withheld too, for the same reason (more).

A hybrid trip records no end SoC when none arrived during it. Some plug-in hybrids never stream their state of charge; the only reading is the one from before the drive. Rather than store that as the end too, a battery that apparently never moved, the trip keeps its start SoC and leaves the end, the SoC used and the energy blank, and the card shows no SoC line for it. A battery car streams its SoC whenever it changes, so on a short hop an unchanged SoC is real and is kept.

Recuperation is likewise shown in kWh/100 km, not kWh: BMW’s recuperationTotal is documented as an average per 100 km, so a month is a distance-weighted mean of it, never a sum.

The monthly sensor and summaries

  • One Driving Distance (This Month) sensor per vehicle carries the monthly total and the business/private/commute split.
  • One Trip in Progress binary sensor per vehicle for the drive happening now — see above.
  • The detail lives in the services (and the card), not a flood of entities:
    • bavariandata.get_trips — recorded trips as response data, plus open_trips for a drive still under way. Each trip carries the odometer when the car set off and stopped (odometer_start_km, odometer_end_km; null on trips recorded before 0.9.34).
    • bavariandata.get_driving_summary — the “month in review”: distance (vs last month), the split, consumption, recuperation, a driving-style score, top destinations, and (with a tariff) an estimated driving cost. Consumption arrives as two keys — energy_balance (plug-side, with the window and the inputs it was derived from) and avg_consumption_kwh_per_100km (battery-side); see how consumption is measured. Either can be absent when its inputs don’t support a figure.

Viewing & exporting

Updated Edit this page on GitHub