50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from liquidctl import find_liquidctl_devices, cli
|
|
|
|
class LiquidCTL_Helper():
|
|
device_name = None
|
|
device_temp = 0
|
|
device_fanSpeed = 0
|
|
device_pumpSpeed = 0
|
|
device_fwVers = None
|
|
|
|
devices = find_liquidctl_devices()
|
|
try:
|
|
for dev in devices:
|
|
with dev.connect():
|
|
#print(f'{dev.description}')
|
|
device_name = dev.description
|
|
device_fwVers = ''.join(map(str, dev.firmware_version))
|
|
except:
|
|
pass
|
|
|
|
def ForceInit(self):
|
|
init_status = self.dev.initialize()
|
|
if init_status:
|
|
for key, value, unit in init_status:
|
|
#print(f'- {key}: {value} {unit}')
|
|
device_fwVers = value
|
|
|
|
def TestConnectionState(self):
|
|
if self.device_name != None:
|
|
return False
|
|
else:
|
|
return True
|
|
|
|
def Update(self):
|
|
with self.dev.connect():
|
|
status = self.dev.get_status()
|
|
for key, value, unit in status:
|
|
#print(f'- {key}: {value} {unit}')
|
|
if key == "Liquid temperature":
|
|
self.device_temp = value
|
|
elif key == "Fan speed":
|
|
self.device_fanSpeed = value
|
|
elif key == "Pump speed":
|
|
self.device_pumpSpeed = value
|
|
|
|
def SetFanSpeed(self, speed):
|
|
with self.dev.connect():
|
|
cli._device_set_speed(self.dev, args={"<temperature>": [],
|
|
"<channel>": "fan",
|
|
"<percentage>": [str(speed)]})
|