Bug 464535 - Charging limit is not saved
Summary: Charging limit is not saved
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_powerdevil (show other bugs)
Version: 5.26.90
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 464650 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-20 06:30 UTC by Iyán Méndez Veiga
Modified: 2023-02-16 18:24 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.1


Attachments
There are no settings. (371.18 KB, image/jpeg)
2023-02-14 18:29 UTC, Victor Ryzhykh
Details
Removed this commit. (416.09 KB, image/jpeg)
2023-02-14 18:34 UTC, Victor Ryzhykh
Details
So good, now it works. (380.25 KB, image/jpeg)
2023-02-14 19:57 UTC, Victor Ryzhykh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Iyán Méndez Veiga 2023-01-20 06:30:43 UTC
SUMMARY
Trying to change the value of "Stop charging at" doesn't work anymore.

STEPS TO REPRODUCE
1. Go to System settings -> Power management -> Advanced Power Settings
2. Change "Stop charging at" to any value
3. Click apply and introduce password when asked
4. Close system settings
5. Open system settings again and check the value of "Stop charging at"

OBSERVED RESULT
The limit is not changed/saved.

I'm not 100% sure if this started to happen after upgrading to the Plasma 5.27 Beta, to Frameworks 5.102.0, or due to recent kernel upgrades. I can still change the limit manually by setting the value in /sys/class/power_supply/BAT0. After doing that, system settings shows the updated value. So it looks like it can read but not write the setting.

The other limit, "Start charging only once below", is saved correctly.

EXPECTED RESULT
Both limits should be saved correctly. Also, would be nice to warn the user if there was an error trying to update the values.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Kernel Version: 6.1.6-arch1-3 (64-bit)
Graphics Platform: Wayland
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20XYCTO1WW
System Version: ThinkPad X1 Yoga Gen 6
Comment 1 Iyán Méndez Veiga 2023-01-20 07:24:57 UTC
Reverting this fixes the issue for me:
https://invent.kde.org/plasma/powerdevil/-/commit/a002ab4718760dfae156bd8fe8a17c59b0f09182

As additional info, my laptop has a pen with some battery that charges when stored in the laptop. It appears as wacom_battery_0 in /sys/class/power_supply. Maybe after that commit, powerdevil tries to changes the limit on the pen instead of the laptop's battery?
Comment 2 Nate Graham 2023-01-23 21:56:15 UTC

*** This bug has been marked as a duplicate of bug 450551 ***
Comment 3 Iyán Méndez Veiga 2023-01-23 21:57:14 UTC
I don't think it's the same bug.
Comment 4 Nate Graham 2023-01-24 16:38:15 UTC
My mistake, sorry
Comment 5 Fabian Vogt 2023-01-26 12:00:24 UTC
*** Bug 464650 has been marked as a duplicate of this bug. ***
Comment 6 Iyán Méndez Veiga 2023-01-26 12:04:18 UTC
As requested in matrix.

