@@ -85,6 +85,8 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
8585 energyStart = snapshot.energySinceStartKwh,
8686 socStart = snapshot.socPercent,
8787 tempC = snapshot.outsideTempC,
88+ tempSum = snapshot.outsideTempC ? : 0f ,
89+ tempCount = if (snapshot.outsideTempC != null ) 1 else 0 ,
8890 lastMs = snapshot.timestampMs,
8991 odometerLast = snapshot.odometerKm,
9092 energyLast = snapshot.energySinceStartKwh,
@@ -101,6 +103,9 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
101103 climateLast = snapshot.climateSinceStartKwh ? : enCours.climateLast,
102104 accessoriesLast = snapshot.accessoriesSinceStartKwh ? : enCours.accessoriesLast,
103105 regenLast = snapshot.regenSinceStartKwh ? : enCours.regenLast,
106+ // Moyenne et non valeur de départ : voir [moyenne].
107+ tempSum = enCours.tempSum + (snapshot.outsideTempC ? : 0f ),
108+ tempCount = enCours.tempCount + if (snapshot.outsideTempC != null ) 1 else 0 ,
104109 integratedKm = enCours.integratedKm + (pas ? : 0f ),
105110 integrated = enCours.integrated || pas != null ,
106111 // Une vitesse manquée ne réinitialise pas le trapèze : le prochain intervalle
@@ -129,6 +134,8 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
129134 socStart = snapshot.socPercent,
130135 type = snapshot.chargeType,
131136 tempC = snapshot.outsideTempC,
137+ tempSum = snapshot.outsideTempC ? : 0f ,
138+ tempCount = if (snapshot.outsideTempC != null ) 1 else 0 ,
132139 powerSum = 0f ,
133140 powerCount = 0 ,
134141 lastMs = snapshot.timestampMs,
@@ -140,6 +147,10 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
140147 lastMs = snapshot.timestampMs,
141148 socLast = snapshot.socPercent ? : chargeEnCours.socLast,
142149 type = chargeEnCours.type ? : snapshot.chargeType,
150+ // Une charge de nuit traverse plusieurs degrés : la moyenne dit quelque chose,
151+ // la température du branchement ne dit rien.
152+ tempSum = chargeEnCours.tempSum + (snapshot.outsideTempC ? : 0f ),
153+ tempCount = chargeEnCours.tempCount + if (snapshot.outsideTempC != null ) 1 else 0 ,
143154 )
144155 } else if (snapshot.charging == false && chargeEnCours != null ) {
145156 events + = Event .ChargeEnded (
@@ -191,7 +202,7 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
191202 regenKwh = p.regenLast,
192203 socStart = p.socStart,
193204 socEnd = p.socLast,
194- outsideTempC = p.tempC ,
205+ outsideTempC = p.averageTempC ,
195206 integratedKm = integre,
196207 )
197208 }
@@ -206,7 +217,7 @@ class StatsTracker(private val capacityKwh: Float = StatsSettings.DEFAULT_CAPACI
206217 socEnd = socEnd,
207218 energyKwh = delta?.takeIf { it > 0f }?.let { (it / 100f * capacityKwh).roundTenth() },
208219 measuredPowerKw = if (p.powerCount > 0 ) (p.powerSum / p.powerCount).roundTenth() else null ,
209- outsideTempC = p.tempC ,
220+ outsideTempC = p.averageTempC ,
210221 )
211222 }
212223
0 commit comments