CyberPower PowerPanel UPS Integration Script

All kinds of 'OS' scripts
Post Reply
ben53252642
Posts: 240
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

CyberPower PowerPanel UPS Integration Script

Post by ben53252642 » Sunday 22 January 2017 0:19

Linux script for getting data from CyberPower PowerPanel software into Domoticz:
Screen Shot 2017-01-22 at 9.15.43 am.png
Screen Shot 2017-01-22 at 9.15.43 am.png (96.82 KiB) Viewed 599 times
Screen Shot 2017-01-22 at 9.15.50 am.png
Screen Shot 2017-01-22 at 9.15.50 am.png (75.77 KiB) Viewed 599 times
startup.sh script I use for looping the main script in the background:

Code: Select all

# Start upsmonitor
/usr/bin/screen -S upsmonitor -d -m /root/ups/updatedomoticz.sh
updatedomoticz.sh script that gets the data from PowerPanel and loads it into Domoticz.

Code: Select all

#!/bin/bash
while true; do
# Check if UPS is connected
state=$(/usr/sbin/pwrstat -status | grep 'State' | awk '{print $2}')
if [ "$state" != "Lost" ]; then
# Mains Voltage
mainsvoltage=$(/usr/sbin/pwrstat -status | grep 'Utility Voltage' | awk '{print $3}')
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=316&svalue=${mainsvoltage}"
# Load in Watts
loadwatts=$(/usr/sbin/pwrstat -status | grep 'Load' | awk '{print $2}')
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=318&svalue=${loadwatts}"
# Remaining Runtime
remainingruntime=$(/usr/sbin/pwrstat -status | grep 'Remaining Runtime' | awk '{print $3}')
curl -s "http://USERNAME:[email protected]/json.htm?type=command&param=udevice&idx=319&svalue=${remainingruntime}"
else
echo "Communication with UPS lost, attempting reconnection..."
service pwrstatd stop
service pwrstatd start
fi
sleep 10
done
Remember to set your custom sensor idx values to the ones you have setup in Domoticz.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest