NUT with APC UPS

I have tried multiple times to get NUT working with my set up - need help.

I have a RPi4 running the latest HA install (not sure what to call it, but it’s the version for numpties like me…docker containers and everything). I have an APC Smart-UPS 1000 plugged into the RPi via USB cable.

I have installed the NUT Add-on and configured it. Here’s my config:

users:
  - username: username
    password: 'password'
    instcmds:
      - all
    actions: []
devices:
  - name: myups
    driver: apcsmart
    port: auto
    config: []
mode: netserver
shutdown_host: 'false'

and here’s the network piece:

Container	Host	     Description
3493/tcp	        null        Network UPS Tools

and here’s my sensor:

sensor:
  - platform: nut
    name: APC UPS
    host: a0d7b954-nut
    port: 3493
    username: Username
    password: password
    resources:
      - battery.charge
      - battery.runtime
      - ups.load
      - ups.status
      - input.voltage
      - ups.status.display

and here’s the log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] nut: applying... 
[fix-attrs.d] nut: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: Network UPS Tools
 Manage battery backup (UPS) devices
-----------------------------------------------------------
 Add-on version: 0.2.0
 You are running the latest version of this add-on.
 System: HassOS 4.11  (armv7 / raspberrypi4)
 Home Assistant Core: 0.112.3
 Home Assistant Supervisor: 228
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] nut.sh: executing... 
[18:19:09] INFO: Setting mode to netserver...
[18:19:10] INFO: Generating /etc/nut/upsd.users...
[18:19:10] INFO: Configuring user: Username
[18:19:11] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[18:19:12] INFO: Configuring Device named myups...
[18:19:12] INFO: Starting the UPS drivers...
Network UPS Tools - UPS driver controller 3.8.0-3396-gcdc7c4b5b1
Network UPS Tools - APC Smart protocol driver 3.1 (3.8.0-3396-gcdc7c4b5b1)
Fatal error: unusable configuration
APC command table version 3.1
Unable to open auto: No such file or directory
Things to try:
 - Check 'port=' in ups.conf
 - Check owner/permissions of all parts of path
Driver failed to start (exit status=1)
[cont-init.d] nut.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I am at a complete loss. Would very much appreciate any help anyone can render.
Thanks,
Phil

You haven’t set the outgoing (host) port in your addon configuration. It’s currently null. Change the null value to 3493.

Marc,
Thanks for that. I set the port to 3493, but still no joy.

Network UPS Tools - UPS driver controller 3.8.0-3396-gcdc7c4b5b1
Network UPS Tools - APC Smart protocol driver 3.1 (3.8.0-3396-gcdc7c4b5b1)
Fatal error: unusable configuration
APC command table version 3.1
Unable to open auto: No such file or directory
Things to try:
 - Check 'port=' in ups.conf
 - Check owner/permissions of all parts of path
Driver failed to start (exit status=1)
[cont-init.d] nut.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

Any other ideas?

According to the error message, the port is still not set.

I suppose it could maybe be that it can’t secure that port, maybe try a different one :man_shrugging:

I changed the driver to generic, and put in the vendor ID for APC. Now the log shows this:

[07:33:32] INFO: Setting mode to netserver...
[07:33:32] INFO: Generating /etc/nut/upsd.users...
[07:33:32] INFO: Configuring user: Thibodeaux
[07:33:34] INFO: Password is NOT in the Have I Been Pwned database! Nice!
[07:33:35] INFO: Configuring Device named myups...
[07:33:36] INFO: Starting the UPS drivers...
Network UPS Tools - UPS driver controller 3.8.0-3396-gcdc7c4b5b1
Network UPS Tools - Generic HID driver 0.41 (3.8.0-3396-gcdc7c4b5b1)
Using subdriver: APC HID 0.96
USB communication driver 0.33
[cont-init.d] nut.sh: exited 0.
[cont-init.d] nutclient.sh: executing... 
[cont-init.d] nutclient.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[07:33:36] INFO: Starting the UPS information server...
Network UPS Tools upsd 3.8.0-3396-gcdc7c4b5b1
   0.000000	fopen /var/run/nut/upsd.pid: No such file or directory
   0.000406	listening on 0.0.0.0 port 3493
   0.001621	Connected to UPS [myups]: usbhid-ups-myups
[07:33:37] INFO: Starting the UPS monitor and shutdown controller...
Network UPS Tools upsmon 3.8.0-3396-gcdc7c4b5b1
   0.000000	fopen /var/run/upsmon.pid: No such file or directory
   0.000832	Using power down flag file /etc/killpower
   0.001455	UPS: myups@localhost (master) (power value 1)
   0.001625	debug level is '1'
   0.001660	Warning: running as one big root process by request (upsmon -p)
   0.009584	Trying to connect to UPS [myups@localhost]
   0.529189	User [email protected] logged into UPS [myups]
   0.010806	Logged into UPS myups@localhost

