diff --git a/ts/systemd.ts b/ts/systemd.ts index 312791e..9c2b3c3 100644 --- a/ts/systemd.ts +++ b/ts/systemd.ts @@ -330,7 +330,16 @@ WantedBy=multi-user.target // Display battery with color coding const batteryColor = getBatteryColor(status.batteryCapacity); - const batterySymbol = status.batteryCapacity >= ups.thresholds.battery ? symbols.success : symbols.warning; + + // Get threshold from actions (if any action has thresholds defined) + const actionWithThresholds = ups.actions?.find((action: any) => action.thresholds); + const batteryThreshold = actionWithThresholds?.thresholds?.battery; + const batterySymbol = batteryThreshold !== undefined && status.batteryCapacity >= batteryThreshold + ? symbols.success + : batteryThreshold !== undefined + ? symbols.warning + : ''; + logger.log(` Battery: ${batteryColor(status.batteryCapacity + '%')} ${batterySymbol} Runtime: ${getRuntimeColor(status.batteryRuntime)(status.batteryRuntime + ' min')}`); // Display host info