Monitor CyberPower UPS plugged into Windows Machine via USB

Hello,

I have 3 CyberPower UPS’s. One is plugged directly into my HA NUC, one is plugged into my UnRAID server and is shared to the network via NUT. Both of these I was able to get integrated into HA.

For the “local” UPS, I used this docker and a REST sensor to provide the API to obtain the battery stats:
https://hub.docker.com/r/dwinks/pwrstat_docker

For the UnRAID UPS, I used the default nut sensor.

My 3rd CyberPower UPS is plugged in via USB to a Windows 10 box.

I cannot figure out a way to access the data from HomeAssistant. I tried to install WinNUT but can’t get past it failing because of LibUSB drivers.

I have the PowerPanel for Business software installed but also can’t find any sort of API to tap into.

Has anyone ever successfully exported CyberPower UPS data out of Windows and into HA?

The only tools I can find are limited to CyberPower for Linux.

Thanks

1 Like

Did you ever solve this? NUT for linux worked great for two of my UPS’s, but my windows machine not so much.

Trying to screen-scrape the PowerPanel doesn’t seem terribly fruitful without a defined API.

I’m thinking of devoting a rPi to just running NUT to make that UPS basically a network UPS. Seems a waste but maybe the path of least resistance.

Did you find a better approach?

Unfortunately, no, I never came up with a solution.

I was thinking along the lines of what you said about just running it off a Pi instead, but haven’t gotten around to it yet.

Of the 3 UPS’s that I have, the one on the Windows box isn’t mission-critical so it just hasn’t been a priority. It will at least shut itself down properly via the PowerPanel software.

Hi,
Had the same issue.
I found that the business software is on port 3052 and query-able.
I used a python script to login on the page http://x.x.x.x:3052/local/rest/v1/login/verify
I keep the cookie and I could query http://x.x.x.x:3052/local/rest/v1/ups/status and poll 13 variables. I then publish them in MQTT and gather them with HA.

You can try to login first on the web page with a browser and then check the /local/rest/v1/ups/status if you see the JSON vars. if yes, then the python script should work. I made a cron job on a linux server to serve the script.
Since my HA already have python and libraries, I execute the script “inside” the docker from my host.

docker exec -t ha_docker python /config/python_scripts/test.py

import requests
import paho.mqtt.client as paho
import json
url = "http://192.168.x.x:3052/local/rest/v1/login/verify"
url2 = "http://192.168.x.x:3052/local/rest/v1/ups/status"

