Apcupsd for multiple UPS

Currently have the apcupsd component working but would like to be able to add multiple ups or add apcupsd_2:…:etc components.

Thanks!

anyonee? .

Not exactly a fix, but I went a different direction with my (6) home APC UPS units. I already had SNMP management cards in each of them and poll them via SNMP in Home Assistant. I can share the config if interested.

mine our only the usb models so i dont know if snmp is possible? but id be interested

APC 1000, 1500, etc Smart UPS can take snmp management cards.

This is all done in the configuration.yaml. I run HA on Windows, so using a Windows based snmpget command line utility. The utility syntax differs from platform to platform, but this should show the general idea.

Using one of my UPS units as an example:

sensor:

  • platform: command_line
    name: ‘UPS1 Name’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.1.1.2.0 -q’
    scan_interval: 600
  • platform: command_line
    name: ‘UPS1 Type’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.1.1.1.0 -q’
    scan_interval: 600
  • platform: command_line
    name: ‘UPS1 Location’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.4.2.2.1.7.1 -q’
    scan_interval: 600
  • platform: command_line
    name: ‘UPS1 Battery Capacity’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.2.2.1.0 -q’
    unit_of_measurement: ‘%’
    scan_interval: 60
  • platform: command_line
    name: ‘UPS1 Runtime Remaining’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.2.2.3.0 -q’
    unit_of_measurement: ‘Minutes’
    scan_interval: 60
  • platform: command_line
    name: ‘UPS1 Load Percentage’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.4.2.3.0 -q’
    unit_of_measurement: ‘%’
    scan_interval: 60
  • platform: command_line
    name: ‘UPS1 Battery Temperature’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.2.2.2.0 -q’
    unit_of_measurement: ‘°F’
    value_template: “{{ ((value|float*9)/5+32) | round(0) }}”
    scan_interval: 60
  • platform: command_line
    name: ‘UPS1 Battery Status’
    command: ‘d:\apps\snmpget -r:192.168.254.100 -c:“secretpw” -o:1.3.6.1.4.1.318.1.1.1.2.2.4.0 -q’
    value_template: “{%if value == ‘1’ %}Good{% elif value == ‘2’ %}Failed{% endif %}”
    scan_interval: 60
2 Likes

1 Like

I’m trying to pull multiple APC UPS rack mount units with management cards in them into HA. Having a hard time getting past the apc add on and the nut add on that mostly seem like they deal with connected devices and not network. I was doing something similar to what you have above with my Nagios monitoring platform. Curious. Are you on Windows with HA? Noticed the command path. Is there an equivalent capability built into HA to pull SNMP info?

I’m not aware of a comparable way to do this native inside of HA. Yes, I am running HA on Windows 10 64-bit. I am using the HA command_line parameters to pull the SNMP information from all the UPS units using the snmpget program for Windows. Works perfectly for as many UPS units as you want. All mine are APC Smart UPS1000s or 1500s.

Still using this setup today…

Cool, thanks for the reply. I have all the data loaded with SNMP on my linux box now so just need to make it look pretty and work on automating shutdown of my systems should the batteries be close to failing.

I wrote a python based server to poll the local apcups status via the apcaccess command and report the status to Home Assistant via MQTT. I’ve got it running on my raspberry pi, should work on most Linux systems. This is still very fresh, feedback would be welcome.


I created an addon Apcupsd2MQTT
If you are still interested, please add a repo (https://github.com/alex-savin/hassio-addons) and install it
It has MQTT Auto Discovery, so it like plug’n’play.
Feel free to report any issues

Thank you so much! ive got it installed and am setting it up. Which topic do i set and which url do i need for the ups? I didnt see any instructions

Please, leave it empty, it will be “homeassistant/#” by default

thank you and what is the url i set for each UPS? is that just the IP address?

edit: ok i added the IP address and port 3551. Checking the logs it says it has connected to my mqtt broker so now what do i need to do to add the sensors i guess??? Sorry im a noob

Please give a name to a ups something like (“apc_01”, “cyberpower_01”), the name is going to be use to form a sensor entity_id, it will create (“ups_apc_01_status”, “ups_cyberpower_01_status” and etc)
For the URL please use an IP address of the host maintains UPS and a Port (standart 3551) in format “127.0.0.1:3551”
After you start the Addon, and it scans all of the UPSes, it will add all online UPSes as a devices with proper sensor entity_ids, assigned to the device.

Thank you ive got this working for 1 out of 3 ups but i think its some config on my end! thanks for your work on this integration i will continue to work on getting it to work 100% is there anyway to get the load %?

edit: after a day or so all of my ups’s are reporting… i had to restart the add on a number of times to get it to create all of the entities. But once they were all created i just let it run and eventually they all reported info. THANK YOU!

I’m trying the same thing but I keep getting the error:
Couldn’t connect to a MQTT Broker (Network Error : dial tcp 127.0.0.1:1883: connect: connection refused)
Could you share your config please?
Thanks;
Jon

i had to put the explicit ip of the mqtt broker even if on same machine