ADR-0083: The « Trajets » page of the Voitures popup — kilometres per day and an estimated kWh / 100 km¶
Status: Proposed (2026-11-10; draft pull request, judged on the off-device render only — not on the real screen, and not with a real car's data: the author has no Tesla). Date: 2026-11-10
Context¶
Lot 9 of the author's plan for the electric cars (sketch C3). The « Voitures » popup (ADR-0079) shows where each car stands now; this page answers « how much did it drive, and what does it take? ». Two facts of the Tesla integrations (Tesla Fleet, Teslemetry) frame it: the odometer entity is disabled by default (it has to be enabled in the integration), and distances are native in miles (Home Assistant converts them when asked: the recorder's units). The analysis of ADR-0074 already accepted an optional odometre per car and used it for the kilometres of the month; nothing in the blueprint passed it yet.
Decision¶
- The odometer is picked in the blueprint, one per car (
voiture_1_odometre,voiture_2_odometre: a distance sensor, empty by default), and handed toscript.tab5_voitures_analyse. Without an odometer picked the car has no column and, when no car has one, the page does not exist (ADR-0046: a popup with fewer than two pages shows no tabs; a page without data has no tab). The page also needs the charging-power sensor of the car, as the rest of the analysis. - One new service,
tab5_maj_voiture_trajets(rang, payload), the family oftab5_maj_voiture_charges(fields|, lists;, empty = unknown,continue_on_error):debut|compteur_km|km_mois|kwh_100km|km_jours|kwh_jours.debutis the first of seven local days (the last is today),km_joursandkwh_jourshold seven numbers, oldest first. It is the stringtrajets_1/trajets_2that the analysis now also returns, pushed as it is, after the charges and with the same cadence. A new field goes at the end only. The existing outputs of the analysis are untouched. - Kilometres per day come from the recorder's daily statistics (
recorder.get_statistics,period: day,types: [change, state],units: {distance: km}): thechangeof each local day, never negative (an odometer does not go back), and the laststateas the odometer reading. A day without a row is empty, not « 0 km »: a day the integration was offline must not read as a day parked. A known zero is a zero (drawn as a short grey stroke, no number). - The energy a car received each day is summed from the same 5-minute / hourly charging-power rows as the charges (the slots above the 100 W threshold), per local day, in kWh with one decimal. It is shown as a second row of bars under the kilometres. The sketch drew a « consumption » curve there; this is what the analysis can state honestly (see below).
- The kWh / 100 km is an approximation, and the screen says so (« estimé »; the word « consommation » is not used on this page, in any of the seven languages): it is the energy charged this month (the analysis' month value) divided by the kilometres of the month — charge losses, the air conditioning, the pre-heating and a charge not yet finished are all inside. Under 20 km the field stays empty (« -- »). The Python reference (
tools/voitures_charges.py:fenetre_trajets,kilometres_jours,kwh_jours,trajets_en_texte) and the Jinja of the package give the same strings on the same series (tests/test_voitures.py, rendered in a sandbox) and the numbers are checked by hand (tests/test_voitures_charges.py: a daylight-saving window, a local day that is another day in UTC, a negative change, an odometer with no row). - The firmware reads it in the socle (
trajets_lire()andtrajets_jour(),Tab5/socle/tab5_parse.*, tolerant like the other readings and fuzzed): every number has its own ceiling (kTrajets*), above it or unreadable it is « unknown »; an unreadable date leaves the days without a name; an odometer picked but with no reading at all makes the car present with seven unknown values (the card says « Pas encore de relevé du compteur »). The page is drawn in new files (Tab5/ecran/tab5_voitures_trajets.*, widgets created in C++ at the first show, no YAML id): one glass card per car — the name in its rank colour, the odometer, the kilometres of the month in large type, the estimated kWh / 100 km, seven bars of kilometres (today's label highlighted, the day compared with the tablet's own date), seven bars of kWh. Two cars side by side, one car full width (as the Overview). Fonts are read from the Overview's widgets: no line added totab5-voitures.yaml. - Not on the 7B in full: its popup body is 478 px high, so the second row (the kWh bars) is not drawn there (
kAvecKwh = kCorpsH >= kCorpsHTab5, like the consumption of ADR-0078); the kilometres are. - Contract 1.7.0, a pure addition (
tab5_maj_voiture_trajets); the firmware must be updated first (contrat_api.py --matrice).
Consequences¶
- No odometer picked: the popup is the one of before, pixel for pixel (every existing screen of the off-device render is compared with
main; the new ones have no reference). - One more recorder call per analysis (daily statistics of the odometers, a few rows), made only when an odometer is picked,
continue_on_error; the analysis, which already reads thousands of rows, does not get measurably heavier. The time it takes on a real Home Assistant was not measured. - About 90 LVGL objects are created the first time the page is shown (two cards of 46); the RAM and PSRAM they take, and the time of that first build, were not measured.
- The kWh bars are energy received, not driven efficiency: a day with a long drive and no charge shows a tall kilometre bar and no kWh bar. A real consumption curve would need the car's own energy counter, which the integrations do not give; it stays out.
- The odometer's
stateis taken from the recorder's statistics (a daily row exists only once the sensor reported); a sensor with nostate_classhas no statistics at all and the card says so (« Pas encore de relevé du compteur »). Not verified on real data: no Tesla was available; what was checked is the Jinja against the Python reference on synthetic series and the screens on the off-device render. - Not judged on the real screen: the legibility of the seven-day labels in German and Turkish at 541 px, the grey zero strokes, the highlighted day.