Bug 448372 - Round battery health
Summary: Round battery health
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Power and Battery widget (show other bugs)
Version: 5.23.90
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Kai Uwe Broulik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-13 16:30 UTC by Iyán M. V.
Modified: 2022-01-18 21:51 UTC (History)
2 users (show)

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


Attachments
Screenshot showing the battery info (134.60 KB, image/png)
2022-01-14 10:36 UTC, Iyán M. V.
Details
Screenshot second battery (150.86 KB, image/png)
2022-01-14 10:41 UTC, Iyán M. V.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Iyán M. V. 2022-01-13 16:30:58 UTC
SUMMARY
The battery health percentage in the battery applet does not show decimals, which is fine, but is not properly rounded so a capacity of, for example 99.9825% (according to `upower -i /org/freedesktop/UPower/devices/battery_BAT0`) shows a battery health of 99% instead of 100%. This is annoying because even fresh new laptops will not show a 100% battery health even though battery is perfectly fine.


SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.90
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.0-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Comment 1 Bug Janitor Service 2022-01-13 21:34:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1360
Comment 2 ratijas 2022-01-13 23:08:48 UTC
Iyán, Can you please post some screenshots? UPower output would be great too.

1. Launch Plasma Engine Explorer (plasmaengineexplorer command),
2. Navigate to the "powermanagement" data engine (first drop-down menu),
3. In the table below open (expand) all data sources that start with "Battery" (including the general "Battery" itself).
4. Resize columns and window such that everything interesting is visible.
5. Take screenshots and post them here.

I found an inconsistency in data engine, such that it may send total data in double (floating point) format, while individual batteries are providing already rounded integer values. I wonder how does it look like on your side.
Comment 3 Iyán M. V. 2022-01-14 10:36:50 UTC
Created attachment 145453 [details]
Screenshot showing the battery info
Comment 4 Iyán M. V. 2022-01-14 10:41:05 UTC
Created attachment 145454 [details]
Screenshot second battery

This is wrongly reported as 0. It is the battery of the pencil to use with the touchscreen. It started to appear recently (not related with Plasma update, probably it was after a kernel update). In order to show a correct value I have to take the pencil out and put it back in again to the laptop.
Comment 5 ratijas 2022-01-14 11:03:58 UTC
Oh, so we are dealing with an issue on an entirely different level here. Backend manages to recognize Wacom device as something-something-has-battery, but can't obtain any useful state from it.

By the way, are you sure this is not Plasma related? There was a patch recently that exposed more battery types to the applet IIRC, and your software versions look very fresh.

Anyway, thanks for the info. I see now that we should better account for batteries without actual data use case.
Comment 6 Iyán M. V. 2022-01-14 11:08:20 UTC
No, no, I'm not sure and maybe it was some change in Plasma. When I realized it happened that I also got a kernel update (I think from 5.14 -> 5.15) so maybe I wrongly assumed that. Maybe you are right and it was after some Plasma update. Should I open a different report for that?
Comment 7 Bug Janitor Service 2022-01-16 23:30:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/solid/-/merge_requests/71
Comment 8 ratijas 2022-01-16 23:40:54 UTC
Not gonna lie, it took me some time to realize what your original issue really was. But here we go, this patch should take care of it.

> Should I open a different report for that?

Yes, please. Missing data is a different problem, quite likely even out of KDE's control.
Comment 9 Iyán M. V. 2022-01-17 21:21:32 UTC
Thank you for your patch! ;)

I will open the other issue tomorrow when I have a bit of free time.
Comment 10 Nate Graham 2022-01-18 21:51:36 UTC
Git commit 2f305a7134f27489203c3fd2e9ca81790f35ac3b by Nate Graham, on behalf of ivan tkachenko.
Committed on 18/01/2022 at 21:42.
Pushed by ngraham into branch 'master'.

[upower] Properly round up battery's capacity

The same rounding is already used for charge percent just few lines
above. Without it, for example, values that are close to 100%
(e.g. 99.9825%) were rounded down to 99% instead of up to 100%.
FIXED-IN: 5.91

M  +1    -1    src/solid/devices/backends/upower/upowerbattery.cpp

https://invent.kde.org/frameworks/solid/commit/2f305a7134f27489203c3fd2e9ca81790f35ac3b