Skip to content

ADR-0076: Electric cars on the Flux page of the Energy popup

Status: Accepted (2026-11-09). Date: 2026-11-09

Context

The Flux page of the Energy popup (ADR-0058) draws four circles — solar, home, grid, battery — and the lines between them. A house with an electric car shows the car only as part of the « home » circle: a 7 kW charge looks like a house that eats 8 kW, and nothing says where that energy comes from. A user in Türkiye with two Teslas and solar panels is the first to need it; the layout follows the author's sketch B1 (lot 1 of his plan for the cars).

Decision

  • One service, one payload per car. tab5_maj_voiture(rang, payload): rang « 1 » or « 2 » (two cars at most), payload nom|batterie_%|autonomie|unite_distance|etat|puissance_W|energie_ajoutee_kWh|limite_%|minutes_restantes|compteur (read by voiture_lire(), Tab5/socle/tab5_parse.*, tested on a PC and fuzzed). etat is 0 unknown, 1 unplugged, 2 plugged, 3 charging. A field left empty is unknown; an empty payload removes the car (its circle disappears). Home Assistant pushes it with the instant of the popup (script.tab5_energie, continue_on_error), nothing without a car chosen. The contract goes to 1.5.0 (a pure addition); the firmware must be updated first.
  • Plan correction — the 10th field. The plan kept « the home meter counts the cars » as a blueprint option only, but the tablet needs it to subtract the cars from the home circle, and no field carried it. It travels as the last field of every car payload (compteur, « 0 » = the meter does not count the cars; « 1 », empty or unreadable = it does, the default). The tablet keeps the last one received. A later field is appended after this one, never inserted (the fields only grow at the end).
  • Flow model (energie_flux_calculer, pure). The home is served first (solar, then battery, then grid), the cars share what is left in proportion to their charging power. With the option on, the cars' power is subtracted from the measured home (never below 0), so the home does not count it twice. With no car the function takes the early path it had before: the same numbers, bit for bit (tested on nine input sets). Cars are drawn only where the page is as tall as the Tab5's (kFluxVoitures); on the 7B (994 × 478) nothing is drawn and the home is not reduced, since nothing would show it.
  • Layouts from a table. The two arrays of four centres and the flux_disposer of two cases become kDispositions[]: six layouts (no car or battery, battery, one car, two cars, battery and one car, battery and two cars), each with its centres and a mask of lines never drawn — the one that would cross a circle (grid → car 2 passes through car 1; grid → battery passes through car 1). The share of a hidden line toward a car stays readable on that car's ring; the grid ↔ battery exchange has no ring (only the home and the cars carry one), so with a car, only the battery's own text tells it (open, see the consequences). tests/test_energie.py computes, layout by layout, which lines would cross a circle and requires the mask to be exactly that set, so a moved circle or a useless mask is caught.
  • Battery and two cars: one circle. The bottom row has room for the battery and one car, not two: with both cars it shows a single « 2 voitures » circle (the total power, both levels). The battery without a car, and the layouts of before, are unchanged.
  • Screen texts go through tr() in the seven languages (« Branchée », « Débranchée », « Pas en charge », « %d voitures », « Voiture %d », « +%s ajoutés », « Limite %d %% », « Prête dans %s »); the car glyph (car-electric) is in mdi_font_45 and MDI_CODE_TARGETS.
  • Home Assistant side. A collapsed section « Énergie : voitures » of the blueprint (nine optional sensors per car, only the battery makes a car appear, plus the option of the meter) feeds capteurs.voitures; the package turns each sensor into the payload (W / kW / MW, Wh / kWh / MWh, a duration with its unit or a timestamp for the end of the charge, the state read in words or deduced from the cable and the power). No entity ID in the public files (ADR-0024).

Consequences

  • No car chosen: Home Assistant pushes nothing and the Flux page is the one of before (proved by the off-device render, the geometry tests and the host tests of the flow).
  • What the plan's notes say of the Tesla integrations is taken into account: the charger power arrives in kW (converted), « Time to full charge » is a timestamp (turned into minutes, and pushed only while charging), the range is in miles natively (sent with its unit) and disabled by default in Teslemetry (said in the blueprint's help), a sleeping car answers « unavailable » or « unknown » (empty fields, state 0, nothing is ever woken: the package only reads states). The words of the state sensor are known only from the documentation, not checked on a real account. An unknown word falls back on the cable, then on the power (10 W or more = charging), then « unknown ». A car unplugged counts for 0 W whatever its power sensor still says.
  • The cars are kept in the tablet's memory like the other instants: a car removed from the blueprint while its rank 1 stays is pushed empty and disappears; with both removed, Home Assistant pushes nothing, so the old circles stay and the home keeps subtracting their last charge until the next restart (open: a push of two empty payloads when no car is chosen would fix it, but an older firmware has no such action; clearing the cars when the popup closes needs the push to come back at each opening, not checked).
  • Open — battery and car(s). The battery's layouts are drawn and tested (no line crosses a circle, the layout without a car is unchanged), but the grid ↔ battery line is hidden as soon as a car is shown, and with two cars they are merged into one circle. Whether that reads well on the real screen is not judged; a better arrangement (a taller page, a ring for the battery) is left to the author's look at the render.
  • The grid's colour (2026-11-09): the grid circle, its lines and the grid share of the rings were WARNING, almost the sun's GOLD; they are now POWER_GRID, a violet per theme that is neither the sun's yellow nor the battery's ACCENT_ALT (ADR-0077).
  • About 26 more LVGL objects are created when the popup is first built (two circles, their rings, four legends); the RAM and PSRAM were not measured for this change.
  • The Voiture struct stays private to tab5_energie.cpp; a later screen that shows the cars elsewhere moves it to a header and appends its fields after the tenth.