diff --git a/app.py b/app.py index 64b22c5..7ce4909 100644 --- a/app.py +++ b/app.py @@ -362,10 +362,13 @@ def smart_temperature(device): # 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"Current Drive Temperature|Drive Temperature|^\s*Temperature:\s*", line, re.IGNORECASE)] - ordered += [line for line in lines if line not in ordered and re.search(r"Temperature_Celsius", line, re.IGNORECASE)] + ordered = [line for line in lines if re.search(r"Temperature_Celsius", line, re.IGNORECASE)] + ordered += [line for line in lines if line not in ordered and re.search(r"Current Drive Temperature|Drive Temperature|^\s*Temperature:\s*", 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: + raw_temperature = re.search(r"Temperature_Celsius.*-\s*(-?\d{1,3})\s*(?:\([^)]*\))?\s*$", line, re.IGNORECASE) + if raw_temperature and 0 < int(raw_temperature.group(1)) < 150: + return f"{int(raw_temperature.group(1))} °C" 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"