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
This commit is contained in:
2026-08-16 20:11:34 +02:00
parent f820a99c7c
commit c2e2f7552f
+7 -3
View File
@@ -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"