Battery health always reports as 0% in KDE Plasma Battery Monitor widget

Hi, long time KDE user first time poster here.

My problem is that the KDE Plasma Battery Monitor widget always lists my battery health as 0%, even though the battery works fine.

On the other hand, inxi seems to report a reasonable-sounding capacity:

[anton@Biloxi ~]$ inxi -B
Battery:
  ID-1: BAT0 charge: 44.1 Wh (99.8%) condition: 44.2/52.5 Wh (84.2%)

I think I’ve found the source code for the Battery Monitor widget, but I’m not sure how to track down the issue further (i.e. how “batteryCapacity” gets set).

https://invent.kde.org/plasma/powerdevil/-/blob/master/applets/batterymonitor/BatteryItem.qml?ref_type=heads

Not a deal breaker for using KDE but would be nice to get it fixed.

Here’s what I’m seeing…
System info?

jonzn4SUSE@Elitebook-865-G9:(pts/5)
[3:48pm]> inxi -B
Battery:
ID-1: BAT0 charge: 36.7 Wh (99.5%) condition: 36.9/51.3 Wh (72.0%)

Operating System: openSUSE Leap 15.6
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12
Kernel Version: 6.4.0-150600.23.100-default (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 PRO 6850HS with Radeon Graphics
Memory: 62.1 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: HP
Product Name: HP EliteBook 865 16 inch G9 Notebook PC

Here’s my system:

Operating System: EndeavourOS
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.25.0
Qt Version: 6.11.0
Kernel Version: 7.0.2-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 PRO 6850U with Radeon Graphics
Memory: 16 GiB of RAM (11.4 GiB usable)
Graphics Processor: AMD Radeon Graphics
Manufacturer: LENOVO
Product Name: 21J5S06N00
System Version: ThinkPad P14s Gen 3

I’m having the same problem on Leap 16.0.

Furthermore, the charge limits set in the advanced configuration of the KDE power management system are not persistent.

While investigating, I came across this file:

/usr/lib/udev/hwdb.d/60-upower-battery.hwdb

# This file is part of upower.
#
# The lookup keys are composed in:
#   60-upower-battery.rules
#
# Match string format:
# battery:<kernel>:<model_name>:dmi:<dmi pattern>
#
# The kernel is the name of battery in /sys/class/power_supply for
# differentiating between multiple batteries.
#
# The model_name is battery model name in for example
# /sys/class/power_supply/BAT0/model_name.
#
# The full DMI string of the running machine can be read from
#   /sys/class/dmi/id/modalias
# That requires a kernel built with CONFIG_DMIID set, which is common.
# The full DMI string is not needed here and the meaning of individual parts
# can be seen in the source of the DMIID kernel module
#   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/firmware/dmi-id.c
#
# To add local overrides, create a new file
# /etc/udev/hwdb.d/61-battery-local.hwdb
# and add your rules there. To load the new rules execute (as root):
# systemd-hwdb  update
# udevadm trigger -v -p /sys/class/power_supply/BAT
# where BAT is the battery in question.
#
# CHARGE_LIMIT is in tuple format and each of the variables can be disabled by "_" character.
# For example:
# CHARGE_LIMIT=60,80 (charge_control_start_threshold is 60 and charge_control_end_threshold is 80.)
# CHARGE_LIMIT=_,80 (charge_control_start_threshold will be skipped and charge_control_end_threshold is 80.)

battery:*:*:dmi:*
 CHARGE_LIMIT=75,80

What I find strange is that on openSUSE, we both have a battery health of 72%.

I now think there must be an issue with several configuration files interacting with each other.