mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 01:46:18 -05:00
Fix SMART temperature always reporting null.
Real drives report attribute 194 raw values like "52 (Min/Max 16/57)" which int() cannot parse, so every drive's temperature was null. Prefer pySMART's `temperature` property, which parses these formats and also works for NVMe devices that have no ATA attribute table. Verified on real hardware (WD100EMAZ over USB-SAT): 51-53C now reported where null was returned before. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6088cbfe2a
commit
87ed286f7d
2 changed files with 46 additions and 1 deletions
|
|
@ -62,7 +62,16 @@ def _get_device_smart(device) -> dict:
|
|||
|
||||
|
||||
def _get_temperature(device) -> Optional[int]:
|
||||
"""Get drive temperature from SMART attributes."""
|
||||
"""Get drive temperature.
|
||||
|
||||
Prefer pySMART's `temperature` property: it parses real-world raw
|
||||
values like "52 (Min/Max 16/57)" that int() cannot, and works for
|
||||
NVMe devices which have no ATA attribute table. Fall back to the
|
||||
plain attributes for devices where the property is unavailable.
|
||||
"""
|
||||
temp = getattr(device, "temperature", None)
|
||||
if isinstance(temp, int):
|
||||
return temp
|
||||
temp = _get_attribute(device, "Temperature_Celsius")
|
||||
if temp is None:
|
||||
temp = _get_attribute(device, "Airflow_Temperature_Cel")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue