Bug 430964

Summary: Limit of charging seems to be set only for one battery even in laptop there are two
Product: [Plasma] plasmashell Reporter: Piotr Mierzwinski <piotr.mierzwinski>
Component: Power management & brightnessAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: denk, kde, mail, nate, piotr.mierzwinski
Priority: NOR    
Version First Reported In: 6.2.4   
Target Milestone: 1.0   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Battery charge limit
Plasmoid_Battery-and-Brightness
ls output
upower output
Battery Information in System Tray
Battery Information on Desktop Widget
Battery Information in KInfoCenter

Description Piotr Mierzwinski 2020-12-29 23:27:40 UTC
Created attachment 134387 [details]
Battery charge limit

SUMMARY
I have Lenovo T480 which has two batteries. Plasmoid "Battery and Brightness" shows correctly two batteries only in System Settings -> Power Management -> Advanced Setting I can set the limit of charging only for one battery.
Note please that in software provided by Lenovo is possible to set charging limit for both batteries.

STEPS TO REPRODUCE
1. Need to have laptop with two batteries
2. Try to set limit of charging in System Settings -> Power Management -> Advanced Setting
3. 

OBSERVED RESULT
Is possible to set limit only for one battery even if in system there are two

EXPECTED RESULT
should be possible to set charge limit for all batteries built in laptop

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: YES
(available in About System)
KDE Plasma Version: 5.20.80
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Piotr Mierzwinski 2020-12-29 23:29:19 UTC
Created attachment 134388 [details]
Plasmoid_Battery-and-Brightness
Comment 2 Kai Uwe Broulik 2020-12-29 23:56:05 UTC
The code is actually written to set the limit on all batteries. [1]

Can you provide the output of:
$ ls -la /sys/class/power_supply/BAT*/*
and
$ cat /sys/class/power_supply/BAT*/charge_stop_threshold

Did you plug in the battery after applying charge threshold? It's only applied when you save settings, it does not monitor new batteries being added.

[1] https://invent.kde.org/plasma/powerdevil/-/blob/master/daemon/chargethresholdhelper.cpp#L74
Comment 3 Piotr Mierzwinski 2021-01-04 23:01:37 UTC
Created attachment 134553 [details]
ls output
Comment 4 Piotr Mierzwinski 2021-01-04 23:04:55 UTC
(In reply to Kai Uwe Broulik from comment #2)
> The code is actually written to set the limit on all batteries. [1]
So the same limit will be applied for all batteries. Even user wants/needs set different for both.
In mu opinion this might be confused. In application provided by Lenovo is possible to set separately limit for each battery. 
Second thing is that user might be surprised, like me, seeing in plasmoid "Battery and Brightness" two batteries and trying to set charging threshold just see only one. 

> Can you provide the output of:
> $ ls -la /sys/class/power_supply/BAT*/*
Please check attached text file

> and
> $ cat /sys/class/power_supply/BAT*/charge_stop_threshold
$ cat /sys/class/power_supply/BAT*/charge_stop_threshold
85
85

If I understood this result correctly - both batteries are set with the same limit.

> Did you plug in the battery after applying charge threshold? It's only
> applied when you save settings, it does not monitor new batteries being
> added.
I didn't. I have applied threshold having both batteries working in laptop.
BTW. I think first battery is built in permanently and second exchangeable.

> [1]
> https://invent.kde.org/plasma/powerdevil/-/blob/master/daemon/
> chargethresholdhelper.cpp#L74
Comment 5 Kai Uwe Broulik 2021-01-04 23:10:17 UTC
To be honest, I never had a laptop with more than one battery, so I don't really knew about the use cases, I just assumed (and of course implementation and UI-wise was the simplest option) that one would want to limit all of them, so I value your feedback on this.

I wonder how it could be implemented in a way that it's not too overwhelming UI-wise and how we could tell the internal one from an exchangeable one.

Can you provide the output of
$ upower -d 
I wonder if UPower has any clue about which battery is which.
Comment 6 Piotr Mierzwinski 2021-01-04 23:36:55 UTC
Created attachment 134554 [details]
upower output
Comment 7 denk 2021-10-20 07:06:55 UTC
With Plasma 5.23.0 under Arch Linux on a ThinkPad T470s, this works for both batteries as it should:

cat /sys/class/power_supply/BAT*/charge_stop_threshold
95
95

But I've stumbled upon another issue: The various places, where battery information are displayed, show different aspects, as can be seen in the screenshots.

1. The system tray shows both batteries of the laptop as well as the batteries of my mouse and keyboard. Also the set Charging Threshold is displayed.
2. The widget on the desktop only shows both batteries of the laptop and not the batteries of my input devices. The Charging Threshold is not displayed.
3. The InfoCenter shows both batteries of my laptop as well as both batteries of  my input devices. The set Charging Threshold is not displayed.

Can this be harmonized?

And a second issue: The system tray also shows set Charging Thresholds for my mouse and keyboard, which is weird. Is there really the possibility to set a threshold for mouse and keyboard? And if so, then I would propose, that such threshold should only be set explicitely, and not just because of the fact, that the user set a threshold for the laptop battery/ies.

If you need further info, please ask. If I should open new tickets for these issues, I will do so.
Comment 8 denk 2021-10-20 07:08:15 UTC
Created attachment 142655 [details]
Battery Information in System Tray
Comment 9 denk 2021-10-20 07:08:38 UTC
Created attachment 142656 [details]
Battery Information on Desktop Widget
Comment 10 denk 2021-10-20 07:09:07 UTC
Created attachment 142657 [details]
Battery Information in KInfoCenter
Comment 11 Nate Graham 2021-10-25 20:39:54 UTC
*** Bug 444277 has been marked as a duplicate of this bug. ***