SNMP


The snmp sensor platform displays information available through the Simple Network Management Protocol (SNMP). SNMP uses a tree-like hierarchy where each node is an object, and is mainly supported by network-oriented devices such as routers, modems, and printers.

To enable this sensor in your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: snmp
    host: 192.168.1.32
    baseoid: 1.3.6.1.4.1.2021.10.1.3.1

Configuration Variables

host

(string)(Optional)The IP address of your host, eg. 192.168.1.32.

Default value: localhost

baseoid

(string)(Required)The OID where the information is located. It’s advised to use the numerical notation.

port

(string)(Optional)The SNMP port of your host.

Default value: 161

community

(string)(Optional)The SNMP community which is set for the device for SNMP v1 and v2c. Most devices have a default community set to public with read-only permission (which is sufficient).

Default value: public

username

(string)(Optional)Username to use for authentication.

Default value:

auth_key

(string)(Optional)Authentication key to use for SNMP v3.

Default value: no key

auth_protocol

(string)(Optional)Authentication protocol to use for SNMP v3.

Default value: none

priv_key

(string)(Optional)Privacy key to use for SNMP v3.

Default value: no key

priv_protocol

(string)(Optional)Privacy protocol to use for SNMP v3.

Default value: none

version

(string)(Optional)Version of SNMP protocol, 1, 2c or 3. Version 2c or higher is needed to read data from 64-bit counters.

Default value: 1

name

(string)(Optional)Name of the SNMP sensor.

unit_of_measurement

(string)(Optional)Defines the unit of measurement of the sensor, if any.

value_template

(template)(Optional)Defines a template to parse the value.

accept_errors

(string)(Optional)Determines whether the sensor should start and keep working even if the SNMP host is unreachable or not responding. This allows the sensor to be initialized properly even if, for example, your printer is not on when you start Home Assistant.

Default value: false

default_value

(string)(Optional)Determines what value the sensor should take if accept_errors is set and the host is unreachable or not responding. If not set, the sensor will have value unknown in case of errors.

Valid values for auth_protocol:

  • none
  • hmac-md5
  • hmac-sha
  • hmac128-sha224
  • hmac192-sha256
  • hmac256-sha384
  • hmac384-sha512

Valid values for priv_protocol:

  • none
  • des
  • 3des-ede
  • aes-cfb-128
  • aes-cfb-192
  • aes-cfb-256

Finding OIDs

OIDs may vary on different systems because they are vendor-specific. Besides the device’s manual, the OID Repository is a good place to start if you are looking for OIDs. As an example, the following OIDs are for the load of a Linux system.

  • 1 minute Load: 1.3.6.1.4.1.2021.10.1.3.1
  • 5 minute Load: 1.3.6.1.4.1.2021.10.1.3.2
  • 15 minute Load: 1.3.6.1.4.1.2021.10.1.3.3

There is a large amount of tools available to work with SNMP. snmpwalk let you easily retrieve the value of an OID.

$ snmpwalk -Os -c public -v 2c 192.168.1.32 1.3.6.1.4.1.2021.10.1.3.1
laLoad.1 = STRING: 0.19

Examples

Printer uptime minutes

According to the most common SNMP standard, the uptime of a device is accessible under OID 1.3.6.1.2.1.1.3.0. The value represented using a format called TimeTicks, in units of hundredths of a second.

To create a sensor that displays the uptime for your printer in minutes, you can use this configuration:

# Example configuration.yaml entry
sensor:
  - platform: snmp
    name: 'Printer uptime'
    host: 192.168.2.21
    baseoid: 1.3.6.1.2.1.1.3.0
    accept_errors: true
    unit_of_measurement: 'minutes'
    value_template: '{{((value | int) / 6000) | int}}'

The accept_errors option will allow the sensor to work even if the printer is not on when Home Assistant is first started: the sensor will just display a - instead of a minute count.

The value_template option converts the original value to minutes.