New apcupsd Hass.io add-on

I had issues starting mine as i already had a APCUPSD server running on the same machine, so it could not start because port was in use (error message: 3551: bind: address already in use).

Only found by using Docker Portainer to manually start as the hassio interface does not give error messages!

I have posted about this and riased a issue on github: Hass.io provides no error messages shown when starting add-ons

However, I still cannot start, as I have no USB on my system :frowning:
Issue riased: Need ethernet version: Cannot start on hassio running on Docker on a virtualized Ubuntu Server. (No "/dev/usb/") Ā· Issue #7 Ā· korylprince/hassio-apcupsd Ā· GitHub

My config:

{
  "name": "APC UPS",
  "cable": "ether",
  "type": "snmp",
  "device": "192.168.1.60:161:APC:private",
  "extra": []
}

Error message before removing other server:
18-09-09 19:21:11 ERROR (SyncWorker_3) [hassio.docker] Can't start addon_a722577e_apcupsd: 500 Server Error: Internal Server Error ("driver failed programming external connectivity on endpoint addon_a722577e_apcupsd (77b4e8f39e7d0e20f99dc3f9e8b611fc5c13e354d74d94e445ea15d9fb120e03): Error starting userland proxy: listen tcp 0.0.0.0:3551: bind: address already in use")

Error message after removing other server:
18-09-09 19:27:55 ERROR (SyncWorker_0) [hassio.docker] Can't start addon_a722577e_apcupsd: 500 Server Error: Internal Server Error ("linux runtime spec devices: error gathering device information while adding custom device "/dev/usb/": no such file or directory")

Any update on a network only build?
That would be fantastic :grinning:

Any chance you could consider looking at this?

Hello all. Iā€™m sorry for the lack of activity here. Life has been pretty busy.

Iā€™ve released version 1.6 which is really just version updates, but with it I also released a second version of the add-on for use with network UPSs. Just refresh the repository in your Hass.io dashboard and you should see the second add-on show up.

If you have issues with it, please create an issue on Github.

Iā€™ve made the decision not to try and make multiple UPSs work in the add-on. You can technically use two (one USB and one network) if you run both add-ons (make sure to use different ports.)

Beyond that, I just donā€™t have the time to devote to making that work. Iā€™ll happily accept a PR if someone wants to work on that feature :slight_smile:

Hello and congrats on a great job!
I have just adquired an APC UPS, installed your add-on and everything seems to work perfect, thank you.
Where can I find the logic under the provided scripts for commfailure, offbattery, changeme, commok and onbattery. I assume everything is working fine as I can see the sensors and no error found in the logs, but realy donā€™t know what to expect on those events.
Sorry if the question is very basic, Iā€™m quite newby.

Those scripts come straight from the apcupsd source. They are included in the alpine package which is installed in my add-on.

Thank you very much for your quick answer, I will take a clorser look at the information and try to undestand how it works. Just one quick question to try get a better undestanding, does the add-on shutdown hassio or the host (rpi in my case) when any of the predeffined conditions are met? Which one?
Thanks again for the great add-on and your help!

Youā€™ll want to read the README here and here.

Worked perfectly. Thanks!

Hello,
I have a problem with the deamon.
The shutdown of the machine is initiated five minutes aprox after I cut the power of the inverter.
But the inverter is new, battery is new, the load is very low (16 W on a 900 WUPS)
I donā€™t know what is the cause of the initiated shutdown?
I donā€™t overrided default apcupsd parameter.
When the machine is down the inverter provide output power.
I run apcaccess as you explain and all values are normal.
The autonomy is 340 min when the server shutdownā€¦

Many thanks for your help and best regards

@vormsty,

Iā€™m assuming youā€™re Vorms on Github. If so, please make sure you fix that issue first to see if it fixes your issue.

If you still have an issue after fixing that (and you are actually running this add-on on Hass.io), please cut the power, wait a couple of minutes, then copy the add-on logs so I can see whatā€™s going on. Also please show the full add-on configuration.

hello,
Yes, i am the same person on github, sorry to spam you.
Yes, I run Hass.io
Yes the inverter is new.
I miss understanted how to configur the apcupsd deamon on hass.io.
So, in the configuration.yaml I have nothing but the declaration of the service (apcupsd:) and the sensors.
I can also display the remaining time and all value on the display, and the binary sensor.
I installad power chute on my windows pc with the same load, and after 10 minutes nothing special.
So, no shutdown is initiated.
I reconnect the usb cable to the linux machine and cut the power again, and after 5 minutes, the machine initiate the shutdown procedure.
Here is the result of the access command, connecting with ssh as you explain in this web page:

