How to connect your APC UPS to Rpi and Home Assistant using apcupsd!

@akajester FINAL UPDATE(see below)…First let me say how fantastic your post is…never would have even tried this without this detailed how to! Nice work!
Anyway…I have my Rpi 3 b+ up and running with Raspbian and after following your proceedure I have come to a halt at the point of:

The output included the below:

Unpacking apcupsd-doc (3.14.14-2) ...
Selecting previously unselected package s-nail.
Preparing to unpack .../s-nail_14.9.11-2_armhf.deb ...
Unpacking s-nail (14.9.11-2) ...
Setting up apcupsd (3.14.14-2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/apcupsd.service → /lib/systemd/system/apcupsd.service.
Setting up s-nail (14.9.11-2) ...
Setting up apcupsd-doc (3.14.14-2) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for systemd (241-7~deb10u1+rpi1) ...
pi@raspberrypi:~ $ lsusb
Bus 001 Device 006: ID 0557:2008 ATEN International Co., Ltd UC-232A Serial Port [pl2303]
Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Just to confirm the pi is connected to my APC SmartUPS 3000XL via a RS232 (9 pin) serial cable (Part No: 940-0024) which is connected to a RS232 to USB serial adaptor. The output above seems to confirm that the RS232 to USB serial adaptor is detected by the pi but that the UPS is not communicating it seems? Could this be because the serial adaptor (although detected) does not have the necessary driver installed on the pi?

If that is likely how do I ensure the driver is installed? I am a reasonably new player on these but know enough to get up and running to this point. I have searched for answers but not sure I was able to come up with relavent search terms for this problem.

Out of interest I plugged in my FTDI that I use to flash my devices (with Tasmota etc) and the below output was observed after running “lsusb” command:

pi@raspberrypi:~ $ lsusb
Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC
Bus 001 Device 004: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

So it seems (the pi) does recognise the FTDI device also but does that also indicate the driver is in place as well? My guess is no?

To be clear…the FTDI was just plugged in to the pi USB and nothing else was connected to it.

New Update:
Look here for advice that works to setup the usb-serial device: https://www.raspberrypi.org/forums/viewtopic.php?t=146215

[91774.230653] usb 1-1.3: New USB device found, idVendor=0557, idProduct=2008, bcdDevice= 3.00
[91774.230670] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[91774.230679] usb 1-1.3: Product: USB-Serial Controller D
[91774.230689] usb 1-1.3: Manufacturer: Prolific Technology Inc. 
[91774.233044] pl2303 1-1.3:1.0: pl2303 converter detected
[91774.240321] usb 1-1.3: pl2303 converter now attached to ttyUSB0

It seems USB now attached to ttyUSB0.

So I moved on to try to setup the config files but I may be on the wrong track and got loads of errors after editing the config files to use a smart cable.

So…I set the config all back to default and tried the command “sudo apcaccess”

pi@raspberrypi:~ $ sudo apcaccess
APC      : 001,017,0426
DATE     : 2019-11-19 16:50:40 +1000  
HOSTNAME : raspberrypi
VERSION  : 3.14.14 (31 May 2016) debian
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2019-11-19 16:50:13 +1000  
STATUS   : COMMLOST 
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000100
END APC  : 2019-11-19 16:50:40 +1000

It seems from the above I have the USB Driver setup and now the software is looking through the USB serial device and knows its not connected??? Maybe?

So anyone have an idea how I should configure this?
I am leaning towards it being configured as a USB cable as it is using the RS232 (9 pin) serial cable (Part No: 940-0024) which is connected to a RS232 to USB serial adaptor? In essence its a USB connected UPS right?

Does that sound feasible?

I’ll have a crack at that and report back if I make any progress.

FINAL UPDATE Well it can be done but the documentation is scattered for the full answer I believe.

First Source: APCUPSD User Manual

Also: [SOLVED] UPS setup on USB port/stty and via AP9716 Network Card ? - General Support - Unraid

Plus read the reply to that post which is just below it in the forum.

If you don’t want to buy a cable build it from this design: APCUPSD User Manual

To ensure your USB to serial converter is setup look here: https://www.raspberrypi.org/forums/viewtopic.php?t=146215

And for the full configuration advice: APCUPSD User Manual and then refer to the initial fantastic post above for bringing it all together!

My output is:

APC : 001,051,1144
DATE : 2019-11-20 17:13:14 +1000
HOSTNAME : raspberrypi
VERSION : 3.14.14 (31 May 2016) debian
UPSNAME : WellsUps
CABLE : Custom Cable Smart
DRIVER : APC Smart UPS (any)
UPSMODE : Stand Alone
STARTTIME: 2019-11-20 16:57:43 +1000
MODEL : SMART-UPS 3000 RM XL
STATUS : ONLINE
LINEV : 243.1 Volts
LOADPCT : 5.2 Percent
BCHARGE : 100.0 Percent
TIMELEFT : 116.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
MAXLINEV : 245.7 Volts
MINLINEV : 240.5 Volts
OUTPUTV : 243.1 Volts
SENSE : High
DWAKE : 0 Seconds
DSHUTD : 20 Seconds
DLOWBATT : 2 Minutes
LOTRANS : 196.0 Volts
HITRANS : 253.0 Volts
RETPCT : 0.0 Percent
ITEMP : 34.2 C
ALARMDEL : 5 Seconds
BATTV : 55.0 Volts
LINEFREQ : 50.0 Hz
LASTXFER : Low line voltage
NUMXFERS : 0
TONBATT : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
SELFTEST : NO
STESTI : 336
STATFLAG : 0x05000008
DIPSW : 0x00
REG1 : 0x00
REG2 : 0x00
REG3 : 0x00
MANDATE : 09/24/05
SERIALNO : QS0539320307
BATTDATE : 09/24/05
NOMOUTV : 230 Volts
NOMBATTV : 48.0 Volts
EXTBATTS : 0
FIRMWARE : 93.14.I
END APC : 2019-11-20 17:13:51 +1000

Cheers to everyone here for being part of this wonderful community!

3 Likes

Quick question to anyone using APCUPSD, like someone before me commented, it is working great for 1 UPS. However i need to use Home Assistant to monitor multiple UPS.I have purchased 5 raspberry pi zeros, loaded them up with APCUPSD and they are all reporting data. The issue is - how do i get multiple instances in to Home Assistant?

References same question by @ittchmh earleir in this thread

Thanks for your help

This thread, which comes up first in searches, mentions multiple times a repo (https://github.com/colindunn/hassio-addons) which does not seem to exist anymore.
however, docs mention this other repo: https://github.com/korylprince/hassio-apcupsd/
What should I use?

When I switched to HassIO I moved to using this; https://github.com/korylprince/hassio-apcupsd/tree/master/apcupsd

2 Likes

Hi,
first of all: THANK YOU ALL for the great work and the detailed guide how to get this working.

Everything is running fine. I just noticed one minor/major problem in my setup: When ever I cut the grid power to my USV and the USV jumps to battery power the apcusvd on my RB3 goes to status “COMMLOST”. This status also gets reported to Home Assistant together with missing battery level and runtime information.

My setup: USV -> USB -> RB3 -> LAN -> HASS Server. As the problem already becomes visible on the RB3 with apcaccess, I don’t think its an issue with the ip connection between RB3 and HASS.

Anyone experiencing the same problem?

Thanks! :grinning:

APC      : 001,023,0574
DATE     : 2020-02-15 16:45:38 +0000  
HOSTNAME : raspberrypi
VERSION  : 3.14.14 (31 May 2016) debian
UPSNAME  : BACKUPSCS350
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2020-02-15 16:32:09 +0000  
MODEL    : Back-UPS 350 
STATUS   : ONLINE 
BCHARGE  : 94.0 Percent
TIMELEFT : 43.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000008
SERIALNO : BB03160BLABLABLA
FIRMWARE : 5.4.I USB FW: c1 
END APC  : 2020-02-15 16:46:30 +0000  

Log from apcaccess with online power.

Hi Guys I have a APCUPS wich has no internet connection, I am able to see the device informations trhough the USB cable plugged on my desktop running its localhost.

Is this one possible to integrate with HA?
The model is this one:
image

Sure. I’m using Hassio now and they have an addon for it called “APC UPS Daemon” which works perfectly.

where did you get that add on? the first one listed above is gone, and the other one won’t work as the addon store. keeps failing to add.

if you have a link to the new “APC UPS daemon” addon please let me know.

The main point is that my APC does not have internet cable to plug on it.
So I cant connect it to the network, I tried hassio APC UPS Daemon USB addon but also no success…

Here’s the install instructions that I followed and had success with. https://github.com/korylprince/hassio-apcupsd/

I connected my ups directly to the raspberry pi using the usb cable that came with it.

This worked perfectly for me.

Sorry to post on such an old topic but is it possible to connect a XS 1400u to HASS via Rpi or anything else?

it doesnt have a serial port or rj45 for data, only powerchute port to their software and the standard in and out of modem.

Here is the back of the UPS

Thank you in advance,
dRage

Hi, I migrated to NUT :slight_smile:
Both UPS’s connected to Rpi3B via USB

Use NUT plugin and USB connection it will work

You need a USB data cable. If you want to make it, then need an RJ50 (10pin) plug, RJ50 crimping tool and a simple usb A data cable. You can find pinouts on the web. I made 3 for myself. I have back ups CS500, CS350 and RS800. The CS500 is dumber than the other two because only its status is visible. Neither the voltage values nor other data are visible.

1 Like

I have connected the APC UPS to power chute to a PC which had installed VM and HA. It was visible in HA but then i switched to Rpi4 and connected the APC UPS to Rpi4 with USB cable. The Rpi4 with HA installed is not seeing APC UPS. Any idea how to proceed?

Despite hours of searches and several attempts, I cannot configure apcupsd to manage my UPS.

This is my UPS:

My configuration:

  1. Raspberry Pi 4, 5.10.63-v7l+
  2. Serial to USB Cable, correctly configured:
Bus 001 Device 003: ID 067b:23c3 Prolific Technology, Inc. USB-Serial Controller
  1. The port is configured correctly:
pi@raspberrypi:~ $ ls -ltra /dev/serial/by-id
total 0
drwxr-xr-x 4 root root 80 Dec 29 23:05 ..
drwxr-xr-x 2 root root 60 Dec 29 23:05 .
lrwxrwxrwx 1 root root 13 Dec 29 23:05 usb-Prolific_Technology_Inc._USB-Serial_Controller_BRA_h10CD20-if00-port0 -> ../../ttyUSB0
  1. I tried every possible configuration in the apcupsd.conf file. The furthest I went in terms of results from testing was with the following:
UPSCABLE simple
UPSTYPE dumb
DEVICE /dev/ttyUSB0

But even then, the every option under apctest fails: Illegal response.

I followed these guides:

I tried with NUT, it is twice as complicate compared to apcupsd and I gave up.

Try setting DEVICE to nothing (auto detect).

DEVICE

Once you’ve restarted apcupsd try running another “sudo apcaccess” and see if that returns any data.

1 Like