New apcupsd Hass.io add-on

Tags: #<Tag:0x00007f780373c850>

Hello, all!

I created an apcupsd add-on for Hass.io: https://github.com/korylprince/hassio-apcupsd

Its able to fully configure all apcupsd configuration options, and works for most USB APC UPSs by default.

I do have builds hosted on Docker Hub so you won’t have to build locally.

I’d love any feedback you have, or if you use this and have issues, submit an issue on Github.

9 Likes

After that i update to 1.2 and 1.3 the components stop working:

Failure while testing APCUPSd status retrieval.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 54, in setup
    DATA.update(no_throttle=True)
  File "/usr/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
    result = method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 90, in update
    self._status = self._get_status()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 85, in _get_status
    return self._parse(self._get(host=self._host, port=self._port))
  File "/usr/lib/python3.6/site-packages/apcaccess/status.py", line 37, in get
    sock.connect((host, port))
socket.gaierror: [Errno -3] Try again

How can I fix this, it also say that there is a problemi in dependency :frowning:

First, make sure the add-on is running. If it’s not, post the add-on logs so we can see why it’s not running.

If it is running, try restarting home assistant. That error basically means that home assistant can’t even resolve DNS for the add-on.

My add-on is running but even with a reboot I’m not able to see APC Status. With the 1.0 version of your modules all was ok :confused: but from version 1.2 all stop working

2018-01-02 15:44:10 ERROR (SyncWorker_2) [homeassistant.components.apcupsd] Failure while testing APCUPSd status retrieval.
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 54, in setup
    DATA.update(no_throttle=True)
  File "/usr/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
    result = method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 90, in update
    self._status = self._get_status()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/apcupsd.py", line 85, in _get_status
    return self._parse(self._get(host=self._host, port=self._port))
  File "/usr/lib/python3.6/site-packages/apcaccess/status.py", line 37, in get
    sock.connect((host, port))
socket.gaierror: [Errno -3] Try again
2018-01-02 15:44:11 ERROR (MainThread) [homeassistant.setup] Setup failed for apcupsd: Component failed to initialize.

From components log:

starting version 3.2.4
Jan  2 15:42:35 a722577e-apcupsd syslog.info syslogd started: BusyBox v1.27.2
Jan  2 14:42:35 a722577e-apcupsd daemon.notice apcupsd[9]: apcupsd 3.14.14 (31 May 2016) unknown startup succeeded
Jan  2 14:42:35 a722577e-apcupsd daemon.info apcupsd[9]: NIS server startup succeeded

Let me know if I can help with additional informations and thank for this component :slight_smile:

I’m sorry to hear it’s still not working. To help you further, I’m going to need some more information.

First, make sure you’ve updated to 1.3, the current latest version.

Next, what is your Options JSON? (That’s the text part you can edit on the apcupsd add-on page.)

Next, what model of UPS do you have?

Next, how are you running Hass.io (on a Raspberry Pi, etc)?

Finally, I need to get some information from the running container itself. To do that you’ll first need to set up SSH access to your host (assuming using the Hass.io image.)

Once you’ve SSH’d into your host, run the following command:

docker exec -it addon_a722577e_apcupsd /bin/bash

This should give you a bash prompt in the apcupsd container. Run the following commands and paste the output.

ls /dev/usb
ps
apcaccess

Now run exit to get out of that container and run the following command on the host:

docker exec -it homeassistant /bin/bash

This will give you a bash prompt in the homeassistant container. Run the following command and paste the output:

nslookup a722577e-apcupsd

Run exit twice to get out of the container, then out of the host.

One final thing to try is to install acpupsd on your computer. Then run the following command and paste the output:

apcaccess -h <your Hass.io IP Address>

Depending on your OS, you may need to cd into the folder containing apcaccess before running the command.

Note: sorry if this is a bit pedantic; I’m not sure how comfortable you are with docker, linux, etc.

Worked like a charm the first time out (v0.60.1). Thank you for all your hard work and contribution to the community. Much appreciated.

Hi there and sorry for delay but I was very busy at work. The solution for me, like MQTT, was to set the ip of my Raspberry running Hass.io as Host :smiley: hope This help for reference

I was wrong because I don’t see the card of error in my front-page… the plugin still don’t start, I’ll take a look this weekend with your how-to

EDIT: Setting localhost fixed the problem :smiley:

