fix: update to 4.0.6 and improved unvr support

* We should hopefully have working fans for the UNVR4 now
* Update to latest pre-release unifi firmware 4.0.6
* Improve hwmon logic in our scripts
This commit is contained in:
Chris Blake 2024-06-18 08:45:27 -05:00
parent 76c17952a7
commit 5962f1ea30
5 changed files with 59 additions and 23 deletions

View file

@ -21,9 +21,21 @@ THERMAL_SYS_PATHS = {
"/sys/class/hwmon/hwmon0/device/pwm3",
],
},
"UNVR4": {
"thermal": [
"/sys/devices/virtual/thermal/thermal_zone0/temp",
"/sys/class/hwmon/hwmon0/device/temp1_input",
"/sys/class/hwmon/hwmon0/device/temp2_input",
"/sys/class/hwmon/hwmon0/device/temp3_input",
],
"fan_pwms": [
"/sys/class/hwmon/hwmon0/device/pwm1",
"/sys/class/hwmon/hwmon0/device/pwm2",
"/sys/class/hwmon/hwmon0/device/pwm3",
],
},
}
def __get_board_temps():
# Are we supported?
if get_ubnt_shortname() not in THERMAL_SYS_PATHS:
@ -37,8 +49,16 @@ def __get_board_temps():
with open(path, "r") as f:
board_temps.append(int(f.readline().rstrip("\n")))
except FileNotFoundError:
print(f"Warning: Unable to open {path}; ignoring and continuing...")
continue
# If we are here, either it doesn't exist, OR, we need to change paths from
# /sys/class/hwmon/hwmon0/device/temp*_input to /sys/class/hwmon/hwmon0/temp*_input
# since there could be a different thermal sensor/controller being used on the board
try:
with open(path.replace('/device',''), "r") as f:
board_temps.append(int(f.readline().rstrip("\n")))
except FileNotFoundError:
print(f"Warning: Unable to open {path}; ignoring and continuing...")
continue
# Did we get ANY temps?!?
if len(board_temps) == 0:
@ -100,10 +120,17 @@ def __set_fan_speed(speed: int):
with open(fan, "w") as f:
f.write(str(speed))
except FileNotFoundError:
print(
f"Error: Unable to write to PWM at {fan}! Why can't we set fan speed!?"
)
raise
# If we are here, either it doesn't exist, OR, we need to change paths from
# /sys/class/hwmon/hwmon0/device/pwm* to /sys/class/hwmon/hwmon0/pwm* since
# there could be a different thermal sensor/controller being used on the board
try:
with open(fan.replace('/device',''), "w") as f:
f.write(str(speed))
except FileNotFoundError:
print(
f"Error: Unable to write to PWM at {fan}! Why can't we set fan speed!?"
)
raise
def __write_out_temp(temp: int, path: str = "/tmp/.unvr_temp"):