mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-24 06:48:00 +01:00
#707 add UPS status info
This commit is contained in:
parent
a0540ea1b9
commit
1de1693f69
1 changed files with 34 additions and 0 deletions
|
@ -7,6 +7,7 @@ source /mnt/hdd/raspiblitz.conf
|
|||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "Configure a UPS (Uninterruptible Power Supply)"
|
||||
echo "blitz.ups.sh on apcusb"
|
||||
echo "blitz.ups.sh status"
|
||||
echo "blitz.ups.sh off"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -58,6 +59,39 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
|||
|
||||
fi
|
||||
|
||||
###################
|
||||
# STATUS
|
||||
###################
|
||||
|
||||
if [ "$1" = "status" ]; then
|
||||
|
||||
# check if already activated
|
||||
if [ ${#ups} -eq 0 ]; then
|
||||
echo "upsStatus='OFF'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${ups}" = "apcusb" ]; then
|
||||
status=$(apcaccess -p STATUS)
|
||||
if [ ${#status} -eq 0 ]; then
|
||||
echo "upsStatus='n/a'"
|
||||
else
|
||||
# get battery level if possible
|
||||
if [ "${status}" = "ONLINE" ] || [ "${status}" = "ONLINE" ]; then
|
||||
status=$(apcaccess -p BCHARGE | cut -d "." -f1)
|
||||
echo "upsStatus='${status}%'"
|
||||
else
|
||||
echo "upsStatus='${status}'"
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo "upsStatus='CONFIG'"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
###################
|
||||
# SWITCH OFF
|
||||
###################
|
||||
|
|
Loading…
Add table
Reference in a new issue