SNMP data in energy management for APC PDU

It wasn’t obvious how to achieve getting energy data from an APC PDU into home assistant’s new energy dashboard. Here is an example config I’m using for an APC PDU. It would be a nice feature enhancement to allow setting the device and state classes from the snmp sensor but for now via customize.yaml works!

configuration.yaml

sensor:
  - platform: snmp
    host: sfpdu1.home
    baseoid: 1.3.6.1.4.1.318.1.1.26.4.3.1.9.1
    version: 2c
    community: !secret snmp
    name: energy_rack
    unit_of_measurement: "kWh"
    value_template: "{{((value | int) / 10)}}"
  - platform: snmp
    host: sfpdu1.home
    baseoid: 1.3.6.1.4.1.318.1.1.26.4.3.1.5.1
    version: 2c
    community: !secret snmp
    name: power_rack
    unit_of_measurement: "watts"
    value_template: "{{((value | int) * 10) | int}}"

customize.yaml

sensor.energy_rack:
  device_class: energy
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'

A few notes, the snmp values need to be adjusted as they measure either 10s watts or 0.1ths of a kWh, I do this with the value_template. The name for energy consumption sensors needs to start with energy_ at this time.

image
image

2 Likes