Page 1 of 1

CyberPower PowerPanel UPS Integration Script

Posted: Saturday 21 January 2017 23:19
by ben53252642
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 4711 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 4711 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.

Re: CyberPower PowerPanel UPS Integration Script

Posted: Monday 18 December 2017 20:40
by jendrush
Hi. Are you using CyberPower's PowerPanel on Raspberry Pi? If answer is yes, how did you manage to install, and run this?

Re: CyberPower PowerPanel UPS Integration Script

Posted: Tuesday 19 December 2017 4:19
by ben53252642
I spent about 10 hours trying to get PowerPanel on raspberry pi, the issue being that CyberPower don't have an ARM compatible version available for download.

I was able to adapt the above script to work with:

http://networkupstools.org/

Only thing I couldn't get via NUT was the current watts reading.

It is possible to get an approx watts reading by calculating the math via the "load" percentage based on the capacity of the UPS however my experience was that the PowerPanel software running on x86 / x64 gave me the best results as it did display the Watts.

Re: CyberPower PowerPanel UPS Integration Script

Posted: Tuesday 19 December 2017 7:51
by jendrush
I've noticed lack of ARM version... Have you tried maybe running this app in x86 emulator(i found information about emulators when i was searching way to make it run on RPi). Console app probably isn't power hungry so possibly it could work?

Re: CyberPower PowerPanel UPS Integration Script

Posted: Tuesday 19 December 2017 8:07
by Logread
ben53252642 wrote: Tuesday 19 December 2017 4:19 I was able to adapt the above script to work with: http://networkupstools.org/
Only thing I couldn't get via NUT was the current watts reading.
I do not know about the CyberPower ups, but if it runs a NUT server, you could also use the python plugin I wrote. No additional features, but simpler installation: https://www.domoticz.com/forum/viewtopi ... 65&t=18154

Re: CyberPower PowerPanel UPS Integration Script

Posted: Tuesday 19 December 2017 8:21
by jendrush
Thank you @Logread for this information, this is indeed nice script. The problem with CyberPower UPS is that by NUT it is not displaying ups.realpower, only ups.realpower.nominal which is just constant infomation related to model. Other problem with NUTs PowerPanel driver is that the values are not given explicitly(people from NUT giving this information). So part od data are displayed not correctly. For example on my CyberPower CP900EPFCLCD input voltage looks good, but voltage output is totally not right( input ~230V, output ~260V). Original PowerPanel probably just have right parameters to calculate all values right.

PS - @ben53252642 Do you know how to configure CyberPower parameters through NUT?

Re: CyberPower PowerPanel UPS Integration Script

Posted: Friday 29 December 2017 18:56
by ben53252642
I attempted to run it via Exagear emulation on the Pi, the software ran but I was unable to get it to detect the CyberPower USB device.

Best current solution if you need to see watts is to use something like a NUC to run PowerPanel on x86.