From c2e2f7552fec867e429564236362816bef1f39f1 Mon Sep 17 00:00:00 2001 From: nessi Date: Sun, 16 Aug 2026 20:11:34 +0200 Subject: [PATCH] feat: prioritize Temperature_Celsius over Airflow_Temperature in SMART parsing to prefer physical drive temperature Reorder temperature line matching to first search for Temperature_Celsius/Drive_Temperature/Current Drive Temperature attributes before falling back to generic temperature/airflow keywords. Add ordered list construction with preferred patterns first, then append remaining temperature lines, to ensure physical drive temperature is selected over airflow sensor when both are present in --- app.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index a4e9e11..90203e6 100644 --- a/app.py +++ b/app.py @@ -358,9 +358,13 @@ def smart_temperature(device): return "Nicht verfügbar" smart_device = device.replace("/dev/", f"{HOST_DEVICE_PATH.rstrip('/')}/", 1) def extract(output): - for line in output.splitlines(): - if not re.search(r"temperature|airflow", line, re.IGNORECASE): - continue + lines = output.splitlines() + # Seagate and similar drives often expose both Airflow_Temperature + # and Temperature_Celsius. Prefer the latter because it is the + # physical drive temperature shown by the usual terminal command. + ordered = [line for line in lines if re.search(r"Temperature_Celsius|Drive_Temperature|Current Drive Temperature", line, re.IGNORECASE)] + ordered += [line for line in lines if line not in ordered and re.search(r"temperature|airflow", line, re.IGNORECASE)] + for line in ordered: explicit = re.search(r"(\d{1,3})\s*(?:°\s*C|Celsius|degrees?\s*C)\b", line, re.IGNORECASE) if explicit and 0 < int(explicit.group(1)) < 150: return f"{int(explicit.group(1))} °C"