CyberPower PowerPanel UPS Integration Script

All kinds of 'OS' scripts
Post Reply
ben53252642
Posts: 381
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 1596 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 1596 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:PASSWORD@192.168.0.5/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:PASSWORD@192.168.0.5/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:PASSWORD@192.168.0.5/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.

jendrush
Posts: 19
Joined: Wednesday 21 May 2014 20:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by jendrush » Monday 18 December 2017 21:40

Hi. Are you using CyberPower's PowerPanel on Raspberry Pi? If answer is yes, how did you manage to install, and run this?

ben53252642
Posts: 381
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by ben53252642 » Tuesday 19 December 2017 5:19

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.

jendrush
Posts: 19
Joined: Wednesday 21 May 2014 20:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by jendrush » Tuesday 19 December 2017 8:51

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?

Logread
Posts: 178
Joined: Sunday 28 August 2016 7:48
Target OS: Raspberry Pi
Domoticz version:
Location: France
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by Logread » Tuesday 19 December 2017 9:07

ben53252642 wrote:
Tuesday 19 December 2017 5: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

jendrush
Posts: 19
Joined: Wednesday 21 May 2014 20:39
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by jendrush » Tuesday 19 December 2017 9:21

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?

ben53252642
Posts: 381
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: CyberPower PowerPanel UPS Integration Script

Post by ben53252642 » Friday 29 December 2017 19:56

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest