From 1cc5a247cf97cb3790f166cc2b8ab59c2cdc0bc3 Mon Sep 17 00:00:00 2001 From: Barely Removable Date: Thu, 27 Aug 2026 06:21:41 -0700 Subject: [PATCH] Fetch per-disk temp and spin state for the Storage card The GraphQL query only asked for aggregate array fsSize/fsFree, so the per-disk breakdown added in templates/dashboard.html (commit 5045316) had no data to render. Now pulls name/device/temp/isSpinning for data disks, cache disks, and parity disks, and shapes them into the disks/caches/parities lists the template expects. Co-Authored-By: Claude Sonnet 5 --- app.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 2446478..949ed06 100644 --- a/app.py +++ b/app.py @@ -813,7 +813,12 @@ def get_unraid_stats(): headers = {"x-api-key": UNRAID_API_KEY, "Content-Type": "application/json"} query = """{ vars { version } - array { state disks { fsSize fsFree type } } + array { + state + disks { name device fsSize fsFree type temp isSpinning } + caches { name device fsSize fsFree type temp isSpinning } + parities { name device temp isSpinning } + } }""" try: resp = requests.post(url, json={"query": query}, headers=headers, @@ -828,6 +833,26 @@ def get_unraid_stats(): free_bytes = sum(int(dk.get("fsFree", 0) or 0) for dk in data_disks) used_bytes = total_bytes - free_bytes used_pct = round(used_bytes / total_bytes * 100) if total_bytes else 0 + + def disk_row(dk, with_usage=True): + row = { + "name": dk.get("name") or dk.get("device") or "disk", + "device": dk.get("device", ""), + "temp": dk.get("temp"), + "spinning": dk.get("isSpinning"), + } + if with_usage: + dtotal = int(dk.get("fsSize", 0) or 0) + dfree = int(dk.get("fsFree", 0) or 0) + dused = dtotal - dfree + row.update({ + "total": fmt_bytes(dtotal), + "used": fmt_bytes(dused), + "free": fmt_bytes(dfree), + "used_pct": round(dused / dtotal * 100) if dtotal else 0, + }) + return row + return { "status": "ok", "source": "api", @@ -838,6 +863,9 @@ def get_unraid_stats(): "array_used": fmt_bytes(used_bytes), "array_free": fmt_bytes(free_bytes), "array_used_pct": used_pct, + "disks": [disk_row(dk) for dk in data_disks], + "caches": [disk_row(dk) for dk in arr.get("caches", [])], + "parities": [disk_row(dk, with_usage=False) for dk in arr.get("parities", [])], } except Exception: pass