@skillet Thanks! I’m glad it’s working for you.

@MastroPino it sounds like your docker hassio network isn’t resolving DNS correctly. Are you running the standard Hass.io image on a raspberry pi? I’m glad you were able to get it working, though!

Hi!

Been looking for this one for a while :).

I am trying to get it to work using the net option, but the add-on is not starting, using the following settings:
{
“name”: “BI”,
“cable”: “ether”,
“type”: “net”,
“device”: “10.0.0.4:3551”,
“extra”: []
}

I have 2 UPS devices, one connected to a PC and one to a rPi. Would it be possible to run this for two UPS devices?

@boneless try starting the add-on, then go to the bottom and click the refresh under the logs section. There should be some information on why the container crashed. Go ahead and post those so I can see what’s going wrong.

This add-on doesn’t currently support multiple UPS’s. If this is a feature you’d like to see, please create an issue on the Github project and I’ll try to add that when I get some time.

Hi!

I re-added the add-on with standard settings and it is not starting either, logs are empty.

Did I miss a pre-requisite somewhere? :slight_smile:

Thanks!

The logs should always at least have something like starting version 3.2.4 at the beginning. Sometimes it can take a few seconds for the container to start after you click Start, so you may have to wait a bit before clicking Refresh.

I found out what was causing the issues! There was a bug in the container run.sh script that caused it to write the DEVICE configuration line incorrectly, causing apcupsd to crash. That’s been fixed in version 1.4, so please try updating the add-on and starting it again. You may have to go to the Hass.io store page and click the refresh button in the top right for it to see the update is available.

Hi, thanks for the help! I did find v1.4, but…
It is still not starting tho, log is also empty.

Try going to http://<hassio ip>:8123/hassio/supervisor and see if there’s any log messages there about the failure.

18-01-23 03:35:30 INFO (SyncWorker_18) [hassio.docker.interface] Clean korylprince/hassio-apcupsd-armhf docker application
18-01-23 03:35:31 ERROR (SyncWorker_18) [hassio.docker] Can’t start addon_a722577e_apcupsd: 404 Client Error: Not Found (“linux runtime spec devices: error gathering device information while adding custom device “/dev/usb/hiddev0”: lstat /dev/usb/hiddev0: no such file or directory”)

There was something there yes :slight_smile:

Hello again,

It is this line causing the error:
“devices”: ["/dev/usb/hiddev0:/dev/usb/hiddev0:rwm"],

Since I have no USB hooked on to rPi, there is nothing in that folder (I assume?)

Alright, small steps :slight_smile:

I changed my set up a little bit. Now the UPS is connected to the HASS.IO pi with USB and the add-on is up and running.

I do not, however see any sensors in my device list. I see you have to map using the following:
apcupsd:
host: a722577e-apcupsd

Is this a constant ID or do I need to figure out what number I have?

@boneless sorry for the late reply; this has been a busy week.

First, yes, a722577e-apcupsd is constant for my add-on, no matter the device. Have you tried that and it not work? What do the add-on logs say?

Now for the device problems you were having… This is frustrating to say the least. I’ve spent several hours on this and I’m fairly convinced that currently there’s not a good option to fix this. I’ve outlined the issues here.

Hopefully Hass.io will eventually support user-set devices which would solve this issue, but right now there’s nothing I can do. If it doesn’t look like that feature is going to be added any time soon, I may create another non-USB add-on that could be used as an alternative.

No worries, just have been trying to figure things out and wanted to keep you updated!

Is there a way I can check the add-on logs beside through the front-end? They are empty, only when I restart the add-on there is some information:

starting version 3.2.4
Jan 26 14:12:27 a722577e-apcupsd syslog.info syslogd started: BusyBox v1.27.2
Jan 26 20:12:27 a722577e-apcupsd daemon.notice apcupsd[9]: apcupsd 3.14.14 (31 May 2016) unknown startup succeeded
Jan 26 20:12:27 a722577e-apcupsd daemon.info apcupsd[9]: NIS server startup succeeded

I think a separate add-on for ethernet based devices should be fine. Currently I have my net device hooked to another PI which sends the data to my HASS.IO using MQTT. Which is fine, but I like the apcupsd add-on :slight_smile:

I can help you test if you need, just let me know what I can do.

Appreciate your time and effort!