mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-26 14:01:16 -07:00
Enhancement: support custom labels for cpu temp sensors (#6595)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
This commit is contained in:
@@ -11,12 +11,16 @@ import Resource from "../widget/resource";
|
||||
import Resources from "../widget/resources";
|
||||
import WidgetLabel from "../widget/widget_label";
|
||||
|
||||
const cpuSensorLabels = ["cpu_thermal", "Core", "Tctl", "Temperature"];
|
||||
const defaultCpuSensorLabels = ["cpu_thermal", "Core", "Tctl", "Temperature"];
|
||||
|
||||
function convertToFahrenheit(t) {
|
||||
return (t * 9) / 5 + 32;
|
||||
}
|
||||
|
||||
function getCpuSensorLabels(options) {
|
||||
return [...defaultCpuSensorLabels, options.cpuSensorLabel].filter(Boolean);
|
||||
}
|
||||
|
||||
export default function Widget({ options }) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const { settings } = useContext(SettingsContext);
|
||||
@@ -56,6 +60,7 @@ export default function Widget({ options }) {
|
||||
const unit = options.units === "imperial" ? "fahrenheit" : "celsius";
|
||||
let mainTemp = 0;
|
||||
let maxTemp = 80;
|
||||
const cpuSensorLabels = getCpuSensorLabels(options);
|
||||
const cpuSensors = data.sensors?.filter(
|
||||
(s) => cpuSensorLabels.some((label) => s.label.startsWith(label)) && s.type === "temperature_core",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user