diff --git a/docs/widgets/info/resources.md b/docs/widgets/info/resources.md
index b4f85d695..8281cec0a 100644
--- a/docs/widgets/info/resources.md
+++ b/docs/widgets/info/resources.md
@@ -19,6 +19,8 @@ _Note: unfortunately, the package used for getting CPU temp ([systeminformation]
memory: true
disk: /disk/mount/path
cputemp: true
+ tempmin: 0 # optional, minimum cpu temp
+ tempmax: 100 # optional, maximum cpu temp
uptime: true
units: imperial # only used by cpu temp
refresh: 3000 # optional, in ms
diff --git a/src/components/widgets/resources/cputemp.jsx b/src/components/widgets/resources/cputemp.jsx
index 96f980963..ef994c658 100644
--- a/src/components/widgets/resources/cputemp.jsx
+++ b/src/components/widgets/resources/cputemp.jsx
@@ -9,7 +9,7 @@ function convertToFahrenheit(t) {
return (t * 9) / 5 + 32;
}
-export default function CpuTemp({ expanded, units, refresh = 1500 }) {
+export default function CpuTemp({ expanded, units, refresh = 1500, tempmin = 0, tempmax = -1 }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/widgets/resources?type=cputemp`, {
@@ -39,7 +39,12 @@ export default function CpuTemp({ expanded, units, refresh = 1500 }) {
}
const unit = units === "imperial" ? "fahrenheit" : "celsius";
mainTemp = unit === "celsius" ? mainTemp : convertToFahrenheit(mainTemp);
- const maxTemp = unit === "celsius" ? data.cputemp.max : convertToFahrenheit(data.cputemp.max);
+
+ const minTemp = tempmin < mainTemp ? tempmin : mainTemp;
+ let maxTemp = tempmax;
+ if (maxTemp < minTemp) {
+ maxTemp = unit === "celsius" ? data.cputemp.max : convertToFahrenheit(data.cputemp.max);
+ }
return (
);
diff --git a/src/components/widgets/resources/resources.jsx b/src/components/widgets/resources/resources.jsx
index e2f2bfb80..634e0ff53 100644
--- a/src/components/widgets/resources/resources.jsx
+++ b/src/components/widgets/resources/resources.jsx
@@ -8,7 +8,7 @@ import CpuTemp from "./cputemp";
import Uptime from "./uptime";
export default function Resources({ options }) {
- const { expanded, units, diskUnits } = options;
+ const { expanded, units, diskUnits, tempmin, tempmax } = options;
let { refresh } = options;
if (!refresh) refresh = 1500;
refresh = Math.max(refresh, 1000);
@@ -23,7 +23,9 @@ export default function Resources({ options }) {
))
: options.disk && }
- {options.cputemp && }
+ {options.cputemp && (
+
+ )}
{options.uptime && }
{options.label && (