added interval and min/max config options
added [min, max] option to fans added pid check interval setting to daemon
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
loglevel: DEBUG
|
loglevel: DEBUG
|
||||||
|
interval: 1
|
||||||
|
|
||||||
thermalzones:
|
thermalzones:
|
||||||
- name: GPU+SYSTEM
|
- name: GPU+SYSTEM
|
||||||
@@ -16,7 +17,7 @@ thermalzones:
|
|||||||
source: coretemp/temp1_input
|
source: coretemp/temp1_input
|
||||||
factor: 1000
|
factor: 1000
|
||||||
fan:
|
fan:
|
||||||
- it8686/pwm1
|
- it8686/pwm1: [100, 200]
|
||||||
target: 50
|
target: 50
|
||||||
pid:
|
pid:
|
||||||
p: 1
|
p: 1
|
||||||
|
|||||||
27
pyfan.py
27
pyfan.py
@@ -36,14 +36,24 @@ class ThermalZone:
|
|||||||
def eval(self):
|
def eval(self):
|
||||||
if self.get_temp():
|
if self.get_temp():
|
||||||
diff = self.target - self.get_temp()
|
diff = self.target - self.get_temp()
|
||||||
val = self.pid(diff)
|
val = int(self.pid(diff))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for target_fan in self.fans:
|
for target_fan in self.fans:
|
||||||
if type(target_fan) is dict:
|
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:
|
else:
|
||||||
self.write_sysfs(target_fan, int(val))
|
self.write_sysfs(fan, min(val, fan_val))
|
||||||
|
else:
|
||||||
|
self.write_sysfs(target_fan, val)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
logging.getLogger("pyfan").warning(
|
logging.getLogger("pyfan").warning(
|
||||||
"[%s] Failed to set pwm, trying to reset it. (%s)" % (self.name, err.strerror))
|
"[%s] Failed to set pwm, trying to reset it. (%s)" % (self.name, err.strerror))
|
||||||
@@ -74,8 +84,8 @@ class ThermalZone:
|
|||||||
else:
|
else:
|
||||||
self.set_pwm_mode(target_fan, value)
|
self.set_pwm_mode(target_fan, value)
|
||||||
except FileNotFoundError as err:
|
except FileNotFoundError as err:
|
||||||
logging.getLogger("pyfan").warning("[%s] pwm not found. Not ready yet or wrong path? (%s)" % (self.name,
|
logging.getLogger("pyfan").warning("[%s] pwm not found."
|
||||||
err.strerror))
|
" Not ready yet or wrong path? (%s)" % (self.name, err.strerror))
|
||||||
|
|
||||||
def replace_alias(self, path):
|
def replace_alias(self, path):
|
||||||
replaced = self.alias_replace.sub(lambda x: self.hwmap[x.group()], path)
|
replaced = self.alias_replace.sub(lambda x: self.hwmap[x.group()], path)
|
||||||
@@ -111,6 +121,11 @@ class PyFan:
|
|||||||
self.hwmon_map = {}
|
self.hwmon_map = {}
|
||||||
self.gen_hwmon_map()
|
self.gen_hwmon_map()
|
||||||
|
|
||||||
|
if self.config["interval"]:
|
||||||
|
self.interval = self.config["interval"]
|
||||||
|
else:
|
||||||
|
self.interval = 1
|
||||||
|
|
||||||
for zone in self.config["thermalzones"]:
|
for zone in self.config["thermalzones"]:
|
||||||
self.zones.append(ThermalZone(zone, self.hwmon_map))
|
self.zones.append(ThermalZone(zone, self.hwmon_map))
|
||||||
|
|
||||||
@@ -147,6 +162,6 @@ if __name__ == "__main__":
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
pyfan.eval()
|
pyfan.eval()
|
||||||
sleep(1)
|
sleep(pyfan.interval)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user