# upower-0.9.8 + udev-164-r1 report incorrect battery stats?

## Lupusceleri

Hello all,

Last night, I let my ~x86 Dell Inspiron 6400 laptop perform an "emerge -DuNav world". Included with these updates was KDE 4.6.0, which has finally removed all HAL dependencies - making kde-base/solid-4.6.0 depend on udev's upower, udisks, et cetera instead.

Subsequently, I unmerged HAL as KDE was the last software in my system that was using it.

I received the following message after starting my laptop today: "Your battery capacity is 35%. This means your battery is broken and needs a replacement."

Worried, I shut down the OS and opened my BIOS. Unplugged/replugged the AC cable a few times, and every time I did that charge showed as 97% - which it has been for months, when fully charged. Started up Gentoo again, and opened a terminal:

```
martijn@martijnlaptop ~ $ upower -d

Device: /org/freedesktop/UPower/devices/line_power_AC

  native-path:          /sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC

  power supply:         yes

  updated:              Sat Feb  5 19:09:09 2011 (682 seconds ago)

  has history:          no

  has statistics:       no

  line-power

    online:             yes

Device: /org/freedesktop/UPower/devices/battery_BAT0

  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0

  vendor:               Sanyo

  model:                DELLJN1497

  serial:               1001

  power supply:         yes

  updated:              Sat Feb  5 19:20:15 2011 (16 seconds ago)

  has history:          yes

  has statistics:       yes

  battery

    present:             yes

    rechargeable:        yes

    state:               charging

    energy:              30.2364 Wh

    energy-empty:        0 Wh

    energy-full:         86.58 Wh

    energy-full-design:  86.58 Wh

    energy-rate:         14.8074 W

    voltage:             12.298 V

    time to full:        3.8 hours

    percentage:          34.9231%

    capacity:            35.2949%

    technology:          lithium-ion

  History (charge):

    1296929925  34.923  charging

  History (rate):

    1296930015  14.807  charging

    1296929985  0.011   charging

Daemon:

  daemon-version:  0.9.8

  can-suspend:     no

  can-hibernate    no

  on-battery:      no

  on-low-battery:  no

  lid-is-closed:   no

  lid-is-present:  yes

  is-docked:       no
```

Yup.. confirmed my theory that the change to upower as power management backend was the culprit reporting an erroneous capacity/charge.

Looking for additional confirmation that it was a software bug, rather than a dieing battery, I started to experiment some with unplugging the AC line while monitoring the upower daemon, and changing things such as the LCD screen's brightness which should make a big impact on the estimated "time to empty".

```
martijn@martijnlaptop ~ $ upower --monitor-detail | grep "time to empty"

    time to empty:       1.6 hours # Unplugged battery, Powerdevil switched to profile Powersave.

    time to empty:       1.6 hours

    time to empty:       1.6 hours

    time to empty:       1.6 hours

    time to empty:       1.6 hours

    time to empty:       1.1 hours # Changed LCD brightness to maximum value, rather than the value Powerdevil had set.

    time to empty:       1.3 hours # Changed LCD brightness to minimum value, rather than the value Powerdevil had set.

    time to empty:       1.3 hours
```

For reference, using my laptop on a 100% charged battery for ~30 minutes used to put it at ~50-60% battery charge, so upower's approximation sounds realistic and unchanged from what it used to be under HAL.  :Smile: 

Repeated the aforementioned test.

```
martijn@martijnlaptop ~ $ upower --monitor-detail | grep "time to empty"

    time to empty:       5.3 hours # Unplugged battery, Powerdevil switched to profile Powersave.

    time to empty:       5.3 hours

    time to empty:       4.7 hours

    time to empty:       4.7 hours

    time to empty:       4.7 hours

    time to empty:       3.7 hours

    time to empty:       1.3 hours # upower finally gives a realistic value.

    time to empty:       1.3 hours

    time to empty:       1.1 hours # Changed LCD brightness to maximum value, rather than the value Powerdevil had set.

    time to empty:       1.1 hours

    time to empty:       1.3 hours # Changed LCD brightness to minimum value, rather than the value Powerdevil had set.

    time to empty:       1.3 hours

    time to empty:       1.5 hours # Closed the lid, which deactivates the screen.

    time to empty:       1.4 hours

    time to empty:       1.4 hours

    time to empty:       1.1 hours #Reopened the lid, and set LCD brightness back to Powerdevil's default.

    time to empty:       1.1 hours
```

Is anyone else experiencing erroneous battery statuses from upower? Should I report this to upstream?

EDIT: The saga continues.

```
martijnlaptop ~ # cd /sys/devices/LNXSYSTM\:00/device\:00/PNP0C0A\:00/power_supply/BAT0/

martijnlaptop BAT0 # cat charge_full

2753000

martijnlaptop BAT0 # cat charge_now 

2724000

martijnlaptop BAT0 # cat charge_full_design 

7800000
```

So it would seem udev is getting the wrong stats, and upower is simply reading them out.

----------

## Zarhan

I'm getting something similar.

My battery indicator in system tray now says 10%. However, 

```
$ acpi -V

Battery 0: Unknown, 99%

```

This typically happens to me if I go through system/resume cycle.

As a result, I've had to take away all automatic reactions to battery status.

Oh, and I'm on udev-151-r4.

----------

## Zarhan

Found this:

https://bugs.freedesktop.org/show_bug.cgi?id=27399

----------

## Lupusceleri

Funny enough, I left the laptop off for a few days and today booted it up on battery power. The battery meter is now giving the correct %.

No package updates, no config changes, no nothing.

I don't understand.  :Razz:  But well.

----------

## Lupusceleri

 *Lupusceleri wrote:*   

> Funny enough, I left the laptop off for a few days and today booted it up on battery power. The battery meter is now giving the correct %.
> 
> No package updates, no config changes, no nothing.
> 
> I don't understand.  But well.

 

And we're back to erroneous battery status. It's almost like the thing is connected to a random number generator.

----------

## keba

I've got the exact same problem   :Sad:   No idea what causes it. Screen brightness is not being adjusted either...

----------

## hephooey

I had similar problems, it happens when I put the laptop to sleep or use the battery instead of AC, simply removing and pluging the battery back makes the report of upower -d normal again.

----------

