Is there an existing issue for this?
What happened?
charge_energy_added appears cumulative for the whole plug-in session, not per charging_process, causing under/overcounting across segmented charges
Hi, I believe TeslaMate may be misinterpreting the semantics of Tesla's charge_energy_added field.
After investigating both the database records and the source code, it looks like charge_energy_added behaves more like a counter for the whole plug-in session (since the cable was plugged in), not a counter local to a single charging_process.
TeslaMate currently seems to treat it as if it were per-process added energy, which leads to incorrect results in at least these scenarios:
- scheduled charging after the car has already been plugged in for hours
- Sentry / vampire drain between plug-in and actual charging start
- a single plug-in session being split into multiple charging segments / charging_processes
Environment
- TeslaMate version:
4.0.1
- Bare-metal install on Ubuntu
- PostgreSQL backend
- Grafana dashboards restored from TeslaMate
- Vehicle: Tesla Model Y Long Range (China)
What I observed
Case 1: scheduled AC charging after plug-in, with energy loss before charging actually starts
I plugged in the car in the evening at about 40%, then scheduled charging to start at 03:00 local time.
Sentry mode was enabled, so the battery dropped before charging actually began.
Plug-in baseline before scheduled charging
From positions, around plug-in time, the car was still at about:
18:47:44 local: 40%, rated range 225.89 km
18:52:32 local: 40%, rated range 225.61 km
18:57:34 local: 40%, rated range 225.49 km
Actual charging process
This charging process then ran from about 03:00 to 05:26.
From charges:
- session start:
03:00:30
- battery level:
38%
- rated range:
214.85 km
charge_energy_added = 0.00
- first non-zero
charge_energy_added: 03:23:40
- battery level:
40%
- rated range:
225.74 km
charge_energy_added = 0.02
- session end:
05:26:25
- battery level:
50%
- rated range:
280.93 km
charge_energy_added = 8.30
charge_energy_used = 10.54
Why this looks suspicious
Charging was clearly active from the beginning of the process:
- charger current / voltage / power were already non-zero
- SOC increased from
38% to 40%
- rated range increased from
214.85 km to 225.74 km
But charge_energy_added stayed at 0.00 for the first ~23 minutes and only became non-zero when the car had roughly returned to the same range/SOC level it had when first plugged in.
That strongly suggests that the raw field is not "energy added since this charging_process started", but something closer to:
- "net energy added since the cable was plugged in"
I also back-extrapolated the counted portion of the curve and got an implied hidden initial value of about -1.61 kWh, which fits this interpretation very well.
Case 2: one plug-in session split into two charging processes
This is the more direct evidence.
Under the same plug-in session, TeslaMate recorded two charge entries:
Charging process A
- start:
2026-07-09 03:00:32
- duration:
35m
- SOC:
35% -> 38%
- rated range:
198 km -> 214 km
- energy added:
1.20 kWh
- energy used:
2.53 kWh
- efficiency:
47%
Charging process B
- start:
2026-07-09 03:38:56
- duration:
2.1 h
- SOC:
38% -> 50%
- rated range:
214 km -> 282 km
- energy added:
10.22 kWh
- energy used:
10.79 kWh
- efficiency:
95%
These two charging processes belong to the same plug-in session.
The important part is this:
- process A ended with
charge_energy_added = 1.20
- process B appears to start with that
1.20 already included
- TeslaMate then reports process B's added energy as the full
10.22, instead of rebasing it
So TeslaMate totals become:
- process A added:
1.20
- process B added:
10.22
- summed total:
11.42
But if 10.22 is the cumulative net added value for the whole plug-in session, then process B's own contribution should be:
So at least 1.20 kWh is counted twice across the two processes.
Why I believe this is a TeslaMate interpretation / aggregation issue
From the source code:
lib/tesla_api/vehicle/state.ex maps charge["charge_energy_added"]
lib/teslamate/vehicles/vehicle.ex stores vehicle.charge_state.charge_energy_added directly into charges
lib/teslamate/vehicles/vehicle.ex also normalizes nil -> 0 in put_charge_defaults/1
lib/teslamate/log.ex aggregates charging_processes.charge_energy_added using the values stored in charges
This means:
- TeslaMate stores the upstream field more or less directly
- TeslaMate then aggregates it per
charging_process
- If the upstream field is actually cumulative over the whole plug-in session, the per-process aggregation is semantically wrong
- Converting
nil to 0 also hides the distinction between:
- "no positive value yet / counter not usable yet"
- real zero
Impact
This appears to affect at least:
Charge Details -> Added
- charge efficiency
- total energy added
- summed statistics across multiple processes
- and possibly higher-level derived dashboards if they use these charge totals
I also observed obviously implausible downstream values such as battery capacity estimates temporarily exceeding the configured "new" capacity, which suggests that these bad charge totals can propagate into higher-level estimation.
Expected behavior
For each charging_process, added energy should reflect only the energy attributable to that process.
If charge_energy_added is actually cumulative for the whole plug-in session, TeslaMate should probably not use it directly as a per-process counter.
Possible directions:
- preserve raw
nil instead of coercing it to 0
- rebase
charge_energy_added against the start of the plug-in session, or at least against the start of the process
- detect carry-over when one plug-in session is split into multiple charging processes
- avoid using affected sessions for higher-level estimations if the raw field cannot be safely rebased
Summary
The observed behavior is consistent with this interpretation:
- Tesla's
charge_energy_added is cumulative for the whole plug-in session
- TeslaMate currently treats it as if it were local to each
charging_process
- this causes undercounting when charging starts below the original plug-in baseline
- and overcounting / double-counting when one plug-in session is split into multiple charging processes
Expected Behavior
No response
Can the issue reliably be reproduced?
Yes
Steps To Reproduce the issue
No response
Relevant log output
Charging process A
start: 2026-07-09 03:00:32
duration: 35m
SOC: 35% -> 38%
rated range: 198 km -> 214 km
energy added: 1.20 kWh
energy used: 2.53 kWh
efficiency: 47%
Charging process B
start: 2026-07-09 03:38:56
duration: 2.1 h
SOC: 38% -> 50%
rated range: 214 km -> 282 km
energy added: 10.22 kWh
energy used: 10.79 kWh
efficiency: 95%
These two charging processes belong to the same plug-in session.
The important part is this:
process A ended with charge_energy_added = 1.20
process B appears to start with that 1.20 already included
TeslaMate then reports process B's added energy as the full 10.22, instead of rebasing it
So TeslaMate totals become:
process A added: 1.20
process B added: 10.22
summed total: 11.42
But if 10.22 is the cumulative net added value for the whole plug-in session, then process B's own contribution should be:
10.22 - 1.20 = 9.02
So at least 1.20 kWh is counted twice across the two processes.
Screenshots
No response
Additional data
No response
Type of installation
Manual (no support)
Version
v4.0.1
PostgreSQL version
No response
Are you running latest major supported PostgreSQL version?
Are you using a reverse Proxy for TeslaMate?
No
Details about your reverse Proxy if applicable
No response
Is there an existing issue for this?
What happened?
charge_energy_added appears cumulative for the whole plug-in session, not per charging_process, causing under/overcounting across segmented chargesHi, I believe TeslaMate may be misinterpreting the semantics of Tesla's
charge_energy_addedfield.After investigating both the database records and the source code, it looks like
charge_energy_addedbehaves more like a counter for the whole plug-in session (since the cable was plugged in), not a counter local to a singlecharging_process.TeslaMate currently seems to treat it as if it were per-process added energy, which leads to incorrect results in at least these scenarios:
Environment
4.0.1What I observed
Case 1: scheduled AC charging after plug-in, with energy loss before charging actually starts
I plugged in the car in the evening at about
40%, then scheduled charging to start at03:00local time.Sentry mode was enabled, so the battery dropped before charging actually began.
Plug-in baseline before scheduled charging
From
positions, around plug-in time, the car was still at about:18:47:44local:40%, rated range225.89 km18:52:32local:40%, rated range225.61 km18:57:34local:40%, rated range225.49 kmActual charging process
This charging process then ran from about
03:00to05:26.From
charges:03:00:3038%214.85 kmcharge_energy_added = 0.00charge_energy_added:03:23:4040%225.74 kmcharge_energy_added = 0.0205:26:2550%280.93 kmcharge_energy_added = 8.30charge_energy_used = 10.54Why this looks suspicious
Charging was clearly active from the beginning of the process:
38%to40%214.85 kmto225.74 kmBut
charge_energy_addedstayed at0.00for the first ~23 minutes and only became non-zero when the car had roughly returned to the same range/SOC level it had when first plugged in.That strongly suggests that the raw field is not "energy added since this charging_process started", but something closer to:
I also back-extrapolated the counted portion of the curve and got an implied hidden initial value of about
-1.61 kWh, which fits this interpretation very well.Case 2: one plug-in session split into two charging processes
This is the more direct evidence.
Under the same plug-in session, TeslaMate recorded two charge entries:
Charging process A
2026-07-09 03:00:3235m35% -> 38%198 km -> 214 km1.20 kWh2.53 kWh47%Charging process B
2026-07-09 03:38:562.1 h38% -> 50%214 km -> 282 km10.22 kWh10.79 kWh95%These two charging processes belong to the same plug-in session.
The important part is this:
charge_energy_added = 1.201.20already included10.22, instead of rebasing itSo TeslaMate totals become:
1.2010.2211.42But if
10.22is the cumulative net added value for the whole plug-in session, then process B's own contribution should be:10.22 - 1.20 = 9.02So at least
1.20 kWhis counted twice across the two processes.Why I believe this is a TeslaMate interpretation / aggregation issue
From the source code:
lib/tesla_api/vehicle/state.exmapscharge["charge_energy_added"]lib/teslamate/vehicles/vehicle.exstoresvehicle.charge_state.charge_energy_addeddirectly intochargeslib/teslamate/vehicles/vehicle.exalso normalizesnil -> 0input_charge_defaults/1lib/teslamate/log.exaggregatescharging_processes.charge_energy_addedusing the values stored inchargesThis means:
charging_processnilto0also hides the distinction between:Impact
This appears to affect at least:
Charge Details -> AddedI also observed obviously implausible downstream values such as battery capacity estimates temporarily exceeding the configured "new" capacity, which suggests that these bad charge totals can propagate into higher-level estimation.
Expected behavior
For each
charging_process, added energy should reflect only the energy attributable to that process.If
charge_energy_addedis actually cumulative for the whole plug-in session, TeslaMate should probably not use it directly as a per-process counter.Possible directions:
nilinstead of coercing it to0charge_energy_addedagainst the start of the plug-in session, or at least against the start of the processSummary
The observed behavior is consistent with this interpretation:
charge_energy_addedis cumulative for the whole plug-in sessioncharging_processExpected Behavior
No response
Can the issue reliably be reproduced?
Yes
Steps To Reproduce the issue
No response
Relevant log output
Screenshots
No response
Additional data
No response
Type of installation
Manual (no support)
Version
v4.0.1
PostgreSQL version
No response
Are you running latest major supported PostgreSQL version?
Are you using a reverse Proxy for TeslaMate?
No
Details about your reverse Proxy if applicable
No response