$ upower -d

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Thu 26 Jan 2023 10:45:16 (8045 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Sunwoda
  model:                5B10W13975
  serial:               24869
  power supply:         yes
  updated:              Thu 26 Jan 2023 12:59:02 (19 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               pending-charge
    warning-level:       none
    energy:              48.72 Wh
    energy-empty:        0 Wh
    energy-full:         56.99 Wh
    energy-full-design:  57 Wh
    energy-rate:         0 W
    voltage:             17.402 V
    charge-cycles:       172
    percentage:          85%
    capacity:            99.9825%
    technology:          lithium-polymer
    icon-name:          'battery-full-charging-symbolic'

Device: /org/freedesktop/UPower/devices/battery_wacom_battery_0
  native-path:          wacom_battery_0
  model:                Wacom HID 527A
  power supply:         no
  updated:              Thu 01 Jan 1970 01:00:00 (1674734361 seconds ago)
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               unknown
    warning-level:       none
    percentage:          0%
    icon-name:          'battery-missing-symbolic'
  History (charge):
    1674734361  0.000   unknown
  History (rate):
    1674734361  0.000   unknown

Device: /org/freedesktop/UPower/devices/line_power_ucsi_source_psy_USBC000o001
  native-path:          ucsi-source-psy-USBC000:001
  power supply:         yes
  updated:              Thu 26 Jan 2023 10:45:16 (8045 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/line_power_ucsi_source_psy_USBC000o002
  native-path:          ucsi-source-psy-USBC000:002
  power supply:         yes
  updated:              Thu 26 Jan 2023 10:45:21 (8040 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/DisplayDevice
  power supply:         yes
  updated:              Thu 26 Jan 2023 12:36:01 (1400 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               pending-charge
    warning-level:       none
    energy:              48.72 Wh
    energy-full:         56.99 Wh
    energy-rate:         0 W
    charge-cycles:       N/A
    percentage:          85%
    icon-name:          'battery-full-charging-symbolic'

Daemon:
  daemon-version:  1.90.0
  on-battery:      no
  lid-is-closed:   yes
  lid-is-present:  yes
  critical-action: PowerOff

$ cat /sys/class/power_supply/BAT0/type
Battery

$ cat /sys/class/power_supply/wacom_battery_0/type
Battery
Comment 7 Iyán Méndez Veiga 2023-01-26 12:05:22 UTC
After using the pen at least once (needs to touch the screen to report battery status)

Device: /org/freedesktop/UPower/devices/battery_wacom_battery_0
  native-path:          wacom_battery_0
  model:                Wacom HID 527A
  power supply:         no
  updated:              Thu 26 Jan 2023 13:04:36 (11 seconds ago)
  has history:          yes
  has statistics:       yes
  keyboard
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    percentage:          100%
    icon-name:          'battery-full-charged-symbolic'
  History (charge):
    1674734675  100.000 fully-charged
Comment 8 Fabian Vogt 2023-01-26 12:26:56 UTC
FWICT the issue is that the helper stops if it fails to set the threshold on a battery instead of continuing with the other batteries.
Comment 9 Bug Janitor Service 2023-01-26 13:13:01 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/131
Comment 10 Iyán Méndez Veiga 2023-01-26 13:47:43 UTC
Patch works for me ;)
Comment 11 Fabian Vogt 2023-01-26 13:50:11 UTC
Git commit e0a74cc3bd358abeb64b9a3857c00c1d71802553 by Fabian Vogt.
Committed on 26/01/2023 at 13:13.
Pushed by fvogt into branch 'master'.

chargethresholdhelper: Filter out batteries without thresholds early

Previously, getBatteries() returned all batteries, even those without support
for thresholds. While getthreshold simply skipped those where reading
fails, setthreshold exited early on the first failure, leaving the remaining
batteries untouched.

By already performing filtering in getBatteries(), this should now behave more
consistently and work also if not all batteries support thresholds.

M  +14   -3    daemon/chargethresholdhelper.cpp

https://invent.kde.org/plasma/powerdevil/commit/e0a74cc3bd358abeb64b9a3857c00c1d71802553
Comment 12 Fabian Vogt 2023-01-26 13:50:46 UTC
Git commit b2e33beeed1a7ba60fb20a784c3209f97b887b8f by Fabian Vogt.
Committed on 26/01/2023 at 13:50.
Pushed by fvogt into branch 'Plasma/5.27'.

chargethresholdhelper: Filter out batteries without thresholds early

Previously, getBatteries() returned all batteries, even those without support
for thresholds. While getthreshold simply skipped those where reading
fails, setthreshold exited early on the first failure, leaving the remaining
batteries untouched.

By already performing filtering in getBatteries(), this should now behave more
consistently and work also if not all batteries support thresholds.


(cherry picked from commit e0a74cc3bd358abeb64b9a3857c00c1d71802553)

M  +14   -3    daemon/chargethresholdhelper.cpp

https://invent.kde.org/plasma/powerdevil/commit/b2e33beeed1a7ba60fb20a784c3209f97b887b8f
Comment 13 Victor Ryzhykh 2023-02-14 18:29:39 UTC
Created attachment 156238 [details]
There are no settings.

This commit disables the battery limit setting.

Operating System: ROSA Fresh Desktop 2021.1
KDE Plasma Version: 5.27.0
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.5
Kernel Version: 6.1.11-generic-4rosa2021.1-x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 16 × 11th Gen Intel® Core™ i7-11800H @ 2.30GHz
Memory: 38.9 ГиБ of RAM
Graphics Processor: Mesa Intel® UHD Graphics
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Zephyrus M16 GU603HE_GU603HE
System Version: 1.0
Comment 14 Victor Ryzhykh 2023-02-14 18:34:01 UTC
Created attachment 156239 [details]
Removed this commit.

Removed this commit by building the package with the parameter

Patch1: https://invent.kde.org/plasma/powerdevil/-/commit/b2e33beeed1a7ba60fb20a784c3209f97b887b8.patch

%prep
%setup -n %{oname}-%{version}
%patch1 -p1 -R
Comment 15 Fabian Vogt 2023-02-14 18:34:55 UTC
What's the output of ls -l /sys/class/power_supply/*/*threshold*?

I suspect the battery either has a start or stop threshold, but not both.
Comment 16 Victor Ryzhykh 2023-02-14 18:42:54 UTC
(In reply to Victor Ryzhykh from comment #13)
> Created attachment 156238 [details]
> There are no settings.
> 
> This commit disables the battery limit setting.
> 

Settings are not available on this tab.
but managed to enable the limit with package asusctl.
Package asusctl works correctly in both cases.
https://gitlab.com/asus-linux/asusctl
Comment 17 Victor Ryzhykh 2023-02-14 18:47:59 UTC
(In reply to Fabian Vogt from comment #15)
> What's the output of ls -l /sys/class/power_supply/*/*threshold*?
> 
> I suspect the battery either has a start or stop threshold, but not both.

victor@asus-rog ~ $ ls -l /sys/class/power_supply/*/*threshold
-rw-r--r-- 1 root root 4096 фев 14 21:38 /sys/class/power_supply/BAT0/charge_control_end_threshold
victor@asus-rog ~ $ su -
Пароль: 
asus-rog ~ # ls -l /sys/class/power_supply/*/*threshold
-rw-r--r-- 1 root root 4096 фев 14 21:38 /sys/class/power_supply/BAT0/charge_control_end_threshold
asus-rog ~ #
Comment 18 Bug Janitor Service 2023-02-14 18:53:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/powerdevil/-/merge_requests/135
Comment 19 Fabian Vogt 2023-02-14 18:54:25 UTC
(In reply to Victor Ryzhykh from comment #17)
> (In reply to Fabian Vogt from comment #15)
> > What's the output of ls -l /sys/class/power_supply/*/*threshold*?
> > 
> > I suspect the battery either has a start or stop threshold, but not both.
> 
> victor@asus-rog ~ $ ls -l /sys/class/power_supply/*/*threshold
> -rw-r--r-- 1 root root 4096 фев 14 21:38
> /sys/class/power_supply/BAT0/charge_control_end_threshold
> victor@asus-rog ~ $ su -
> Пароль: 
> asus-rog ~ # ls -l /sys/class/power_supply/*/*threshold
> -rw-r--r-- 1 root root 4096 фев 14 21:38
> /sys/class/power_supply/BAT0/charge_control_end_threshold
> asus-rog ~ #

Ok, so my suspicion was correct. Please try https://invent.kde.org/plasma/powerdevil/-/merge_requests/135.
Comment 20 Victor Ryzhykh 2023-02-14 19:24:01 UTC
(In reply to Fabian Vogt from comment #19)
> Ok, so my suspicion was correct. Please try
> https://invent.kde.org/plasma/powerdevil/-/merge_requests/135.

/builddir/build/BUILD/powerdevil-5.27.0/daemon/chargethresholdhelper.cpp:67:16: error: expected identifier before '!' token
Comment 21 Fabian Vogt 2023-02-14 19:31:25 UTC
(In reply to Victor Ryzhykh from comment #20)
> (In reply to Fabian Vogt from comment #19)
> > Ok, so my suspicion was correct. Please try
> > https://invent.kde.org/plasma/powerdevil/-/merge_requests/135.
> 
> /builddir/build/BUILD/powerdevil-5.27.0/daemon/chargethresholdhelper.cpp:67:
> 16: error: expected identifier before '!' token

Fixed.
Comment 22 Victor Ryzhykh 2023-02-14 19:56:48 UTC
(In reply to Fabian Vogt from comment #21)
> (In reply to Victor Ryzhykh from comment #20)
> > (In reply to Fabian Vogt from comment #19)
> > > Ok, so my suspicion was correct. Please try
> > > https://invent.kde.org/plasma/powerdevil/-/merge_requests/135.
> > 
> > /builddir/build/BUILD/powerdevil-5.27.0/daemon/chargethresholdhelper.cpp:67:
> > 16: error: expected identifier before '!' token
> 
> Fixed.

So good, now it works.
Comment 23 Victor Ryzhykh 2023-02-14 19:57:29 UTC
Created attachment 156245 [details]
So good, now it works.

So good, now it works.
Comment 24 Fabian Vogt 2023-02-15 16:06:21 UTC
Git commit d4fff0747290575705c09a2bfe265390d857d90a by Fabian Vogt.
Committed on 15/02/2023 at 16:04.
Pushed by fvogt into branch 'master'.

Only skip batteries if neither start or stop thresholds are available

Previously only those batteries which had both thresholds available were
returned.

M  +4    -7    daemon/chargethresholdhelper.cpp

https://invent.kde.org/plasma/powerdevil/commit/d4fff0747290575705c09a2bfe265390d857d90a
Comment 25 Fabian Vogt 2023-02-15 16:09:42 UTC
Git commit eed8ef2f06f29b1c8983b3af950349b7d603bb7f by Fabian Vogt.
Committed on 15/02/2023 at 16:09.
Pushed by fvogt into branch 'Plasma/5.27'.

Only skip batteries if neither start or stop thresholds are available

Previously only those batteries which had both thresholds available were
returned.
(cherry picked from commit d4fff0747290575705c09a2bfe265390d857d90a)
(cherry picked from commit 9cc6650a0b2946c80b62950f57ec6b50cb7aaed8)

M  +3    -6    daemon/chargethresholdhelper.cpp

https://invent.kde.org/plasma/powerdevil/commit/eed8ef2f06f29b1c8983b3af950349b7d603bb7f