Bug 347470 - Shutdown when one of two batteries is empty
Summary: Shutdown when one of two batteries is empty
Status: RESOLVED FIXED
Alias: None
Product: Powerdevil
Classification: Plasma
Component: general (show other bugs)
Version: 5.3.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Development Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-09 14:37 UTC by Philipp Rehs
Modified: 2015-05-10 16:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.3.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Rehs 2015-05-09 14:37:19 UTC
I think this bug report is related to https://bugs.kde.org/show_bug.cgi?id=329537
I am running a T440s with Archlinux and KDE 5 / Plasma and Powerdevil 5.3 and two batteries.
My systems shuts down every time one battery is empty and I resume from suspend or reboot. I receive the shutdown notification but even disabling power management does not help to stop it. i have to use a charger.

Reproducible: Always

Steps to Reproduce:
1. Use laptop until one battery is empty (< 5%)
2. Shutdown or suspend to ram/disk
3. Reboot / wake system

Actual Results:  
I receive a notification that the battery is empty and i have 30 seconds to add a charger

Expected Results:  
I would expect the system to run normaly until the second battery is empty too

Lenovo T440s
Archlinux with Kernel 4.0.1
Powerdevil 5.3
Upower 0.99.2
Plasma-workspace: 5.3.0
Plasma-framework 5.9.0
Comment 1 Kai Uwe Broulik 2015-05-09 14:44:31 UTC
Are both batteries recognized by the system? Can you provide the output of upower -d? 
Quickly skimming through the code, when a battery changes its percentage, it calculates the overall percentage and when that one is below the configured threshold, it emits a warning and starts the shutdown timer. I don't see why it would not work in your case :/ I don't have the hardware to test this, unfortunately.
Also, it might make sense to add a "Cancel" button to the notification, if sbd is willing to take the risk of data loss.
Comment 2 Kai Uwe Broulik 2015-05-09 14:45:46 UTC
Ah, no, I misunderstood your bug report. So apparently when the system wakes up or starts, then one battery is added (well, it iterates over all of them initially), examined, found to be low of charge, and the next one that appears, doesn't cancel the shutdown process. Makes sense, I'll have a look.
Comment 3 Philipp Rehs 2015-05-09 14:47:08 UTC
philipp@philipp-t440s ~ $ upower -d
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Sa 09 Mai 2015 16:46:53 CEST (3 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               SONY
  model:                45N1111
  serial:               10860
  power supply:         yes
  updated:              Sa 09 Mai 2015 16:46:53 CEST (3 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              15,34 Wh
    energy-empty:        0 Wh
    energy-full:         19,29 Wh
    energy-full-design:  23,2 Wh
    energy-rate:         13,075 W
    voltage:             11,957 V
    time to empty:       1,2 hours
    percentage:          79%
    capacity:            83,1466%
    technology:          lithium-polymer
    icon-name:          'battery-full-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               LGC
  model:                45N1127
  serial:               5990
  power supply:         yes
  updated:              Sa 09 Mai 2015 16:46:53 CEST (3 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       low
    energy:              4,44 Wh
    energy-empty:        0 Wh
    energy-full:         21,13 Wh
    energy-full-design:  23,48 Wh
    energy-rate:         26,616 W
    voltage:             11,295 V
    time to empty:       10,0 minutes
    percentage:          21%
    capacity:            89,9915%
    technology:          lithium-ion
    icon-name:          'battery-low-symbolic'
  History (charge):
    1431182813  21,000  discharging
    1431182801  20,000  charging
  History (rate):
    1431182813  26,616  discharging
    1431182813  26,862  discharging
    1431182804  26,616  charging
    1431182801  26,574  charging

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Sa 09 Mai 2015 16:46:53 CEST (3 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              19,78 Wh
    energy-full:         40,42 Wh
    energy-rate:         39,691 W
    time to empty:       29,9 minutes
    percentage:          48,9362%
    icon-name:          'battery-good-symbolic'

Daemon:
  daemon-version:  0.99.2
  on-battery:      yes
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep
Comment 4 Philipp Rehs 2015-05-09 14:49:09 UTC
Your idea could be right. This time it happened when the second battery was empty.

off-topic:
is there any way to give a priority to batteries? or give them differend names?
Comment 5 Kai Uwe Broulik 2015-05-09 15:04:32 UTC
If you can, please try this patch: https://git.reviewboard.kde.org/r/123704/

I'm afraid, no, the order is determined by the system (whatever battery comes first), at least for mouse batteries it shows the device name but internal batteries usually have cryptic serial numbers and so it just shows them numbered.
Comment 6 Philipp Rehs 2015-05-09 15:45:27 UTC
I just compiled powerdevil-git with this patch and it seems to fix the problem in a short test.
I will run it the next days and give you some feedback
Comment 7 Kai Uwe Broulik 2015-05-09 18:55:40 UTC
Thank you!
Comment 8 Kai Uwe Broulik 2015-05-10 16:55:43 UTC
Git commit d3d2ebcfd214a892ac79484cfb8cb6fcbf7fc917 by Kai Uwe Broulik.
Committed on 10/05/2015 at 16:54.
Pushed by broulik into branch 'Plasma/5.3'.

Consider overall percentage when emitting battery warning on startup

Otherwise you might have your session shutdown after logging in when the first battery
that was detected happened to be below the critical threshold.

REVIEW: 123704
FIXED-IN: 5.3.1

M  +4    -9    daemon/powerdevilcore.cpp

http://commits.kde.org/powerdevil/d3d2ebcfd214a892ac79484cfb8cb6fcbf7fc917