DEV Community

milton rojas
milton rojas

Posted on

I Built a Python Battery Health Dashboard Because Windows' Built-in Report is Useless

Windows has a built-in battery report. You run powercfg /batteryreport, open an HTML file, and stare at a wall of raw numbers — full charge capacity in mWh, design capacity, usage logs spanning months. There's no grade, no trend, no answer to the actual question: is my battery dying or fine?

I built a terminal dashboard that answers that question directly.

What the tool does

Windows Battery Health Dashboard reads WMI battery data directly, assigns an A–F health grade, tracks degradation over time in SQLite, predicts remaining useful life via linear regression, and generates a plain-English AI summary via Groq. It runs entirely in the terminal. No GUI, no bloat.

┌─────────────────────────────────────────────────┐
│         BATTERY HEALTH DASHBOARD v1.0           │
├─────────────────────────────────────────────────┤
│  Health Grade:     B  (78.4% capacity retained) │
│  Design Capacity:  45,000 mWh                   │
│  Full Charge Now:  35,280 mWh                   │
│  Cycle Count:      312                          │
│  Status:           Discharging  (67%)           │
├─────────────────────────────────────────────────┤
│  Trend: -0.8% capacity/month over 6 snapshots   │
│  Estimated lifespan: ~14 months remaining       │
├─────────────────────────────────────────────────┤
│  AI Summary:                                    │
│  Your battery is in good shape but showing      │
│  steady degradation. At the current rate, plan  │
│  for a replacement within the next 14 months.   │
└─────────────────────────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

How the WMI queries work

Python's wmi library exposes the root/wmi namespace, which is where the real battery data lives — not the surface-level stuff in root/cimv2.

import wmi

c = wmi.WMI(namespace="root/wmi")

# Design capacity (the original maximum, in mWh)
static_data = c.BatteryStaticData()[0]
design_capacity = static_data.DesignedCapacity

# Current full charge capacity (degrades over time)
full_charge = c.BatteryFullChargedCapacity()[0]
current_full = full_charge.FullChargedCapacity

# Cycle count (not available on all hardware)
try:
    cycle_data = c.BatteryCycleCount()[0]
    cycles = cycle_data.CycleCount
except:
    cycles = None

# Health as a percentage
health_pct = (current_full / design_capacity) * 100
Enter fullscreen mode Exit fullscreen mode

That health_pct is the core signal. The grading scale maps directly to it:

Grade Health %
A 90–100%
B 75–89%
C 60–74%
D 40–59%
F < 40%

Degradation tracking and prediction

A single snapshot tells you where you are. SQLite history tells you where you're going.

Each run writes a row: (timestamp, full_charge_capacity, health_pct). After a few weeks of snapshots, the dashboard runs a linear regression over the health percentage values to estimate the monthly degradation rate and project when the battery will cross the 40% threshold — the point most manufacturers consider end-of-life.

import numpy as np

# x = days since first snapshot, y = health_pct values
slope, intercept = np.polyfit(x_days, y_health, 1)

# months until health_pct hits 40%
months_remaining = (40 - current_health) / (slope * 30)
Enter fullscreen mode Exit fullscreen mode

The prediction sharpens with more data points. Run it weekly and you'll have a useful trend within a month.

The AI summary

The dashboard sends the health grade, cycle count, trend slope, and predicted lifespan to Groq's API (llama-3.3-70b) and gets back two sentences. That's it. No API key required to use the core dashboard — the summary is optional and clearly marked as such in the output.

The prompt is intentionally terse:

Battery health: {grade} ({health_pct:.1f}%). Cycles: {cycles}.
Degradation: {slope:.3f}%/day. Estimated months remaining: {months:.0f}.
Write a 2-sentence plain-English summary for a non-technical user.
Enter fullscreen mode Exit fullscreen mode

Groq's free tier handles this easily.

Honest caveats

This only works on Windows laptops and tablets with a real battery. Desktops, VMs, and WSL will either throw a WMI error or return no battery data. The wmi Python package requires Windows — this is not a cross-platform tool and doesn't pretend to be.

Some manufacturers also block or omit cycle count data from WMI. The dashboard handles that gracefully and skips cycle count if unavailable.

Get it

The full dashboard — including the SQLite history module, regression logic, Groq integration, and a clean terminal UI — is available for $15:

Download on Gumroad →

Direct ZIP download: battery-dashboard-v1.zip

Requirements: Python 3.9+, Windows 10/11, wmi, pywin32, psutil. Optional: groq for the AI summary.


Built by RedKingsDesigns — small tools that solve real problems.

Top comments (0)