APC : 001,037,0964
DATE : 2019-08-23 23:17:35 -0400
HOSTNAME : a722577e-apcupsd.local.hass.io
VERSION : 3.14.14 (31 May 2016) unknown
UPSNAME : APC UPS
CABLE : USB Cable
DRIVER : USB UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2019-08-20 20:30:18 -0400
MODEL : Back-UPS NS 1500M2
STATUS : ONLINE
LINEV : 123.0 Volts
LOADPCT : 1.0 Percent
BCHARGE : 99.0 Percent
TIMELEFT : 179.1 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 88.0 Volts
HITRANS : 139.0 Volts
ALARMDEL : 30 Seconds
BATTV : 27.3 Volts
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 4
XONBATT : 2019-08-23 23:05:56 -0400
TONBATT : 0 Seconds
CUMONBATT: 1632 Seconds
XOFFBATT : 2019-08-23 23:14:18 -0400
SELFTEST : NO
STATFLAG : 0x05000008
SERIALNO : 3B1914X25000
BATTDATE : 2019-04-04
NOMINV : 120 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 900 Watts
FIRMWARE : 957.e3 .D USB FW:e3
END APC : 2019-08-23 23:17:36 -0400
bash-5.0#

Blockquote

Here is the log of the deamon on the hass.io add on page:

Aug 20 20:30:18 a722577e-apcupsd syslog.info syslogd started: BusyBox v1.30.1
Aug 21 00:30:18 a722577e-apcupsd daemon.notice apcupsd[6]: apcupsd 3.14.14 (31 May 2016) unknown startup succeeded
Aug 21 00:30:18 a722577e-apcupsd daemon.info apcupsd[6]: NIS server startup succeeded
Aug 21 00:43:02 a722577e-apcupsd daemon.crit apcupsd[6]: Power failure.
Aug 21 00:43:08 a722577e-apcupsd daemon.crit apcupsd[6]: Running on UPS batteries.
send-mail: account default not found: no configuration file available
Aug 21 00:46:46 a722577e-apcupsd daemon.crit apcupsd[6]: Mains returned. No longer on UPS batteries.
Aug 21 00:46:46 a722577e-apcupsd daemon.alert apcupsd[6]: Power is back. UPS running on mains.
send-mail: account default not found: no configuration file available
Aug 21 00:53:44 a722577e-apcupsd daemon.crit apcupsd[6]: Power failure.
Aug 21 00:53:50 a722577e-apcupsd daemon.crit apcupsd[6]: Running on UPS batteries.
send-mail: account default not found: no configuration file available
Aug 21 01:08:44 a722577e-apcupsd daemon.crit apcupsd[6]: Mains returned. No longer on UPS batteries.
Aug 21 01:08:44 a722577e-apcupsd daemon.alert apcupsd[6]: Power is back. UPS running on mains.
send-mail: account default not found: no configuration file available
Aug 24 02:32:03 a722577e-apcupsd daemon.warn apcupsd[6]: Communications with UPS lost.
send-mail: account default not found: no configuration file available
Aug 24 02:49:01 a722577e-apcupsd daemon.warn apcupsd[6]: Communications with UPS restored.
Aug 24 02:49:02 a722577e-apcupsd daemon.crit apcupsd[6]: Power failure.
send-mail: account default not found: no configuration file available
Aug 24 02:49:07 a722577e-apcupsd daemon.crit apcupsd[6]: Running on UPS batteries.
Aug 24 02:49:07 a722577e-apcupsd daemon.crit apcupsd[6]: Mains returned. No longer on UPS batteries.
Aug 24 02:49:07 a722577e-apcupsd daemon.alert apcupsd[6]: Power is back. UPS running on mains.
send-mail: account default not found: no configuration file available
send-mail: account default not found: no configuration file available
Aug 24 03:05:57 a722577e-apcupsd daemon.crit apcupsd[6]: Power failure.
Aug 24 03:06:02 a722577e-apcupsd daemon.crit apcupsd[6]: Running on UPS batteries.
send-mail: account default not found: no configuration file available
Aug 24 03:14:18 a722577e-apcupsd daemon.crit apcupsd[6]: Mains returned. No longer on UPS batteries.
Aug 24 03:14:18 a722577e-apcupsd daemon.alert apcupsd[6]: Power is back. UPS running on mains.
send-mail: account default not found: no configuration file available

Blockquote

So in resume, in the hass.io apcupsd, the machine is executing the shutdown after 5 minute of power line down.
So, i would like to know the reason wich the shutdown is initiated.

Best regards and thank you very much for helping me !

To get the add-on configuration, you need to go to the add-on page.

For me, itā€™s something like http://hassio:8123/hassio/addon/a722577e_apcupsd

You need to replace the http://hassio:8123 part with whatever you normally use to connect to home assistant. On that page, scroll down to the ā€œConfigā€ section. Thatā€™s where you set the add-on configuration.

