Tanken: Distanz-Vorschlag bevorzugt TANK_DISTANZ_SENSOR; Zuletzt-Kachel: Zeilenabstand ergänzt

- distanzVorschlag(): liest jetzt zuerst den Live-Wert von TANK_DISTANZ_SENSOR
  (wie backendseitig schon in distanz_seit_tankung()), fällt ohne Zuordnung
  auf die bisherige FILLS-Berechnung zurück (jetzt distanzVorschlagBerechnet()).
- .leaf .v: gap:3px ergänzt (fehlte im Gegensatz zu .leaf .k) - die zweizeiligen
  Werte in der "Zuletzt"-Kachel (Übersicht) berührten sich sonst.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 11:26:23 +02:00
parent ff9aaeb338
commit dd8d62e3b3
4 changed files with 56 additions and 7 deletions
+31
View File
@@ -4344,6 +4344,37 @@ Verified: `py_compile` clean on `einstellungen.py` (inside `audi_ha_test`, `MSYS
Windows path once, worth remembering for future sessions), manifest bumped to `2026.8.28.10`,
`audi_ha_test` restarted and confirmed clean via log, both fixes confirmed live in the browser as above.
**`.11`: "Gefahrene Distanz" in `Neuer Tankvorgang` prefers the live `TANK_DISTANZ_SENSOR` reading.**
Owner report: after the `.9` negative-distance clamp, the field showed a plain "0" placeholder and the
owner expected "the current sensor output" there instead, plus asked to confirm the AUTO-DETECTED refuel
path already uses `TANK_DISTANZ_SENSOR`. Confirmed the second part first by reading `tankerkennung.py`:
`distanz_seit_tankung()` (called from `_automatisch_anlegen()`) already prefers the sensor and only falls
back to the odometer-subtraction when unmapped - built in section Q, unchanged. The frontend's manual-entry
prefill never had that preference though - `distanzVorschlag()` only ever did the FILLS-based subtraction.
Split it: the old body is now `distanzVorschlagBerechnet()` (pure fallback, same negative-clamp from `.9`),
and `distanzVorschlag()` itself now checks `ENTITAETEN.werte.TANK_DISTANZ_SENSOR` first and returns its
live numeric state if mapped and valid, falling back to `distanzVorschlagBerechnet()` otherwise - the exact
same "sensor preferred, own calculation as fallback" order as the backend, just mirrored in JS for the
still-unsaved form. Verified live: the container's real mapped sensor
(`sensor.testcar_b9_fmm003_testintegratoin_calculated_distance_covered_after_the_latest_refueling`) reads
`407` - opening `Neuer Tankvorgang` now shows `407` (real value, not placeholder-grey) instead of the
`.9`-era empty/`"0"`-placeholder state. companion-app has no "Gefahrene Distanz" field in its own Tanken
form at all (structurally never had one - the backend fills it in itself when omitted), so nothing to port
there, per the parity rule's carve-out for structural differences.
**`.12`: "offen"/"offen" and "51,59 l"/"85,59 €" were touching, not just close** - the Übersicht's
"Zuletzt" tile (`teaser()`) stacks a value and a `<small>` caption via `.leaf .v{display:flex;
flex-direction:column}` - the sibling `.leaf .k` column already had `gap:3px` for the same two-line
pattern, but `.leaf .v` never got it, so its two lines had zero gap and visually touched. Added the
matching `gap:3px`. Panel-only bug (companion-app's equivalent "Letzte Fahrt"/"Letzter Tankvorgang" tiles
use the shared `@audi-dash/ui` `NaviKachel` grid component, a structurally different layout with no
equivalent gap-less two-line stack) - confirmed via source, no companion-app change needed. Verified live:
`getComputedStyle` on the real rendered `.leaf .v` reports `gap: 3px`, and the screenshot shows clear
separation between both stacked value pairs.
Verified across `.11`/`.12`: `node --check` clean each time, manifest bumped `2026.8.28.10``.11``.12`,
`audi_ha_test` restarted and confirmed clean via log at each step.
Verified live in `audi_ha_test` at every step (`.6` then `.7`), each time reading the actual rendered Setup
popup fresh after a real restart (not a stale tab - confirmed via `performance.getEntriesByType('resource')`
showing the new `?v=` served with a nonzero transfer size each time). Final state (`.7`), all 20 single-value
@@ -3515,13 +3515,14 @@ function badgePraefix() {
input-Handler in ereignisseVerdrahten, endgültig beim Speichern). */
const KRAFTSTOFFSORTEN = ["V-Power Racing", "Super Plus", "Super"];
/* Vorschlag für "Gefahrene Distanz" bei einer NEUEN Erfassung: Differenz zum
zeitlich letzten bereits erfassten Tankvorgang in FILLS - dieselbe Regel
wie backendseitig in _distanz_seit_letzter_tankung() (belegverarbeitung.py),
hier nur zur Vorbefüllung, da der neue Datensatz noch nicht existiert. Beim
/* Eigene Berechnung als RÜCKFALL für "Gefahrene Distanz" bei einer NEUEN
Erfassung, wenn kein TANK_DISTANZ_SENSOR zugeordnet ist oder dieser gerade
keinen gültigen Wert liefert (siehe distanzVorschlag() unten): Differenz
zum zeitlich letzten bereits erfassten Tankvorgang in FILLS - dieselbe
Regel wie backendseitig in ablage.distanz_seit_letzter_tankung(). Beim
Bearbeiten eines bestehenden Vorgangs kommt der Wert dagegen direkt aus
f.distance_km (siehe Aufrufer). */
function distanzVorschlag(aktuellerKm) {
function distanzVorschlagBerechnet(aktuellerKm) {
if (aktuellerKm === "" || aktuellerKm == null || !FILLS.length) return "";
const letzte = FILLS.reduce((a, b) => (new Date(b.ts) > new Date(a.ts) ? b : a));
if (letzte.odometer_km == null) return "";
@@ -3534,6 +3535,23 @@ function distanzVorschlag(aktuellerKm) {
return distanz < 0 ? "" : distanz;
}
/* Vorschlag für "Gefahrene Distanz" bei einer NEUEN Erfassung: bevorzugt den
aktuellen Live-Wert von TANK_DISTANZ_SENSOR (vom Fahrzeug selbst berechnet,
z. B. FMM003s "calculated_distance_covered_after_the_latest_refueling"),
fällt ohne Zuordnung oder bei einem gerade nicht-numerischen Zustand
(unavailable/unknown) auf distanzVorschlagBerechnet() zurück - dieselbe
"Sensor bevorzugt, eigene Berechnung als Rückfall"-Reihenfolge wie
backendseitig in distanz_seit_tankung() (tankerkennung.py), hier nur zur
Vorbefüllung im Formular, da der neue Datensatz noch nicht existiert. */
function distanzVorschlag(aktuellerKm) {
const id = ENTITAETEN && ENTITAETEN.werte && ENTITAETEN.werte.TANK_DISTANZ_SENSOR;
if (id && HASS && HASS.states[id]) {
const wert = parseFloat(HASS.states[id].state);
if (Number.isFinite(wert)) return wert;
}
return distanzVorschlagBerechnet(aktuellerKm);
}
function tankFelder(praefix, f) {
// Ein zuvor hochgeladener, noch nicht gespeicherter Beleg (belegEntwurf)
// überlagert hier nur die Beleg-Felder - Kilometerstand/Distanz kommen
@@ -469,7 +469,7 @@ button.sicherheitszeile:active { background: var(--tile-2); }
}
.leaf .k { font-size: 14px; color: var(--fg); display: flex; flex-direction: column; gap: 3px; line-height: 1.35; }
.leaf .k small { font-size: 12px; color: var(--fg3); }
.leaf .v { font-size: 13px; color: var(--fg2); text-align: right; display: flex; flex-direction: column; flex: 0 0 auto; }
.leaf .v { font-size: 13px; color: var(--fg2); text-align: right; display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; }
.leaf .v small { font-size: 12px; color: var(--fg3); }
/* cursor/:active nur für echte .leaf-Buttons (data-go, navigieren bei Klick)
- die Batterie-Messwertliste (vBatterieliste()) ist bewusst ein reines
@@ -1,7 +1,7 @@
{
"domain": "audi_dashboard",
"name": "Audi Dashboard",
"version": "2026.8.28.10",
"version": "2026.8.28.12",
"documentation": "https://gitea.nothaft.cloud/paul/audi-app/src/branch/main/README.md",
"issue_tracker": "https://gitea.nothaft.cloud/paul/audi-app/issues",
"codeowners": ["@paul"],