print real fan name to proxmox gui

This commit is contained in:
Meliox 2024-06-16 14:53:19 +02:00
parent 47335ab0d1
commit c0b74a3080

View File

@ -207,7 +207,7 @@ function configure {
# Look for fan speeds # Look for fan speeds
msg "\nDetecting support for fan speed readings..." msg "\nDetecting support for fan speed readings..."
if (echo "$sensorsOutput" | grep -q "fan[0-9]*_input"); then if (echo "$sensorsOutput" | grep -q "fan[0-9]*_input"); then
msg "Detected fan speed sensors:\n$(echo "$sensorsOutput" | grep -Po '"[^"]*":\{\s*"fan[0-9]*_input[^}]*' | sed -E 's/"([^"]*)":.*/\1/')" msg "Detected fan speed sensors:\n$(echo $sensorsOutput | grep -Po '"[^"]*":\s*\{\s*"fan[0-9]*_input[^}]*' | sed -E 's/"([^"]*)":.*/\1/')"
enableFanSpeed=true enableFanSpeed=true
sensorsDetected=true sensorsDetected=true
else else
@ -680,15 +680,15 @@ Ext.define('PVE.mod.TempHelper', {\n\
}\n\ }\n\
\n\ \n\
// Recursive function to find fan keys and values\n\ // Recursive function to find fan keys and values\n\
function findFanKeys(obj, fanKeys) {\n\ function findFanKeys(obj, fanKeys, parentKey = null) {\n\
Object.keys(obj).forEach(key => {\n\ Object.keys(obj).forEach(key => {\n\
const value = obj[key];\n\ const value = obj[key];\n\
if (typeof value === 'object' && value !== null) {\n\ if (typeof value === 'object' && value !== null) {\n\
// If the value is an object, recursively call the function\n\ // If the value is an object, recursively call the function\n\
findFanKeys(value, fanKeys);\n\ findFanKeys(value, fanKeys, key);\n\
} else if (/^fan[0-9]+(_input)?$/.test(key)) {\n\ } else if (/^fan[0-9]+(_input)?$/.test(key)) {\n\
// If the key matches the pattern, add the key-value pair to the fanKeys array\n\ // If the key matches the pattern, add the parent key and value to the fanKeys array\n\
fanKeys.push({ key: key, value: value });\n\ fanKeys.push({ key: parentKey, value: value });\n\
}\n\ }\n\
});\n\ });\n\
}\n\ }\n\
@ -706,9 +706,8 @@ Ext.define('PVE.mod.TempHelper', {\n\
// Process each fan key and value\n\ // Process each fan key and value\n\
fanKeys.forEach(({ key: fanKey, value: fanSpeed }) => {\n\ fanKeys.forEach(({ key: fanKey, value: fanSpeed }) => {\n\
try {\n\ try {\n\
// Extract fan number from the key\n\ const fan = fanKey.charAt(0).toUpperCase() + fanKey.slice(1); // Capitalize the first letter of fanKey\n\
const fanNumber = fanKey.match(/^fan([0-9]+)(_input)?$/)[1];\n\ speeds.push(\`\${fan}: \${fanSpeed} RPM\`);\n\
speeds.push(\`Fan \${fanNumber}: \${fanSpeed} RPM\`);\n\
} catch(e) {\n\ } catch(e) {\n\
console.error(\`Error retrieving fan speed for \${fanKey} in \${parentKey}:\`, e); // Debug: Log specific error\n\ console.error(\`Error retrieving fan speed for \${fanKey} in \${parentKey}:\`, e); // Debug: Log specific error\n\
}\n\ }\n\