App 2.19.7: meter AC charging too, while the app runs

A session runs whenever power flows into the pack, AC or DC; gaps the
head unit slept through are dropped as before. Dashboard and server
texts no longer say DC only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-23 22:07:03 +02:00
co-authored by Claude Opus 5.5
parent e6f8258203
commit 93e7e4cb63
10 changed files with 60 additions and 25 deletions
@@ -14,9 +14,10 @@ import java.util.List;
import java.util.UUID;
/**
* Persistent DC charging session meter and offline upload queue.
* Persistent charging session meter (AC and DC) and offline upload queue.
*
* Only DC is metered — see {@link ChargingState#DC_MIN_KW}. Energy and duration are
* A session is metered while power flows in — see {@link ChargingState#isMeteredCharging} —
* and only while the app runs: gaps are dropped, not billed. Energy and duration are
* integrated on {@link SystemClock#elapsedRealtime()} for the same reason
* {@link ConsumptionTracker} is: the head unit's wall clock jumps when it picks up GPS or
* NTP time, and one forward jump mid-charge used to invent both kWh and hours. Wall-clock
@@ -104,7 +105,7 @@ final class ChargeSessionTracker {
long elapsed = SystemClock.elapsedRealtime();
Float power = snapshot.getBatteryPowerKw();
Float soc = snapshot.getSocPercent();
boolean charging = ChargingState.isDcCharging(snapshot.getChargingStatus(),
boolean charging = ChargingState.isMeteredCharging(snapshot.getChargingStatus(),
snapshot.getChargePortConnected(), power, snapshot.getSpeedKmh());
if (charging) {
@@ -237,7 +238,7 @@ final class ChargeSessionTracker {
}
if (soc != null) lastSoc = soc;
if (power != null) lastPower = power;
if (power != null && -power >= ChargingState.DC_MIN_KW &&
if (power != null && power < ChargingState.CHARGING_POWER_KW &&
(points.isEmpty() || nowMs - points.get(points.size() - 1).timestampMs >= curveIntervalMs)) {
points.add(new Point(nowMs, soc, Math.abs(power)));
decimateIfFull();