Which looks good, but I can’t get a sensor to work. I’ve used the example in the documentation, and some others I found. Here’s what I have currently:

  - platform: nut
    name: UPS
    host: 127.0.0.1
    port: 3493
    username: username
    password: password
    resources:
      - battery.charge
      - battery.runtime
      - ups.load
      - ups.status
      - input.voltage
      - ups.status.display

Anything else I should try?

I don’t think 127.0.0.1 will work, because that’s the local host of the homeassistant container. Try the ip address for the machine (like 192.168.0.200 or whatever). Remember to restart homeassistant for your changes to take effect.

Tried that…it didn’t work either…ugh…

I got it to work. I have NO idea what I did, but it just started working…
The crazy part is, I commented out the sensor in my config file…but all the entities show up.

1 Like

Hi, did you ever get a resolve on this one?
I am getting the same Check ‘port=’ in ups.conf error when I user the powercom driver.
I managed to get NUT installed on raspbian and it works with the usbhid-ups driver on raspbian, but I can’t get it working with the Home Assistant addon using exacly the same settings in the config file.

Had a similar problem. My issue ended up being spaces in the sensor name I guess. Just in case someone else was pulling their hair out.

Here is my working config on Hassio:

users:
  - username: monuser
    password: apcups123
    instcmds:
      - all
    actions: []
devices:
  - name: ups
    driver: usbhid-ups
    port: auto
    config:
      - vendorid = 051d
mode: netserver
shutdown_host: 'true'

Note that the name ups and user monuser make this compatible with my Synology NAS. They do not need to be those values if you are connecting something else.

4 Likes

Thank you so much for this! Was trying to connect an APC ES-700 to my HA and was not playing. (at all) This config worked perfectly! Both my Readynas can also connect to the remote UPS now. Jackanackanory. :raised_hands:

1 Like

Is there any other setup that you made to make this work with Synology NAS? I put “ups” and “monuser” just like you but my Synology NAS still does not recognise the network UPS, I can’t figure this out

It’s been a long time since I looked at it and my NAS is no longer in the same house as my HA, but that is the only config that I got to work. I have a Synology DS412+ if that makes a difference.

1 Like

Thanks anyway and sorry for the necrobump. In the meantime, I set an automation that shuts down my NAS after 10 minutes with no power. In this way I do not need to configure the UPS in the NAS for now, I will keep looking into it

thaks!!, work for me on an APC Pro 550G

thanks for this - worked on Back-UPS XS 700U

I have a APC ES 700 and used @safepay config but can’t get it to play, at all. Did you do anything else? The UPS is connected and the log gives me:

[15:04:37] INFO: Starting the UPS drivers...
Using subdriver: APC HID 0.98
Network UPS Tools - Generic HID driver 0.47 (2.8.0)
USB communication driver (libusb 1.0) 0.43
Network UPS Tools - UPS driver controller 2.8.0
[15:04:37] WARNING: UPS Shutdown will shutdown the host
cont-init: info: /etc/cont-init.d/nut.sh exited 0
cont-init: info: running /etc/cont-init.d/nutclient.sh
cont-init: info: /etc/cont-init.d/nutclient.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun upsd (no readiness notification)
services-up: info: copying legacy longrun upsmon (no readiness notification)
s6-rc: info: service legacy-services successfully started
[15:04:39] INFO: Starting the UPS information server...
   0.000000	fopen /run/nut/upsd.pid: No such file or directory
   0.000081	Could not find PID file '/run/nut/upsd.pid' to see if previous upsd instance is already running!

   0.000878	[D1] debug level is '1'
   0.001262	listening on 0.0.0.0 port 3493
   0.002095	Connected to UPS [ups]: usbhid-ups-ups
   0.004365	Running as foreground process, not saving a PID file
[15:04:39] INFO: Starting the UPS monitor and shutdown controller...
   0.000000	fopen /run/nut/upsmon.pid: No such file or directory
   0.000074	Could not find PID file to see if previous upsmon instance is already running!

   0.000559	Using power down flag file /etc/killpower
   0.000857	UPS: ups@localhost (primary) (power value 1)
   0.001217	[D1] debug level is '1'
   0.001397	[D1] debug level is '1'
   0.001421	Warning: running as one big root process by request (upsmon -p)
   0.001700	[D1] Saving PID 462 into /run/nut/upsmon.pid
Init SSL without certificate database
   0.009517	[D1] Trying to connect to UPS [ups@localhost]
   0.491934	User [email protected] logged into UPS [ups]
   0.011793	[D1] Logged into UPS ups@localhost

I’m do not understand much of what’s going on and how to debug or continue. Any information would be of value.

Cheers!