6 Commits
1.2 ... 1.3

Author SHA1 Message Date
8d95e69048 added more debug log to determine current pwm setting 2019-12-27 15:11:19 +01:00
772408fc6d fixed interval key check 2019-12-27 14:48:16 +01:00
e980293ab6 added interval and min/max config options
added [min, max] option to fans
added pid check interval setting to daemon
2019-12-27 14:30:38 +01:00
6e45b77aba Update 'README.md' 2019-10-04 11:26:12 +02:00
6074353b95 Merge remote-tracking branch 'origin/master' 2019-10-04 11:13:27 +02:00
3f96734d84 removed unused config variable 2019-10-04 11:13:19 +02:00
3 changed files with 28 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
## PyFAN
This python script utilizes linux's hwmon interface and a PID controller for fan controlling. No external dependencies besides simple_pid are needed.
This python script utilizes linux's hwmon interface and a PID controller for fan controlling. No external dependencies besides simple_pid and PyYAML are needed.
# Usage

View File

@@ -1,8 +1,8 @@
loglevel: DEBUG
interval: 1
thermalzones:
- name: GPU+SYSTEM
hwmon: amdgpu
source: amdgpu/temp1_input
factor: 1000
fan:
@@ -14,11 +14,10 @@ thermalzones:
i: 1
d: 1.5
- name: CPU
hwmon: it8686
source: coretemp/temp1_input
factor: 1000
fan:
- it8686/pwm1
- it8686/pwm1: [100, 200]
target: 50
pid:
p: 1

View File

@@ -20,7 +20,6 @@ class ThermalZone:
self.factor = 1 / config["factor"]
self.name = config["name"]
self.target = config["target"]
self.hwname = config["hwmon"]
self.hwmap = hwmon_map
self.alias_replace = re.compile('|'.join(self.hwmap.keys()))
self.setup_pwm()
@@ -37,14 +36,28 @@ class ThermalZone:
def eval(self):
if self.get_temp():
diff = self.target - self.get_temp()
val = self.pid(diff)
val = int(self.pid(diff))
try:
for target_fan in self.fans:
if type(target_fan) is dict:
self.write_sysfs(list(target_fan.keys())[0], min(int(val), list(target_fan.values())[0]))
fan = list(target_fan.keys())[0]
fan_val = list(target_fan.values())[0]
if type(fan_val) is list:
if len(fan_val) < 2:
logging.getLogger("pyfan").warning(
"[%s] max/min for %s was not set correctly (%s)" % (self.name, fan, fan_val))
self.write_sysfs(fan, min(fan_val[1], max(val, fan_val[0])))
else:
self.write_sysfs(target_fan, int(val))
self.write_sysfs(fan, min(val, fan_val))
logging.getLogger("pyfan").debug(
"[{name}] {fan} is set at {val}%".format(name=self.name, fan=fan,
val=int(int(self.read_sysfs(fan)) / 255 * 100)))
else:
self.write_sysfs(target_fan, val)
except OSError as err:
logging.getLogger("pyfan").warning(
"[%s] Failed to set pwm, trying to reset it. (%s)" % (self.name, err.strerror))
@@ -75,8 +88,8 @@ class ThermalZone:
else:
self.set_pwm_mode(target_fan, value)
except FileNotFoundError as err:
logging.getLogger("pyfan").warning("[%s] pwm not found. Not ready yet or wrong path? (%s)" % (self.name,
err.strerror))
logging.getLogger("pyfan").warning("[%s] pwm not found."
" Not ready yet or wrong path? (%s)" % (self.name, err.strerror))
def replace_alias(self, path):
replaced = self.alias_replace.sub(lambda x: self.hwmap[x.group()], path)
@@ -112,6 +125,11 @@ class PyFan:
self.hwmon_map = {}
self.gen_hwmon_map()
if "interval" in self.config:
self.interval = self.config["interval"]
else:
self.interval = 1
for zone in self.config["thermalzones"]:
self.zones.append(ThermalZone(zone, self.hwmon_map))
@@ -148,6 +166,6 @@ if __name__ == "__main__":
while True:
try:
pyfan.eval()
sleep(1)
sleep(pyfan.interval)
except KeyboardInterrupt:
sys.exit(0)