KostyaEsmukov / afancontrol

Advanced Fan Control program, which controls PWM fans according to the current temperatures of the system components.
https://afancontrol.readthedocs.io/
MIT License
55 stars 3 forks source link

[Suggestion] Use hwmon name instead of the hwmon path #15

Open Br31zh opened 1 week ago

Br31zh commented 1 week ago

Hello,

I’m using the drivetemp kernel module since hddclient is deprecated, but sometimes the numbers of the hwmon interfaces change.

So my CPU is normally hwmon6 while my disks are hwmon1 to hwmon5, but sometimes 6 is a disk and 5 the CPU, and it mess up with my configuration.

It could be interesting to have a way to select the name of the hwmon interface instead of a path (/sys/class/hwmon/hwmon?/name, here I have amdgpu, zenpower, drivetemp and others).

For now I’m trying to use predictable paths, if anyone have the same problem, it looks like this (you can obtain it using realpath on /sys/class/hwmon entries):

# GPU
path = /sys/devices/pci0000:00/0000:00:03.1/0000:27:00.0/0000:28:00.0/0000:29:00.0/hwmon/hwmon?/temp2_input
# CPU
path = /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon?/temp1_input

# Fans
pwm = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/pwm2
fan_input = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/fan2_input
pwm = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/pwm3
fan_input = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/fan3_input
pwm = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/pwm5
fan_input = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/fan5_input
pwm = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/pwm6
fan_input = /sys/devices/platform/nct6775.2592/hwmon/hwmon?/fan6_input

It seems to work (and I have a fake hddclient that use /sys/devices/pci0000:00/0000:00:01.3/0000:03:00.1/ata?/host?/target?:0:0/?:0:0:0/hwmon/hwmon?/temp1_input for the disks).

geosone commented 5 days ago

could you provide the fake hddcleint or is it in any repository ?

Br31zh commented 5 days ago

It’s litteraly just this:

#!/bin/bash
cat /sys/devices/pci0000:00/0000:00:01.3/0000:03:00.1/ata?/host?/target?:0:0/?:0:0:0/hwmon/hwmon?/temp1_input

I made it executable, in /usr/local/bin/hddtemp-client and then using this in the afancontrol configuration file:

[daemon]
hddtemp = /usr/local/bin/hddtemp-client

[temp:hdd]
type = hdd
path = whatever
min = 40000
max = 50000
panic = 50000

Since afancontrol is using the highest value hddtemp return when you’re using the hdd temp type, you just have to return all the drive you want to check, one by line. I didn’t bother dividing the results by 1000 since it was easier to just add some zeros in the config file.

If you want separate control (if they depends on different fans), you can just change the path in the script (or add a condition so you can return something different depending on the parameter you’ve set instead of whatever in my example).

geosone commented 5 days ago

i have created an script with the help of copilot

hddtemp-next.sh.txt

that is a drop in replacement for hddtemp and it si working with the drivetemp kernel module