Repository navigation
Conversation
2 tasks done
Preview build
|
joszz
force-pushed
the
fix/phev-battery-capacity
branch
from
November 8, 2026 16:22
40686c8 to
75a7c28
Compare
…s capacity is set MG's API scales the state of charge by a nominal 72.5 kWh pack, and the gateway only replaces that for the BEV series it has a table entry for. A PHEV with a pack of about 23 kWh showed 68.9 of 72.5 kWh at 95%. Only a BEV now falls back to the gateway's capacity; every other car needs HV_BATTERY_CAPACITY_KWH for kWh figures. Refs #571 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joszz
force-pushed
the
fix/phev-battery-capacity
branch
from
November 9, 2026 13:13
75a7c28 to
a100484
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #571 (not
Fixesuntil the reporter confirms on the car).Cause
The HV Battery card showed 68.9 of 72.5 kWh at 95% on a plug-in hybrid with a pack of about 23 kWh.
72.5 is not something GarageStack or the gateway works out. MG's API scales the state of charge by a nominal 72.5 kWh pack, and saic-python-mqtt-gateway (
VehicleInfo.real_battery_capacity) swaps in the real size only for the series it has a table entry for: EH32 (MG4), AH4EM (MG4 Urban), EC32 (Cyberster), EP2 (MG5), ZS EV and MZS3E (MGS5). All of those are BEVs. Every hybrid and plug-in hybrid gets 72.5 throughdrivetrain/totalBatteryCapacityanddrivetrain/soc_kwh.We already hid that figure on a plain hybrid (the HS Hybrid+, 1.83 kWh). A PHEV still showed it.
The fix
hvBatteryReadingnow uses the gateway's capacity only on a BEV. A PHEV or a car of unknown type shows its charge as a percentage untilHV_BATTERY_CAPACITY_KWHis set. When it is set, it wins on every drivetrain, as before. The SoC percentage is unchanged.Updated the wording in CONFIGURATION.md, the Unraid template and the
HvBatteryCapacitysummary to match. The Unraid template change needs the CA repo sync after merge.Not in this PR
The energy counters (
powerUsageOfDay,powerUsageSinceLastCharge) get the same scale factor in the gateway assoc_kwh. So on a PHEV they may also be about 72.5 / real too high. I left them alone until the reporter's data shows it either way. They also overlap with #556 and #569.Tests
hvBatteryReadingcases: PHEV and unknown without a capacity, PHEV with a configured capacity, percentage from the reported pair.dotnet test: 1551 passed.dotnet format --verify-no-changesclean.No migrations.
🤖 Generated with Claude Code