Assuming that doesnā€™t have any weird options in it, it sounds like your UPS may be sending bad data randomly. This (very old) post shows some issues like that. If your configuration is correct, you may need to turn to the apcupsd mailing lists so they can help you diagnose and fix whatā€™s going on.

If you just want to prevent the shutdown completely by this add-on, read the README.

Hello,
Yes, i undestand the config is on the addon page and not in the configuartion.yaml page.
I just have the default config.
I already write to the apcupsd mailing list and my request is pendingā€¦
It seems with the powerchute windows software, the beahviour is correct.
Why it sound like the ups send bad data ?
I didnā€™t see the shtudown reason in any log.
Is that possible to have more detailled log ? changing the log level ?
Is that possible to have the log of the data from and to the ups ?

Many thanks for your help and best regards
Thierry

All of those questions are for the apcupsd developers. I donā€™t develop apcupsd, I just created the add-on using it.

Your best bet is to use a dedicated linux machine (not this add-on) to debug the issue.

@korylprince I have been running apcupsd forever and recently found itā€™s not working :frowning: I run Hass in a Virtual box VM and have never used the apcupsd add-onā€¦ I only now realised that a add-on exists (when looking at the integrations). Iā€™m not sure what has gone wrong or maybe Iā€™ve gone mad! Iā€™ve gone back in the release notes just incase there was breaking changes but I canā€™t find anything.
I tried running the add-on and it wonā€™t start, and no info in the add-on log.
really confused here and unsure how to progress.

I did very recently rebuild hass in a new vm and restored the config- maybe related to thisā€¦

from the homeassistant log:

2019-09-01 23:57:45 WARNING (MainThread) [homeassistant.setup] Setup of apcupsd is taking over 10 seconds.
2019-09-01 23:58:05 ERROR (SyncWorker_0) [homeassistant.components.apcupsd] Failure while testing APCUPSd status retrieval.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/apcupsd/__init__.py", line 51, in setup
    DATA.update(no_throttle=True)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/apcupsd/__init__.py", line 88, in update
    self._status = self._get_status()
  File "/usr/src/homeassistant/homeassistant/components/apcupsd/__init__.py", line 83, in _get_status
    return self._parse(self._get(host=self._host, port=self._port))
  File "/usr/local/lib/python3.7/site-packages/apcaccess/status.py", line 37, in get
    sock.connect((host, port))
socket.timeout: timed out
2019-09-01 23:58:05 ERROR (MainThread) [homeassistant.setup] Setup failed for apcupsd: Integration failed to initialize.
2019-09-01 23:58:05 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform apcupsd.sensor: Unable to set up component.

Thereā€™s lots of issues that could be going on here, so please answer these questions so I can help troubleshoot:

Are you currently running apcupsd anywhere on your network?

Is the connection to the UPS over USB or does the UPS have its own network cable?

If the UPS communicates with USBā€¦
    Is the USB cable plugged into the physical box that runs the Hass.io VM?
    Is the USB passed through to the Hass.io VM?
    Are you using the VirtualBox Extension Pack?

If the add-on isnā€™t starting, you need to try starting it then check the Hass.io supervisor logs to find out whatā€™s going on. It should print an error. Post that. You can find this on the Hass.io page -> System tab -> System Log.

Thanks for the prompt response!

So, Apcupsd is running via USB on the host machine (Win10). APCupsd appears OK on the host machine-

image

I have never passed through the USB, but Iā€™m happy to do this if it fixes thingsā€¦
yes Iā€™m running the Virtualbox extension pack.

Here are the logs from the Hass Supervisor:

19-09-01 23:39:28 INFO (SyncWorker_7) [hassio.docker.interface] Clean addon_a722577e_apcupsd application
19-09-01 23:39:31 ERROR (SyncWorker_7) [hassio.docker] Can't start addon_a722577e_apcupsd: 500 Server Error: Internal Server Error ("error gathering device information while adding custom device "/dev/usb/": no such file or directory")

Okay, thatā€™s what I figured. You donā€™t need this add-on. This add-on is to let you run apcupsd using Hass.io. Since you already have apcupsd running, you just need to troubleshoot why Home Assistant canā€™t connect to your apcupsd instance.

What do you have configured as the host in your yaml configuration? And whatā€™s the IP your apcupsd instance is hosted on?

Some networking modes in VirtualBox donā€™t allow communication between the VM and the host, so you may need to play with those settings so your VM can communicate with your apcupsd instance.

Gee this was a bit confusing, sorry for wasting your time! You were spot onā€¦ the problem was that the new VM network ā€œPromiscous modeā€ was set to ā€œDenyā€, changed it to ā€œAllow Allā€ and now working perfectly. Donā€™t understand Promiscous mode but whatever!

I got confused when I seen the integration page mentioning the add-on :blush:

Thanks for your help. I am also using your caddy add-on which is awesome- Love your work. How can I buy you a beer?