Problem to get data from apcupsd

I haven openhab 3.4.0 on a windows 10 machine. I am trying to get information from apcupsd. It’s an ups where the information is send to the computer through an USB cable.
As far as I can see there is no binding for that.

The deamon is running. The data are also available in a tekst file.

Can anyone tell me how to get the data from the deamon (apcupsd@:3551 does not work)? Or how I can read the data from the tekst file in to an item or so?

This one doesn’t work?

Unfortunaly not, that means: I can’t get it working. It seems to require a network ups. Mine is not a network one, but connected via usb.

1 Like

I would love to help as I have an old APC BACK-UPS ES 700 lying around that I have always wanted to integrate with openHAB. The first thing I need to do is find the RJ45 USB cable … :slight_smile:

Please identify your UPS (manufacturer, model no.) and describe your setup in more detail.

In the meantime, the following way might be possible (but quite complex and probably overkill):
UPS <-> apcupsd <-> apcups-mqtt <-> MQTT Broker <-> MQTT Binding <-> openHAB

Edit:
Cable found - it’s really amazing how many cables I own … :astonished:

Edit #2:
apcupsd is up and running on my Windows 10 machine. apcupsd comes with apcaccess:


C:\apcupsd\bin>apcaccess
APC      : 001,034,0841
DATE     : 2022-12-27 20:18:25 +0100
HOSTNAME : DESKTOP-UQDUKRR
VERSION  : 3.14.14 (31 May 2016) mingw
UPSNAME  : ES700
CABLE    : USB Cable
DRIVER   : USB UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2022-12-27 20:07:37 +0100
MODEL    : Back-UPS ES 700G
STATUS   : ONLINE
LINEV    : 230.0 Volts
LOADPCT  : 0.0 Percent
BCHARGE  : 100.0 Percent
TIMELEFT : 43.8 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
SENSE    : Medium
LOTRANS  : 180.0 Volts
HITRANS  : 266.0 Volts
ALARMDEL : 30 Seconds
BATTV    : 13.6 Volts
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000008
SERIALNO : 5BXXXXXXXXX
BATTDATE : 2011-05-18
NOMINV   : 230 Volts
NOMBATTV : 12.0 Volts
FIRMWARE : 871.O2 .I USB FW:O2
END APC  : 2022-12-27 20:18:48 +0100

Edit #3:
Use the Exec Binding to transfer a specific parameter into an openHAB Thing:
Exec Command:
apcaccess -p TIMELEFT
Drawback: only one parameter per Exec Thing (limitation of the Exec Binding).
Going NUTs seems to be the better way.

It requires you to run the NUT server so that data can be sent over your network.

Found a solution: exec binding and a thing with command:
c:\progra~1\apcupsd\bin\apcaccess status

did the trick!

Just for reference the main steps for the ‘UPS - apcuspd (Win) - NUT (Win) - NUT Binding (openHABian) - openHAB (openHABian)’ way:

Installation of NUT/Windows:

  • Install NUT, but do not install a driver (we’ll use apcupsd which comes with its own driver).
  • Adjust etc\nut.conf:
MODE=netserver
  • Adjust etc\ups.conf:
[apcupsd]
            driver = apcupsd-ups
            port = localhost
            desc = "apcupsd client"
  • Adjust etc\upsd.conf:

LISTEN 127.0.0.1 3493
  • Adjust etc\upsd.users:
[admin]
	    password = topsecret
	    actions = SET
	    instcmds = ALL
	    upsmon master
  • Restart Network UPS Tools Service.

  • Install Network UPS Tools Binding.

  • Create Thing: Add Manually: Network UPS Tool

  • Result:

**COMMUNICATION_ERROR** 
java.net.ConnectException: Connection refused (Connection refused)

Probably some Windows firewall problems:

openhabian@openhabian:~ $ nmap -p3493 192.168.1.178
Starting Nmap 7.80 ( https://nmap.org ) at 2022-12-28 00:13 CET
Nmap scan report for DESKTOP-XXXXXXX (192.168.1.178)
Host is up (0.0027s latency).

PORT     STATE  SERVICE
3493/tcp closed nut

Nmap done: 1 IP address (1 host up) scanned in 0.17 seconds

Edit:
Unfortunately, the driver apcupsd-ups is missing from the Windows binaries. So it looks like it is not possible to use apcupsd and NUT (standalone, netserver modes) in parallel on a Windows machine.