This commit is contained in:
Brandon McFarlin 2024-12-13 11:49:44 -05:00
parent 8c64b3f28a
commit fb7ee84934
3 changed files with 65 additions and 29 deletions

View File

@ -0,0 +1,17 @@
---
title: PeaNUT
description: PeaNUT Information Widget Configuration
---
_(Find the PeaNUT service widget [here](../services/peanut.md))_
The PeaNUT widget allows you to monitor your UPS device and is designed to match the `resources` info widget. You can have multiple instances by adding another configuration block.
```yaml
- peanut:
url: http://peanut.host.or.ip:port # the URL of the PeaNUT server
key: nameofyourups # the name of the device
refresh: 3000 # optional, in ms
label: My UPS # optional
expanded: false # show the expanded view
```

View File

@ -552,7 +552,9 @@
"ups_status": "UPS Status",
"online": "Online",
"on_battery": "On Battery",
"low_battery": "Low Battery"
"low_battery": "Low Battery",
"load": "Load",
"battery": "Battery"
},
"nextdns": {
"wait": "Please Wait",

View File

@ -4,6 +4,8 @@ import { useTranslation } from "next-i18next";
import Error from "../widget/error";
import Resource from "../widget/resource";
import Raw from "../widget/raw";
import Container from "../widget/container";
export default function Widget({ options }) {
const { t } = useTranslation();
@ -24,37 +26,52 @@ export default function Widget({ options }) {
if (!data) {
return (
<Resource
icon={FaCarBattery}
value="-"
label="Load"
expandedValue="-"
expandedLabel="Battery"
expanded={expanded}
percentage="0"
/>
<Container options={options}>
<Raw>
<div>
<Resource
icon={FaCarBattery}
value="-"
label={t("peanut.load")}
expandedValue="-"
expandedLabel={t("peanut.battery")}
expanded={expanded}
percentage="0"
/>
</div>
</Raw>
</Container>
);
}
return (
<Resource
icon={FaCarBattery}
value={t("common.number", {
value: data['ups.load'],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
label="Load"
expandedValue={t("common.number", {
value: data['battery.charge'],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
expandedLabel="Battery"
percentage={data['ups.load']}
expanded={expanded}
/>
<Container options={options}>
<Raw>
<div>
<Resource
icon={FaCarBattery}
value={t("common.number", {
value: data['ups.load'],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
label={t("peanut.load")}
expandedValue={t("common.number", {
value: data['battery.charge'],
style: "unit",
unit: "percent",
maximumFractionDigits: 0,
})}
expandedLabel={t("peanut.battery")}
percentage={data['ups.load']}
expanded={expanded}
/>
</div>
{options.label && (
<div className="ml-6 pt-1 text-center text-theme-800 dark:text-theme-200 text-xs">{options.label}</div>
)}
</Raw>
</Container>
);
}