More than 100% battery reported with 2+ batteries

Bug #2117707 reported by Dariusz Gadomski
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
upower (Ubuntu)
New
Undecided
Unassigned
Jammy
New
Undecided
Ghadi Rahme
Noble
New
Undecided
Ghadi Rahme
Plucky
New
Undecided
Ghadi Rahme

Bug Description

Thank you @dgadomski for the bug report and original description!

[Impact]
On machines with more than one battery and running on Ubuntu releases prior to Questing. Upower can occasionally incorrectly calculate the battery percentage leading to it adding the two percentages together instead of averaging them out when waking from sleep or restarting the upower daemon. This generally causes the battery percentage to show up as <100%.

This has been fixed upstream in this PR: https://gitlab.freedesktop.org/upower/upower/-/merge_requests/246

The proposed debdiff backports two out of the three commits since integration tests are disabled during the build process.

[Test Plan]
1- On a machine with more than one battery, wake the machine from sleep repeatedly
2- After each wake from sleep check the battery level
3- If the charge level is much greater than what is expected or even <100% than the issue was reproduced successfully.

[Where problems could occur]
* The machine could fail to detect a battery as being present leading to a much lower charge percentage than expected.

[Original description]
I can reproduce it after a couple of tries on my Dell Rugged 5430 equipped with 2 batteries. My assumption is that may happen on any hardware with 2+ batteries with plucky and upower 1.90.7-1build1.

Sometimes after resuming from suspend upower reports more than 100% percentage on the DisplayDevice composite battery:

upower -d /org/freedesktop/UPower/devices/DisplayDevice

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply: yes
  updated: śro, 23 lip 2025, 13:43:08 (28 seconds ago)
  has history: no
  has statistics: no
  battery
    present: yes
    state: discharging
    warning-level: none
    energy: 66,633 Wh
    energy-full: 36,2634 Wh
    energy-rate: 4,3434 W
    charge-cycles: N/A
    time to empty: 15,3 hours
    percentage: 183,747%
    icon-name: 'battery-full-symbolic'

After I added some debugging code in src/up-daemon.c (ppa:dgadomski/test upower) I figured that energy_full_total is set only to the energy_full of the first battery, while energy_total has the sum of both batteries:

journal -b 0 -u upower.service
(...)
lip 23 13:39:37 zack upowerd[3578]: TI:13:39:37 battery 0, energy: 36,263400, energy_full: 36,263400, energy_rate: 0,011400, time_to_empty: 11>
lip 23 13:39:37 zack upowerd[3578]: TI:13:39:37 battery 1, energy: 30,688800, energy_full: 0,000000, energy_rate: 4,879200, time_to_empty: 226>
lip 23 13:39:37 zack upowerd[3578]: TI:13:39:37 Calculating percentage and time to full/to empty for 2 batteries
lip 23 13:39:37 zack upowerd[3578]: TI:13:39:37 energy_total: 66,952200 energy_full_total: 36,263400

This leads the total percentage to exceed 100% which should never be the case as I understood from the code.

This results also in broken UI in gnome-control-center expecting the percentage to go as high as 100% (screenshot attached).

The actual cause to this is why the battery 1 reports energy_full as 0.

Test plan:
1. Suspend the machine
2. Resume from suspend.
3. Go to 1 if battery percentage is <=100%.

Revision history for this message
Dariusz Gadomski (dgadomski) wrote :

Screenshot showing the effect of 100+% in the Gnome UI.

description: updated
description: updated
Revision history for this message
Dariusz Gadomski (dgadomski) wrote :

Restarting upower or ejecting and reinserting the battery "fixes" the issue.

Revision history for this message
Ghadi Rahme (ghadi-rahme) wrote :

Plucky debdiff:

description: updated
Changed in upower (Ubuntu Plucky):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Changed in upower (Ubuntu Noble):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Changed in upower (Ubuntu Jammy):
assignee: nobody → Ghadi Rahme (ghadi-rahme)
Revision history for this message
Dariusz Gadomski (dgadomski) wrote :

Thanks for your work on this Ghadi!

I have managed to just reproduce it on resolute, so despite my hopes it hasn't been fixed yet in the latest devel release.

I'm attaching the contents of my /sys/class/power_supply/BAT{0,1}.

Revision history for this message
Dariusz Gadomski (dgadomski) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.