Bug 506860

Summary: Energy KCM forgets battery stats when swapping out batteries
Product: [Applications] kinfocenter Reporter: Sebastian Kügler <sebas>
Component: generalAssignee: Sebastian Kügler <sebas>
Status: CONFIRMED ---    
Severity: wishlist CC: nate, sitter
Priority: LO    
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Sebastian Kügler 2025-07-10 12:48:34 UTC
Currently, battery stats are saved in upower per battery. For swappable batteries, this means that we lose useful information whenever the user swaps out a battery.

Proposed solution is to cache battery stats so we can display these regardless of batteries having been swapped out, and do so per battery bay.
Comment 1 Nate Graham 2025-08-26 19:38:18 UTC
Does it make sense though? The information shown about the battery really is specific to that battery. Are you saying you want to continue to be able to see the stats of a battery that was seen in the past but isn't currently in use?
Comment 2 Sebastian Kügler 2025-08-28 09:08:06 UTC
Yes, essentially that. I think it does, since it can be quite interesting how the system drained the battery when the older one was still inserted. Since there can only ever be one battery inserted into the bay, we won't override data by definition.

That said, this issue is somewhat lower on my list currently. I don't think it would be too hard to do this without getting in the way of what's normal on current hardware (namely just one battery which isn't even replaceable). For systems that hardly ever get connected to mains, but which have 2 bays to be able to swap out batteries in the field, this is more useful (and actually where we observed said behavior). Upstream upower doesn't seem very interested, but it seems a simple cache (track energy consumption, write it to disk once in a while) can nicely solve this problem.

Anyway, low priority for now. We can discuss details once it bubbles up on my to-do list.
Comment 3 Nate Graham 2025-08-28 15:25:04 UTC
All right, go for it!