@@ -116,15 +116,27 @@ def update(self, lp: Loadpoint) -> None:
116116 with self ._svc as s :
117117 currents = lp .charge_currents
118118 voltages = lp .charge_voltages
119- # Per-phase power = current * per-phase voltage. Real grids run
120- # 225-237 V; EVCC reports actuals, so we use them instead of 230.
121- s ["/Ac/L1/Power" ] = float (currents [0 ]) * float (voltages [0 ])
122- s ["/Ac/L2/Power" ] = float (currents [1 ]) * float (voltages [1 ])
123- s ["/Ac/L3/Power" ] = float (currents [2 ]) * float (voltages [2 ])
119+ charge_power = float (lp .charge_power )
120+ apparent = [
121+ float (currents [0 ]) * float (voltages [0 ]),
122+ float (currents [1 ]) * float (voltages [1 ]),
123+ float (currents [2 ]) * float (voltages [2 ]),
124+ ]
125+ apparent_total = sum (apparent )
126+ if apparent_total > 0 and charge_power > 0 :
127+ phase_powers = [
128+ charge_power * apparent_power / apparent_total
129+ for apparent_power in apparent
130+ ]
131+ else :
132+ phase_powers = [0.0 , 0.0 , 0.0 ]
133+ s ["/Ac/L1/Power" ] = phase_powers [0 ]
134+ s ["/Ac/L2/Power" ] = phase_powers [1 ]
135+ s ["/Ac/L3/Power" ] = phase_powers [2 ]
124136 s ["/Ac/Voltage" ] = (
125137 float (voltages [0 ]) + float (voltages [1 ]) + float (voltages [2 ])
126138 ) / 3.0
127- s ["/Ac/Power" ] = float ( lp . charge_power )
139+ s ["/Ac/Power" ] = charge_power
128140
129141 total_current = sum (float (c ) for c in currents )
130142 s ["/Current" ] = total_current
@@ -150,11 +162,15 @@ def update(self, lp: Loadpoint) -> None:
150162 s ["/Status" ] = status
151163 s ["/Connected" ] = 1
152164
153- # Cumulative counters only refreshed while connected. UNVERIFIED:
154- # chargedEnergy is treated as Wh (-> /1000 = kWh). Must be confirmed
155- # against a real EVCC /api/state sample before deploy.
156- if status != STATUS_DISCONNECTED :
165+ # chargeTotalImport is EVCC's cumulative kWh meter value. It keeps
166+ # increasing for continuous heating devices where chargedEnergy is
167+ # a per-session counter and may stay at 0.
168+ total_import = float (lp .charge_total_import or 0.0 )
169+ if total_import > 0 :
170+ s ["/Ac/Energy/Forward" ] = total_import
171+ elif status != STATUS_DISCONNECTED :
157172 s ["/Ac/Energy/Forward" ] = float (lp .charged_energy ) / 1000.0
173+ if status != STATUS_DISCONNECTED :
158174 s ["/ChargingTime" ] = int (lp .charge_duration_ns ) // 1_000_000_000
159175
160176 idx = (int (s ["/UpdateIndex" ]) + 1 ) % 256
0 commit comments