Skip to content

fix(battery): no made-up kWh on a plug-in hybrid - #572

Closed
joszz wants to merge 1 commit into
mainfrom
fix/phev-battery-capacity
Closed

joszz wants to merge 1 commit into
mainfrom
fix/phev-battery-capacity

Conversation

@joszz

@joszz joszz commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Refs #571 (not Fixes until 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 through drivetrain/totalBatteryCapacity and drivetrain/soc_kwh.

We already hid that figure on a plain hybrid (the HS Hybrid+, 1.83 kWh). A PHEV still showed it.

The fix

hvBatteryReading now uses the gateway's capacity only on a BEV. A PHEV or a car of unknown type shows its charge as a percentage until HV_BATTERY_CAPACITY_KWH is 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 HvBatteryCapacity summary 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 as soc_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

  • New hvBatteryReading cases: PHEV and unknown without a capacity, PHEV with a configured capacity, percentage from the reported pair.
  • Vitest 1287 passed, vue-tsc, oxlint, ESLint, stylelint, Prettier clean.
  • dotnet test: 1551 passed. dotnet format --verify-no-changes clean.

No migrations.

🤖 Generated with Claude Code

@joszz joszz added the test-build Publish pr-<number> preview images for testers label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Preview build pr-572

The preview images are deleted. Anyone who ran them should change the image back to the latest release (or latest, which follows main and carries the fix once it is merged), or from a clone run docker compose up -d --build in the same folder.
Adding the test-build label again publishes a fresh build.

@joszz joszz removed the test-build Publish pr-<number> preview images for testers label Nov 8, 2026
@joszz

joszz commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

The test-build label moved to #574, which is branched from this one and gives the #571 reporter one build (pr-574) for #570 and #571. Merge this PR before #574.

…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
joszz force-pushed the fix/phev-battery-capacity branch from 75a7c28 to a100484 Compare November 9, 2026 13:13
@joszz joszz closed this Nov 9, 2026
@joszz
joszz deleted the fix/phev-battery-capacity branch November 9, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant