Announcement

Collapse
No announcement yet.

CyberPower UPS - issuing external commands

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CyberPower UPS - issuing external commands

    I've had a CyberPower UPS protecting various systems in my rack for years now, but it wasn't until I recently bought a new NAS that I began digging more intently on how to integrate with it beyond letting the Power Panel software manage shutdown of systems. This was largely because the NAS had no native apps for the UPS, short of plugging a UPS directly into the NAS via USB - which wasn't a great option as it would mean reconfiguring my current setup. Rather, I just wanted to find a better way to capture events over the network from the UPS. Consequently, this would also provide a way to integrate the UPS with HomeSeer and create a virtual device for the UPS along with states.

    I first went down the path of SNMP. The UPS does, today, send SNMP trap information to my Dell OpenManage environment, but the events are not well constructed and HomeSeer seems to lack a reliable way to capture SNMP. I fiddled with a plug-in - maybe with some more time it would have worked well.

    However, I discovered a pretty simple solution in the CyberPower agent software. There's a built-in capability to trigger external commands (batch files) upon events. In the agent software, you'll find a directory where a "default.cmd" file is stored and gives some basic framework for structuring commands.

    So, first experimenting with the NAS, I created a script to open a secure shell (used Plink but any other command line SSH will also do) with the NAS and issue a poweroff command once the UPS reached limited power remaining and was otherwise initiating shutdown commands to its own Power Panel software. The next step (haven't done yet) is scripting a quick curl request to the HomeSeer API to otherwise set the power state on a virtual device when power is lost. I have another thread posted on the forum, however, regarding passing authentication information to the HomeSeer API - right now it doesn't appear to be working!

    For reference, below is a picture of where to set the external command file on the Power Panel agent software. If you take note of event 11, you'll see "default" listed under the Command / File column. Clicking the event will give you the option (dropdown) to select any *.cmd file in the Power Panel external commands directory. In this case, I just edited the default file with my necessary commands and wanted it executed when the UPS would otherwise initiate shutdown. Elsewhere, I have the UPS configured to initiate shutdown with 5 minutes runtime remaining.

    In any case, I hope some of this information helps anyone who may have a CyberPower UPS and looking for a way to trigger events, whether to HomeSeer or any other device, upon power state change. As I said, SNMP may be an option, but it was taking more effort than I liked to get the trap information into HS.


    Click image for larger version

Name:	PowerPanel Events.png
Views:	278
Size:	167.5 KB
ID:	1511004
Working...
X