https://bugs.kde.org/show_bug.cgi?id=526280

            Bug ID: 526280
           Summary: Dual-battery setups evaluate low/critical battery
                    thresholds against raw percentage sum (up to 200%)
                    rather than capacity-weighted average
    Classification: Plasma
           Product: plasmashell
      Version First 6.7.5
       Reported In:
          Platform: Fedora RPMs
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Power management & brightness
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: 1.0

SUMMARY
On dual-battery laptops (such as Lenovo ThinkPads with internal BAT0 and
external BAT1), PowerDevil's daemon calculates total system battery charge by
directly summing the raw percentages of all batteries together (producing
values up to 200%). 

This creates an inconsistency with the Plasma system tray battery applet (which
correctly uses a capacity-weighted average in Wh) and causes low and critical
battery thresholds to trigger at completely wrong battery levels.

STEPS TO REPRODUCE
1. On a dual-battery laptop, configure the "Low battery" threshold to 50% in
System Settings -> Energy Saving.
2. Unplug the laptop and allow the batteries to discharge.
3. Observe the behavior when Battery 0 is at 30% and Battery 1 is at 20% (or
when Battery 1 is exhausted to ~5% and Battery 0 reaches 45%).

OBSERVED RESULT
- PowerDevil triggers the "Low Battery" notification: "Battery Low (50%
Remaining) - Plug in the power cord".
- The system profile switches to "LowBattery" (screen dims,
power-profiles-daemon switches to power-saver).
- However, hovering over the system tray battery applet shows only ~12% to ~22%
remaining charge.
- PowerDevil's internal currentChargePercent() returns 50 because it literally
calculated: 30% + 20% = 50%.
- If thresholds are left at defaults (e.g. 20% low, 7% critical), low battery
warnings may fail to trigger until the machine is nearly dead (requiring an
average of 10% per battery), risking sudden brownout shutdowns before critical
action completes.

EXPECTED RESULT
PowerDevil should calculate the system's global charge percentage as a
capacity-weighted average (in Wh) across all batteries:
    (Total Energy / Total Full Energy) * 100
Thresholds (Low, Critical) and notification titles should be evaluated against
this 0-100% weighted average, matching the system tray widget and UPower's
DisplayDevice.

ADDITIONAL TECHNICAL DETAILS & ROOT CAUSE
The bug is in powerdevil/daemon/powerdevilcore.cpp:

1. In Core::currentChargePercent():
```cpp
int Core::currentChargePercent() const
{
    int chargePercent = 0;
    for (auto it = m_batteriesPercent.constBegin(); it !=
m_batteriesPercent.constEnd(); ++it) {
        chargePercent += it.value();
    }
    return chargePercent;
}

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to