Skip to content

fix(smart): correct inverted v.b.power sign on SQ/SE (issue #40) - #44

Draft
kezarjg wants to merge 1 commit into
iternio:devfrom
kezarjg:fix/smart-power-sign
Draft

fix(smart): correct inverted v.b.power sign on SQ/SE (issue #40)#44
kezarjg wants to merge 1 commit into
iternio:devfrom
kezarjg:fix/smart-power-sign

Conversation

@kezarjg

@kezarjg kezarjg commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What & why

Fixes the inverted battery-power sign on smart 453/forfour (SQ) and smart ED/fortwo (SE), which causes ABRP's calibrated reference consumption to drift toward zero (#40).

Both OVMS smart modules report v.b.power with the wrong sign - negative while driving (consuming), positive while charging - the opposite of the OVMS core / Iternio convention (positive = output/discharging). ABRP uses power for consumption calibration, so it reads consumption as regen and the reference consumption decays.

This was confirmed with on-device captures from both cars (telemetry as received by ABRP):

forfour (SQ), n=1747 fortwo (SE), n=431
median( power / (V*I) ) -0.999 -1.000
driving (>= 5 m/s): current > 0 90% 86%
driving (>= 5 m/s): power > 0 7% 10%

Driving is net discharge (must be positive by convention), so v.b.current is the correctly-signed metric and v.b.power is inverted on both cars.

The fix

overrideMetricMap now corrects power for SQ/SE by keeping the module's power magnitude and taking its sign from v.b.current:

if (current < 0) { return -Math.abs(power); }
if (current > 0) { return Math.abs(power); }
return power; // current == 0: power ~0, sign irrelevant

Self-healing: v.b.current is correctly signed in both the current (buggy) firmware and a future upstream-fixed firmware (the fix only touches v.b.power). So once the module's v.b.power sign is corrected upstream, this override returns v.b.power unchanged - it becomes a no-op with no plugin change needed to retire it.

Scope is limited to power; current, is_charging, and is_dcfc are unchanged.

Upstream

The root defect is in the OVMS vehicle-module firmware; separate firmware bugs are being filed against vehicle_smarteq and vehicle_smarted. This PR is the plugin-side workaround so affected users get correct calibration now.

Tests

Added overrideMetricMap coverage for the smart override (driving correction, charging correction, post-fix no-op, zero-current, SE shares the override, unsupported when current absent, and non-smart passthrough). Full suite: 71 passing. VERSION -> 2.3.1, CHANGELOG updated.

Both OVMS smart modules (453/forfour = SQ, ED/fortwo = SE) report v.b.power
with an inverted sign: negative while driving (consuming), positive while
charging - the opposite of the OVMS core / Iternio convention. ABRP uses
power for consumption calibration, so it read consumption as regen and the
calibrated reference consumption drifted toward zero.

overrideMetricMap now corrects power for these vehicles by keeping the
module's power magnitude and taking its sign from v.b.current, which the
same modules report correctly. Because v.b.current is correct in both the
buggy and a future upstream-fixed firmware, the correction is self-healing:
once v.b.power's sign is fixed upstream it becomes a no-op, with no plugin
change needed to retire it. Only power is affected.

Upstream firmware bugs filed separately against vehicle_smarteq and
vehicle_smarted.
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