payload = {"userName": "adminuser", "password": "adminpassword"}
headers = {'Content-Type': "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
# the json parameter should handle encoding for you
cookies = response.cookies

response = requests.request("GET", url2, cookies=cookies)
r_dictionary= response.json()

iv = r_dictionary['input']['voltages'][0]
ov = r_dictionary['output']['voltages'][0]
ol = r_dictionary['output']['loads'][0]
br = r_dictionary['battery']['remainingRunTimeInSecs']/60
brf = r_dictionary['battery']['remainingRunTimeFormated']
sys = r_dictionary['system']['stateText']
batt = r_dictionary['battery']['stateText']
cap = r_dictionary['battery']['capacity']
comm = r_dictionary['communicationAvaiable']
broker="192.168.x.x"
port=1883
client1= paho.Client("control1")                           #create client object
client1.connect(broker,port)                                 #establish connection
ret= client1.publish("ups1/iv",iv)
ret= client1.publish("ups1/ov",ov)
ret= client1.publish("ups1/ol",ol)
ret= client1.publish("ups1/br",br)
ret= client1.publish("ups1/sys",sys)
ret= client1.publish("ups1/comm",comm)
ret= client1.publish("ups1/brf",brf)
ret= client1.publish("ups1/cap",cap)
ret= client1.publish("ups1/batt",batt)

2 Likes

Wow, thanks a ton!

The status page works for me in the browser so I will for sure be giving this a go.

I think I may have a better solution, at least a more generally usable one.

The PowerPanel software version 4 (unlike 3) supports snmp queries, and HA supports SNMP as sensor definitions.

If you install it, you can configure and enable SNMP (it is disabled by default - expand the SNMP band at the top of the page). If you are using SNMP on the system to which the USB connected UPS is attached, then you can use a different port (I chose 1161 instead of 161).

Then configure the software as usual on the system, whatever you want it to do; irrelevant for HA.

On HA you define a sensor as:

  - platform: snmp
    host: 192.168.130.41    <<<< PC running Powerpanel 
    baseoid: .1.3.6.1.4.1.3808.1.1.1.4.2.3.0  <<< Get these from CPS's MIB
    community: somesecret        <<<<<<<<<<< defaults to public
    port: 1161    <<<<< Coordinate with what you put in powerpanel setup
    name: Office UPS Load Percentage
    value_template: '{{ (value | float) }}'
    unit_of_measurement: "%"

MIB definitions are here: https://www.cyberpowersystems.com/product/software/mib-v2-0/

If you can’t read MIB’s (it’s painful without automation), here are a few OID’s:

Input voltage: .1.3.6.1.4.1.3808.1.1.1.3.2.1.0
Output Voltage: .1.3.6.1.4.1.3808.1.1.1.4.2.1.0
Charge Remaining: .1.3.6.1.2.1.33.1.2.4.0
Time Remaining: .1.3.6.1.2.1.33.1.2.3.0

Here’s one I will list in full as I think it’s neat how you can translate:

  - platform: snmp
    host: 192.168.130.41
    baseoid: .1.3.6.1.4.1.3808.1.1.1.4.1.1.0
    community: secret
    port: 1161
    name: Office UPS Status
    value_template: >
      {% set vals = {'1': 'unknown', '2':'onLine', '3':'onBattery', '4':'onBoost', '5':'sleep', '6':'off', '7':'rebooting'} %}
      {{vals[value]}}

I like this approach as it should be system neutral and require nothing be installed on the remote systems except the powerpanel software.

Postscript: I am finding the reported load percentage does not match the dashboard, checking, will update. I’ve opened a ticket with Cyberpower.

Postscript 2: If you have a firewall on the PC running powerpanel don’t forget to open up udp connections to the port you use or you will get no response; you can test by turning off the firewall for a bit. Powerpanel does not apparently take care of it.

1 Like

Oh man, this is awesome. Thanks again!

Looks like I’m on v4.3.0 so this should work.

I’ll update the thread once I get it going.

I tried installing powerpanel on a rPi, but they do not have a version compatible, so I installed NUT there. Not is pretty easy to get working (it’s in the distro for the rPi ubuntu I’m running):

  - platform: nut
    host: 192.168.132.100
    port: 3493
    alias: netups
    name: netups
    resources: 
      - ups.load
      - battery.runtime
      - battery.charge
      - ups.status.display

It’s a little less wordy than SNMP since each sensor takes just one line per host, rather than half a dozen or so. But I could not get NUT running on windows 10, issues with missing dll’s notably for SSL and usb drivers.

SNMP seems to be working well. I like that solution because it doesn’t require any additional software or device, however clunky the SNMP / OID syntax is.

The only issue I have right now is that the OID for “load (percentage)” doesn’t seem to be giving me the right data.

.1.3.6.1.4.1.3808.1.1.1.4.2.3.0

I checked multiple sources that say that is correct, even downloaded the MIB from CyberPower and opened it with iReasoning’s MIB browser… and it says that is correct.

But, the value in home assistant doesn’t change. It just says 24. I can ramp up the video card in the machine plugged into it and watch the time remaining change, but the load stays at 24.

When I look at the actual power panel dashboard, the load changes. 24.0 V also happens to be the output voltage, so I’m wondering if somehow the OIDs are crossed.

All 3 UPS’s are CP1500PFCLCD, and both the pwrstat and NUT methods report the correct load.

So, still troubleshooting that one, but the rest of the sensors are working great!

I have the same issue. I opened a ticket at Cyberpower, but they said I needed to call, and I keep getting distracted and never have. Though it looks like they are open, I’m going to call now. You might open a ticket with the above information also (and don’t mention me)…two people complaining makes it more real. :grinning:

Well… the initial response I got is “that should not work”, “the chipset doesn’t support it”, followed by “you shouldn’t be using the business version on that UPS as it’s a consumer UPS”.

After a lot of discussion Todd promised to send off my comment “to the product management group who can forward it to Engineering”. So, it might make it, might not.

In all seriousness, anyone who wants this might also want to call them, give a prod so they do not think it was an oddball request.

Incidentally, @iankaufmann, you appear right on the voltage. I did not notice that, but it’s an integer version of the battery voltage on mine also. There’s a table somewhere that’s just… wrong.

Very interesting! Glad it wasn’t just me doing it wrong.

I just sent in a support ticket as well. I’m sure I’ll get the same response. I guess I didn’t realize the business version of the software was forbidden for us consumers. It works a lot better than their other app, at least on Windows. I was using it before even trying to do this.

Thanks for calling them up, and for all of your input here!

@Linwood, thanks for pointing out the SNMP in PowerPanel. I’ve been looking for an API to access the status data. The latest version of PowerPanel Business | Windows that I can find to download from CyberPower is version 3.4.
It does have SNMP settings, which I enabled. I thought maybe you meant it was added between version 3.3 and 3.4. In any case I have not been able to make it work.

I downloaded Paessler SNMP Tester and run it on the same Windows 2008r2 server as PowerPanel. In the PowerPanel agent running at localhost:3052, SNMP settings are under Security / Authentication. I set the Agent port to 1161, clicked Allow Access in SNMPv1 Service, set community to public, and entered the host IP of the system.

From the test program, I entered Local IP: Any, Device IP: localhost, Port 1161, SNMPv1, community public. I selected custom OID with yours for input voltage: .1.3.6.1.4.1.3808.1.1.1.3.2.1.0.
I get these results:

----------------------- New Test -----------------------
Paessler SNMP Tester - 20.1.58 Computername: SUN Interface: (192.168.2.1)
4/4/2020 5:44:37 PM (1 ms) : Device: localhost
4/4/2020 5:44:37 PM (3 ms) : SNMP v1
4/4/2020 5:44:37 PM (6 ms) : Custom OID .1.3.6.1.4.1.3808.1.1.1.3.2.1.0
4/4/2020 5:44:39 PM (2009 ms) : SNMP Datatype: ASN_UNIVERSAL
4/4/2020 5:44:39 PM (2012 ms) : -------
4/4/2020 5:44:39 PM (2015 ms) : Value: No response (check: firewalls, routing, snmp settings of device, IPs, SNMP version, community, passwords etc) (SNMP error # -2003)
4/4/2020 5:44:39 PM (2018 ms) : Done

It seems really close, but I’m not sure if I’m just missing something on the setup, or if there is really a “Version 4” out there that I have not located.

I don’t know how I missed it, but I did find the software version 4.4. I uninstalled 3.4 and installed 4.4.

Oddly, none of the settings were retained, but I re-configured the SNMP again - SNMPv1 on local port 1161, public community assigned to the IP address of the machine.

Unfortunately, I still have the same results as above from the tester - No Response.

OK, to check a few things.

Settings, SNMNP, check V1 and put in a local port. 1161 sounds right.

Under SNMP V1 Profiles, put your community name in the first line, and access type read-only. I/P address can be 0.0.0.0 which means all. This is the address the request comes FROM.

The machine which has PowerPanel running needs to allow inbound access to 1161 if there’s some kind of firewall. If it’s windows just turn the firewall off to test first, you can turn it on and see what happens later.

If you can, try testing it from a utility like snmpwalk if you can, make sure it’s not something related to your tester. But assuming the tester is working…

I’m a bit confused by the “Device: Localhost”, is that saying it is trying to access your powerpanel as localhost? Try the device’s actual IP (though I have no reason to think localhost won’t work if both are on the same host, I never tried that).

Got it working. It was the community IP address. I thought it was the IP of the local interface to bind the service to. I now conclude it must actually be the network to allow connection from. So it could be used to limit access to a particular subnet: 192.168.99.0 for example.
When I changed public back to 0.0.0.0 it started to work immediately. Thanks!

Ah… I had that ambiguous in my post, though I left it all zeros which should always work. That makes sense and is consistent with other SNMP implementations. I’ll edit my post above.

Hi,

I’m in a very similar situation - I have a CyberPower CP1500EPFCLCD and I’m trying to get monitoring to work. The Personal PowerPanel is a bit lacking - no historical graphs for voltage etc.

Trying to do things one at a time - but while the Personal Edition can communicate with the UPS via USB, the login on the browser to the Business Local says “Connection has not been established.”

I’ve tried turning the firewall off and Uninstalling Personal Edition, as well as replugging the USB several times. No difference however.

Do I need to get the business version working, to activate SNMP, before I can start with making historical graphs of input voltage?

For a 2nd UPS, it’s simply connected to the router, and would like to get an email whenever that UPS needs to switch to battery. Is there a way to get it to send an email without being connected by USB to a PC? Thanks.

Yes, you need the business edition to work first. I don’t know why it is not, mine just came up working after installation.

For the UPS on a router, you could check and see if it has something called “NUT” available, which is a unix based piece of software that monitors UPS’ generally. It would NOT normally be on a router, but if you have something like openwrt or some expandable system, you may be able to put it there. Alternatively, the simplest thing (ok, not simple exactly) is to get a raspberry pi, install linux and nut, and monitor it from there. Home Assistant has the ability to monitor NUT monitors. But that’s not exactly a simple solution if you don’t know linux.

Thanks for the advice re: the routers. I am aware of opwnwrt and similar, but this would be for a set and forget stock system for non-techy people, so fiddly things like raspberry pi and flashing ROMswon’t be to their liking (warranty and so forth.) Guess I’ll have to forgo the email notification on the router then.

Mine is the CP1500EPFCLCD, which seems to be the non-US version of the same UPS discussed in the thread. Not sure if that makes a difference? But yes, would love to get the Business part working - I assume when it’s working, after logging in by browser everything is displayed etc. ?

And once it is, activate SNMP via the menu - anyone have a monitor already set up to graph voltage/power etc. time series? Thanks.

Edit: I might not need SNMP for my application - I just want to be able to record (and graph) voltage time series (and possibly power.) Doing this on the Windows PC that is attached via USB is fine, but the CyberPower Panel software doesn’t do this. Anyone know of a way I could achieve this? Thanks.