statd: add pwm fan support

Due to their nature we cannot read out the RPM of the pwm fans on the
BPi-R3.  But we can at least show it's alive, or steering out a signal
to the fan.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-11-30 17:16:21 +01:00
parent 5e62adae7e
commit fdb02895fb
2 changed files with 44 additions and 1 deletions
+13
View File
@@ -652,7 +652,20 @@ class Sensor:
else:
return f"{self.value} W"
# Handle PWM fan sensors (reported as "other" type with milli scale)
# PWM duty cycle is reported as percentage (0-100)
elif self.value_type == 'other' and self.value_scale == 'milli':
# Check if this is likely a PWM sensor based on description or name
name_lower = self.name.lower()
desc_lower = (self.description or "").lower()
if 'pwm' in desc_lower or 'fan' in name_lower or 'fan' in desc_lower:
percent = self.value / 1000.0
return f"{percent:.1f}%"
# Fall through for other "other" type sensors
# For unknown sensor types, show raw value
if self.value_type in ['other', 'unknown']:
return f"{self.value}"
else:
return f"{self.value} {self.value_type}"