Get data from APC Smart + Network Management Card via SMTP

Thank you @aqualx . I was able to fix the temperature measurement ( I had to updated all the local users in the card to US Customary) and also I removed the % from sensor definition.

I am planning to add the secondary UPS card - by adding UPS02 to the name string - hope will work.

Great work again !!!

adding multiple UPSs is working as well - I was able to add the second UPS by changing the host IP and name for identification.
Great job !!!

1 Like

i added to lovelace but i got “unknown”

I don’t understand how to configure please explain to me where the text should be put?

config.yaml or other?
in the board / ups setup I have to do something
thanks

If all your configuration is in configuration.yaml, than put it there.
You will need replace SNMP_IP with real address of your APC.

I did as you told me but nothing
immagine

Solved
immagine

set SNMPv1
Community Name : public
Hostname : 0.0.0.0
Access Type: Read

perfect work

This is an excellent post, however, the Home Assistant NUT tools provide a very easy way to configure the UPS via SNMP and provide automatic shutdown:

Install the Hassio NUT add-in via the Supervisor: https://github.com/hassio-addons/addon-nut

Configure it - here is my config. Just set the host to the IP address of your UPS network address and set your own username and password for the HA integration.

Make sure the UPS access control for SNMP v1 is in a profile called public and is accessible (E.g. 0.0.0.0)

users:
  - username: username
    password: password
    instcmds:
      - all
    actions: []
devices:
  - name: ups
    driver: snmp-ups
    port: 192.168.1.???
    config: []
mode: netserver
shutdown_host: 'true'

Then install the NUT integration as per the instructions: https://www.home-assistant.io/integrations/nut/

3 Likes

I just tried setting this up with my UPS, but Nut complains it doesn’t know what to do with the MIB that was found:

No matching MIB found for sysOID ‘.1.3.6.1.4.1.318.1.3.27’!
Please report it to NUT developers, with an ‘upsc’ output for your device.
Going back to the classic MIB detection method.

But when I ssl into HA, I try the upsc command, and it says upsc isn’t found.

I am using an APC SRT 8000 (which BTW I picked up on a craigslist sale for $300!)

EDIT: Sorry, I figured out I needed to stick a port number in the network config below so the integration would actually work. Things seem ok now!

Where did you stick that port number? And what port was NUT looking for? I have the same issue here.

@fdlou147 I had to add 3493 in the Network section of the config page, down at the bottom. Once I did that, the UPS info updated just fine.

1 Like

Just use one line for the runtime. You don’t need that bunch of code with lots of ifs ifs ifs )))

value_template: "{{((value | int) / 100)|timestamp_custom('%-H hours %-M min', false)}}"

It’s also convenient to use device_class: battery for batt capacity and the system will automatically detect the icon and change it depending on the state.

Also use a unique_id for each sensor, this will allow you to change their names and icons directly in UI
unique_id: apc2200_smart_battery_voltage

My code:

# APC 2200 snmp    
  - platform: snmp
    name: apc2200_smart_type
    unique_id: apc2200_smart_type
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.1.1.1.0
    accept_errors: true
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_status
    unique_id: apc2200_smart_status
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.4.1.1.0
    accept_errors: true
    value_template: >-
      {%if value == '1' %}
        Unknown
      {% elif value == '2' %}
        Online
      {% elif value == '3' %}
        On Battery
      {% elif value == '4' %}
        On Smart Boost
      {% elif value == '5' %}
        Timed Sleeping
      {% elif value == '6' %}
        Software Bypass
      {% elif value == '7' %}
        Off
      {% elif value == '8' %}
        Rebooting
      {% elif value == '9' %}
        Switched Bypass
      {% elif value == '10' %}
        Hardware Failure Bypass
      {% elif value == '11' %}
        Sleeping Until Power Returns
      {% elif value == '12' %}
        On Smart Trim
      {% endif %}
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_battery_voltage
    unique_id: apc2200_smart_battery_voltage
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.2.3.4.0
    device_class: voltage
    unit_of_measurement: "V"
    accept_errors: true
    value_template: "{{((value | int) / 10)}}"
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_battery_capacity
    unique_id: apc2200_smart_battery_capacity
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.2.2.1.0
    device_class: battery
    unit_of_measurement: "%"
    accept_errors: true
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_input_voltage
    unique_id: apc2200_smart_input_voltage
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.3.2.1.0
    device_class: voltage
    unit_of_measurement: "V"
    accept_errors: true
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_output_frequency
    unique_id: apc2200_smart_output_frequency
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.3.3.4.0
    accept_errors: true
    value_template: "{{((value | int) / 10)}}"
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_load
    unique_id: apc2200_smart_load
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.4.3.3.0
    unit_of_measurement: "%"
    accept_errors: true
    value_template: "{{((value | int) / 10)}}"
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_ups_temperature
    unique_id: apc2200_smart_ups_temperature
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.2.2.2.0
    device_class: temperature
    unit_of_measurement: "°C"
    accept_errors: true
  - platform: snmp
    scan_interval: 10
    name: apc2200_smart_runtime
    unique_id: apc2200_smart_runtime
    host: 192.168.1.50
    baseoid: 1.3.6.1.4.1.318.1.1.1.2.2.3.0
    accept_errors: true
    value_template: "{{((value | int) / 100)|timestamp_custom('%-H год %-M хв', false)}}"

2 Likes

Just wanted to hop and say thanks for this, was debating on doing the APC NIS method but this was much easier!

1 Like

I’m new to Home Assistant and have an APC SmartUPS 1500 with an NMC2 card installed. I’m on the latest version of HA and all devices have the latest firmware from APC.

From what I understand, the code above acts like a driver to create a new sensor in HA for the APC NMC cards. What I don’t understand is where to put this code. How do I create this new sensor?

Any help would be greatly appreciated.

Inside configuration.yaml

I changed the device name and ip address and pasted the code to the end of configuration.yaml. I then tested it in HA Developer tools. Here is the message:

Error loading /config/configuration.yaml: while parsing a block mapping
in “/config/configuration.yaml”, line 3, column 1
expected , but found ‘’
in “/config/configuration.yaml”, line 18, column 3

I’m trying to add my much older APC SmartUPS 1000XL with a APC9606 network card using SNMP. My baseoid is only 9 to 12 characters .1.3.6.1.2.1.1.1.0 and varies. Nothing like what I’m seeing in this thread.

Also adding the different examples (editing for a single UPS) and inputting the needed changes causes issues.

Solved

Had to place it in with other declared sensor: section in the config.yaml and just change the IP address working like a charm.

If using NUT integration, localhost should be replaced with “a0d7b954-nut”

Hy,

any idea to get the power in Watt?

Steffen

1 Like